hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
108
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
ee5163f6688dce211845577c668c980e453285fd
3,737
cpp
C++
src/backends/cl/test/Fp16SupportTest.cpp
korabelnikov/armnn
8c3259fa007d43fcc5ea56fe6928526dbe79f3c0
[ "MIT" ]
null
null
null
src/backends/cl/test/Fp16SupportTest.cpp
korabelnikov/armnn
8c3259fa007d43fcc5ea56fe6928526dbe79f3c0
[ "MIT" ]
null
null
null
src/backends/cl/test/Fp16SupportTest.cpp
korabelnikov/armnn
8c3259fa007d43fcc5ea56fe6928526dbe79f3c0
[ "MIT" ]
null
null
null
// // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // #include <armnn/Descriptors.hpp> #include <armnn/IRuntime.hpp> #include <armnn/INetwork.hpp> #include <Half.hpp> #include <Graph.hpp> #include <Optimizer.hpp> #include <backendsCommon/CpuTensorHandle.hpp> #include <boost/core/ignore_unused.hpp> #include <boost/test/unit_test.hpp> #include <set> using namespace armnn; BOOST_AUTO_TEST_SUITE(Fp16Support) BOOST_AUTO_TEST_CASE(Fp16DataTypeSupport) { Graph graph; Layer* const inputLayer1 = graph.AddLayer<InputLayer>(1, "input1"); Layer* const inputLayer2 = graph.AddLayer<InputLayer>(2, "input2"); Layer* const additionLayer = graph.AddLayer<AdditionLayer>("addition"); Layer* const outputLayer = graph.AddLayer<armnn::OutputLayer>(0, "output"); TensorInfo fp16TensorInfo({1, 2, 3, 5}, armnn::DataType::Float16); inputLayer1->GetOutputSlot(0).Connect(additionLayer->GetInputSlot(0)); inputLayer2->GetOutputSlot(0).Connect(additionLayer->GetInputSlot(1)); additionLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0)); inputLayer1->GetOutputSlot().SetTensorInfo(fp16TensorInfo); inputLayer2->GetOutputSlot().SetTensorInfo(fp16TensorInfo); additionLayer->GetOutputSlot().SetTensorInfo(fp16TensorInfo); BOOST_CHECK(inputLayer1->GetOutputSlot(0).GetTensorInfo().GetDataType() == armnn::DataType::Float16); BOOST_CHECK(inputLayer2->GetOutputSlot(0).GetTensorInfo().GetDataType() == armnn::DataType::Float16); BOOST_CHECK(additionLayer->GetOutputSlot(0).GetTensorInfo().GetDataType() == armnn::DataType::Float16); } BOOST_AUTO_TEST_CASE(Fp16AdditionTest) { using namespace half_float::literal; // Create runtime in which test will run IRuntime::CreationOptions options; IRuntimePtr runtime(IRuntime::Create(options)); // Builds up the structure of the network. INetworkPtr net(INetwork::Create()); IConnectableLayer* inputLayer1 = net->AddInputLayer(0); IConnectableLayer* inputLayer2 = net->AddInputLayer(1); IConnectableLayer* additionLayer = net->AddAdditionLayer(); IConnectableLayer* outputLayer = net->AddOutputLayer(0); inputLayer1->GetOutputSlot(0).Connect(additionLayer->GetInputSlot(0)); inputLayer2->GetOutputSlot(0).Connect(additionLayer->GetInputSlot(1)); additionLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0)); //change to float16 TensorInfo fp16TensorInfo(TensorShape({4}), DataType::Float16); inputLayer1->GetOutputSlot(0).SetTensorInfo(fp16TensorInfo); inputLayer2->GetOutputSlot(0).SetTensorInfo(fp16TensorInfo); additionLayer->GetOutputSlot(0).SetTensorInfo(fp16TensorInfo); // optimize the network std::vector<BackendId> backends = {Compute::GpuAcc}; IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); // Loads it into the runtime. NetworkId netId; runtime->LoadNetwork(netId, std::move(optNet)); std::vector<Half> input1Data { 1.0_h, 2.0_h, 3.0_h, 4.0_h }; std::vector<Half> input2Data { 100.0_h, 200.0_h, 300.0_h, 400.0_h }; InputTensors inputTensors { {0,ConstTensor(runtime->GetInputTensorInfo(netId, 0), input1Data.data())}, {1,ConstTensor(runtime->GetInputTensorInfo(netId, 0), input2Data.data())} }; std::vector<Half> outputData(input1Data.size()); OutputTensors outputTensors { {0,Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data())} }; // Does the inference. runtime->EnqueueWorkload(netId, inputTensors, outputTensors); // Checks the results. BOOST_TEST(outputData == std::vector<Half>({ 101.0_h, 202.0_h, 303.0_h, 404.0_h})); // Add } BOOST_AUTO_TEST_SUITE_END()
33.666667
107
0.732138
korabelnikov
ee517b57c817336d7f94399562147e452ef994d1
340
hh
C++
include/utils.hh
Stalker2106x/Mini8BVM
d384ad30f6c870b32aa8e4b9d00705a1406779ad
[ "MIT" ]
1
2021-11-30T06:52:58.000Z
2021-11-30T06:52:58.000Z
include/utils.hh
Stalker2106x/Mini8BVM
d384ad30f6c870b32aa8e4b9d00705a1406779ad
[ "MIT" ]
null
null
null
include/utils.hh
Stalker2106x/Mini8BVM
d384ad30f6c870b32aa8e4b9d00705a1406779ad
[ "MIT" ]
null
null
null
#ifndef UTILS_HH_ #define UTILS_HH_ #include <string> #include "config.h" #define HEX_DELIM 'x' #define BIN_DELIM 'b' long long int int128FromString(std::string str); template <wordSizeType WordSize> std::string binStringFromInt128(long long int value) { return (std::bitset<WordSize>(value).to_string()); } #endif /* !UTILS_HH_ */
18.888889
54
0.738235
Stalker2106x
ee52224c99fdfec2563dad899f89884ef4240be6
6,017
cpp
C++
source/EvalVar.cpp
xzrunner/shadergraph
a5bf002b40738010ef4d9870f507d4faf07ba893
[ "MIT" ]
1
2018-12-04T15:32:42.000Z
2018-12-04T15:32:42.000Z
source/EvalVar.cpp
xzrunner/shadergraph
a5bf002b40738010ef4d9870f507d4faf07ba893
[ "MIT" ]
null
null
null
source/EvalVar.cpp
xzrunner/shadergraph
a5bf002b40738010ef4d9870f507d4faf07ba893
[ "MIT" ]
null
null
null
#include "shadergraph/EvalVar.h" #include "shadergraph/Variant.h" #include "shadergraph/ValueImpl.h" #include "shadergraph/block/Float2.h" #include <cpputil/StringHelper.h> #include <assert.h> namespace shadergraph { std::shared_ptr<Value> EvalVar::ValueTrans(const Variant& var, VarType type) { if (var.type == type || type == VarType::Dynamic) { return var.val; } std::shared_ptr<Value> ret = nullptr; switch (var.type) { case VarType::Int: { int i = std::static_pointer_cast<IntVal>(var.val)->x; float f = static_cast<float>(i); switch (type) { case VarType::Int2: ret = std::make_shared<Int2Val>(i, i); break; case VarType::Int3: ret = std::make_shared<Int3Val>(i, i, i); break; case VarType::Int4: ret = std::make_shared<Int4Val>(i, i, i, i); break; case VarType::Float: ret = std::make_shared<FloatVal>(f); break; case VarType::Float2: ret = std::make_shared<Float2Val>(f, f); break; case VarType::Float3: ret = std::make_shared<Float3Val>(f, f, f); break; case VarType::Float4: ret = std::make_shared<Float4Val>(f, f, f, f); break; default: assert(0); } } break; case VarType::Float: { float f = std::static_pointer_cast<FloatVal>(var.val)->x; switch (type) { case VarType::Float2: ret = std::make_shared<Float2Val>(f, f); break; case VarType::Float3: ret = std::make_shared<Float3Val>(f, f, f); break; case VarType::Float4: ret = std::make_shared<Float4Val>(f, f, f, f); break; default: assert(0); } } break; default: assert(0); } assert(ret); return ret; } std::string EvalVar::VariantToString(const Variant& var, VarType type) { if (var.type == VarType::String) { return std::static_pointer_cast<StringVal>(var.val)->str; } auto val = ValueTrans(var, type); switch (type) { //case VarType::Bool: // return "false"; //case VarType::Bool2: // return "bvec2(false, false)"; //case VarType::Bool3: // return "bvec3(false, false, false)"; //case VarType::Bool4: // return "bvec4(false, false, false, false)"; case VarType::UInt: case VarType::Int: return std::to_string(std::static_pointer_cast<IntVal>(val)->x).c_str(); case VarType::Int2: { auto v = std::static_pointer_cast<Int2Val>(val); return cpputil::StringHelper::Format("ivec2(%s, %s)", std::to_string(v->xy[0]), std::to_string(v->xy[1]).c_str()); } case VarType::Int3: { auto v = std::static_pointer_cast<Int3Val>(val); return cpputil::StringHelper::Format("ivec3(%s, %s, %s)", std::to_string(v->xyz[0]).c_str(), std::to_string(v->xyz[1]).c_str(), std::to_string(v->xyz[2]).c_str()); } case VarType::Int4: { auto v = std::static_pointer_cast<Int4Val>(val); return cpputil::StringHelper::Format("ivec4(%s, %s, %s, %s)", std::to_string(v->xyzw[0]).c_str(), std::to_string(v->xyzw[1]).c_str(), std::to_string(v->xyzw[2]).c_str(), std::to_string(v->xyzw[3]).c_str()); } case VarType::Float: return std::to_string(std::static_pointer_cast<FloatVal>(val)->x).c_str(); case VarType::Float2: { auto v = std::static_pointer_cast<Float2Val>(val); return cpputil::StringHelper::Format("vec2(%s, %s)", std::to_string(v->xy[0]).c_str(), std::to_string(v->xy[1]).c_str()); } case VarType::Float3: { auto v = std::static_pointer_cast<Float3Val>(val); return cpputil::StringHelper::Format("vec3(%s, %s, %s)", std::to_string(v->xyz[0]).c_str(), std::to_string(v->xyz[1]).c_str(), std::to_string(v->xyz[2]).c_str()); } case VarType::Float4: { auto v = std::static_pointer_cast<Float4Val>(val); return cpputil::StringHelper::Format("vec4(%s, %s, %s, %s)", std::to_string(v->xyzw[0]).c_str(), std::to_string(v->xyzw[1]).c_str(), std::to_string(v->xyzw[2]).c_str(), std::to_string(v->xyzw[3]).c_str()); } default: return ""; } } std::string EvalVar::GetDefaultValueString(VarType type) { switch (type) { case VarType::Bool: return "false"; case VarType::Bool2: return "bvec2(false, false)"; case VarType::Bool3: return "bvec3(false, false, false)"; case VarType::Bool4: return "bvec4(false, false, false, false)"; case VarType::UInt: case VarType::Int: return "0"; case VarType::Int2: return "ivec2(0, 0)"; case VarType::Int3: return "ivec3(0, 0, 0)"; case VarType::Int4: return "ivec4(0, 0, 0, 0)"; case VarType::Float: return "0.0"; case VarType::Float2: return "vec2(0.0, 0.0)"; case VarType::Float3: return "vec3(0.0, 0.0, 0.0)"; case VarType::Float4: return "vec4(0.0, 0.0, 0.0, 0.0)"; case VarType::Matrix2: return "mat2()"; case VarType::Matrix3: return "mat3()"; case VarType::Matrix4: return "mat4()"; default: return ""; } } Variant EvalVar::Calc(const Block::Port& in_port) { Variant ret; auto& conns = in_port.conns; if (conns.empty()) { return ret; } assert(conns.size() == 1); auto node = conns[0].node.lock(); if (!node) { return ret; } ret = node->GetExports()[0].var.type; if (node->get_type() == rttr::type::get<block::Float2>()) { auto v = std::static_pointer_cast<block::Float2>(node)->GetValue(); ret.val = std::make_shared<Float2Val>(v.x, v.y); } return ret; } }
28.516588
156
0.551105
xzrunner
ee55f79803751596b833422ab0647a76385770d0
78
hpp
C++
src/boost_numeric_odeint_stepper_generation_generation_rosenbrock4.hpp
miathedev/BoostForArduino
919621dcd0c157094bed4df752b583ba6ea6409e
[ "BSL-1.0" ]
10
2018-03-17T00:58:42.000Z
2021-07-06T02:48:49.000Z
src/boost_numeric_odeint_stepper_generation_generation_rosenbrock4.hpp
miathedev/BoostForArduino
919621dcd0c157094bed4df752b583ba6ea6409e
[ "BSL-1.0" ]
2
2021-03-26T15:17:35.000Z
2021-05-20T23:55:08.000Z
src/boost_numeric_odeint_stepper_generation_generation_rosenbrock4.hpp
miathedev/BoostForArduino
919621dcd0c157094bed4df752b583ba6ea6409e
[ "BSL-1.0" ]
4
2019-05-28T21:06:37.000Z
2021-07-06T03:06:52.000Z
#include <boost/numeric/odeint/stepper/generation/generation_rosenbrock4.hpp>
39
77
0.858974
miathedev
ee563871c9ed5e0de6c33f102232f6084ec6c980
3,111
cc
C++
test/data_serialize/main.cc
schinmayee/nimbus
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
[ "BSD-3-Clause" ]
20
2017-07-03T19:09:09.000Z
2021-09-10T02:53:56.000Z
test/data_serialize/main.cc
schinmayee/nimbus
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
[ "BSD-3-Clause" ]
null
null
null
test/data_serialize/main.cc
schinmayee/nimbus
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
[ "BSD-3-Clause" ]
9
2017-09-17T02:05:06.000Z
2020-01-31T00:12:01.000Z
/* * Copyright 2013 Stanford University. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * - Neither the name of the copyright holders 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. */ /* * An Example application that is meant to run over multiple workers. * It is simply applying a stencil over a one dimensional array. * * Author: Omid Mashayekhi<omidm@stanford.edu> */ #include <string> #include <iostream> #include "protobufs/vector_msg.pb.h" using vector_msg::VectorMsg; bool Serialize() { VectorMsg vec_msg; int size_ = 1; for (int i = 0; i < size_; i++) { std::cout << "****" << i << std::endl; vec_msg.add_elem(i); } // Preliminary string test printf("Testing static allocation.\n"); std::string staticStr; bool result = vec_msg.SerializeToString(&staticStr); printf("Testing dynamic allocation.\n"); char* testArray = new char[128]; // strncpy(testArray, "test text", 10); testArray[0] = 0; std::string* prelim = new std::string(testArray); prelim->clear(); prelim->resize(10); printf("Vector message string test.\n"); //std::string str = "test"; // str = str + " test "; std::string* str = new std::string(testArray); result = vec_msg.SerializeToString(str); testArray[0] = 0; str = new std::string(testArray); result = vec_msg.SerializeToString(str); if (result) { printf("Serialzed to string correctly.\n"); const char* ptr = str->c_str(); printf("\t"); for (uint32_t i = 0; i < str->length(); i++) { printf("%02hx ", ptr[i]); } printf("\n"); } else { printf("Serialized to string incorrectly.\n"); } return true; } int main(int argc, char** argv) { Serialize(); }
31.11
72
0.697525
schinmayee
ee587dffa973ab80e44909d551edc1a0508fa814
4,402
cpp
C++
clicache/src/Objects.cpp
rhoughton-pivot/geode-native
ab6fe7d996e5ec23832f90663d03f1d66b9f5fbd
[ "Apache-2.0" ]
48
2017-02-08T22:24:07.000Z
2022-02-06T02:47:56.000Z
clicache/src/Objects.cpp
rhoughton-pivot/geode-native
ab6fe7d996e5ec23832f90663d03f1d66b9f5fbd
[ "Apache-2.0" ]
388
2017-02-13T17:09:45.000Z
2022-03-29T22:18:39.000Z
clicache/src/Objects.cpp
rhoughton-pivot/geode-native
ab6fe7d996e5ec23832f90663d03f1d66b9f5fbd
[ "Apache-2.0" ]
68
2017-02-09T18:43:15.000Z
2022-03-14T22:59:13.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. */ #include "Objects.hpp" #include "CacheableDate.hpp" #include "ICacheableKey.hpp" using namespace System; using namespace System::Collections; using namespace Apache::Geode::Client; namespace Apache { namespace Geode { Int32 Objects::Hash(... array<Object^>^ values) { return Objects::GetHashCode(values); } Int32 Objects::GetHashCode(Object^ value) { if (nullptr == value) { return 0; } else if (auto s = dynamic_cast<String^>(value)) { return GetHashCode(s); } else if (auto i = dynamic_cast<Int32^>(value)) { return GetHashCode(*i); } else if (auto l = dynamic_cast<Int64^>(value)) { return GetHashCode(*l); } else if (auto s = dynamic_cast<Int16^>(value)) { return GetHashCode(*s); } else if (auto s = dynamic_cast<Char^>(value)) { return GetHashCode(*s); } else if (auto d = dynamic_cast<DateTime^>(value)) { return GetHashCode(*d); } else if (auto b = dynamic_cast<SByte^>(value)) { return GetHashCode(*b); } else if (auto s = dynamic_cast<Single^>(value)) { return GetHashCode(*s); } else if (auto d = dynamic_cast<Double^>(value)) { return GetHashCode(*d); } else if (auto b = dynamic_cast<Boolean^>(value)) { return GetHashCode(*b); } else if (auto k = dynamic_cast<ICacheableKey^>(value)) { return k->GetHashCode(); } else if (auto c = dynamic_cast<IDictionary^>(value)) { return GetHashCode(c); } else if (auto c = dynamic_cast<ICollection^>(value)) { return GetHashCode(c); } return value->GetHashCode(); } Int32 Objects::GetHashCode(String^ value) { Int32 hash = 0; for each(auto c in value) { hash = 31 * hash + c; } return hash; } Int32 Objects::GetHashCode(Char value) { return value; } Int32 Objects::GetHashCode(Boolean value) { return value ? 1231 : 1237; } Int32 Objects::GetHashCode(SByte value) { return value; } Int32 Objects::GetHashCode(Int16 value) { return value; } Int32 Objects::GetHashCode(Int32 value) { return value; } Int32 Objects::GetHashCode(Int64 value) { return static_cast<Int32>(value ^ (value >> 32)); } union float_int64_t { float f; int32_t u; }; constexpr auto kJavaFloatNaN = 0x7fc00000; Int32 Objects::GetHashCode(Single value) { float_int64_t v; if (Single::IsNaN(value)) { // .NET and Java don't aggree on NaN encoding v.u = kJavaFloatNaN; } else { v.f = value; } return GetHashCode(v.u); } union double_int64_t { double d; int64_t u; }; constexpr auto kJavaDoubleNaN = 0x7ff8000000000000L; Int32 Objects::GetHashCode(Double value) { double_int64_t v; if (Double::IsNaN(value)) { // .NET and Java don't aggree on NaN encoding v.u = kJavaDoubleNaN; } else { v.d = value; } return GetHashCode(v.u); } Int32 Objects::GetHashCode(DateTime^ value) { if (value == nullptr) { return 0; } return GetHashCode(*value); } Int32 Objects::GetHashCode(DateTime value) { auto timeSpanSinceEpoch = value - CacheableDate::EpochTime; auto milliseconds = timeSpanSinceEpoch.Ticks / TimeSpan::TicksPerMillisecond; return GetHashCode(milliseconds); } Int32 Objects::GetHashCode(ICollection^ value) { if (value == nullptr) { return 0; } int result = 1; for each (auto element in value) { result = 31 * result + Objects::GetHashCode(element); } return result; } Int32 Objects::GetHashCode(System::Collections::IDictionary^ dictionary) { int h = 0; for each(System::Collections::DictionaryEntry^ entry in dictionary) { h = h + (GetHashCode(entry->Key) ^ GetHashCode(entry->Value)); } return h; } } // namespace Geode } // namespace Apache
27.006135
79
0.689232
rhoughton-pivot
ee5a71d6030465c1a479905f845f5fe986fa4be9
10,563
cpp
C++
src/shape2d.cpp
myociss/pathfinder
4c0b14e074cfc8f0e41836abc056989f2d465c12
[ "MIT" ]
null
null
null
src/shape2d.cpp
myociss/pathfinder
4c0b14e074cfc8f0e41836abc056989f2d465c12
[ "MIT" ]
null
null
null
src/shape2d.cpp
myociss/pathfinder
4c0b14e074cfc8f0e41836abc056989f2d465c12
[ "MIT" ]
null
null
null
#include "shape2d.hpp" #include <iostream> #define _USE_MATH_DEFINES #include <math.h> //#include <sort.h> using namespace Eigen; using namespace std; Shape2d::Shape2d(unsigned long int _id, int _numVertices, double _weight){ id=_id; numVertices=_numVertices; weight=_weight; vertices.reserve(numVertices); endVertex=0; } bool Shape2d::Complete(){ return numVertices==vertices.size(); } void Shape2d::addPoint(Point2d point){ int vectorPos = point.ShapeVectorPos(); if(vertices.size()==0 || vectorPos > vertices.back().ShapeVectorPos()){ vertices.push_back(point); } else if(vertices[0].ShapeVectorPos() > vectorPos){ vertices.insert(vertices.begin(), point); } else { for(int i=0; i<vertices.size()-1; i++){ if(vectorPos>vertices[i].ShapeVectorPos() && vectorPos<vertices[i+1].ShapeVectorPos()){ vertices.insert(vertices.begin()+i+1, point); break; } } } } void Shape2d::arrange(vector<LineInterval>& lineIntervals){ int startVertex; for(int i=0; i<vertices.size(); i++){ Vector2d prev; if(i==0){ prev=vertices.back().Vec(); } else { prev=vertices[i-1].Vec(); } Vector2d next; if(i==vertices.size()-1){ next=vertices[0].Vec(); } else{ next=vertices[i+1].Vec(); } LineInterval& li=lineIntervals[vertices[i].AngleId()]; Vector2d liPoint=li.Point(); if(-liPoint[1]*prev[0] + liPoint[0]*prev[1]>0 && -liPoint[1]*next[0] + liPoint[0]*next[1]>=0){ startVertex=i; } } setVerticesClockwise(startVertex); } void Shape2d::setVerticesClockwise(int startVertex){ Vector2d p = vertices[0].Vec(); Vector2d q = vertices[1].Vec(); Vector2d r = vertices[2].Vec(); bool orientedClockwise=(r[0]-p[0])*(q[1]-p[1])-(q[0]-p[0])*(r[1]-p[1]) > 0; vector<Point2d> tmpVertices; tmpVertices.reserve(vertices.size()); if(orientedClockwise){ int idx=startVertex; for(int i=0; i<vertices.size(); ++i){ tmpVertices.push_back(vertices[idx]); ++idx; if(idx==vertices.size()){ idx=0; } } } else { int idx=startVertex; for(int i=0; i<vertices.size(); ++i){ tmpVertices.push_back(vertices[idx]); --idx; if(idx<0){ idx=vertices.size()-1; } } } setNewVertices(tmpVertices); } void Shape2d::setNewVertices(vector<Point2d> tmpVertices){ double angleMax=tmpVertices[0].Angle(); for(int i=0; i<numVertices; ++i){ vertices[i]=tmpVertices[i]; double vertexAngle=vertices[i].Angle(); if(vertices[i].Angle()<0 && vertices[0].Angle()>0){ vertexAngle += 2 * M_PI; } if(vertexAngle>angleMax){ endVertex=i; angleMax=vertexAngle; } } } vector<Vector2d> Shape2d::Vertices(){ vector<Vector2d> vecs; for(int i=0; i<vertices.size(); ++i){ for(int j=0; j<vertices.size(); ++j){ if(vertices[j].ShapeVectorPos()==i){ vecs.push_back(vertices[j].Vec()); break; } } } return vecs; } vector<Vector2d> Shape2d::VerticesArranged(){ vector<Vector2d> vecs; for(int i=0; i<vertices.size(); ++i){ vecs.push_back(vertices[i].Vec()); } return vecs; } void Shape2d::calculateOneIntervalTarget(LineInterval& li){ for(int i=vertices.size()-1; i>=0; --i){ int next=i-1; if(next<0){ next=vertices.size()-1; } if(li.IntersectsEdge(vertices[i].Angle(), vertices[next].Angle())){ array<double, 2> edgePolar=polarEquation(vertices[i].Vec(), vertices[next].Vec()); computeBoundsTarget(li, edgePolar); } } } void Shape2d::calculateOneInterval(LineInterval& li){ array<double, 2> entryPolar=EntryEdge(li); array<double, 2> terminalPolar=TerminalEdge(li); array<double, 3> entryFStart=li.FunctionsAt(entryPolar, 0); array<double, 3> terminalFStart=li.FunctionsAt(terminalPolar, 0); array<double, 3> entryFEnd=li.FunctionsAt(entryPolar, 1); array<double, 3> terminalFEnd=li.FunctionsAt(terminalPolar, 1); computeBounds(entryFStart, entryFEnd, terminalFStart, terminalFEnd, li); } void Shape2d::calculateAllIntervalsTarget(vector<LineInterval>& lineIntervals){ for(int i=vertices.size()-1; i>=0; --i){ int next=i-1; if(next<0){ next=vertices.size()-1; } unsigned long int startIntervalId=vertices[i].AngleId(); unsigned long int intervalId=startIntervalId; //double upperBound=0.0; //double lowerBound=0.0; array<double, 2> edgePolar=polarEquation(vertices[i].Vec(), vertices[next].Vec()); while(intervalId!=vertices[next].AngleId()){ LineInterval& li=lineIntervals[intervalId]; /*double startSide=li.DistAt(edgePolar, 0); double endSide=li.DistAt(edgePolar, 1); if(li.containsNormal(edgePolar)){ upperBound=weight * max(startSide, endSide); lowerBound=weight * edgePolar[0]; } else { upperBound=weight * max(startSide, endSide); lowerBound=weight * min(startSide, endSide); } li.update(upperBound, lowerBound, startSide, endSide, id);*/ computeBoundsTarget(li, edgePolar); intervalId=(intervalId+1)%lineIntervals.size(); } } } void Shape2d::calculateAllIntervals(vector<LineInterval>& lineIntervals){ unsigned long int startIntervalId=vertices[0].AngleId(); unsigned long int intervalId=startIntervalId; unsigned long int endVertexIntervalId=vertices[endVertex].AngleId(); int entryEdge=(vertices[0].AngleId()==vertices[1].AngleId() ? 1 : 0); if(entryEdge==1){ cout << "guess this happens" << endl; } int terminalEdge=vertices.size()-1; array<double, 3> entryFStart; array<double, 3> terminalFStart; array<double, 2> entryPolar=polarEquation(vertices[entryEdge].Vec(), vertices[entryEdge+1].Vec()); array<double, 2> terminalPolar=polarEquation(vertices[0].Vec(), vertices[terminalEdge].Vec()); //cout << endVertexIntervalId << endl; while(intervalId!=endVertexIntervalId){ //cout << intervalId << endl; LineInterval& li = lineIntervals[intervalId]; //new entry edge if(vertices[entryEdge].AngleId()==intervalId){ entryFStart=li.FunctionsAt(entryPolar, 0); } //new exit edge if(vertices[(terminalEdge+1)%vertices.size()].AngleId()==intervalId){ terminalFStart=li.FunctionsAt(terminalPolar, 0); } array<double, 3> entryFEnd=li.FunctionsAt(entryPolar, 1); array<double, 3> terminalFEnd=li.FunctionsAt(terminalPolar, 1); computeBounds(entryFStart, entryFEnd, terminalFStart, terminalFEnd, li); terminalFStart=terminalFEnd; entryFStart=entryFEnd; unsigned long int nextInterval = (intervalId+1)%lineIntervals.size(); if(vertices[terminalEdge].AngleId()==nextInterval){ --terminalEdge; terminalPolar=polarEquation(vertices[terminalEdge+1].Vec(), vertices[terminalEdge].Vec()); } if(vertices[entryEdge+1].AngleId()==nextInterval){ ++entryEdge; entryPolar=polarEquation(vertices[entryEdge].Vec(), vertices[entryEdge+1].Vec()); } intervalId=nextInterval; } } void Shape2d::computeBoundsTarget(LineInterval& li, array<double, 2> edgePolar){ double startSide=li.DistAt(edgePolar, 0); double endSide=li.DistAt(edgePolar, 1); double upperBound=0.0; double lowerBound=0.0; if(li.containsNormal(edgePolar)){ upperBound=weight * max(startSide, endSide); lowerBound=weight * edgePolar[0]; } else { upperBound=weight * max(startSide, endSide); lowerBound=weight * min(startSide, endSide); } li.update(upperBound, lowerBound, startSide, endSide, id); } void Shape2d::computeBounds(array<double, 3> entryFStart, array<double, 3> entryFEnd, array<double, 3> terminalFStart, array<double, 3> terminalFEnd, LineInterval& li){ double startDist=max(terminalFStart[0]-entryFStart[0], 0.0); double startDeriv=terminalFStart[1]-entryFStart[1]; double startDeriv2=terminalFStart[2]-entryFStart[2]; double endDist=max(terminalFEnd[0]-entryFEnd[0], 0.0); double endDeriv=terminalFEnd[1]-entryFEnd[1]; double endDeriv2=terminalFEnd[2]-entryFEnd[2]; double maxSide=max(startDist, endDist); double minSide=min(startDist, endDist); double upperBound = 0.0; double lowerBound = 0.0; if(startDeriv2*endDeriv2 <= 0 || startDeriv*endDeriv <= 0){ //if(startDeriv*endDeriv <= 0){ upperBound=weight * maxDist(); } else if(startDeriv*endDeriv <= 0){ double root=li.ApproxRoot(startDist, endDist, startDeriv, endDeriv); if(root < 0){ root=0.0; } if(startDeriv<0 || (startDeriv==0 && endDeriv>0)){ //cout << "root lower bound" << endl; upperBound=weight*maxSide; lowerBound=weight*root; } else{ /*cout << "root upper bound" << endl; cout << maxDist() << endl; cout << root << endl; cout << maxSide << endl;*/ //upperBound=weight*maxDist(); upperBound=weight*min(maxDist(), root); lowerBound=weight*minSide; } } else { upperBound=weight*maxSide; lowerBound=weight*minSide; } li.update(upperBound, lowerBound, terminalFStart[0], terminalFEnd[0], id); } array<double, 2> Shape2d::EntryEdge(LineInterval& li){ array<double, 2> entryEdgePolar; for(int i=1; i<=endVertex; ++i){ if(li.IntersectsEdge(vertices[i-1].Angle(), vertices[i].Angle())){ entryEdgePolar=polarEquation(vertices[i-1].Vec(), vertices[i].Vec()); break; } } return entryEdgePolar; } array<double, 2> Shape2d::TerminalEdge(LineInterval& li){ array<double, 2> terminalEdgePolar; for(int i=endVertex; i<vertices.size(); ++i){ int next=i+1; if(next==vertices.size()){ next=0; } if(li.IntersectsEdge(vertices[next].Angle(), vertices[i].Angle())){ terminalEdgePolar=polarEquation(vertices[next].Vec(), vertices[i].Vec()); break; } } return terminalEdgePolar; } double Shape2d::maxDist(){ double maxDist=0.0; for(int i=0; i<vertices.size(); ++i){ for(int j=i+1; j<vertices.size();++j){ Vector2d v0=vertices[i].Vec(); Vector2d v1=vertices[j].Vec(); double dist=sqrt(pow(v0[0]-v1[0], 2.0) + pow(v0[1]-v1[1], 2.0)); if(maxDist<dist){ maxDist=dist; } } } return maxDist; } int Shape2d::EndVertex(){ return endVertex; } Point2d::Point2d(Vector2d _vec, unsigned long int _shapeId, int _shapeVectorPos){ vec = _vec; shapeId = _shapeId; shapeVectorPos = _shapeVectorPos; angle = atan2(vec[1], vec[0]); } double Point2d::Angle(){ return angle; } unsigned long int Point2d::AngleId(){ return angleId; } unsigned long int Point2d::ShapeId(){ return shapeId; } int Point2d::ShapeVectorPos(){ return shapeVectorPos; } void Point2d::setAngleId(unsigned long int _angleId){ angleId = _angleId; } Vector2d Point2d::Vec(){ return vec; }
26.809645
168
0.673672
myociss
ee5bff431b78418152a18d87387fdf6e5eebe22e
1,147
cpp
C++
Day6_EvenOddString.cpp
Dkaban/30DaysOfCodePractice
a07bbefbd29fab22728402e2de25b2c086ed3749
[ "MIT" ]
null
null
null
Day6_EvenOddString.cpp
Dkaban/30DaysOfCodePractice
a07bbefbd29fab22728402e2de25b2c086ed3749
[ "MIT" ]
null
null
null
Day6_EvenOddString.cpp
Dkaban/30DaysOfCodePractice
a07bbefbd29fab22728402e2de25b2c086ed3749
[ "MIT" ]
null
null
null
// THE PROBLEM // *************************** // Given a string, S , of length N that is indexed from 0 to N-1, print its even-indexed // and odd-indexed characters as 2 space-separated strings on a single line. // Note: 0 is considered to be an even index. // Solution Created By: Dustin Kaban // Date: June 1st, 2020 // *************************** #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; string getEvenString(string word) { string temp = ""; //for(size_t i=0, max = word.length();i != max;i++) for(int i=0;i<word.length();i++) { if(i%2==0) { temp += word[i]; } } return temp; } string getOddString(string word) { string temp = ""; //for(size_t i=0, max = word.length();i != max;i++) for(int i=0;i<word.length();i++) { if(i%2 != 0) { temp += word[i]; } } return temp; } int main() { int size; scanf("%d",&size); string str; while(cin >> str) { cout << getEvenString(str) << " " << getOddString(str) << endl; } }
20.482143
89
0.523104
Dkaban
ee5dc5830dbf201725bed848402eadf34cc54fae
2,343
hpp
C++
Siv3D/src/Siv3D/Shader/GL/CShader_GL.hpp
Fuyutsubaki/OpenSiv3D
4370f6ebe28addd39bfdd75915c5a18e3e5e9273
[ "MIT" ]
null
null
null
Siv3D/src/Siv3D/Shader/GL/CShader_GL.hpp
Fuyutsubaki/OpenSiv3D
4370f6ebe28addd39bfdd75915c5a18e3e5e9273
[ "MIT" ]
null
null
null
Siv3D/src/Siv3D/Shader/GL/CShader_GL.hpp
Fuyutsubaki/OpenSiv3D
4370f6ebe28addd39bfdd75915c5a18e3e5e9273
[ "MIT" ]
1
2019-10-06T17:09:26.000Z
2019-10-06T17:09:26.000Z
//----------------------------------------------- // // This file is part of the Siv3D Engine. // // Copyright (c) 2008-2018 Ryo Suzuki // Copyright (c) 2016-2018 OpenSiv3D Project // // Licensed under the MIT License. // //----------------------------------------------- # pragma once # include <Siv3D/Platform.hpp> # if defined(SIV3D_TARGET_MACOS) || defined(SIV3D_TARGET_LINUX) # include "../IShader.hpp" # include <Siv3D/Array.hpp> # include <Siv3D/ByteArrayView.hpp> # include "VertexShader_GL.hpp" # include "PixelShader_GL.hpp" # include "../../AssetHandleManager/AssetHandleManager.hpp" namespace s3d { class CShader_GL : public ISiv3DShader { private: Array<VertexShader> m_standardVSs; Array<PixelShader> m_standardPSs; AssetHandleManager<VertexShaderID, VertexShader_GL> m_vertexShaders{ U"VertexShader" }; AssetHandleManager<PixelShaderID, PixelShader_GL> m_pixelShaders{ U"PixelShader" }; public: CShader_GL(); ~CShader_GL() override; bool init(); VertexShaderID createVS(ByteArray&&) override { return VertexShaderID::NullAsset(); } VertexShaderID createVSFromFile(const FilePath& path, const Array<BindingPoint>&) override; VertexShaderID createVSFromSource(const String& source, const Array<BindingPoint>& bindingPoints) override; PixelShaderID createPS(ByteArray&&) override { return PixelShaderID::NullAsset(); } PixelShaderID createPSFromFile(const FilePath& path, const Array<BindingPoint>&) override; PixelShaderID createPSFromSource(const String& source, const Array<BindingPoint>& bindingPoints) override; void releaseVS(VertexShaderID handleID) override; void releasePS(PixelShaderID handleID) override; ByteArrayView getBinaryViewVS(VertexShaderID) override { return ByteArrayView(); } ByteArrayView getBinaryViewPS(PixelShaderID) override { return ByteArrayView(); } const VertexShader& getStandardVS(size_t index) const override { return m_standardVSs[index]; } const PixelShader& getStandardPS(size_t index) const override { return m_standardPSs[index]; } void setVS(VertexShaderID) override {} void setPS(PixelShaderID) override {} GLuint getVSProgram(VertexShaderID handleID); GLuint getPSProgram(PixelShaderID handleID); void setPSSamplerUniform(PixelShaderID handleID); }; } # endif
24.925532
109
0.724285
Fuyutsubaki
ee602ff754eb713f5ee5f40e7faee640222c1d93
5,633
cpp
C++
extras/DemFiles/src/GridLib/RecordA.cpp
jebreimo/GridLib
a90a5299512eb01623881c62a1e5f73b9f2c2513
[ "BSD-2-Clause" ]
null
null
null
extras/DemFiles/src/GridLib/RecordA.cpp
jebreimo/GridLib
a90a5299512eb01623881c62a1e5f73b9f2c2513
[ "BSD-2-Clause" ]
null
null
null
extras/DemFiles/src/GridLib/RecordA.cpp
jebreimo/GridLib
a90a5299512eb01623881c62a1e5f73b9f2c2513
[ "BSD-2-Clause" ]
null
null
null
//**************************************************************************** // Copyright © 2020 Jan Erik Breimo. All rights reserved. // Created by Jan Erik Breimo on 2020-09-27. // // This file is distributed under the BSD License. // License text is included with the source distribution. //**************************************************************************** #include "RecordA.hpp" #include <ostream> #include "FortranReader.hpp" #include "PrintMacros.hpp" namespace GridLib { double to_degrees(const DegMinSec& dms) { return double(dms.degree) + dms.minute / 60.0 + dms.second / 3600.0; } std::ostream& operator<<(std::ostream& os, const DegMinSec& dms) { os << dms.degree << ' ' << dms.minute << ' ' << dms.second; return os; } std::ostream& operator<<(std::ostream& os, const CartesianCoordinates& cc) { return os << cc.easting << ' ' << cc.northing; } void print(const RecordA& rec, std::ostream& os) { WRITE_STRING(file_name); WRITE_STRING(text); WRITE_OPTIONAL(longitude); WRITE_OPTIONAL(latitude); WRITE_OPTIONAL(process_code); WRITE_OPTIONAL(process_code); WRITE_STRING(sectional_indicator); WRITE_STRING(origin_code); WRITE_OPTIONAL(dem_level_code); WRITE_OPTIONAL(elevation_pattern_code); WRITE_OPTIONAL(ref_sys); WRITE_OPTIONAL(ref_sys_zone); WRITE_ARRAY(map_projection_params); WRITE_OPTIONAL(horizontal_unit); WRITE_OPTIONAL(vertical_unit); WRITE_OPTIONAL(polygon_sides); WRITE_ARRAY(quadrangle_corners); WRITE_OPTIONAL(min_elevation); WRITE_OPTIONAL(max_elevation); WRITE_OPTIONAL(rotation_angle); WRITE_OPTIONAL(elevation_accuracy); WRITE_OPTIONAL(x_resolution); WRITE_OPTIONAL(y_resolution); WRITE_OPTIONAL(z_resolution); WRITE_OPTIONAL(rows); WRITE_OPTIONAL(columns); WRITE_OPTIONAL(largest_contour_interval); WRITE_OPTIONAL(largest_contour_interval_units); WRITE_OPTIONAL(smallest_contour_interval); WRITE_OPTIONAL(smallest_contour_interval_units); WRITE_OPTIONAL(data_source_year); WRITE_OPTIONAL(data_completion_year); WRITE_OPTIONAL(inspection_flag); WRITE_OPTIONAL(data_validation_flag); CAST_AND_WRITE_OPTIONAL(suspect_and_void_area_flag, int); CAST_AND_WRITE_OPTIONAL(vertical_datum, int); CAST_AND_WRITE_OPTIONAL(horizontal_datum, int); WRITE_OPTIONAL(data_edition); WRITE_OPTIONAL(percent_void); WRITE_OPTIONAL(edge_match_flag); WRITE_OPTIONAL(vertical_datum_shift); } std::optional<DegMinSec> read_DegMinSec(FortranReader& reader) { auto d = reader.read_int16(4); auto m = reader.read_int16(2); auto s = reader.read_float32(7); if (!d || !m || !s) return {}; return DegMinSec{*d, *m, *s}; } RecordA read_record_a(FortranReader& reader) { RecordA result; result.file_name = reader.read_string(40); result.text = reader.read_string(40); reader.skip(29); result.longitude = read_DegMinSec(reader); result.latitude = read_DegMinSec(reader); result.process_code = reader.read_char(); reader.skip(1); result.sectional_indicator = reader.read_string(3); result.origin_code = reader.read_string(4); result.dem_level_code = reader.read_int16(6); result.elevation_pattern_code = reader.read_int16(6); result.ref_sys = reader.read_int16(6); result.ref_sys_zone = reader.read_int16(6); for (auto& param : result.map_projection_params) param = reader.read_float64(24); result.horizontal_unit = reader.read_int16(6); result.vertical_unit = reader.read_int16(6); result.polygon_sides = reader.read_int16(6); for (auto& corner : result.quadrangle_corners) { auto e = reader.read_float64(24); auto n = reader.read_float64(24); if (e && n) corner = {*e, *n}; } result.min_elevation = reader.read_float64(24); result.max_elevation = reader.read_float64(24); result.rotation_angle = reader.read_float64(24); result.elevation_accuracy = reader.read_int16(6); result.x_resolution = reader.read_float32(12); result.y_resolution = reader.read_float32(12); result.z_resolution = reader.read_float32(12); result.rows = reader.read_int16(6); result.columns = reader.read_int16(6); result.largest_contour_interval = reader.read_int16(5); result.largest_contour_interval_units = reader.read_int8(1); result.smallest_contour_interval = reader.read_int16(5); result.smallest_contour_interval_units = reader.read_int8(1); result.data_source_year = reader.read_int16(4); result.data_completion_year = reader.read_int16(4); result.inspection_flag = reader.read_char(); result.data_validation_flag = reader.read_int8(1); result.suspect_and_void_area_flag = reader.read_int8(2); result.vertical_datum = reader.read_int8(2); result.horizontal_datum = reader.read_int8(2); result.data_edition = reader.read_int16(4); result.percent_void = reader.read_int16(4); result.edge_match_flag = reader.read_int32(8); result.vertical_datum_shift = reader.read_float64(7); reader.skip(109); return result; } }
39.391608
78
0.644239
jebreimo
ee621943b6e50ddee2c12886a961aba64ef11a73
1,528
cpp
C++
fxjs/xfa/cjx_area.cpp
aosp-caf-upstream/platform_external_pdfium
c8a0db7d7c3e0017de4eeeb69e434b5f3b6ee386
[ "BSD-3-Clause" ]
2,151
2020-04-18T07:31:17.000Z
2022-03-31T08:39:18.000Z
fxjs/xfa/cjx_area.cpp
aosp-caf-upstream/platform_external_pdfium
c8a0db7d7c3e0017de4eeeb69e434b5f3b6ee386
[ "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
fxjs/xfa/cjx_area.cpp
aosp-caf-upstream/platform_external_pdfium
c8a0db7d7c3e0017de4eeeb69e434b5f3b6ee386
[ "BSD-3-Clause" ]
338
2020-04-18T08:03:10.000Z
2022-03-29T12:33:22.000Z
// Copyright 2017 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "fxjs/xfa/cjx_area.h" #include "xfa/fxfa/parser/cxfa_area.h" CJX_Area::CJX_Area(CXFA_Area* node) : CJX_Container(node) {} CJX_Area::~CJX_Area() = default; void CJX_Area::colSpan(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { Script_Attribute_String(pValue, bSetting, eAttribute); } void CJX_Area::relevant(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { Script_Attribute_String(pValue, bSetting, eAttribute); } void CJX_Area::use(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { Script_Attribute_String(pValue, bSetting, eAttribute); } void CJX_Area::usehref(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { Script_Attribute_String(pValue, bSetting, eAttribute); } void CJX_Area::x(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { Script_Attribute_String(pValue, bSetting, eAttribute); } void CJX_Area::y(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { Script_Attribute_String(pValue, bSetting, eAttribute); }
30.56
80
0.657723
aosp-caf-upstream
ee63df5b7532e903b35e11f31434233845efc52c
7,464
cpp
C++
src/linux/PeripheralBase.cpp
fidoriel/SimpleBLE
6ffb6bec0624913c47d3bac36370bdd3e2744a15
[ "MIT" ]
2
2021-07-20T06:27:08.000Z
2021-07-28T05:47:11.000Z
third_party/SimpleBLE/src/linux/PeripheralBase.cpp
HDPNC/brainflow
ede79fbd5fcc823c1c64bcc3af3e88b4d12177bf
[ "MIT" ]
null
null
null
third_party/SimpleBLE/src/linux/PeripheralBase.cpp
HDPNC/brainflow
ede79fbd5fcc823c1c64bcc3af3e88b4d12177bf
[ "MIT" ]
null
null
null
#include "PeripheralBase.h" #include <simpleble/Exceptions.h> #include "Bluez.h" #include <iostream> using namespace SimpleBLE; using namespace std::chrono_literals; PeripheralBase::PeripheralBase(std::shared_ptr<BluezDevice> device) { device_ = device; // NOTE: As Bluez will delete the object if it was advertising as non-connectable, // we need to keep a copy of some of the properties around. identifier_ = device->get_name(); address_ = device->get_address(); } PeripheralBase::~PeripheralBase() {} std::string PeripheralBase::identifier() { return identifier_; } BluetoothAddress PeripheralBase::address() { return address_; } void PeripheralBase::connect() { // Attempt to connect to the device. for (size_t i = 0; i < 5; i++) { if (_attempt_connect()) { break; } } if (!is_connected()) { throw Exception::OperationFailed(); } } void PeripheralBase::disconnect() { // Attempt to connect to the device. for (size_t i = 0; i < 5; i++) { if (_attempt_disconnect()) { break; } } if (is_connected()) { throw Exception::OperationFailed(); } } bool PeripheralBase::is_connected() { auto device = _get_device(); // NOTE: For Bluez, a device being connected means that it's both // connected and services have been resolved. return device->Property_Connected() && device->Property_ServicesResolved(); } bool PeripheralBase::is_connectable() { return identifier_ != ""; } std::vector<BluetoothService> PeripheralBase::services() { auto device = _get_device(); std::vector<BluetoothService> service_list; for (auto service_uuid : device->get_service_list()) { BluetoothService service; service.uuid = service_uuid; service.characteristics = device->get_characteristic_list(service_uuid); service_list.push_back(service); } return service_list; } std::map<uint16_t, ByteArray> PeripheralBase::manufacturer_data() { auto device = _get_device(); std::map<uint16_t, ByteArray> manufacturer_data; for (auto& [manufacturer_id, value_array] : device->get_manufacturer_data()) { manufacturer_data[manufacturer_id] = ByteArray((const char*)value_array.data(), value_array.size()); } return manufacturer_data; } ByteArray PeripheralBase::read(BluetoothUUID service, BluetoothUUID characteristic) { // TODO: Check if the characteristic is readable. auto characteristic_object = _get_characteristic(service, characteristic); std::vector<uint8_t> value = characteristic_object->Property_Value(); return ByteArray((const char*)value.data(), value.size()); } void PeripheralBase::write_request(BluetoothUUID service, BluetoothUUID characteristic, ByteArray data) { // TODO: Check if the characteristic is writable. auto characteristic_object = _get_characteristic(service, characteristic); characteristic_object->write_request((const uint8_t*)data.c_str(), data.size()); } void PeripheralBase::write_command(BluetoothUUID service, BluetoothUUID characteristic, ByteArray data) { // TODO: Check if the characteristic is writable. auto characteristic_object = _get_characteristic(service, characteristic); characteristic_object->write_command((const uint8_t*)data.c_str(), data.size()); } void PeripheralBase::notify(BluetoothUUID service, BluetoothUUID characteristic, std::function<void(ByteArray payload)> callback) { // TODO: What to do if the characteristic is already being notified? // TODO: Check if the property can be notified. auto characteristic_object = _get_characteristic(service, characteristic); characteristic_object->ValueChanged = [=](std::vector<uint8_t> value) { callback(ByteArray((const char*)value.data(), value.size())); }; characteristic_object->Action_StartNotify(); } void PeripheralBase::indicate(BluetoothUUID service, BluetoothUUID characteristic, std::function<void(ByteArray payload)> callback) { // TODO: What to do if the characteristic is already being indicated? // TODO: Check if the property can be indicated. auto characteristic_object = _get_characteristic(service, characteristic); characteristic_object->ValueChanged = [=](std::vector<uint8_t> value) { callback(ByteArray((const char*)value.data(), value.size())); }; characteristic_object->Action_StartNotify(); } void PeripheralBase::unsubscribe(BluetoothUUID service, BluetoothUUID characteristic) { // TODO: What to do if the characteristic is not being notified? auto characteristic_object = _get_characteristic(service, characteristic); characteristic_object->Action_StopNotify(); // Wait for the characteristic to stop notifying. // TODO: Upgrade SimpleDBus to provide a way to wait for this signal. auto timeout = std::chrono::system_clock::now() + 5s; while (characteristic_object->Property_Notifying() && std::chrono::system_clock::now() < timeout) { std::this_thread::sleep_for(50ms); } } void PeripheralBase::set_callback_on_connected(std::function<void()> on_connected) { callback_on_connected_ = on_connected; } void PeripheralBase::set_callback_on_disconnected(std::function<void()> on_disconnected) { callback_on_disconnected_ = on_disconnected; } // Private methods bool PeripheralBase::_attempt_connect() { auto device = _get_device(); // Set the OnServiceDiscovered callback, which should properly indicate // if the connection has been established. device->OnServicesResolved = [=]() { this->connection_cv_.notify_all(); }; // Set the OnDisconnected callback device->OnDisconnected = [this]() { this->disconnection_cv_.notify_all(); if (this->callback_on_disconnected_) { this->callback_on_disconnected_(); } }; device->Action_Connect(); // Wait for the connection to be confirmed. // The condition variable will return false if the connection was not established. std::unique_lock<std::mutex> lock(connection_mutex_); return connection_cv_.wait_for(lock, 1s, [this]() { return is_connected(); }); } bool PeripheralBase::_attempt_disconnect() { auto device = _get_device(); device->Action_Disconnect(); // Wait for the disconnection to be confirmed. // The condition variable will return false if the connection is still active. std::unique_lock<std::mutex> lock(disconnection_mutex_); return disconnection_cv_.wait_for(lock, 1s, [this]() { return !is_connected(); }); } std::shared_ptr<BluezDevice> PeripheralBase::_get_device() { std::shared_ptr<BluezDevice> device = device_.lock(); if (!device) { throw Exception::InvalidReference(); } return device; } std::shared_ptr<BluezGattCharacteristic> PeripheralBase::_get_characteristic(BluetoothUUID service_uuid, BluetoothUUID characteristic_uuid) { auto device = _get_device(); auto service = device->get_service(service_uuid); if (!service) { throw Exception::ServiceNotFound(service_uuid); } auto characteristic = service->get_characteristic(characteristic_uuid); if (!characteristic) { throw Exception::CharacteristicNotFound(characteristic_uuid); } return characteristic; }
35.042254
113
0.703108
fidoriel
ee6516faf70ef7cc7b34e4633d03baa835bd3fd2
866
cpp
C++
QtQuickPlotScene/utils.cpp
pwuertz/QtQuickPlotScene
6afb0f99132e29b705d991dfce6107f6732ffcbd
[ "MIT" ]
10
2021-12-23T12:07:24.000Z
2022-01-15T09:20:22.000Z
QtQuickPlotScene/utils.cpp
pwuertz/QtQuickPlotScene
6afb0f99132e29b705d991dfce6107f6732ffcbd
[ "MIT" ]
null
null
null
QtQuickPlotScene/utils.cpp
pwuertz/QtQuickPlotScene
6afb0f99132e29b705d991dfce6107f6732ffcbd
[ "MIT" ]
2
2021-12-24T04:03:45.000Z
2022-01-15T08:08:34.000Z
#include "utils.hpp" #include <cmath> Utils::Utils(QObject *parent) : QObject {parent} { } std::pair<qreal, qreal> Utils::calcNiceNum(const qreal number, const bool logMode) noexcept { const auto exponent = std::floor(std::log10(number)); const auto fraction = number / std::pow(qreal(10), exponent); auto nicePrecision = -exponent; const auto niceFrac = [&]() -> qreal { if (fraction <= 1) { return 1; } else if (fraction <= 2) { return 2; } else if (fraction <= 2.5) { nicePrecision += 1; return 2.5; } else if (fraction <= 5) { return 5; } else { nicePrecision -= 1; return 10; } }(); const auto niceNumber = niceFrac * std::pow(qreal(10), exponent); if (logMode) { return { std::ceil(std::max(qreal(1), niceNumber)), std::max(nicePrecision, qreal(0)) }; } return { niceNumber, std::max(nicePrecision, qreal(0)) }; }
33.307692
92
0.635104
pwuertz
ee65d7cba452972cc0e47752543c8e8f9f0383e6
2,491
cpp
C++
snapshotable_allocator_test.cpp
jyaif/snapshotable_allocator
711dff8d6414265476bf8eb83eece563c0c183a8
[ "MIT" ]
null
null
null
snapshotable_allocator_test.cpp
jyaif/snapshotable_allocator
711dff8d6414265476bf8eb83eece563c0c183a8
[ "MIT" ]
null
null
null
snapshotable_allocator_test.cpp
jyaif/snapshotable_allocator
711dff8d6414265476bf8eb83eece563c0c183a8
[ "MIT" ]
null
null
null
#include "application/memory/snapshotable_allocator.h" #include "application/memory/snapshotable_allocator_impl.h" #include "third_party/nex_test/src/test.h" #include <cassert> #include <cstdio> template <class T> void SnapshotTest() { T sm; auto snapshot1 = sm.NewEmptySnapshot(); sm.SaveMemoryIntoSnapshot(*snapshot1); const char special_char_1 = 'k'; const char special_char_2 = 'p'; void* ptr = sm.Alloc(100); memset(ptr, special_char_1, 100); auto snapshot2 = sm.NewEmptySnapshot(); sm.SaveMemoryIntoSnapshot(*snapshot2); sm.LoadMemoryFromSnapshot(*snapshot1); void* ptr2 = sm.Alloc(100); assert(ptr == ptr2); memset(ptr2, special_char_2, 100); sm.LoadMemoryFromSnapshot(*snapshot2); for (int i = 0; i < 100; i++) { assert(static_cast<char*>(ptr)[i] == special_char_1); } } template <class T> void AllocAndFree() { T sm; // Check that you can free nullptr without crashing. sm.Free(nullptr); // Check that you can write to allocated memory. void* ptr = sm.Alloc(1000); memset(ptr, 0, 1000); // Check that the same allocation after a |free| returns the same pointer. sm.Free(ptr); void* ptr2 = sm.Alloc(1000); assert(ptr == ptr2); } template <class T> void Realloc() { T sm; // Check that re-allocating the same size returns the same pointer and same // data. uint8_t* ptr = static_cast<uint8_t*>(sm.Alloc(100)); for (int i = 0; i < 100; i++) { ptr[i] = i * 2; } uint8_t* ptr2 = static_cast<uint8_t*>(sm.Realloc(ptr, 100)); assert(ptr == ptr2); for (int i = 0; i < 100; i++) { assert(ptr2[i] == i * 2); } // Check that re-allocating to a much larger size results in a new pointer // with memory copied. const char special_char = 'x'; memset(ptr, special_char, 100); void* ptr3 = sm.Realloc(ptr2, 1000); assert(ptr3 != ptr); for (int i = 0; i < 100; i++) { assert(static_cast<char*>(ptr3)[i] == special_char); } } template <class T> void ManyAllocations() { T sm; for (int i = 0; i < 1000; i++) { sm.Alloc(100); } auto snapshot = sm.NewEmptySnapshot(); sm.SaveMemoryIntoSnapshot(*snapshot); sm.LoadMemoryFromSnapshot(*snapshot); } NEX_TEST(Memory, AllocAndFree) { AllocAndFree<SnapshotableAllocatorImpl>(); } NEX_TEST(Memory, Realloc) { Realloc<SnapshotableAllocatorImpl>(); } NEX_TEST(Memory, SnapshotTest) { SnapshotTest<SnapshotableAllocatorImpl>(); } NEX_TEST(Memory, ManyAllocations) { ManyAllocations<SnapshotableAllocatorImpl>(); }
23.5
77
0.676435
jyaif
ee687c5ca3d58fe09e5bbd2c5682e697ca462a58
5,530
cpp
C++
Labirinto_AStar/mainwindow.cpp
Bernardo1411/Programacao_Avancada
5005b60155648872ca9d4f374b3d9ea035aa33a3
[ "MIT" ]
null
null
null
Labirinto_AStar/mainwindow.cpp
Bernardo1411/Programacao_Avancada
5005b60155648872ca9d4f374b3d9ea035aa33a3
[ "MIT" ]
null
null
null
Labirinto_AStar/mainwindow.cpp
Bernardo1411/Programacao_Avancada
5005b60155648872ca9d4f374b3d9ea035aa33a3
[ "MIT" ]
null
null
null
#include "mainwindow.h" #include "ui_mainwindow.h" #include "labirinto.h" #include <QFileDialog> #include <QMessageBox> #include <chrono> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); status = new QLabel(""); statusBar()->addWidget(status); ui->tableWidget->setStyleSheet("QHeaderView::section {background-color:lightgray}"); ui->radioButton->setChecked(true); redefinir_tabela(); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_tableWidget_cellDoubleClicked(int row, int column) { if (labirinto.celulaLivre(Coord(row, column))) { if (ui->radioButton->isChecked()) { labirinto.setOrigem(Coord(row, column)); ui->radioButton_2->setChecked(true); } else if (ui->radioButton_2->isChecked()) { labirinto.setDestino(Coord(row, column)); ui->radioButton->setChecked(true); } redefinir_tabela(); status->setText(""); } else { return; } } void MainWindow::on_actionLer_triggered() { QString filename = QFileDialog::getOpenFileName(); if (!labirinto.ler(filename.toStdString())) { QMessageBox erro; erro.setText("erro na leitura do arquivo " + filename); erro.exec(); } else { redefinir_tabela(); } } void MainWindow::on_actionSalvar_triggered() { if (!labirinto.empty()) { QString filename = QFileDialog::getOpenFileName(); if (!labirinto.salvar(filename.toStdString())) { QMessageBox erro; erro.setText("erro na escrita do arquivo " + filename); erro.exec(); } } else { QMessageBox erro; erro.setText("erro: mapa vazio"); erro.exec(); } } void MainWindow::on_actionGerar_triggered() { if (!labirinto.gerar()) { QMessageBox erro; erro.setText("erro na geracao do mapa"); erro.exec(); } else { redefinir_tabela(); } } void MainWindow::on_actionSair_triggered() { QCoreApplication::quit(); } void MainWindow::on_actionCalcular_triggered() { if (labirinto.empty()) { QMessageBox erro; erro.setText("erro: mapa vazio"); erro.exec(); } else if (!labirinto.origDestDefinidos()){ QMessageBox erro; erro.setText("erro: origem e destino nao definidos"); erro.exec(); } else { int NN; int NA; int NF; chrono::steady_clock::time_point t0 = chrono::steady_clock::now(); double comprimento = labirinto.calculaCaminho(NN, NA, NF); chrono::steady_clock::time_point t1 = chrono::steady_clock::now(); chrono::duration<double> dt = chrono::duration_cast<chrono::duration<double>>(t1 - t0); double dt_ms = 1000 * dt.count(); if (comprimento > 0.0) { redefinir_tabela(); status->setText(QString::number(comprimento)); QMessageBox resultado; resultado.setText("caminho encontrado!\nnumero de nos em aberto: " + QString::number(NA) + "\nnumero de nos em fechado: " + QString::number(NF) + "\ntempo de execucao: " + QString::number(dt_ms)); resultado.exec(); } else { QMessageBox resultado; resultado.setText("caminho nao encontrado!\nnumero de nos em aberto: " + QString::number(NA) + "\nnumero de nos em fechado: " + QString::number(NF) + "\ntempo de execucao: " + QString::number(dt_ms)); resultado.exec(); } } } void MainWindow::on_actionLimpar_triggered() { labirinto.limpaCaminho(); redefinir_tabela(); status->setText(""); } void MainWindow::redefinir_tabela() { ui->tableWidget->clear(); ui->tableWidget->setRowCount(labirinto.getNumLin()); ui->tableWidget->setColumnCount(labirinto.getNumCol()); for (int i=0; i<ui->tableWidget->rowCount(); i++) { for (int j=0; j<ui->tableWidget->columnCount(); j++) { QLabel* prov = new QLabel(""); prov->setAlignment(Qt::AlignCenter); ui->tableWidget->setCellWidget(i, j, prov); if (labirinto.at(i, j) == EstadoCel::LIVRE) { ui->tableWidget->cellWidget(i, j)->setStyleSheet("background: white"); prov->setText(""); } else if (labirinto.at(i, j) == EstadoCel::OBSTACULO) { ui->tableWidget->cellWidget(i, j)->setStyleSheet("background: black"); prov->setText(""); } if (labirinto.at(i, j) == EstadoCel::CAMINHO) { ui->tableWidget->cellWidget(i, j)->setStyleSheet("background: white"); prov->setText("X"); } else if (labirinto.at(i, j) == EstadoCel::ORIGEM) { ui->tableWidget->cellWidget(i, j)->setStyleSheet("background: yellow"); prov->setText("O"); } else if (labirinto.at(i, j) == EstadoCel::DESTINO) { ui->tableWidget->cellWidget(i, j)->setStyleSheet("background: green"); prov->setText("D"); } } } status->setText(""); }
28.95288
95
0.55009
Bernardo1411
ee6911d5e489b2224f74a0a45bc6f6287b928219
1,712
cpp
C++
examples/sapp/src/cpp/QRCodeScannerPage.cpp
emarc99/SLib
4e492d6c550f845fd1b3f40bf10183097eb0e53c
[ "MIT" ]
146
2017-03-21T07:50:43.000Z
2022-03-19T03:32:22.000Z
examples/sapp/src/cpp/QRCodeScannerPage.cpp
Crasader/SLib
4e492d6c550f845fd1b3f40bf10183097eb0e53c
[ "MIT" ]
50
2017-03-22T04:08:15.000Z
2019-10-21T16:55:48.000Z
examples/sapp/src/cpp/QRCodeScannerPage.cpp
Crasader/SLib
4e492d6c550f845fd1b3f40bf10183097eb0e53c
[ "MIT" ]
55
2017-03-21T07:52:58.000Z
2021-12-27T13:02:08.000Z
/* * Copyright (c) 2008-2018 SLIBIO <https://github.com/SLIBIO> * * 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 "QRCodeScannerPage.h" void QRCodeScannerPage::onOpen() { scanner->setOnDetect([this](slib::QRCodeScanner*, String qr_code) { result->setText(String::format("%s\n\nDetected on %s", qr_code, Time::now())); }); btnToggleTorch->setOnClick([this](View*) { if (Camera::isMobileDeviceTorchActive()) { Camera::setMobileDeviceTorchMode(CameraTorchMode::Off); btnToggleTorch->setText("Torch: Off"); } else { Camera::setMobileDeviceTorchMode(CameraTorchMode::On); btnToggleTorch->setText("Torch: On"); } }); }
41.756098
82
0.728972
emarc99
ee6bc87d34b309446f6f27f37856c10c4747d49f
781
cpp
C++
src/application/gui/propertyeditor/EvSpiceNumberDelegate.cpp
kaabimg/EvLibrary
47acd8fdb39c05edb843238a61d0faea5ed6ea88
[ "Unlicense" ]
2
2017-02-01T11:05:26.000Z
2017-07-10T13:26:29.000Z
src/application/gui/propertyeditor/EvSpiceNumberDelegate.cpp
kaabimg/EvLibrary
47acd8fdb39c05edb843238a61d0faea5ed6ea88
[ "Unlicense" ]
null
null
null
src/application/gui/propertyeditor/EvSpiceNumberDelegate.cpp
kaabimg/EvLibrary
47acd8fdb39c05edb843238a61d0faea5ed6ea88
[ "Unlicense" ]
null
null
null
#include "EvSpiceNumberDelegate.h" #include "EvSpiceNumber.h" #include <QLineEdit> QWidget *EvSpiceNumberDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const { return new QLineEdit(parent); } void EvSpiceNumberDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QLineEdit * lineEdit = qobject_cast<QLineEdit*>(editor); EvProperty * p = property(index); lineEdit->setText(qvariant_cast<EvSpiceNumber>(p->value()).toString()); } void EvSpiceNumberDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { EvSpiceNumber number(qobject_cast<QLineEdit*>(editor)->text()); if(number.isValid()) model->setData(index,number,Qt::EditRole); }
30.038462
118
0.75032
kaabimg
ee7367f08f54b7d91a1620b3461b3aa2538901c7
3,416
cpp
C++
test/coind_tests/data_test.cpp
frstrtr/cp2pool
13a65a8c809fe559a52c6ca270b3646b38941a30
[ "MIT" ]
1
2020-02-01T12:39:08.000Z
2020-02-01T12:39:08.000Z
test/coind_tests/data_test.cpp
frstrtr/cpool
13a65a8c809fe559a52c6ca270b3646b38941a30
[ "MIT" ]
null
null
null
test/coind_tests/data_test.cpp
frstrtr/cpool
13a65a8c809fe559a52c6ca270b3646b38941a30
[ "MIT" ]
null
null
null
#include <gtest/gtest.h> #include <tuple> #include <string> #include <sstream> #include <iostream> #include <btclibs/uint256.h> #include <btclibs/arith_uint256.h> #include <libcoind/data.h> using namespace std; uint256 CreateUINT256(string _hex){ uint256 result; result.SetHex(_hex); return result; } TEST(BitcoindDataTest, target_to_averate_attempts_test){ auto first = CreateUINT256("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); uint256 first_res = coind::data::target_to_average_attempts(first); cout << first_res.GetHex() << endl; ASSERT_EQ(first_res.GetHex(), "0000000000000000000000000000000000000000000000000000000000000001"); auto second = CreateUINT256("1"); uint256 second_res = coind::data::target_to_average_attempts(second); cout << second_res.GetHex() << endl; //Note: in Python: '0x8000000000000000000000000000000000000000000000000000000000000000' ASSERT_EQ(second_res.GetHex(), "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); auto third = CreateUINT256("100000000000000000000000000000000"); uint256 third_res = coind::data::target_to_average_attempts(third); cout << third_res.GetHex() << endl; ASSERT_EQ(third_res.GetHex(), "00000000000000000000000000000000ffffffffffffffffffffffffffffffff"); auto fourth = CreateUINT256("ffffffffffffffffffffffffffffffff"); uint256 fourth_res = coind::data::target_to_average_attempts(fourth); cout << fourth_res.GetHex() << endl; ASSERT_EQ(fourth_res.GetHex(), "00000000000000000000000000000000ffffffffffffffffffffffffffffffff"); } TEST(BitcoindDataTest, average_attempts_to_target_test){ auto first = CreateUINT256("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); uint256 first_res = coind::data::average_attempts_to_target(first); cout << first_res.GetHex() << endl; ASSERT_EQ(first_res.GetHex(), "0000000000000000000000000000000000000000000000000000000000000000"); auto second = CreateUINT256("100000000000000000000000000000000"); uint256 second_res = coind::data::target_to_average_attempts(second); cout << second_res.GetHex() << endl; //Note: in Python: '0x8000000000000000000000000000000000000000000000000000000000000000' ASSERT_EQ(second_res.GetHex(), "0000000000000000000000000000000100000000000000000000000000000000"); auto third = CreateUINT256("100000000000000000000000000000000"); uint256 third_res = coind::data::target_to_average_attempts(third); cout << third_res.GetHex() << endl; ASSERT_EQ(third_res.GetHex(), "00000000000000000000000000000000ffffffffffffffffffffffffffffffff"); auto fourth = CreateUINT256("ffffffffffffffffffffffffffffffff"); uint256 fourth_res = coind::data::target_to_average_attempts(fourth); cout << fourth_res.GetHex() << endl; ASSERT_EQ(fourth_res.GetHex(), "00000000000000000000000000000000ffffffffffffffffffffffffffffffff"); } TEST(CoindDataTest, hash256_from_hash_link_test) { uint32_t _init[8] {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05644c, 0x1f83d9ab, 0x5be0cd12}; auto result = coind::data::hash256_from_hash_link(_init, (unsigned char*)"12345678901234ac", (unsigned char*) "12345678901234ac", 128/8); std::cout << result.GetHex() << std::endl; ASSERT_EQ(result.GetHex(), "209c335d5b5d3f5735d44b33ec1706091969060fddbdb26a080eb3569717fb9e"); }
48.112676
141
0.780738
frstrtr
ee7520ad663d352625dd18ec50c6c4a6f7de3337
5,754
hpp
C++
cpp/Autogarden/include/pins/factory.hpp
e-dang/Autogarden
b15217e5d4755fc028b8dc4255cbdcb77ead80f4
[ "MIT" ]
null
null
null
cpp/Autogarden/include/pins/factory.hpp
e-dang/Autogarden
b15217e5d4755fc028b8dc4255cbdcb77ead80f4
[ "MIT" ]
null
null
null
cpp/Autogarden/include/pins/factory.hpp
e-dang/Autogarden
b15217e5d4755fc028b8dc4255cbdcb77ead80f4
[ "MIT" ]
null
null
null
#pragma once #include <functional> #include <pins/logic_input.hpp> #include <pins/logic_input_pinset.hpp> #include <pins/logic_output.hpp> #include <pins/logic_output_pinset.hpp> #include <pins/terminal.hpp> #include <pins/terminal_pinset.hpp> class IPinFactory { public: virtual ~IPinFactory() = default; virtual std::unique_ptr<ITerminalPin> createTerminalPin(const int& pinNum, const PinMode& pinMode) = 0; virtual std::unique_ptr<ILogicOutputPin> createLogicOutputPin(const int& pinNum, const PinMode& pinMode) = 0; virtual std::unique_ptr<ILogicInputPin> createLogicInputPin(const int& pinNum, const PinMode& pinMode) = 0; virtual std::unique_ptr<ITerminalPinSet> createTerminalPinSet(const std::initializer_list<int>& pinNums, const PinMode& pinMode) = 0; virtual std::unique_ptr<ITerminalPinSet> createTerminalPinSet(const int& numPins, const PinMode& pinMode) = 0; virtual std::unique_ptr<ILogicOutputPinSet> createLogicOutputPinSet(const std::initializer_list<int>& pinNums, const PinMode& pinMode) = 0; virtual std::unique_ptr<ILogicOutputPinSet> createLogicOutputPinSet(const int& numPins, const PinMode& pinMode) = 0; virtual std::unique_ptr<ILogicInputPinSet> createLogicInputPinSet(const std::initializer_list<int>& pinNums, const PinMode& pinMode) = 0; virtual std::unique_ptr<ILogicInputPinSet> createLogicInputPinSet(const int& numPins, const PinMode& pinMode) = 0; }; class PinFactory : public IPinFactory { public: std::unique_ptr<ITerminalPin> createTerminalPin(const int& pinNum, const PinMode& pinMode) override { return std::make_unique<TerminalPin>(pinNum, pinMode); } std::unique_ptr<ILogicOutputPin> createLogicOutputPin(const int& pinNum, const PinMode& pinMode) override { return std::make_unique<LogicOutputPin>(pinNum, pinMode); } std::unique_ptr<ILogicInputPin> createLogicInputPin(const int& pinNum, const PinMode& pinMode) override { return std::make_unique<LogicInputPin>(pinNum, pinMode); } std::unique_ptr<ITerminalPinSet> createTerminalPinSet(const std::initializer_list<int>& pinNums, const PinMode& pinMode) override { auto createPin = [this](const int& pinNum, const PinMode& pinMode) { return this->createTerminalPin(pinNum, pinMode); }; return __createPinSet<TerminalPinSet, ITerminalPin>(pinNums, pinMode, createPin); } std::unique_ptr<ITerminalPinSet> createTerminalPinSet(const int& numPins, const PinMode& pinMode) override { auto createPin = [this](const int& pinNum, const PinMode& pinMode) { return this->createTerminalPin(pinNum, pinMode); }; return __createPinSet<TerminalPinSet, ITerminalPin>(numPins, pinMode, createPin); } std::unique_ptr<ILogicOutputPinSet> createLogicOutputPinSet(const std::initializer_list<int>& pinNums, const PinMode& pinMode) override { auto createPin = [this](const int& pinNum, const PinMode& pinMode) { return this->createLogicOutputPin(pinNum, pinMode); }; return __createPinSet<LogicOutputPinSet, ILogicOutputPin>(pinNums, pinMode, createPin); } std::unique_ptr<ILogicOutputPinSet> createLogicOutputPinSet(const int& numPins, const PinMode& pinMode) override { auto createPin = [this](const int& pinNum, const PinMode& pinMode) { return this->createLogicOutputPin(pinNum, pinMode); }; return __createPinSet<LogicOutputPinSet, ILogicOutputPin>(numPins, pinMode, createPin); } std::unique_ptr<ILogicInputPinSet> createLogicInputPinSet(const std::initializer_list<int>& pinNums, const PinMode& pinMode) override { auto createPin = [this](const int& pinNum, const PinMode& pinMode) { return this->createLogicInputPin(pinNum, pinMode); }; return __createPinSet<LogicInputPinSet, ILogicInputPin>(pinNums, pinMode, createPin); } std::unique_ptr<ILogicInputPinSet> createLogicInputPinSet(const int& numPins, const PinMode& pinMode) override { auto createPin = [this](const int& pinNum, const PinMode& pinMode) { return this->createLogicInputPin(pinNum, pinMode); }; return __createPinSet<LogicInputPinSet, ILogicInputPin>(numPins, pinMode, createPin); } private: template <typename T, typename U> std::unique_ptr<T> __createPinSet(const std::initializer_list<int>& pinNums, const PinMode& pinMode, std::function<std::unique_ptr<U>(const int&, const PinMode&)> createPin) { std::vector<std::unique_ptr<U>> pins; pins.reserve(pinNums.size()); for (const auto& pinNum : pinNums) { pins.emplace_back(createPin(pinNum, pinMode)); } return std::make_unique<T>(std::move(pins)); } template <typename T, typename U> std::unique_ptr<T> __createPinSet(const int& numPins, const PinMode& pinMode, std::function<std::unique_ptr<U>(const int&, const PinMode&)> createPin) { std::vector<std::unique_ptr<U>> pins; pins.reserve(numPins); for (int i = 0; i < numPins; i++) { pins.emplace_back(createPin(i, pinMode)); } return std::make_unique<T>(std::move(pins)); } };
49.603448
120
0.648766
e-dang
ee7667a329239c078ab356a01f4b4b182a551bbf
978
cpp
C++
BeautifulCPPKateGregory/finding.cpp
przet/CppProgramming
042aff253988b74db47659d36806912ce84dd8bc
[ "MIT" ]
null
null
null
BeautifulCPPKateGregory/finding.cpp
przet/CppProgramming
042aff253988b74db47659d36806912ce84dd8bc
[ "MIT" ]
null
null
null
BeautifulCPPKateGregory/finding.cpp
przet/CppProgramming
042aff253988b74db47659d36806912ce84dd8bc
[ "MIT" ]
null
null
null
#include<iostream> #include<algorithm> #include<vector> #include<string> int main () { std::vector<int> v{1,2,3,5,100,4,7,4}; auto result = std::find(begin(v),end(v),100); auto resultDeref = *result; //STL find's return an iterator for generality: not everything // can be nicely indexed std::cout<< resultDeref << std::endl; result = std::find(result,end(v),4); if (result != end(v)) std::cout << "we have found what we are looking for" << std::endl; //result, begin(v) and end(v) are iterators. end(v) points to one after the end of v //works for strings too (or any collection). Note the initialization style: std::string s{"Hello There Matey!"}; auto letter = std::find(begin(s),end(s),'a'); std::cout << *letter << std::endl; //TODO: the below won't work though... I will get a pointer vs integer comparison forbidden error (C++ forbids) at compile time // auto word = std::find(begin(s),end(s),"Hello"); // std::cout << *word << std::endl; return 0; }
32.6
128
0.668712
przet
ee77501335aab0a7dadba9907bbc0d0c49be8a6a
926
hpp
C++
opengl_renderer/model.hpp
Learko/opengl_renderer
fa930fa0ebf739295f93b0b6ca44568805bf0943
[ "MIT" ]
null
null
null
opengl_renderer/model.hpp
Learko/opengl_renderer
fa930fa0ebf739295f93b0b6ca44568805bf0943
[ "MIT" ]
null
null
null
opengl_renderer/model.hpp
Learko/opengl_renderer
fa930fa0ebf739295f93b0b6ca44568805bf0943
[ "MIT" ]
1
2018-10-29T15:54:16.000Z
2018-10-29T15:54:16.000Z
#pragma once #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <assimp/Importer.hpp> #include <assimp/scene.h> #include <assimp/postprocess.h> #include <filesystem> #include "mesh.hpp" #include "primitives.hpp" #include "shader.hpp" namespace opengl { class Model { public: using path = std::experimental::filesystem::path; Model(const path& path); void render(const Shader& shader) const; const path directory; private: void load_model(const path& path); void process_node(aiNode* node, const aiScene* scene); Mesh process_mesh(aiMesh* mesh, const aiScene* scene); Textures load_material(aiMaterial* material, aiTextureType type, texture_type t_type); TextureCache textures; Meshes meshes; std::size_t diffuse_n = 0; std::size_t specular_n = 0; }; GLuint load_texture(const std::experimental::filesystem::path& path); } // namespace opengl
20.577778
90
0.719222
Learko
ee7962fd9b84f426a40056e2b612d38de1b0d3a2
10,239
hpp
C++
XMPCore/source/XMPUtils.hpp
LaudateCorpus1/XMP-Toolkit-SDK
a3c578859d0c6f6388059f7d6667a266647ef612
[ "BSD-3-Clause" ]
88
2020-01-29T08:47:33.000Z
2022-03-10T06:26:24.000Z
XMPCore/source/XMPUtils.hpp
LaudateCorpus1/XMP-Toolkit-SDK
a3c578859d0c6f6388059f7d6667a266647ef612
[ "BSD-3-Clause" ]
40
2020-03-27T05:25:53.000Z
2022-03-22T20:00:58.000Z
XMPCore/source/XMPUtils.hpp
LaudateCorpus1/XMP-Toolkit-SDK
a3c578859d0c6f6388059f7d6667a266647ef612
[ "BSD-3-Clause" ]
54
2020-01-29T05:38:09.000Z
2022-03-31T11:03:09.000Z
#ifndef __XMPUtils_hpp__ #define __XMPUtils_hpp__ // ================================================================================================= // Copyright 2003 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" #include "public/include/XMP_Const.h" #include "XMPCore/source/XMPMeta.hpp" #include "XMPCore/source/XMPCore_Impl.hpp" #include "public/include/client-glue/WXMPUtils.hpp" #include "XMPCore/XMPCoreDefines.h" #if ENABLE_CPP_DOM_MODEL #include "XMPCommon/Interfaces/IError.h" #include "XMPCore/XMPCoreFwdDeclarations.h" #include "XMPCore/source/XMPMeta2.hpp" #endif #include "XMPCore/source/XMPCore_Impl.hpp" #include "source/XMLParserAdapter.hpp" #include "XMPCore/source/XMPMeta.hpp" #include "third-party/zuid/interfaces/MD5.h" bool IsInternalProperty(const XMP_VarString & schema, const XMP_VarString & prop); // ------------------------------------------------------------------------------------------------- class XMPUtils { public: static bool Initialize(); // ! For internal use only! static void Terminate() RELEASE_NO_THROW; // ! For internal use only! // --------------------------------------------------------------------------------------------- #if ENABLE_CPP_DOM_MODEL static void SetNode(const AdobeXMPCore::spINode & node, XMP_StringPtr value, XMP_OptionBits options); static XMP_OptionBits ConvertNewArrayFormToOldArrayForm(const AdobeXMPCore::spcIArrayNode & arrayNode); static AdobeXMPCore::spINode CreateArrayChildNode(const AdobeXMPCore::spIArrayNode & arrayNode, XMP_OptionBits options); static void DoSetArrayItem(const AdobeXMPCore::spIArrayNode & arrayNode, XMP_Index itemIndex, XMP_StringPtr itemValue, XMP_OptionBits options); static void SetImplicitNodeInformation(bool & firstImplicitNodeFound, AdobeXMPCore::spINode & implicitNodeRoot, AdobeXMPCore::spINode & destNode, XMP_Index & implicitNodeIndex, XMP_Index index = 0); static void GetNameSpaceAndNameFromStepValue(const XMP_VarString & stepStr, const AdobeXMPCore::spcINameSpacePrefixMap & defaultMap, XMP_VarString & stepNameSpace, XMP_VarString & stepName); static bool FindNode(const AdobeXMPCore::spIMetadata & mDOM, XMP_ExpandedXPath & expPath, bool createNodes, XMP_OptionBits leafOptions, AdobeXMPCore::spINode & retNode, XMP_Index * nodeIndex = 0, bool ignoreLastStep = 0); static bool FindCnstNode(const AdobeXMPCore::spIMetadata & mDOM, XMP_ExpandedXPath & expPath, AdobeXMPCore::spINode & destNode, XMP_OptionBits * options = 0, XMP_Index * arrayIndex = 0); static AdobeXMPCore::spINode FindChildNode(const AdobeXMPCore::spINode & parent, XMP_StringPtr childName, XMP_StringPtr childNameSpace, bool createNodes, size_t * pos /* = 0 */); static size_t GetNodeChildCount(const AdobeXMPCore::spcINode & node); static AdobeXMPCore::spcINodeIterator GetNodeChildIterator(const AdobeXMPCore::spcINode & node); static std::vector< AdobeXMPCore::spcINode > GetChildVector(const AdobeXMPCore::spINode & node); static XMP_OptionBits GetIXMPOptions(const AdobeXMPCore::spcINode & node); static bool HandleConstAliasStep(const AdobeXMPCore::spIMetadata & mDOM, AdobeXMPCore::spINode & destNode, const XMP_ExpandedXPath & expandedXPath, XMP_Index * nodeIndex = 0); static bool HandleAliasStep(const AdobeXMPCore::spIMetadata & mDOM, XMP_ExpandedXPath & expandedXPath, bool createNodes, XMP_OptionBits leafOptions, AdobeXMPCore::spINode & destNode, XMP_Index * nodeIndex, bool ignoreLastStep); static AdobeXMPCommon::spcIUTF8String GetNodeValue(const AdobeXMPCore::spINode & node); static XMP_Index LookupFieldSelector_v2(const AdobeXMPCore::spIArrayNode & arrayNode, XMP_VarString fieldName, XMP_VarString fieldValue); static AdobeXMPCore::spINode CreateTerminalNode(const char* nameSpace, const char * name, XMP_OptionBits options); #endif static void ComposeArrayItemPath(XMP_StringPtr schemaNS, XMP_StringPtr arrayName, XMP_Index itemIndex, XMP_VarString * fullPath); static void ComposeStructFieldPath(XMP_StringPtr schemaNS, XMP_StringPtr structName, XMP_StringPtr fieldNS, XMP_StringPtr fieldName, XMP_VarString * fullPath); static void ComposeQualifierPath(XMP_StringPtr schemaNS, XMP_StringPtr propName, XMP_StringPtr qualNS, XMP_StringPtr qualName, XMP_VarString * fullPath); static void ComposeLangSelector(XMP_StringPtr schemaNS, XMP_StringPtr arrayName, XMP_StringPtr langName, XMP_VarString * fullPath); static void ComposeFieldSelector(XMP_StringPtr schemaNS, XMP_StringPtr arrayName, XMP_StringPtr fieldNS, XMP_StringPtr fieldName, XMP_StringPtr fieldValue, XMP_VarString * fullPath); // --------------------------------------------------------------------------------------------- static void ConvertFromBool(bool binValue, XMP_VarString * strValue); static void ConvertFromInt(XMP_Int32 binValue, XMP_StringPtr format, XMP_VarString * strValue); static void ConvertFromInt64(XMP_Int64 binValue, XMP_StringPtr format, XMP_VarString * strValue); static void ConvertFromFloat(double binValue, XMP_StringPtr format, XMP_VarString * strValue); static void ConvertFromDate(const XMP_DateTime & binValue, XMP_VarString * strValue); // --------------------------------------------------------------------------------------------- static bool ConvertToBool(XMP_StringPtr strValue); static XMP_Int32 ConvertToInt(XMP_StringPtr strValue); static XMP_Int64 ConvertToInt64(XMP_StringPtr strValue); static double ConvertToFloat(XMP_StringPtr strValue); static void ConvertToDate(XMP_StringPtr strValue, XMP_DateTime * binValue); // --------------------------------------------------------------------------------------------- static void CurrentDateTime(XMP_DateTime * time); static void SetTimeZone(XMP_DateTime * time); static void ConvertToUTCTime(XMP_DateTime * time); static void ConvertToLocalTime(XMP_DateTime * time); static int CompareDateTime(const XMP_DateTime & left, const XMP_DateTime & right); // --------------------------------------------------------------------------------------------- static void EncodeToBase64(XMP_StringPtr rawStr, XMP_StringLen rawLen, XMP_VarString * encodedStr); static void DecodeFromBase64(XMP_StringPtr encodedStr, XMP_StringLen encodedLen, XMP_VarString * rawStr); // --------------------------------------------------------------------------------------------- static void PackageForJPEG(const XMPMeta & xmpObj, XMP_VarString * stdStr, XMP_VarString * extStr, XMP_VarString * digestStr); #if ENABLE_CPP_DOM_MODEL static void PackageForJPEG(const XMPMeta2 & xmpObj, XMP_VarString * stdStr, XMP_VarString * extStr, XMP_VarString * digestStr); #endif static void MergeFromJPEG(XMPMeta * fullXMP, const XMPMeta & extendedXMP); // --------------------------------------------------------------------------------------------- static void CatenateArrayItems(const XMPMeta & xmpObj, XMP_StringPtr schemaNS, XMP_StringPtr arrayName, XMP_StringPtr separator, XMP_StringPtr quotes, XMP_OptionBits options, XMP_VarString * catedStr); static void SeparateArrayItems(XMPMeta * xmpObj, XMP_StringPtr schemaNS, XMP_StringPtr arrayName, XMP_OptionBits options, XMP_StringPtr catedStr); static void ApplyTemplate(XMPMeta * workingXMP, const XMPMeta & templateXMP, XMP_OptionBits actions); static void RemoveProperties(XMPMeta * xmpObj, XMP_StringPtr schemaNS, XMP_StringPtr propName, XMP_OptionBits options); static void DuplicateSubtree(const XMPMeta & source, XMPMeta * dest, XMP_StringPtr sourceNS, XMP_StringPtr sourceRoot, XMP_StringPtr destNS, XMP_StringPtr destRoot, XMP_OptionBits options); // --------------------------------------------------------------------------------------------- static std::string& Trim(std::string& string); static std::string * WhiteSpaceStrPtr; #if ENABLE_CPP_DOM_MODEL static void MapXMPErrorToIError(XMP_Int32 xmpErrorCodes, AdobeXMPCommon::IError::eErrorDomain & domain, AdobeXMPCommon::IError::eErrorCode & code); static bool SerializeExtensionAsJSON(const AdobeXMPCore::spINode & extensionNode, std::string & key, std::string & value); static bool IsExtensionValidForBackwardCompatibility(const AdobeXMPCore::spINode & extensionNode); static bool CreateExtensionNode(const AdobeXMPCore::spIStructureNode & xmpNode, const XMP_VarString & serializedJSON, const XMP_VarString & doubleQuotesStr); static void CatenateArrayItems_v2(const XMPMeta & xmpObj, XMP_StringPtr schemaNS, XMP_StringPtr arrayName, XMP_StringPtr separator, XMP_StringPtr quotes, XMP_OptionBits options, XMP_VarString * catedStr); static void SeparateArrayItems_v2(XMPMeta * xmpObj, XMP_StringPtr schemaNS, XMP_StringPtr arrayName, XMP_OptionBits options, XMP_StringPtr catedStr); static void RemoveProperties_v2(XMPMeta * xmpMetaPtr, XMP_StringPtr schemaNS, XMP_StringPtr propName, XMP_OptionBits options); static void ApplyTemplate_v2(XMPMeta * workingXMP, const XMPMeta & templateXMP, XMP_OptionBits actions); static void DuplicateSubtree_v2(const XMPMeta & source, XMPMeta * dest, XMP_StringPtr sourceNS, XMP_StringPtr sourceRoot, XMP_StringPtr destNS, XMP_StringPtr destRoot, XMP_OptionBits options); #endif static bool CreateExtensionNode(XMP_Node ** xmpNode, const XMP_VarString & serializedJSON, const XMP_VarString & doubleQuotesString); static bool GetSerializedJSONForExtensionNode(const XMP_Node * xmpNode, XMP_VarString &extensionAsKey, XMP_VarString & serializedJSON); static bool IsSuitableForJSONSerialization(const XMP_Node * xmpNode); }; // XMPUtils // ================================================================================================= #endif // __XMPUtils_hpp__
33.135922
179
0.693818
LaudateCorpus1
ee7a054aa84f0da0ef691965f7dd37607b2c6777
74,489
cpp
C++
src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
chinajeffery/MPC-BE--1.2.3
2229fde5535f565ba4a496a7f73267bd2c1ad338
[ "MIT" ]
null
null
null
src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
chinajeffery/MPC-BE--1.2.3
2229fde5535f565ba4a496a7f73267bd2c1ad338
[ "MIT" ]
1
2019-11-14T04:18:32.000Z
2019-11-14T04:18:32.000Z
src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
chinajeffery/MPC-BE--1.2.3
2229fde5535f565ba4a496a7f73267bd2c1ad338
[ "MIT" ]
null
null
null
/* * $Id: DX9AllocatorPresenter.cpp 2691 2013-05-13 01:53:19Z aleksoid $ * * (C) 2003-2006 Gabest * (C) 2006-2013 see Authors.txt * * This file is part of MPC-BE. * * MPC-BE is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * MPC-BE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ #include "stdafx.h" #include "RenderersSettings.h" #include "DX9AllocatorPresenter.h" #include <InitGuid.h> #include <utility> #include "../../../SubPic/DX9SubPic.h" #include "../../../SubPic/SubPicQueueImpl.h" #include "IPinHook.h" #include <Version.h> #include "../DSUtil/WinAPIUtils.h" CCritSec g_ffdshowReceive; bool queue_ffdshow_support = false; // only for debugging //#define DISABLE_USING_D3D9EX #define FRAMERATE_MAX_DELTA 3000 using namespace DSObjects; // CDX9AllocatorPresenter CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, bool bIsEVR, CString &_Error) : CDX9RenderingEngine(hWnd, hr, &_Error) , m_RefreshRate(0) , m_nTearingPos(0) , m_nVMR9Surfaces(0) , m_iVMR9Surface(0) , m_rtTimePerFrame(0) , m_bInterlaced(false) , m_nUsedBuffer(0) , m_OrderedPaint(0) , m_bCorrectedFrameTime(0) , m_FrameTimeCorrection(0) , m_LastSampleTime(0) , m_LastFrameDuration(0) , m_bAlternativeVSync(0) , m_bIsEVR(bIsEVR) , m_VSyncMode(0) , m_TextScale(1.0) , m_MainThreadId(0) , m_bNeedCheckSample(true) , m_pDirectDraw(NULL) , m_hVSyncThread(NULL) , m_hEvtQuit(NULL) , m_bIsFullscreen(bFullscreen) , m_Decoder(_T("")) , m_InputVCodec(_T("")) , m_nRenderState(Undefined) , m_MonitorName(_T("")) , m_nMonitorHorRes(0), m_nMonitorVerRes(0) , m_rcMonitor(0, 0, 0, 0) { HINSTANCE hDll; if (FAILED(hr)) { _Error += L"ISubPicAllocatorPresenterImpl failed\n"; return; } m_pD3DXLoadSurfaceFromMemory = NULL; m_pD3DXLoadSurfaceFromSurface = NULL; m_pD3DXCreateLine = NULL; m_pD3DXCreateFont = NULL; m_pD3DXCreateSprite = NULL; hDll = GetRenderersData()->GetD3X9Dll(); if (hDll) { (FARPROC&)m_pD3DXLoadSurfaceFromMemory = GetProcAddress(hDll, "D3DXLoadSurfaceFromMemory"); (FARPROC&)m_pD3DXLoadSurfaceFromSurface = GetProcAddress(hDll, "D3DXLoadSurfaceFromSurface"); (FARPROC&)m_pD3DXCreateLine = GetProcAddress(hDll, "D3DXCreateLine"); (FARPROC&)m_pD3DXCreateFont = GetProcAddress(hDll, "D3DXCreateFontW"); (FARPROC&)m_pD3DXCreateSprite = GetProcAddress(hDll, "D3DXCreateSprite"); } else { _Error += L"The installed DirectX End-User Runtime is outdated. Please download and install the "; _Error += DIRECTX_SDK_DATE; _Error += L" release or newer in order for MPC-BE to function properly.\n"; } m_pDwmIsCompositionEnabled = NULL; m_pDwmEnableComposition = NULL; m_hDWMAPI = LoadLibrary(L"dwmapi.dll"); if (m_hDWMAPI) { (FARPROC &)m_pDwmIsCompositionEnabled = GetProcAddress(m_hDWMAPI, "DwmIsCompositionEnabled"); (FARPROC &)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition"); } m_pDirect3DCreate9Ex = NULL; m_hD3D9 = LoadLibrary(L"d3d9.dll"); #ifndef DISABLE_USING_D3D9EX if (m_hD3D9) { (FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex"); } #endif if (m_pDirect3DCreate9Ex) { m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx); if (!m_pD3DEx) { m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx); } } if (!m_pD3DEx) { m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION)); if (!m_pD3D) { m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION)); } } else { m_pD3D = m_pD3DEx; } CRenderersSettings& s = GetRenderersSettings(); if (s.m_AdvRendSets.iVMRDisableDesktopComposition) { m_bDesktopCompositionDisabled = true; if (m_pDwmEnableComposition) { m_pDwmEnableComposition(0); } } else { m_bDesktopCompositionDisabled = false; } hr = CreateDevice(_Error); } CDX9AllocatorPresenter::~CDX9AllocatorPresenter() { if (m_bDesktopCompositionDisabled) { m_bDesktopCompositionDisabled = false; if (m_pDwmEnableComposition) { m_pDwmEnableComposition(1); } } StopWorkerThreads(); m_pFont = NULL; m_pLine = NULL; m_pD3DDev = NULL; m_pD3DDevEx = NULL; CleanupRenderingEngine(); m_pD3D = NULL; m_pD3DEx = NULL; if (m_hDWMAPI) { FreeLibrary(m_hDWMAPI); m_hDWMAPI = NULL; } if (m_hD3D9) { FreeLibrary(m_hD3D9); m_hD3D9 = NULL; } } void ModerateFloat(double& Value, double Target, double& ValuePrim, double ChangeSpeed); #if 0 class CRandom31 { public: CRandom31() { m_Seed = 12164; } void f_SetSeed(int32 _Seed) { m_Seed = _Seed; } int32 f_GetSeed() { return m_Seed; } /* Park and Miller's psuedo-random number generator. */ int32 m_Seed; int32 f_Get() { static const int32 A = 16807; static const int32 M = 2147483647; // 2^31 - 1 static const int32 q = M / A; // M / A static const int32 r = M % A; // M % A m_Seed = A * (m_Seed % q) - r * (m_Seed / q); if (m_Seed < 0) { m_Seed += M; } return m_Seed; } static int32 fs_Max() { return 2147483646; } double f_GetFloat() { return double(f_Get()) * (1.0 / double(fs_Max())); } }; class CVSyncEstimation { private: class CHistoryEntry { public: CHistoryEntry() { m_Time = 0; m_ScanLine = -1; } LONGLONG m_Time; int m_ScanLine; }; class CSolution { public: CSolution() { m_ScanLines = 1000; m_ScanLinesPerSecond = m_ScanLines * 100; } int m_ScanLines; double m_ScanLinesPerSecond; double m_SqrSum; void f_Mutate(double _Amount, CRandom31 &_Random, int _MinScans) { int ToDo = _Random.f_Get() % 10; if (ToDo == 0) { m_ScanLines = m_ScanLines / 2; } else if (ToDo == 1) { m_ScanLines = m_ScanLines * 2; } m_ScanLines = m_ScanLines * (1.0 + (_Random.f_GetFloat() * _Amount) - _Amount * 0.5); m_ScanLines = max(m_ScanLines, _MinScans); if (ToDo == 2) { m_ScanLinesPerSecond /= (_Random.f_Get() % 4) + 1; } else if (ToDo == 3) { m_ScanLinesPerSecond *= (_Random.f_Get() % 4) + 1; } m_ScanLinesPerSecond *= 1.0 + (_Random.f_GetFloat() * _Amount) - _Amount * 0.5; } void f_SpawnInto(CSolution &_Other, CRandom31 &_Random, int _MinScans) { _Other = *this; _Other.f_Mutate(_Random.f_GetFloat() * 0.1, _Random, _MinScans); } static int fs_Compare(const void *_pFirst, const void *_pSecond) { const CSolution *pFirst = (const CSolution *)_pFirst; const CSolution *pSecond = (const CSolution *)_pSecond; if (pFirst->m_SqrSum < pSecond->m_SqrSum) { return -1; } else if (pFirst->m_SqrSum > pSecond->m_SqrSum) { return 1; } return 0; } }; enum { ENumHistory = 128 }; CHistoryEntry m_History[ENumHistory]; int m_iHistory; CSolution m_OldSolutions[2]; CRandom31 m_Random; double fp_GetSquareSum(double _ScansPerSecond, double _ScanLines) { double SquareSum = 0; int nHistory = min(m_nHistory, ENumHistory); int iHistory = m_iHistory - nHistory; if (iHistory < 0) { iHistory += ENumHistory; } for (int i = 1; i < nHistory; ++i) { int iHistory0 = iHistory + i - 1; int iHistory1 = iHistory + i; if (iHistory0 < 0) { iHistory0 += ENumHistory; } iHistory0 = iHistory0 % ENumHistory; iHistory1 = iHistory1 % ENumHistory; ASSERT(m_History[iHistory0].m_Time != 0); ASSERT(m_History[iHistory1].m_Time != 0); double DeltaTime = (m_History[iHistory1].m_Time - m_History[iHistory0].m_Time)/10000000.0; double PredictedScanLine = m_History[iHistory0].m_ScanLine + DeltaTime * _ScansPerSecond; PredictedScanLine = fmod(PredictedScanLine, _ScanLines); double Delta = (m_History[iHistory1].m_ScanLine - PredictedScanLine); double DeltaSqr = Delta * Delta; SquareSum += DeltaSqr; } return SquareSum; } int m_nHistory; public: CVSyncEstimation() { m_iHistory = 0; m_nHistory = 0; } void f_AddSample(int _ScanLine, LONGLONG _Time) { m_History[m_iHistory].m_ScanLine = _ScanLine; m_History[m_iHistory].m_Time = _Time; ++m_nHistory; m_iHistory = (m_iHistory + 1) % ENumHistory; } void f_GetEstimation(double &_RefreshRate, int &_ScanLines, int _ScreenSizeY, int _WindowsRefreshRate) { _RefreshRate = 0; _ScanLines = 0; int iHistory = m_iHistory; // We have a full history if (m_nHistory > 10) { for (int l = 0; l < 5; ++l) { const int nSol = 3+5+5+3; CSolution Solutions[nSol]; Solutions[0] = m_OldSolutions[0]; Solutions[1] = m_OldSolutions[1]; Solutions[2].m_ScanLines = _ScreenSizeY; Solutions[2].m_ScanLinesPerSecond = _ScreenSizeY * _WindowsRefreshRate; int iStart = 3; for (int i = iStart; i < iStart + 5; ++i) { Solutions[0].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY); } iStart += 5; for (int i = iStart; i < iStart + 5; ++i) { Solutions[1].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY); } iStart += 5; for (int i = iStart; i < iStart + 3; ++i) { Solutions[2].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY); } int Start = 2; if (l == 0) { Start = 0; } for (int i = Start; i < nSol; ++i) { Solutions[i].m_SqrSum = fp_GetSquareSum(Solutions[i].m_ScanLinesPerSecond, Solutions[i].m_ScanLines); } qsort(Solutions, nSol, sizeof(Solutions[0]), &CSolution::fs_Compare); for (int i = 0; i < 2; ++i) { m_OldSolutions[i] = Solutions[i]; } } _ScanLines = m_OldSolutions[0].m_ScanLines + 0.5; _RefreshRate = 1.0 / (m_OldSolutions[0].m_ScanLines / m_OldSolutions[0].m_ScanLinesPerSecond); } else { m_OldSolutions[0].m_ScanLines = _ScreenSizeY; m_OldSolutions[1].m_ScanLines = _ScreenSizeY; } } }; #endif void CDX9AllocatorPresenter::VSyncThread() { HANDLE hEvts[] = { m_hEvtQuit}; bool bQuit = false; TIMECAPS tc; DWORD dwResolution; DWORD dwUser = 0; // Tell Vista Multimedia Class Scheduler we are a playback thread (increase priority) //DWORD dwTaskIndex = 0; //if (pfAvSetMmThreadCharacteristicsW) // hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex); //if (pfAvSetMmThreadPriority) // pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/); timeGetDevCaps(&tc, sizeof(TIMECAPS)); dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax); dwUser = timeBeginPeriod(dwResolution); CRenderersData *pApp = GetRenderersData(); CRenderersSettings& s = GetRenderersSettings(); while (!bQuit) { DWORD dwObject = WaitForMultipleObjects (_countof(hEvts), hEvts, FALSE, 1); switch (dwObject) { case WAIT_OBJECT_0 : bQuit = true; break; case WAIT_TIMEOUT : { // Do our stuff if (m_pD3DDev && s.m_AdvRendSets.iVMR9VSync) { if (m_nRenderState != Undefined && m_nRenderState != Started) { // we do not need clear m_DetectedRefreshRate & m_DetectedScanlinesPerFrame variable, so do continue continue; } int VSyncPos = GetVBlackPos(); int WaitRange = max(m_ScreenSize.cy / 40, 5); int MinRange = max(min(int(0.003 * double(m_ScreenSize.cy) * double(m_RefreshRate) + 0.5), m_ScreenSize.cy/3), 5); // 1.8 ms or max 33 % of Time VSyncPos += MinRange + WaitRange; VSyncPos = VSyncPos % m_ScreenSize.cy; if (VSyncPos < 0) { VSyncPos += m_ScreenSize.cy; } int ScanLine = 0; int StartScanLine = ScanLine; UNREFERENCED_PARAMETER(StartScanLine); int LastPos = ScanLine; UNREFERENCED_PARAMETER(LastPos); ScanLine = (VSyncPos + 1) % m_ScreenSize.cy; if (ScanLine < 0) { ScanLine += m_ScreenSize.cy; } int ScanLineMiddle = ScanLine + m_ScreenSize.cy/2; ScanLineMiddle = ScanLineMiddle % m_ScreenSize.cy; if (ScanLineMiddle < 0) { ScanLineMiddle += m_ScreenSize.cy; } int ScanlineStart = ScanLine; bool bTakenLock; WaitForVBlankRange(ScanlineStart, 5, true, true, false, bTakenLock); LONGLONG TimeStart = pApp->GetPerfCounter(); WaitForVBlankRange(ScanLineMiddle, 5, true, true, false, bTakenLock); LONGLONG TimeMiddle = pApp->GetPerfCounter(); int ScanlineEnd = ScanLine; WaitForVBlankRange(ScanlineEnd, 5, true, true, false, bTakenLock); LONGLONG TimeEnd = pApp->GetPerfCounter(); double nSeconds = double(TimeEnd - TimeStart) / 10000000.0; LONGLONG DiffMiddle = TimeMiddle - TimeStart; LONGLONG DiffEnd = TimeEnd - TimeMiddle; double DiffDiff; if (DiffEnd > DiffMiddle) { DiffDiff = double(DiffEnd) / double(DiffMiddle); } else { DiffDiff = double(DiffMiddle) / double(DiffEnd); } if (nSeconds > 0.003 && DiffDiff < 1.3) { double ScanLineSeconds; double nScanLines; if (ScanLineMiddle > ScanlineEnd) { ScanLineSeconds = double(TimeMiddle - TimeStart) / 10000000.0; nScanLines = ScanLineMiddle - ScanlineStart; } else { ScanLineSeconds = double(TimeEnd - TimeMiddle) / 10000000.0; nScanLines = ScanlineEnd - ScanLineMiddle; } double ScanLineTime = ScanLineSeconds / nScanLines; int iPos = m_DetectedRefreshRatePos % 100; m_ldDetectedScanlineRateList[iPos] = ScanLineTime; if (m_DetectedScanlineTime && ScanlineStart != ScanlineEnd) { int Diff = ScanlineEnd - ScanlineStart; nSeconds -= double(Diff) * m_DetectedScanlineTime; } m_ldDetectedRefreshRateList[iPos] = nSeconds; double Average = 0; double AverageScanline = 0; int nPos = min(iPos + 1, 100); for (int i = 0; i < nPos; ++i) { Average += m_ldDetectedRefreshRateList[i]; AverageScanline += m_ldDetectedScanlineRateList[i]; } if (nPos) { Average /= double(nPos); AverageScanline /= double(nPos); } else { Average = 0; AverageScanline = 0; } double ThisValue = Average; if (Average > 0.0 && AverageScanline > 0.0) { CAutoLock Lock(&m_RefreshRateLock); ++m_DetectedRefreshRatePos; if (m_DetectedRefreshTime == 0 || m_DetectedRefreshTime / ThisValue > 1.01 || m_DetectedRefreshTime / ThisValue < 0.99) { m_DetectedRefreshTime = ThisValue; m_DetectedRefreshTimePrim = 0; } if (_isnan(m_DetectedRefreshTime)) {m_DetectedRefreshTime = 0.0;} if (_isnan(m_DetectedRefreshTimePrim)) {m_DetectedRefreshTimePrim = 0.0;} ModerateFloat(m_DetectedRefreshTime, ThisValue, m_DetectedRefreshTimePrim, 1.5); if (m_DetectedRefreshTime > 0.0) { m_DetectedRefreshRate = 1.0/m_DetectedRefreshTime; } else { m_DetectedRefreshRate = 0.0; } if (m_DetectedScanlineTime == 0 || m_DetectedScanlineTime / AverageScanline > 1.01 || m_DetectedScanlineTime / AverageScanline < 0.99) { m_DetectedScanlineTime = AverageScanline; m_DetectedScanlineTimePrim = 0; } ModerateFloat(m_DetectedScanlineTime, AverageScanline, m_DetectedScanlineTimePrim, 1.5); if (m_DetectedScanlineTime > 0.0) { m_DetectedScanlinesPerFrame = m_DetectedRefreshTime / m_DetectedScanlineTime; } else { m_DetectedScanlinesPerFrame = 0; } } //TRACE("Refresh: %f\n", RefreshRate); } } else { m_DetectedRefreshRate = 0.0; m_DetectedScanlinesPerFrame = 0.0; } } break; } } timeEndPeriod (dwResolution); //if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt); } DWORD WINAPI CDX9AllocatorPresenter::VSyncThreadStatic(LPVOID lpParam) { SetThreadName((DWORD)-1, "CDX9Presenter::VSyncThread"); CDX9AllocatorPresenter* pThis = (CDX9AllocatorPresenter*) lpParam; pThis->VSyncThread(); return 0; } void CDX9AllocatorPresenter::StartWorkerThreads() { DWORD dwThreadId; if ( m_bIsEVR ) { m_hEvtQuit = CreateEvent( NULL, TRUE, FALSE, NULL ); if ( m_hEvtQuit != NULL ) { // Don't create a thread with no stop switch m_hVSyncThread = ::CreateThread( NULL, 0, VSyncThreadStatic, (LPVOID)this, 0, &dwThreadId ); if ( m_hVSyncThread != NULL ) { SetThreadPriority( m_hVSyncThread, THREAD_PRIORITY_HIGHEST ); } } } } void CDX9AllocatorPresenter::StopWorkerThreads() { if ( m_bIsEVR ) { if ( m_hEvtQuit != NULL ) { SetEvent( m_hEvtQuit ); if ( m_hVSyncThread != NULL ) { if ( WaitForSingleObject(m_hVSyncThread, 10000) == WAIT_TIMEOUT ) { ASSERT(FALSE); TerminateThread( m_hVSyncThread, 0xDEAD ); } CloseHandle( m_hVSyncThread ); m_hVSyncThread = NULL; } CloseHandle( m_hEvtQuit ); m_hEvtQuit = NULL; } } } bool CDX9AllocatorPresenter::SettingsNeedResetDevice() { CRenderersSettings& s = GetRenderersSettings(); CRenderersSettings::CAdvRendererSettings & New = GetRenderersSettings().m_AdvRendSets; CRenderersSettings::CAdvRendererSettings & Current = m_LastRendererSettings; bool bRet = false; bRet = bRet || New.fVMR9AlterativeVSync != Current.fVMR9AlterativeVSync; bRet = bRet || New.iVMR9VSyncAccurate != Current.iVMR9VSyncAccurate; if (m_bIsFullscreen) { bRet = bRet || New.iVMR9FullscreenGUISupport != Current.iVMR9FullscreenGUISupport; } else { if (Current.iVMRDisableDesktopComposition) { if (!m_bDesktopCompositionDisabled) { m_bDesktopCompositionDisabled = true; if (m_pDwmEnableComposition) { m_pDwmEnableComposition(0); } } } else { if (m_bDesktopCompositionDisabled) { m_bDesktopCompositionDisabled = false; if (m_pDwmEnableComposition) { m_pDwmEnableComposition(1); } } } } if (m_bIsEVR) { bRet = bRet || New.iEVRHighColorResolution != Current.iEVRHighColorResolution; bRet = bRet || New.iEVRForceInputHighColorResolution != Current.iEVRForceInputHighColorResolution; } m_LastRendererSettings = s.m_AdvRendSets; return bRet; } HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) { TRACE("CDX9AllocatorPresenter::CreateDevice()\n"); CAutoLock cRenderLock(&m_CreateLock); StopWorkerThreads(); // extern variable g_bGetFrameType = FALSE; g_nFrameType = PICT_NONE; CRenderersSettings& s = GetRenderersSettings(); CRenderersData* renderersData = GetRenderersData(); m_DetectedFrameRate = 0.0; m_DetectedFrameTime = 0.0; m_DetectedFrameTimeStdDev = 0.0; m_DetectedLock = false; ZeroMemory(m_DetectedFrameTimeHistory, sizeof(m_DetectedFrameTimeHistory)); ZeroMemory(m_DetectedFrameTimeHistoryHistory, sizeof(m_DetectedFrameTimeHistoryHistory)); m_DetectedFrameTimePos = 0; ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap)); ZeroMemory(m_ldDetectedRefreshRateList, sizeof(m_ldDetectedRefreshRateList)); ZeroMemory(m_ldDetectedScanlineRateList, sizeof(m_ldDetectedScanlineRateList)); m_DetectedRefreshRatePos = 0; m_DetectedRefreshTimePrim = 0; m_DetectedScanlineTime = 0; m_DetectedScanlineTimePrim = 0; m_DetectedRefreshRate = 0; memset (m_pllJitter, 0, sizeof(m_pllJitter)); memset (m_pllSyncOffset, 0, sizeof(m_pllSyncOffset)); m_nNextJitter = 0; m_nNextSyncOffset = 0; m_llLastPerf = 0; m_fAvrFps = 0.0; m_fJitterStdDev = 0.0; m_fSyncOffsetStdDev = 0.0; m_fSyncOffsetAvr = 0.0; m_bSyncStatsAvailable = false; m_VBlankEndWait = 0; m_VBlankMin = 300000; m_VBlankMinCalc = 300000; m_VBlankMax = 0; m_VBlankStartWait = 0; m_VBlankWaitTime = 0; m_VBlankLockTime = 0; m_PresentWaitTime = 0; m_PresentWaitTimeMin = 3000000000; m_PresentWaitTimeMax = 0; m_LastRendererSettings = s.m_AdvRendSets; m_VBlankEndPresent = -100000; m_VBlankStartMeasureTime = 0; m_VBlankStartMeasure = 0; m_PaintTime = 0; m_PaintTimeMin = 3000000000; m_PaintTimeMax = 0; m_RasterStatusWaitTime = 0; m_RasterStatusWaitTimeMin = 3000000000; m_RasterStatusWaitTimeMax = 0; m_RasterStatusWaitTimeMaxCalc = 0; m_ClockDiff = 0.0; m_ClockDiffPrim = 0.0; m_ClockDiffCalc = 0.0; m_ModeratedTimeSpeed = 1.0; m_ModeratedTimeSpeedDiff = 0.0; m_ModeratedTimeSpeedPrim = 0; ZeroMemory(m_TimeChangeHistory, sizeof(m_TimeChangeHistory)); ZeroMemory(m_ClockChangeHistory, sizeof(m_ClockChangeHistory)); m_ClockTimeChangeHistoryPos = 0; m_pD3DDev = NULL; m_pD3DDevEx = NULL; m_pDirectDraw = NULL; CleanupRenderingEngine(); if (!m_pD3D) { _Error += L"Failed to create D3D9\n"; return E_UNEXPECTED; } HRESULT hr = S_OK; m_CurrentAdapter = GetAdapter(m_pD3D); /* // TODO : add nVidia PerfHUD !!! // Set default settings UINT AdapterToUse=D3DADAPTER_DEFAULT; D3DDEVTYPE DeviceType=D3DDEVTYPE_HAL; #if SHIPPING_VERSION // When building a shipping version, disable PerfHUD (opt-out) #else // Look for 'NVIDIA PerfHUD' adapter // If it is present, override default settings for (UINT Adapter=0;Adapter<g_pD3D->GetAdapterCount();Adapter++) { D3DADAPTER_IDENTIFIER9 Identifier; HRESULT Res; Res = g_pD3D->GetAdapterIdentifier(Adapter,0,&Identifier); if (strstr(Identifier.Description,"PerfHUD") != 0) { AdapterToUse=Adapter; DeviceType=D3DDEVTYPE_REF; break; } } #endif if (FAILED(g_pD3D->CreateDevice( AdapterToUse, DeviceType, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice) ) ) { return E_FAIL; } */ //#define ENABLE_DDRAWSYNC #ifdef ENABLE_DDRAWSYNC hr = DirectDrawCreate(NULL, &m_pDirectDraw, NULL) ; if (hr == S_OK) { hr = m_pDirectDraw->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL) ; } #endif ZeroMemory(&m_pp, sizeof(m_pp)); BOOL bCompositionEnabled = false; if (m_pDwmIsCompositionEnabled) { m_pDwmIsCompositionEnabled(&bCompositionEnabled); } m_bCompositionEnabled = !!bCompositionEnabled; m_bAlternativeVSync = s.m_AdvRendSets.fVMR9AlterativeVSync; // detect FP textures support renderersData->m_bFP16Support = SUCCEEDED(m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_FILTER, D3DRTYPE_VOLUMETEXTURE, D3DFMT_A32B32G32R32F)); // detect 10-bit textures support renderersData->m_b10bitSupport = SUCCEEDED(m_pD3D->CheckDeviceFormat(m_CurrentAdapter, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, D3DFMT_A2R10G10B10)); // set settings that depend on hardware feature support m_bForceInputHighColorResolution = s.m_AdvRendSets.iEVRForceInputHighColorResolution && m_bIsEVR && renderersData->m_b10bitSupport; m_bHighColorResolution = s.m_AdvRendSets.iEVRHighColorResolution && m_bIsEVR && renderersData->m_b10bitSupport; m_bFullFloatingPointProcessing = s.m_AdvRendSets.iVMR9FullFloatingPointProcessing && renderersData->m_bFP16Support; m_bHalfFloatingPointProcessing = s.m_AdvRendSets.iVMR9HalfFloatingPointProcessing && renderersData->m_bFP16Support && !m_bFullFloatingPointProcessing; // set color formats if (m_bFullFloatingPointProcessing) { m_SurfaceType = D3DFMT_A32B32G32R32F; } else if (m_bHalfFloatingPointProcessing) { m_SurfaceType = D3DFMT_A16B16G16R16F; } else if (m_bForceInputHighColorResolution || m_bHighColorResolution) { m_SurfaceType = D3DFMT_A2R10G10B10; } else { m_SurfaceType = D3DFMT_X8R8G8B8; } D3DDISPLAYMODEEX DisplayMode; ZeroMemory(&DisplayMode, sizeof(DisplayMode)); DisplayMode.Size = sizeof(DisplayMode); D3DDISPLAYMODE d3ddm; ZeroMemory(&d3ddm, sizeof(d3ddm)); if (m_bIsFullscreen) { if (m_bHighColorResolution) { m_pp.BackBufferFormat = D3DFMT_A2R10G10B10; } else { m_pp.BackBufferFormat = D3DFMT_X8R8G8B8; } m_pp.Windowed = false; m_pp.BackBufferCount = 3; m_pp.SwapEffect = D3DSWAPEFFECT_FLIP; // there's no Desktop composition to take care of alternative vSync in exclusive mode, alternative vSync is therefore unused m_pp.hDeviceWindow = m_hWnd; m_pp.Flags = D3DPRESENTFLAG_VIDEO; if (s.m_AdvRendSets.iVMR9FullscreenGUISupport && !m_bHighColorResolution) { m_pp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; } m_D3DDevExError = L"No m_pD3DEx"; if (m_pD3DEx) { m_pD3DEx->GetAdapterDisplayModeEx(m_CurrentAdapter, &DisplayMode, NULL); DisplayMode.Format = m_pp.BackBufferFormat; m_ScreenSize.SetSize(DisplayMode.Width, DisplayMode.Height); m_pp.FullScreen_RefreshRateInHz = m_RefreshRate = DisplayMode.RefreshRate; m_pp.BackBufferWidth = m_ScreenSize.cx; m_pp.BackBufferHeight = m_ScreenSize.cy; hr = m_pD3DEx->CreateDeviceEx( m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd, GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED | D3DCREATE_ENABLE_PRESENTSTATS, //D3DCREATE_MANAGED &m_pp, &DisplayMode, &m_pD3DDevEx); m_D3DDevExError = GetWindowsErrorMessage(hr, m_hD3D9); if (m_pD3DDevEx) { m_pD3DDev = m_pD3DDevEx; m_BackbufferType = m_pp.BackBufferFormat; m_DisplayType = DisplayMode.Format; } } if (!m_pD3DDev) { m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm); d3ddm.Format = m_pp.BackBufferFormat; m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height); m_pp.FullScreen_RefreshRateInHz = m_RefreshRate = d3ddm.RefreshRate; m_pp.BackBufferWidth = m_ScreenSize.cx; m_pp.BackBufferHeight = m_ScreenSize.cy; hr = m_pD3D->CreateDevice( m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd, GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED &m_pp, &m_pD3DDev); m_DisplayType = d3ddm.Format; m_BackbufferType = m_pp.BackBufferFormat; } if (m_pD3DDev && s.m_AdvRendSets.iVMR9FullscreenGUISupport && !m_bHighColorResolution) { m_pD3DDev->SetDialogBoxMode(true); //if (m_pD3DDev->SetDialogBoxMode(true) != S_OK) // ExitProcess(0); } } else { m_pp.Windowed = TRUE; m_pp.hDeviceWindow = m_hWnd; m_pp.SwapEffect = D3DSWAPEFFECT_COPY; m_pp.Flags = D3DPRESENTFLAG_VIDEO; m_pp.BackBufferCount = 1; if (bCompositionEnabled || m_bAlternativeVSync) { // Desktop composition takes care of the VSYNC m_pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; } if (m_pD3DEx) { m_pD3DEx->GetAdapterDisplayModeEx(m_CurrentAdapter, &DisplayMode, NULL); m_ScreenSize.SetSize(DisplayMode.Width, DisplayMode.Height); m_RefreshRate = DisplayMode.RefreshRate; m_pp.BackBufferWidth = m_ScreenSize.cx; m_pp.BackBufferHeight = m_ScreenSize.cy; // We can get 0x8876086a here when switching from two displays to one display using Win + P (Windows 7) // Cause: We might not reinitialize dx correctly during the switch hr = m_pD3DEx->CreateDeviceEx( m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd, GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED | D3DCREATE_ENABLE_PRESENTSTATS, //D3DCREATE_MANAGED &m_pp, NULL, &m_pD3DDevEx); if (m_pD3DDevEx) { m_pD3DDev = m_pD3DDevEx; m_DisplayType = DisplayMode.Format; } } if (!m_pD3DDev) { m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm); m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height); m_RefreshRate = d3ddm.RefreshRate; m_pp.BackBufferWidth = m_ScreenSize.cx; m_pp.BackBufferHeight = m_ScreenSize.cy; hr = m_pD3D->CreateDevice( m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd, GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED &m_pp, &m_pD3DDev); m_DisplayType = d3ddm.Format; } m_BackbufferType = m_pp.BackBufferFormat; } while (hr == D3DERR_DEVICELOST) { TRACE("D3DERR_DEVICELOST. Trying to Reset.\n"); hr = m_pD3DDev->TestCooperativeLevel(); } if (hr == D3DERR_DEVICENOTRESET) { TRACE("D3DERR_DEVICENOTRESET\n"); hr = m_pD3DDev->Reset(&m_pp); } TRACE("CreateDevice: %d\n", (LONG)hr); ASSERT (SUCCEEDED (hr)); m_MainThreadId = GetCurrentThreadId(); if (m_pD3DDevEx) { m_pD3DDevEx->SetGPUThreadPriority(7); } if (FAILED(hr)) { _Error += L"CreateDevice failed\n"; CStringW str; str.Format(L"Error code: 0x%X\n", hr); _Error += str; return hr; } // Get the device caps ZeroMemory(&m_Caps, sizeof(m_Caps)); m_pD3DDev->GetDeviceCaps(&m_Caps); // Initialize the rendering engine InitRenderingEngine(); CComPtr<ISubPicProvider> pSubPicProvider; if (m_pSubPicQueue) { m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider); } CSize size; switch (GetRenderersSettings().nSPCMaxRes) { case 0: default: size = m_ScreenSize; break; case 1: size.SetSize(1024, 768); break; case 2: size.SetSize(800, 600); break; case 3: size.SetSize(640, 480); break; case 4: size.SetSize(512, 384); break; case 5: size.SetSize(384, 288); break; case 6: size.SetSize(2560, 1600); break; case 7: size.SetSize(1920, 1080); break; case 8: size.SetSize(1320, 900); break; case 9: size.SetSize(1280, 720); break; } if (m_pAllocator) { m_pAllocator->ChangeDevice(m_pD3DDev); } else { m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex, false); } if (!m_pAllocator) { _Error += L"CDX9SubPicAllocator failed\n"; return E_FAIL; } hr = S_OK; m_pSubPicQueue = GetRenderersSettings().nSPCSize > 0 ? (ISubPicQueue*)DNew CSubPicQueue(GetRenderersSettings().nSPCSize, !GetRenderersSettings().fSPCAllowAnimationWhenBuffering, m_pAllocator, &hr) : (ISubPicQueue*)DNew CSubPicQueueNoThread(m_pAllocator, &hr); if (!m_pSubPicQueue || FAILED(hr)) { _Error += L"m_pSubPicQueue failed\n"; return E_FAIL; } if (pSubPicProvider) { m_pSubPicQueue->SetSubPicProvider(pSubPicProvider); } m_pFont = NULL; m_pSprite = NULL; m_pLine = NULL; m_LastAdapterCheck = GetRenderersData()->GetPerfCounter(); m_MonitorName.Empty(); m_nMonitorHorRes = m_nMonitorVerRes = 0; HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST); MONITORINFOEX mi; mi.cbSize = sizeof(MONITORINFOEX); if (GetMonitorInfo(hMonitor, &mi)) { ReadDisplay(mi.szDevice, &m_MonitorName, &m_nMonitorHorRes, &m_nMonitorVerRes); m_rcMonitor = mi.rcMonitor; } StartWorkerThreads(); return S_OK; } HRESULT CDX9AllocatorPresenter::AllocSurfaces() { CAutoLock cAutoLock(this); CAutoLock cRenderLock(&m_RenderLock); return CreateVideoSurfaces(); } void CDX9AllocatorPresenter::DeleteSurfaces() { CAutoLock cAutoLock(this); CAutoLock cRenderLock(&m_RenderLock); FreeVideoSurfaces(); } UINT CDX9AllocatorPresenter::GetAdapter(IDirect3D9* pD3D, bool bGetAdapter) { if (m_hWnd == NULL || pD3D == NULL) { return D3DADAPTER_DEFAULT; } m_D3D9Device = _T(""); CRenderersSettings& s = GetRenderersSettings(); if (bGetAdapter && pD3D->GetAdapterCount() > 1 && s.D3D9RenderDevice.GetLength() > 0) { TCHAR strGUID[50]; D3DADAPTER_IDENTIFIER9 adapterIdentifier; for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) { if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK) { if ((::StringFromGUID2(adapterIdentifier.DeviceIdentifier, strGUID, 50) > 0) && (s.D3D9RenderDevice == strGUID)) { m_D3D9Device = adapterIdentifier.Description; return adp; } } } } HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST); if (hMonitor == NULL) { return D3DADAPTER_DEFAULT; } for (UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) { HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp); if (hAdpMon == hMonitor) { if (bGetAdapter) { D3DADAPTER_IDENTIFIER9 adapterIdentifier; if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK) { m_D3D9Device = adapterIdentifier.Description; } } return adp; } } return D3DADAPTER_DEFAULT; } DWORD CDX9AllocatorPresenter::GetVertexProcessing() { HRESULT hr; D3DCAPS9 caps; hr = m_pD3D->GetDeviceCaps(m_CurrentAdapter, D3DDEVTYPE_HAL, &caps); if (FAILED(hr)) { return D3DCREATE_SOFTWARE_VERTEXPROCESSING; } if ((caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0 || caps.VertexShaderVersion < D3DVS_VERSION(2, 0)) { return D3DCREATE_SOFTWARE_VERTEXPROCESSING; } return D3DCREATE_HARDWARE_VERTEXPROCESSING; } // ISubPicAllocatorPresenter STDMETHODIMP CDX9AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) { return E_NOTIMPL; } void CDX9AllocatorPresenter::CalculateJitter(LONGLONG PerfCounter) { // Calculate the jitter! LONGLONG llPerf = PerfCounter; if ((m_rtTimePerFrame != 0) && (labs ((long)(llPerf - m_llLastPerf)) < m_rtTimePerFrame*3) ) { m_nNextJitter = (m_nNextJitter+1) % NB_JITTER; m_pllJitter[m_nNextJitter] = llPerf - m_llLastPerf; m_MaxJitter = MINLONG64; m_MinJitter = MAXLONG64; // Calculate the real FPS LONGLONG llJitterSum = 0; LONGLONG llJitterSumAvg = 0; for (int i=0; i<NB_JITTER; i++) { LONGLONG Jitter = m_pllJitter[i]; llJitterSum += Jitter; llJitterSumAvg += Jitter; } double FrameTimeMean = double(llJitterSumAvg)/NB_JITTER; m_fJitterMean = FrameTimeMean; double DeviationSum = 0; for (int i=0; i<NB_JITTER; i++) { LONGLONG DevInt = m_pllJitter[i] - (LONGLONG)FrameTimeMean; double Deviation = (double)DevInt; DeviationSum += Deviation*Deviation; m_MaxJitter = max(m_MaxJitter, DevInt); m_MinJitter = min(m_MinJitter, DevInt); } double StdDev = sqrt(DeviationSum/NB_JITTER); m_fJitterStdDev = StdDev; m_fAvrFps = 10000000.0/(double(llJitterSum)/NB_JITTER); } m_llLastPerf = llPerf; } bool CDX9AllocatorPresenter::GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bMeasureTime) { LONGLONG llPerf = 0; if (_bMeasureTime) { llPerf = GetRenderersData()->GetPerfCounter(); } int ScanLine = 0; _ScanLine = 0; _bInVBlank = 0; if (m_pDirectDraw) { DWORD ScanLineGet = 0; m_pDirectDraw->GetScanLine(&ScanLineGet); BOOL InVBlank; if (m_pDirectDraw->GetVerticalBlankStatus (&InVBlank) != S_OK) { return false; } ScanLine = ScanLineGet; _bInVBlank = InVBlank; if (InVBlank) { ScanLine = 0; } } else { D3DRASTER_STATUS RasterStatus; if (m_pD3DDev->GetRasterStatus(0, &RasterStatus) != S_OK) { return false; } ScanLine = RasterStatus.ScanLine; _bInVBlank = RasterStatus.InVBlank; } if (_bMeasureTime) { m_VBlankMax = max(m_VBlankMax, ScanLine); if (ScanLine != 0 && !_bInVBlank) { m_VBlankMinCalc = min(m_VBlankMinCalc, ScanLine); } m_VBlankMin = m_VBlankMax - m_ScreenSize.cy; } if (_bInVBlank) { _ScanLine = 0; } else if (m_VBlankMin != 300000) { _ScanLine = ScanLine - m_VBlankMin; } else { _ScanLine = ScanLine; } if (_bMeasureTime) { LONGLONG Time = GetRenderersData()->GetPerfCounter() - llPerf; if (Time > 5000000) { // 0.5 sec TRACE("GetVBlank too long (%f sec)\n", Time / 10000000.0); } m_RasterStatusWaitTimeMaxCalc = max(m_RasterStatusWaitTimeMaxCalc, Time); } return true; } bool CDX9AllocatorPresenter::WaitForVBlankRange(int &_RasterStart, int _RasterSize, bool _bWaitIfInside, bool _bNeedAccurate, bool _bMeasure, bool &_bTakenLock) { if (_bMeasure) { m_RasterStatusWaitTimeMaxCalc = 0; } bool bWaited = false; int ScanLine = 0; int InVBlank = 0; LONGLONG llPerf = 0; if (_bMeasure) { llPerf = GetRenderersData()->GetPerfCounter(); } GetVBlank(ScanLine, InVBlank, _bMeasure); if (_bMeasure) { m_VBlankStartWait = ScanLine; } static bool bOneWait = true; if (bOneWait && _bMeasure) { bOneWait = false; // If we are already in the wanted interval we need to wait until we aren't, this improves sync when for example you are playing 23.976 Hz material on a 24 Hz refresh rate int nInVBlank = 0; for (int i = 0; i < 50; i++) { // to prevent infinite loop if (!GetVBlank(ScanLine, InVBlank, _bMeasure)) { break; } if (InVBlank && nInVBlank == 0) { nInVBlank = 1; } else if (!InVBlank && nInVBlank == 1) { nInVBlank = 2; } else if (InVBlank && nInVBlank == 2) { nInVBlank = 3; } else if (!InVBlank && nInVBlank == 3) { break; } } } if (_bWaitIfInside) { int ScanLineDiff = long(ScanLine) - _RasterStart; if (ScanLineDiff > m_ScreenSize.cy / 2) { ScanLineDiff -= m_ScreenSize.cy; } else if (ScanLineDiff < -m_ScreenSize.cy / 2) { ScanLineDiff += m_ScreenSize.cy; } if (ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) { bWaited = true; // If we are already in the wanted interval we need to wait until we aren't, this improves sync when for example you are playing 23.976 Hz material on a 24 Hz refresh rate int LastLineDiff = ScanLineDiff; for (int i = 0; i < 50; i++) { // to prevent infinite loop if (!GetVBlank(ScanLine, InVBlank, _bMeasure)) { break; } int ScanLineDiff = long(ScanLine) - _RasterStart; if (ScanLineDiff > m_ScreenSize.cy / 2) { ScanLineDiff -= m_ScreenSize.cy; } else if (ScanLineDiff < -m_ScreenSize.cy / 2) { ScanLineDiff += m_ScreenSize.cy; } if (!(ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0)) { break; } LastLineDiff = ScanLineDiff; Sleep(1); // Just sleep } } } double RefreshRate = GetRefreshRate(); LONG ScanLines = GetScanLines(); int MinRange = max(min(int(0.0015 * double(ScanLines) * RefreshRate + 0.5), ScanLines/3), 5); // 1.5 ms or max 33 % of Time int NoSleepStart = _RasterStart - MinRange; int NoSleepRange = MinRange; if (NoSleepStart < 0) { NoSleepStart += m_ScreenSize.cy; } int MinRange2 = max(min(int(0.0050 * double(ScanLines) * RefreshRate + 0.5), ScanLines/3), 5); // 5 ms or max 33 % of Time int D3DDevLockStart = _RasterStart - MinRange2; int D3DDevLockRange = MinRange2; if (D3DDevLockStart < 0) { D3DDevLockStart += m_ScreenSize.cy; } int ScanLineDiff = ScanLine - _RasterStart; if (ScanLineDiff > m_ScreenSize.cy / 2) { ScanLineDiff -= m_ScreenSize.cy; } else if (ScanLineDiff < -m_ScreenSize.cy / 2) { ScanLineDiff += m_ScreenSize.cy; } int LastLineDiff = ScanLineDiff; int ScanLineDiffSleep = long(ScanLine) - NoSleepStart; if (ScanLineDiffSleep > m_ScreenSize.cy / 2) { ScanLineDiffSleep -= m_ScreenSize.cy; } else if (ScanLineDiffSleep < -m_ScreenSize.cy / 2) { ScanLineDiffSleep += m_ScreenSize.cy; } int LastLineDiffSleep = ScanLineDiffSleep; int ScanLineDiffLock = long(ScanLine) - D3DDevLockStart; if (ScanLineDiffLock > m_ScreenSize.cy / 2) { ScanLineDiffLock -= m_ScreenSize.cy; } else if (ScanLineDiffLock < -m_ScreenSize.cy / 2) { ScanLineDiffLock += m_ScreenSize.cy; } int LastLineDiffLock = ScanLineDiffLock; LONGLONG llPerfLock = 0; for (int i = 0; i < 50; i++) { // to prevent infinite loop if (!GetVBlank(ScanLine, InVBlank, _bMeasure)) { break; } int ScanLineDiff = long(ScanLine) - _RasterStart; if (ScanLineDiff > m_ScreenSize.cy / 2) { ScanLineDiff -= m_ScreenSize.cy; } else if (ScanLineDiff < -m_ScreenSize.cy / 2) { ScanLineDiff += m_ScreenSize.cy; } if ((ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0)) { break; } LastLineDiff = ScanLineDiff; bWaited = true; int ScanLineDiffLock = long(ScanLine) - D3DDevLockStart; if (ScanLineDiffLock > m_ScreenSize.cy / 2) { ScanLineDiffLock -= m_ScreenSize.cy; } else if (ScanLineDiffLock < -m_ScreenSize.cy / 2) { ScanLineDiffLock += m_ScreenSize.cy; } if (((ScanLineDiffLock >= 0 && ScanLineDiffLock <= D3DDevLockRange) || (LastLineDiffLock < 0 && ScanLineDiffLock > 0))) { if (!_bTakenLock && _bMeasure) { _bTakenLock = true; llPerfLock = GetRenderersData()->GetPerfCounter(); LockD3DDevice(); } } LastLineDiffLock = ScanLineDiffLock; int ScanLineDiffSleep = long(ScanLine) - NoSleepStart; if (ScanLineDiffSleep > m_ScreenSize.cy / 2) { ScanLineDiffSleep -= m_ScreenSize.cy; } else if (ScanLineDiffSleep < -m_ScreenSize.cy / 2) { ScanLineDiffSleep += m_ScreenSize.cy; } if (!((ScanLineDiffSleep >= 0 && ScanLineDiffSleep <= NoSleepRange) || (LastLineDiffSleep < 0 && ScanLineDiffSleep > 0)) || !_bNeedAccurate) { //TRACE("%d\n", RasterStatus.ScanLine); Sleep(1); // Don't sleep for the last 1.5 ms scan lines, so we get maximum precision } LastLineDiffSleep = ScanLineDiffSleep; } _RasterStart = ScanLine; if (_bMeasure) { m_VBlankEndWait = ScanLine; m_VBlankWaitTime = GetRenderersData()->GetPerfCounter() - llPerf; if (_bTakenLock) { m_VBlankLockTime = GetRenderersData()->GetPerfCounter() - llPerfLock; } else { m_VBlankLockTime = 0; } m_RasterStatusWaitTime = m_RasterStatusWaitTimeMaxCalc; m_RasterStatusWaitTimeMin = min(m_RasterStatusWaitTimeMin, m_RasterStatusWaitTime); m_RasterStatusWaitTimeMax = max(m_RasterStatusWaitTimeMax, m_RasterStatusWaitTime); } return bWaited; } int CDX9AllocatorPresenter::GetVBlackPos() { CRenderersSettings& s = GetRenderersSettings(); BOOL bCompositionEnabled = m_bCompositionEnabled; int WaitRange = max(m_ScreenSize.cy / 40, 5); if (!bCompositionEnabled) { if (m_bAlternativeVSync) { return s.m_AdvRendSets.iVMR9VSyncOffset; } else { int MinRange = max(min(int(0.005 * double(m_ScreenSize.cy) * GetRefreshRate() + 0.5), m_ScreenSize.cy/3), 5); // 5 ms or max 33 % of Time int WaitFor = m_ScreenSize.cy - (MinRange + WaitRange); return WaitFor; } } else { int WaitFor = m_ScreenSize.cy / 2; return WaitFor; } } bool CDX9AllocatorPresenter::WaitForVBlank(bool &_Waited, bool &_bTakenLock) { CRenderersSettings& s = GetRenderersSettings(); if (!s.m_AdvRendSets.iVMR9VSync) { _Waited = true; m_VBlankWaitTime = 0; m_VBlankLockTime = 0; m_VBlankEndWait = 0; m_VBlankStartWait = 0; return true; } //_Waited = true; //return false; BOOL bCompositionEnabled = m_bCompositionEnabled; int WaitFor = GetVBlackPos(); if (!bCompositionEnabled) { if (m_bAlternativeVSync) { _Waited = WaitForVBlankRange(WaitFor, 0, false, true, true, _bTakenLock); return false; } else { _Waited = WaitForVBlankRange(WaitFor, 0, false, s.m_AdvRendSets.iVMR9VSyncAccurate, true, _bTakenLock); return true; } } else { // Instead we wait for VBlack after the present, this seems to fix the stuttering problem. It's also possible to fix by removing the Sleep above, but that isn't an option. WaitForVBlankRange(WaitFor, 0, false, s.m_AdvRendSets.iVMR9VSyncAccurate, true, _bTakenLock); return false; } } void CDX9AllocatorPresenter::UpdateAlphaBitmap() { m_VMR9AlphaBitmapData.Free(); if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0) { HBITMAP hBitmap = (HBITMAP)GetCurrentObject (m_VMR9AlphaBitmap.hdc, OBJ_BITMAP); if (!hBitmap) { return; } DIBSECTION info = {0}; if (!::GetObject(hBitmap, sizeof( DIBSECTION ), &info )) { return; } m_VMR9AlphaBitmapRect = CRect(0, 0, info.dsBm.bmWidth, info.dsBm.bmHeight); m_VMR9AlphaBitmapWidthBytes = info.dsBm.bmWidthBytes; if (m_VMR9AlphaBitmapData.Allocate(info.dsBm.bmWidthBytes * info.dsBm.bmHeight)) { memcpy((BYTE *)m_VMR9AlphaBitmapData, info.dsBm.bmBits, info.dsBm.bmWidthBytes * info.dsBm.bmHeight); } } } STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) { if (m_bPendingResetDevice) { SendResetRequest(); return false; } CRenderersSettings& s = GetRenderersSettings(); //TRACE("Thread: %d\n", (LONG)((CRITICAL_SECTION &)m_RenderLock).OwningThread); #if 0 if (TryEnterCriticalSection (&(CRITICAL_SECTION &)(*((CCritSec *)this)))) { LeaveCriticalSection((&(CRITICAL_SECTION &)(*((CCritSec *)this)))); } else { __debugbreak(); } #endif CRenderersData * pApp = GetRenderersData(); LONGLONG StartPaint = pApp->GetPerfCounter(); CAutoLock cRenderLock(&m_RenderLock); if (m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top || m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0 || !m_pVideoSurface) { if (m_OrderedPaint) { --m_OrderedPaint; } else { //TRACE("UNORDERED PAINT!!!!!!\n"); } return false; } HRESULT hr; m_pD3DDev->BeginScene(); CComPtr<IDirect3DSurface9> pBackBuffer; m_pD3DDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer); // Clear the backbuffer m_pD3DDev->SetRenderTarget(0, pBackBuffer); hr = m_pD3DDev->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0); CRect rSrcVid(CPoint(0, 0), GetVisibleVideoSize()); CRect rDstVid(m_VideoRect); CRect rSrcPri(CPoint(0, 0), m_WindowRect.Size()); CRect rDstPri(m_WindowRect); // Render the current video frame hr = RenderVideo(pBackBuffer, rSrcVid, rDstVid); if (FAILED(hr)) { if (m_RenderingPath == RENDERING_PATH_STRETCHRECT) { // Support ffdshow queueing // m_pD3DDev->StretchRect may fail if ffdshow is using queue output samples. // Here we don't want to show the black buffer. if (m_OrderedPaint) { --m_OrderedPaint; } else { //TRACE("UNORDERED PAINT!!!!!!\n"); } return false; } } // paint the text on the backbuffer AlphaBltSubPic(rSrcPri.Size()); // Casimir666 : show OSD if (m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_UPDATE) { CAutoLock BitMapLock(&m_VMR9AlphaBitmapLock); CRect rcSrc (m_VMR9AlphaBitmap.rSrc); m_pOSDTexture = NULL; m_pOSDSurface = NULL; if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0 && (BYTE *)m_VMR9AlphaBitmapData) { if ( (m_pD3DXLoadSurfaceFromMemory != NULL) && SUCCEEDED(hr = m_pD3DDev->CreateTexture(rcSrc.Width(), rcSrc.Height(), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pOSDTexture, NULL)) ) { if (SUCCEEDED (hr = m_pOSDTexture->GetSurfaceLevel(0, &m_pOSDSurface))) { hr = m_pD3DXLoadSurfaceFromMemory (m_pOSDSurface, NULL, NULL, (BYTE *)m_VMR9AlphaBitmapData, D3DFMT_A8R8G8B8, m_VMR9AlphaBitmapWidthBytes, NULL, &m_VMR9AlphaBitmapRect, D3DX_FILTER_NONE, m_VMR9AlphaBitmap.clrSrcKey); } if (FAILED (hr)) { m_pOSDTexture = NULL; m_pOSDSurface = NULL; } } } m_VMR9AlphaBitmap.dwFlags ^= VMRBITMAP_UPDATE; } if (pApp->m_bResetStats) { ResetStats(); pApp->m_bResetStats = false; } if (pApp->m_fDisplayStats) { g_bGetFrameType = TRUE; DrawStats(); } else { g_bGetFrameType = FALSE; } if (m_pOSDTexture) { AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture); } m_pD3DDev->EndScene(); BOOL bCompositionEnabled = m_bCompositionEnabled; bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_AdvRendSets.iVMR9VSync; LONGLONG PresentWaitTime = 0; CComPtr<IDirect3DQuery9> pEventQuery; m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery); if (pEventQuery) { pEventQuery->Issue(D3DISSUE_END); } if (s.m_AdvRendSets.iVMRFlushGPUBeforeVSync && pEventQuery) { LONGLONG llPerf = pApp->GetPerfCounter(); BOOL Data; //Sleep(5); LONGLONG FlushStartTime = pApp->GetPerfCounter(); while (S_FALSE == pEventQuery->GetData( &Data, sizeof(Data), D3DGETDATA_FLUSH )) { if (!s.m_AdvRendSets.iVMRFlushGPUWait) { break; } Sleep(1); if (pApp->GetPerfCounter() - FlushStartTime > 500000) { break; // timeout after 50 ms } } if (s.m_AdvRendSets.iVMRFlushGPUWait) { m_WaitForGPUTime = pApp->GetPerfCounter() - llPerf; } else { m_WaitForGPUTime = 0; } } else { m_WaitForGPUTime = 0; } if (fAll) { m_PaintTime = (GetRenderersData()->GetPerfCounter() - StartPaint); m_PaintTimeMin = min(m_PaintTimeMin, m_PaintTime); m_PaintTimeMax = max(m_PaintTimeMax, m_PaintTime); } bool bWaited = false; bool bTakenLock = false; if (fAll) { // Only sync to refresh when redrawing all bool bTest = WaitForVBlank(bWaited, bTakenLock); ASSERT(bTest == bDoVSyncInPresent); if (!bDoVSyncInPresent) { LONGLONG Time = pApp->GetPerfCounter(); OnVBlankFinished(fAll, Time); if (!m_bIsEVR || m_OrderedPaint) { CalculateJitter(Time); } } } // Create a device pointer m_pd3dDevice // Create a query object { CComPtr<IDirect3DQuery9> pEventQuery; m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery); LONGLONG llPerf = pApp->GetPerfCounter(); if (m_pD3DDevEx) { if (m_bIsFullscreen) { hr = m_pD3DDevEx->PresentEx(NULL, NULL, NULL, NULL, NULL); } else { hr = m_pD3DDevEx->PresentEx(rSrcPri, rDstPri, NULL, NULL, NULL); } } else { if (m_bIsFullscreen) { hr = m_pD3DDev->Present(NULL, NULL, NULL, NULL); } else { hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL); } } // Issue an End event if (pEventQuery) { pEventQuery->Issue(D3DISSUE_END); } BOOL Data; if (s.m_AdvRendSets.iVMRFlushGPUAfterPresent && pEventQuery) { LONGLONG FlushStartTime = pApp->GetPerfCounter(); while (S_FALSE == pEventQuery->GetData( &Data, sizeof(Data), D3DGETDATA_FLUSH )) { if (!s.m_AdvRendSets.iVMRFlushGPUWait) { break; } if (pApp->GetPerfCounter() - FlushStartTime > 500000) { break; // timeout after 50 ms } } } int ScanLine; int bInVBlank; GetVBlank(ScanLine, bInVBlank, false); if (fAll && (!m_bIsEVR || m_OrderedPaint)) { m_VBlankEndPresent = ScanLine; } for (int i = 0; i < 50 && (ScanLine == 0 || bInVBlank); i++) { // to prevent infinite loop if (!GetVBlank(ScanLine, bInVBlank, false)) { break; } } m_VBlankStartMeasureTime = pApp->GetPerfCounter(); m_VBlankStartMeasure = ScanLine; if (fAll && bDoVSyncInPresent) { m_PresentWaitTime = (pApp->GetPerfCounter() - llPerf) + PresentWaitTime; m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime); m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime); } else { m_PresentWaitTime = 0; m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime); m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime); } } if (bDoVSyncInPresent) { LONGLONG Time = pApp->GetPerfCounter(); if (!m_bIsEVR || m_OrderedPaint) { CalculateJitter(Time); } OnVBlankFinished(fAll, Time); } if (bTakenLock) { UnlockD3DDevice(); } /*if (!bWaited) { bWaited = true; WaitForVBlank(bWaited); TRACE("Double VBlank\n"); ASSERT(bWaited); if (!bDoVSyncInPresent) { CalculateJitter(); OnVBlankFinished(fAll); } }*/ if (!m_bPendingResetDevice) { bool fResetDevice = false; if (hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) { TRACE("Reset Device: D3D Device Lost\n"); fResetDevice = true; } //if (hr == S_PRESENT_MODE_CHANGED) //{ // TRACE("Reset Device: D3D Device mode changed\n"); // fResetDevice = true; //} if (SettingsNeedResetDevice()) { TRACE("Reset Device: settings changed\n"); fResetDevice = true; } bCompositionEnabled = false; if (m_pDwmIsCompositionEnabled) { m_pDwmIsCompositionEnabled(&bCompositionEnabled); } if ((bCompositionEnabled != 0) != m_bCompositionEnabled) { if (m_bIsFullscreen) { m_bCompositionEnabled = (bCompositionEnabled != 0); } else { TRACE("Reset Device: DWM composition changed\n"); fResetDevice = true; } } if (s.fResetDevice) { LONGLONG time = GetRenderersData()->GetPerfCounter(); if (time > m_LastAdapterCheck + 20000000) { // check every 2 sec. m_LastAdapterCheck = time; #ifdef _DEBUG D3DDEVICE_CREATION_PARAMETERS Parameters; if (SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters))) { ASSERT(Parameters.AdapterOrdinal == m_CurrentAdapter); } #endif if (m_CurrentAdapter != GetAdapter(m_pD3D)) { TRACE("Reset Device: D3D adapter changed\n"); fResetDevice = true; } #ifdef _DEBUG else { ASSERT(m_pD3D->GetAdapterMonitor(m_CurrentAdapter) == m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D))); } #endif } } if (fResetDevice) { m_bPendingResetDevice = true; SendResetRequest(); } } if (m_OrderedPaint) { --m_OrderedPaint; } else { //if (m_bIsEVR) // TRACE("UNORDERED PAINT!!!!!!\n"); } return true; } double CDX9AllocatorPresenter::GetFrameTime() { if (m_DetectedLock) { return m_DetectedFrameTime; } return m_rtTimePerFrame / 10000000.0; } double CDX9AllocatorPresenter::GetFrameRate() { if (m_DetectedLock) { return m_DetectedFrameRate; } return m_rtTimePerFrame ? (10000000.0 / m_rtTimePerFrame) : 0; } void CDX9AllocatorPresenter::SendResetRequest() { if (!m_bDeviceResetRequested) { m_bDeviceResetRequested = true; AfxGetApp()->m_pMainWnd->PostMessage(WM_RESET_DEVICE); } } STDMETHODIMP_(bool) CDX9AllocatorPresenter::ResetDevice() { TRACE(_T("CDX9AllocatorPresenter::ResetDevice()\n")); _ASSERT(m_MainThreadId == GetCurrentThreadId()); StopWorkerThreads(); // In VMR-9 deleting the surfaces before we are told to is bad ! // Can't comment out this because CDX9AllocatorPresenter is used by EVR Custom // Why is EVR using a presenter for DX9 anyway ?! DeleteSurfaces(); HRESULT hr; CString Error; // TODO: Report error messages here // In VMR-9 'AllocSurfaces' call is redundant afaik because // 'CreateDevice' calls 'm_pIVMRSurfAllocNotify->ChangeD3DDevice' which in turn calls // 'CVMR9AllocatorPresenter::InitializeDevice' which calls 'AllocSurfaces' if (FAILED(hr = CreateDevice(Error)) || FAILED(hr = AllocSurfaces())) { // TODO: We should probably pause player #ifdef _DEBUG Error += GetWindowsErrorMessage(hr, NULL); TRACE("D3D Reset Error\n%ws\n\n", Error.GetBuffer()); #endif m_bDeviceResetRequested = false; return false; } OnResetDevice(); m_bDeviceResetRequested = false; m_bPendingResetDevice = false; return true; } STDMETHODIMP_(bool) CDX9AllocatorPresenter::DisplayChange() { TRACE(_T("CDX9AllocatorPresenter::DisplayChange()\n")); CAutoLock cRenderLock(&m_CreateLock); if (m_CurrentAdapter != GetAdapter(m_pD3D)) { return false; } D3DDISPLAYMODEEX DisplayMode; ZeroMemory(&DisplayMode, sizeof(DisplayMode)); DisplayMode.Size = sizeof(DisplayMode); D3DDISPLAYMODE d3ddm; ZeroMemory(&d3ddm, sizeof(d3ddm)); HRESULT hr = E_FAIL; if (m_bIsFullscreen) { if (m_pD3DEx) { m_pD3DEx->GetAdapterDisplayModeEx(m_CurrentAdapter, &DisplayMode, NULL); DisplayMode.Format = m_pp.BackBufferFormat; m_ScreenSize.SetSize(DisplayMode.Width, DisplayMode.Height); m_pp.FullScreen_RefreshRateInHz = m_RefreshRate = DisplayMode.RefreshRate; m_pp.BackBufferWidth = m_ScreenSize.cx; m_pp.BackBufferHeight = m_ScreenSize.cy; hr = m_pD3DDevEx->ResetEx(&m_pp, &DisplayMode); } else { m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm); d3ddm.Format = m_pp.BackBufferFormat; m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height); m_pp.FullScreen_RefreshRateInHz = m_RefreshRate = d3ddm.RefreshRate; m_pp.BackBufferWidth = m_ScreenSize.cx; m_pp.BackBufferHeight = m_ScreenSize.cy; hr = m_pD3DDev->Reset(&m_pp); } } else { if (m_pD3DEx) { m_pD3DEx->GetAdapterDisplayModeEx(m_CurrentAdapter, &DisplayMode, NULL); m_ScreenSize.SetSize(DisplayMode.Width, DisplayMode.Height); m_RefreshRate = DisplayMode.RefreshRate; m_pp.BackBufferWidth = m_ScreenSize.cx; m_pp.BackBufferHeight = m_ScreenSize.cy; hr = m_pD3DDevEx->Reset(&m_pp); } else { m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm); m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height); m_RefreshRate = d3ddm.RefreshRate; m_pp.BackBufferWidth = m_ScreenSize.cx; m_pp.BackBufferHeight = m_ScreenSize.cy; hr = m_pD3DDev->Reset(&m_pp); } } return SUCCEEDED(hr); } void CDX9AllocatorPresenter::DrawText(const RECT &rc, const CString &strText, int _Priority) { if (_Priority < 1) { return; } int Quality = 1; //D3DXCOLOR Color1( 1.0f, 0.2f, 0.2f, 1.0f ); // red //D3DXCOLOR Color1( 1.0f, 1.0f, 1.0f, 1.0f ); // white D3DXCOLOR Color1( 1.0f, 0.8f, 0.0f, 1.0f ); // yellow D3DXCOLOR Color0( 0.0f, 0.0f, 0.0f, 1.0f ); // black RECT Rect1 = rc; RECT Rect2 = rc; if (Quality == 1) { OffsetRect (&Rect2 , 2, 2); } else { OffsetRect (&Rect2 , -1, -1); } if (Quality > 0) { m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0); } OffsetRect (&Rect2 , 1, 0); if (Quality > 3) { m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0); } OffsetRect (&Rect2 , 1, 0); if (Quality > 2) { m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0); } OffsetRect (&Rect2 , 0, 1); if (Quality > 3) { m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0); } OffsetRect (&Rect2 , 0, 1); if (Quality > 1) { m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0); } OffsetRect (&Rect2 , -1, 0); if (Quality > 3) { m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0); } OffsetRect (&Rect2 , -1, 0); if (Quality > 2) { m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0); } OffsetRect (&Rect2 , 0, -1); if (Quality > 3) { m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0); } m_pFont->DrawText( m_pSprite, strText, -1, &Rect1, DT_NOCLIP, Color1); } void CDX9AllocatorPresenter::ResetStats() { CRenderersData *pApp = GetRenderersData(); LONGLONG Time = pApp->GetPerfCounter(); m_PaintTime = 0; m_PaintTimeMin = 0; m_PaintTimeMax = 0; m_RasterStatusWaitTime = 0; m_RasterStatusWaitTimeMin = 0; m_RasterStatusWaitTimeMax = 0; m_MinSyncOffset = 0; m_MaxSyncOffset = 0; m_fSyncOffsetAvr = 0; m_fSyncOffsetStdDev = 0; CalculateJitter(Time); } void CDX9AllocatorPresenter::DrawStats() { CRenderersSettings& s = GetRenderersSettings(); CRenderersData *pApp = GetRenderersData(); int bDetailedStats = 2; switch (pApp->m_fDisplayStats) { case 1: bDetailedStats = 2; break; case 2: bDetailedStats = 1; break; case 3: bDetailedStats = 0; break; } LONGLONG llMaxJitter = m_MaxJitter; LONGLONG llMinJitter = m_MinJitter; LONGLONG llMaxSyncOffset = m_MaxSyncOffset; LONGLONG llMinSyncOffset = m_MinSyncOffset; RECT rc = {40, 40, 0, 0 }; static UINT TextHeight = 0; static CRect WindowRect(0, 0, 0, 0); if (WindowRect != m_WindowRect) { m_pFont = NULL; } WindowRect = m_WindowRect; if (!m_pFont && m_pD3DXCreateFont) { UINT FontWidth = m_WindowRect.Width()/130; UINT FontHeight = m_WindowRect.Height()/35; UINT FontWeight = FW_BOLD; if ((m_rcMonitor.Width() - m_WindowRect.Width()) > 100) { FontWeight = FW_NORMAL; } TextHeight = FontHeight; m_pD3DXCreateFont( m_pD3DDev, // D3D device FontHeight, // Height FontWidth, // Width FontWeight, // Weight 0, // MipLevels, 0 = autogen mipmaps FALSE, // Italic DEFAULT_CHARSET, // CharSet OUT_DEFAULT_PRECIS, // OutputPrecision ANTIALIASED_QUALITY, // Quality FIXED_PITCH | FF_DONTCARE, // PitchAndFamily L"Lucida Console", // pFaceName &m_pFont); // ppFont } if (!m_pSprite && m_pD3DXCreateSprite) { m_pD3DXCreateSprite( m_pD3DDev, &m_pSprite); } if (!m_pLine && m_pD3DXCreateLine) { m_pD3DXCreateLine (m_pD3DDev, &m_pLine); } if (m_pFont && m_pSprite) { m_pSprite->Begin(D3DXSPRITE_ALPHABLEND); CString strText; if (bDetailedStats > 1) { double rtMS, rtFPS; rtMS = rtFPS = 0.0; if (m_rtTimePerFrame) { rtMS = double(m_rtTimePerFrame) / 10000.0; rtFPS = 10000000.0 / (double)(m_rtTimePerFrame); } if (m_bIsEVR) { if (g_nFrameType != PICT_NONE) { strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s, %2.03f StdDev) Clock: %1.4f %%", m_fAvrFps, rtMS, rtFPS, g_nFrameType == PICT_FRAME ? L"P" : L"I", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_DetectedFrameTimeStdDev / 10000.0, m_ModeratedTimeSpeed*100.0); } else { strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s) (%7.3f ms = %.03f%s, %2.03f StdDev) Clock: %1.4f %%", m_fAvrFps, rtMS, rtFPS, m_bInterlaced ? L"I" : L"P", GetFrameTime() * 1000.0, GetFrameRate(), m_DetectedLock ? L" L" : L"", m_DetectedFrameTimeStdDev / 10000.0, m_ModeratedTimeSpeed*100.0); } } else { if (g_nFrameType != PICT_NONE) { strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s)", m_fAvrFps, rtMS, rtFPS, g_nFrameType == PICT_FRAME ? L"P" : L"I"); } else { strText.Format(L"Frame rate : %7.03f (%7.3f ms = %.03f, %s)", m_fAvrFps, rtMS, rtFPS, m_bInterlaced ? L"I" : L"P"); } } } else { strText.Format(L"Frame rate : %7.03f (%.03f%s)", m_fAvrFps, GetFrameRate(), m_DetectedLock ? L" L" : L""); } DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); if (g_nFrameType != PICT_NONE) { strText.Format(L"Frame type : %s", g_nFrameType == PICT_FRAME ? L"Progressive" : g_nFrameType == PICT_BOTTOM_FIELD ? L"Interlaced : Bottom field first" : L"Interlaced : Top field first"); DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); } if (bDetailedStats > 1) { strText = L"Settings : "; if (m_bIsEVR) { strText += "EVR "; } else { strText += "VMR9 "; } if (m_bIsFullscreen) { strText += "FS "; } if (s.m_AdvRendSets.iVMR9FullscreenGUISupport) { strText += "FSGui "; } if (s.m_AdvRendSets.iVMRDisableDesktopComposition) { strText += "DisDC "; } if (m_bColorManagement) { strText += "ColorMan "; } if (s.m_AdvRendSets.iVMRFlushGPUBeforeVSync) { strText += "GPUFlushBV "; } if (s.m_AdvRendSets.iVMRFlushGPUAfterPresent) { strText += "GPUFlushAP "; } if (s.m_AdvRendSets.iVMRFlushGPUWait) { strText += "GPUFlushWt "; } if (s.m_AdvRendSets.iVMR9VSync) { strText += "VS "; } if (s.m_AdvRendSets.fVMR9AlterativeVSync) { strText += "AltVS "; } if (s.m_AdvRendSets.iVMR9VSyncAccurate) { strText += "AccVS "; } if (s.m_AdvRendSets.iVMR9VSyncOffset) { strText.AppendFormat(L"VSOfst(%d)", s.m_AdvRendSets.iVMR9VSyncOffset); } if (m_bFullFloatingPointProcessing) { strText += "FullFP "; } if (m_bHalfFloatingPointProcessing) { strText += "HalfFP "; } if (m_bIsEVR) { if (m_bHighColorResolution) { strText += "10bitOut "; } if (m_bForceInputHighColorResolution) { strText += "For10bitIn "; } if (s.m_AdvRendSets.iEVREnableFrameTimeCorrection) { strText += "FTC "; } if (s.m_AdvRendSets.iEVROutputRange == 0) { strText += "0-255 "; } else if (s.m_AdvRendSets.iEVROutputRange == 1) { strText += "16-235 "; } } DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); } if (bDetailedStats > 1) { strText.Format(L"Formats : Surface %s Backbuffer %s Display %s Device %s D3DExError: %s", GetD3DFormatStr(m_SurfaceType), GetD3DFormatStr(m_BackbufferType), GetD3DFormatStr(m_DisplayType), m_pD3DDevEx ? L"D3DDevEx" : L"D3DDev", m_D3DDevExError.GetString()); DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); if (m_bIsEVR) { strText.Format(L"Refresh rate : %.05f Hz SL: %4d (%3d Hz) Last Duration: %10.6f Corrected Frame Time: %s", m_DetectedRefreshRate, int(m_DetectedScanlinesPerFrame + 0.5), m_RefreshRate, double(m_LastFrameDuration)/10000.0, m_bCorrectedFrameTime?L"Yes":L"No"); DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); } } if (m_bSyncStatsAvailable) { if (bDetailedStats > 1) { strText.Format(L"Sync offset : Min = %+8.3f ms, Max = %+8.3f ms, StdDev = %7.3f ms, Avr = %7.3f ms, Mode = %d", (double(llMinSyncOffset)/10000.0), (double(llMaxSyncOffset)/10000.0), m_fSyncOffsetStdDev/10000.0, m_fSyncOffsetAvr/10000.0, m_VSyncMode); } else { strText.Format(L"Sync offset : Mode = %d", m_VSyncMode); } DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); } if (bDetailedStats > 1) { strText.Format(L"Jitter : Min = %+8.3f ms, Max = %+8.3f ms, StdDev = %7.3f ms", (double(llMinJitter)/10000.0), (double(llMaxJitter)/10000.0), m_fJitterStdDev/10000.0); DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); } if (m_pAllocator && bDetailedStats > 1) { CDX9SubPicAllocator *pAlloc = (CDX9SubPicAllocator *)m_pAllocator.p; int nFree = 0; int nAlloc = 0; int nSubPic = 0; REFERENCE_TIME QueueStart = 0; REFERENCE_TIME QueueEnd = 0; if (m_pSubPicQueue) { REFERENCE_TIME QueueNow = 0; m_pSubPicQueue->GetStats(nSubPic, QueueNow, QueueStart, QueueEnd); if (QueueStart) { QueueStart -= QueueNow; } if (QueueEnd) { QueueEnd -= QueueNow; } } pAlloc->GetStats(nFree, nAlloc); strText.Format(L"Subtitles : Free %d Allocated %d Buffered %d QueueStart %7.3f QueueEnd %7.3f", nFree, nAlloc, nSubPic, (double(QueueStart)/10000000.0), (double(QueueEnd)/10000000.0)); DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); } if (bDetailedStats > 1) { if (m_VBlankEndPresent == -100000) { strText.Format(L"VBlank Wait : Start %4d End %4d Wait %7.3f ms Lock %7.3f ms Offset %4d Max %4d", m_VBlankStartWait, m_VBlankEndWait, (double(m_VBlankWaitTime)/10000.0), (double(m_VBlankLockTime)/10000.0), m_VBlankMin, m_VBlankMax - m_VBlankMin); } else { strText.Format(L"VBlank Wait : Start %4d End %4d Wait %7.3f ms Lock %7.3f ms Offset %4d Max %4d EndPresent %4d", m_VBlankStartWait, m_VBlankEndWait, (double(m_VBlankWaitTime)/10000.0), (double(m_VBlankLockTime)/10000.0), m_VBlankMin, m_VBlankMax - m_VBlankMin, m_VBlankEndPresent); } } else { if (m_VBlankEndPresent == -100000) { strText.Format(L"VBlank Wait : Start %4d End %4d", m_VBlankStartWait, m_VBlankEndWait); } else { strText.Format(L"VBlank Wait : Start %4d End %4d EP %4d", m_VBlankStartWait, m_VBlankEndWait, m_VBlankEndPresent); } } DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); BOOL bCompositionEnabled = m_bCompositionEnabled; bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_AdvRendSets.iVMR9VSync; if (bDetailedStats > 1 && bDoVSyncInPresent) { strText.Format(L"Present Wait : Wait %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_PresentWaitTime)/10000.0), (double(m_PresentWaitTimeMin)/10000.0), (double(m_PresentWaitTimeMax)/10000.0)); DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); } if (bDetailedStats > 1) { if (m_WaitForGPUTime) { strText.Format(L"Paint Time : Draw %7.3f ms Min %7.3f ms Max %7.3f ms GPU %7.3f ms", (double(m_PaintTime-m_WaitForGPUTime)/10000.0), (double(m_PaintTimeMin)/10000.0), (double(m_PaintTimeMax)/10000.0), (double(m_WaitForGPUTime)/10000.0)); } else { strText.Format(L"Paint Time : Draw %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_PaintTime-m_WaitForGPUTime)/10000.0), (double(m_PaintTimeMin)/10000.0), (double(m_PaintTimeMax)/10000.0)); } } else { if (m_WaitForGPUTime) { strText.Format(L"Paint Time : Draw %7.3f ms GPU %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime)/10000.0), (double(m_WaitForGPUTime)/10000.0)); } else { strText.Format(L"Paint Time : Draw %7.3f ms", (double(m_PaintTime - m_WaitForGPUTime)/10000.0)); } } DrawText(rc, strText, 2); OffsetRect (&rc, 0, TextHeight); if (bDetailedStats > 1) { strText.Format(L"Raster Status: Wait %7.3f ms Min %7.3f ms Max %7.3f ms", (double(m_RasterStatusWaitTime)/10000.0), (double(m_RasterStatusWaitTimeMin)/10000.0), (double(m_RasterStatusWaitTimeMax)/10000.0)); DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); } if (bDetailedStats > 1) { if (m_bIsEVR) { strText.Format(L"Buffering : Buffered %3d Free %3d Current Surface %3d", m_nUsedBuffer, m_nNbDXSurface - m_nUsedBuffer, m_nCurSurface); } else { strText.Format(L"Buffering : VMR9Surfaces %3d VMR9Surface %3d", m_nVMR9Surfaces, m_iVMR9Surface); } } else { strText.Format(L"Buffered : %3d", m_nUsedBuffer); } DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); if (bDetailedStats > 1) { strText.Format(L"Video size : %d x %d (AR = %d : %d)", m_NativeVideoSize.cx, m_NativeVideoSize.cy, m_AspectRatio.cx, m_AspectRatio.cy); DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); if (m_pVideoTexture[0] || m_pVideoSurface[0]) { D3DSURFACE_DESC desc; if (m_pVideoTexture[0]) { m_pVideoTexture[0]->GetLevelDesc(0, &desc); } else if (m_pVideoSurface[0]) { m_pVideoSurface[0]->GetDesc(&desc); } if (desc.Width != (UINT)m_NativeVideoSize.cx || desc.Height != (UINT)m_NativeVideoSize.cy) { strText.Format(L"Texture size : %d x %d", desc.Width, desc.Height); DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); } } strText.Format(L"%-13s: %s", GetDXVAVersion(), GetDXVADecoderDescription()); DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); strText.Format(L"DirectX SDK : %u", GetRenderersData()->GetDXSdkRelease()); DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); if (!m_D3D9Device.IsEmpty()) { strText = "Render device: " + m_D3D9Device; DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); } if (!m_MonitorName.IsEmpty()) { strText.Format(L"Monitor : %s, Native resolution %ux%u", m_MonitorName, m_nMonitorHorRes, m_nMonitorVerRes); DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); } if (!m_Decoder.IsEmpty()) { strText = "Decoder : " + m_Decoder; DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); } if (!m_InputVCodec.IsEmpty()) { strText = "Input Type : " + m_InputVCodec; DrawText(rc, strText, 1); OffsetRect (&rc, 0, TextHeight); } for (int i=0; i<6; i++) { if (m_strStatsMsg[i][0]) { DrawText(rc, m_strStatsMsg[i], 1); OffsetRect (&rc, 0, TextHeight); } } } m_pSprite->End(); OffsetRect(&rc, 0, TextHeight); // Extra "line feed" } if (m_pLine && bDetailedStats) { D3DXVECTOR2 Points[NB_JITTER]; int nIndex; int StartX = 0; int StartY = 0; float ScaleX = min(1.0f, max(0.4f, 1.4f*m_WindowRect.Width()/m_rcMonitor.Width())); float ScaleY = min(1.0f, max(0.4f, 1.4f*m_WindowRect.Height()/m_rcMonitor.Height())); int DrawWidth = 625 * ScaleX + 50 * ScaleX; int DrawHeight = 250 * ScaleY; int Alpha = 80; StartX = m_WindowRect.Width() - (DrawWidth + 20); StartY = m_WindowRect.Height() - (DrawHeight + 20); DrawRect(RGB(0,0,0), Alpha, CRect(StartX, StartY, StartX + DrawWidth, StartY + DrawHeight)); // === Jitter Graduation m_pLine->SetWidth(2.5 * ScaleX); // Width m_pLine->SetAntialias(1); //m_pLine->SetGLLines(1); m_pLine->Begin(); for (int i=10; i < 250 * ScaleY; i += 10 * ScaleY) { Points[0].x = (FLOAT)(StartX); Points[0].y = (FLOAT)(StartY + i); Points[1].x = (FLOAT)(StartX + ((i-10)%40 ? 50 *ScaleX : 625 * ScaleX)); Points[1].y = (FLOAT)(StartY + i); if (i == 130) { Points[1].x += 50 * ScaleX; } m_pLine->Draw (Points, 2, D3DCOLOR_XRGB(100,100,255)); } // === Jitter curve if (m_rtTimePerFrame) { for (int i=0; i < NB_JITTER; i++) { nIndex = (m_nNextJitter + 1 + i) % NB_JITTER; if (nIndex < 0) { nIndex += NB_JITTER; } double Jitter = m_pllJitter[nIndex] - m_fJitterMean; Points[i].x = (FLOAT)(StartX + (i * 5 * ScaleX + 5)); Points[i].y = (FLOAT)(StartY + ((Jitter * ScaleY)/5000.0 + 125.0 * ScaleY)); } m_pLine->Draw (Points, NB_JITTER, D3DCOLOR_XRGB(255,100,100)); if (m_bSyncStatsAvailable) { for (int i=0; i<NB_JITTER; i++) { nIndex = (m_nNextSyncOffset+1+i) % NB_JITTER; if (nIndex < 0) { nIndex += NB_JITTER; } Points[i].x = (FLOAT)(StartX + (i * 5 * ScaleX + 5)); Points[i].y = (FLOAT)(StartY + ((m_pllSyncOffset[nIndex] * ScaleY)/5000 + 125 * ScaleY)); } m_pLine->Draw (Points, NB_JITTER, D3DCOLOR_XRGB(100,200,100)); } } m_pLine->End(); } // === Text } STDMETHODIMP CDX9AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size) { CheckPointer(size, E_POINTER); HRESULT hr; D3DSURFACE_DESC desc; memset(&desc, 0, sizeof(desc)); m_pVideoSurface[m_nCurSurface]->GetDesc(&desc); DWORD required = sizeof(BITMAPINFOHEADER) + (desc.Width * desc.Height * 32 >> 3); if (!lpDib) { *size = required; return S_OK; } if (*size < required) { return E_OUTOFMEMORY; } *size = required; D3DLOCKED_RECT r; CComPtr<IDirect3DSurface9> pSurface; if (m_bFullFloatingPointProcessing || m_bHalfFloatingPointProcessing || m_bHighColorResolution) { CComPtr<IDirect3DSurface9> fSurface = m_pVideoSurface[m_nCurSurface]; if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &fSurface, NULL)) || FAILED(hr = m_pD3DXLoadSurfaceFromSurface(fSurface, NULL, NULL, m_pVideoSurface[m_nCurSurface], NULL, NULL, D3DX_DEFAULT, 0))) return hr; pSurface = fSurface; if (FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) { pSurface = NULL; if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &pSurface, NULL)) || FAILED(hr = m_pD3DDev->GetRenderTargetData(fSurface, pSurface)) || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) return hr; } } else { pSurface = m_pVideoSurface[m_nCurSurface]; if (FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) { pSurface = NULL; if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pSurface, NULL)) || FAILED(hr = m_pD3DDev->GetRenderTargetData(m_pVideoSurface[m_nCurSurface], pSurface)) || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) return hr; } } BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib; memset(bih, 0, sizeof(BITMAPINFOHEADER)); bih->biSize = sizeof(BITMAPINFOHEADER); bih->biWidth = desc.Width; bih->biHeight = desc.Height; bih->biBitCount = 32; bih->biPlanes = 1; bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount >> 3; BitBltFromRGBToRGB( bih->biWidth, bih->biHeight, (BYTE*)(bih + 1), bih->biWidth*bih->biBitCount>>3, bih->biBitCount, (BYTE*)r.pBits + r.Pitch*(desc.Height-1), -(int)r.Pitch, 32); pSurface->UnlockRect(); return S_OK; } STDMETHODIMP CDX9AllocatorPresenter::SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget) { return SetPixelShader2(pSrcData, pTarget, false); } STDMETHODIMP CDX9AllocatorPresenter::SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace) { CAutoLock cRenderLock(&m_RenderLock); return SetCustomPixelShader(pSrcData, pTarget, bScreenSpace); }
29.606121
328
0.693592
chinajeffery
ee7a9c9c80b5703369dee510031a19daa3c35be2
2,228
hpp
C++
src/beast/include/beast/http/status.hpp
gcbpay/R9Ripple
98f878cf10a32e26021b6a6ed44990bccbbc92c2
[ "BSL-1.0" ]
2
2017-06-09T10:56:26.000Z
2021-05-28T12:58:33.000Z
include/beast/http/status.hpp
somayeghahari/beast
999e2fa0318b5982736d3ea01a418770ea802671
[ "BSL-1.0" ]
1
2016-06-22T17:13:44.000Z
2016-06-22T17:13:44.000Z
include/beast/http/status.hpp
somayeghahari/beast
999e2fa0318b5982736d3ea01a418770ea802671
[ "BSL-1.0" ]
null
null
null
// // Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) // // 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 BEAST_HTTP_STATUS_HPP #define BEAST_HTTP_STATUS_HPP namespace beast { namespace http { /** Returns the string corresponding to the numeric HTTP status code. */ template<class = void> char const* status_text(int status) { switch(status) { case 100: return "Continue"; case 101: return "Switching Protocols"; case 200: return "OK"; case 201: return "Created"; case 202: return "Accepted"; case 203: return "Non-Authoritative Information"; case 204: return "No Content"; case 205: return "Reset Content"; case 206: return "Partial Content"; case 300: return "Multiple Choices"; case 301: return "Moved Permanently"; case 302: return "Found"; case 303: return "See Other"; case 304: return "Not Modified"; case 305: return "Use Proxy"; // case 306: return "<reserved>"; case 307: return "Temporary Redirect"; case 400: return "Bad Request"; case 401: return "Unauthorized"; case 402: return "Payment Required"; case 403: return "Forbidden"; case 404: return "Not Found"; case 405: return "Method Not Allowed"; case 406: return "Not Acceptable"; case 407: return "Proxy Authentication Required"; case 408: return "Request Timeout"; case 409: return "Conflict"; case 410: return "Gone"; case 411: return "Length Required"; case 412: return "Precondition Failed"; case 413: return "Request Entity Too Large"; case 414: return "Request-URI Too Long"; case 415: return "Unsupported Media Type"; case 416: return "Requested Range Not Satisfiable"; case 417: return "Expectation Failed"; case 500: return "Internal Server Error"; case 501: return "Not Implemented"; case 502: return "Bad Gateway"; case 503: return "Service Unavailable"; case 504: return "Gateway Timeout"; case 505: return "HTTP Version Not Supported"; default: break; } return "Unknown HTTP status"; } } // http } // beast #endif
30.944444
79
0.678636
gcbpay
ee7c8f75e654c1e71fc25e7215f53e3ad4ccd233
1,157
cpp
C++
src/sleek/driver/context.cpp
Phirxian/sleek-engine
741d55c8daad67ddf631e8b8fbdced59402d7bda
[ "BSD-2-Clause" ]
null
null
null
src/sleek/driver/context.cpp
Phirxian/sleek-engine
741d55c8daad67ddf631e8b8fbdced59402d7bda
[ "BSD-2-Clause" ]
null
null
null
src/sleek/driver/context.cpp
Phirxian/sleek-engine
741d55c8daad67ddf631e8b8fbdced59402d7bda
[ "BSD-2-Clause" ]
null
null
null
#include "context.h" #include "ogl3/ogl3_context.h" //#include "ogl4/ogl4_context.h" //#include "dx11/dx11_context.h" //#include "dx12/dx12_context.h" //#include "vk/vk_context.h" //#include "metal/metal_context.h" namespace sleek { namespace driver { context::context(std::shared_ptr<device::Device> &d, std::shared_ptr<context> s) noexcept : win(d) { shared = s; } context::~context() noexcept { } std::shared_ptr<context> createContextRenderer(RENDER_CONTEXT cx, std::shared_ptr<device::Device> &d, std::shared_ptr<context> s) noexcept { switch(cx) { case RCTX_OGL3: return std::make_shared<ogl3_context>(d, s); break; // case RCTX_OGL4: // return std::make_shared<ogl4_context>(d, s); // break; #ifdef d3d_context_support case RCTX_D3D: return std::make_shared<d3d_context>(d, s); break; #endif } return nullptr; } } }
26.295455
146
0.52204
Phirxian
ee803a602c550602de8f126b3584ff31694e58b1
1,957
cpp
C++
Modules/REPlatform/Sources/REPlatform/Scene/Private/Systems/EditorVegetationSystem.cpp
stinvi/dava.engine
2b396ca49cdf10cdc98ad8a9ffcf7768a05e285e
[ "BSD-3-Clause" ]
26
2018-09-03T08:48:22.000Z
2022-02-14T05:14:50.000Z
Modules/REPlatform/Sources/REPlatform/Scene/Private/Systems/EditorVegetationSystem.cpp
ANHELL-blitz/dava.engine
ed83624326f000866e29166c7f4cccfed1bb41d4
[ "BSD-3-Clause" ]
null
null
null
Modules/REPlatform/Sources/REPlatform/Scene/Private/Systems/EditorVegetationSystem.cpp
ANHELL-blitz/dava.engine
ed83624326f000866e29166c7f4cccfed1bb41d4
[ "BSD-3-Clause" ]
45
2018-05-11T06:47:17.000Z
2022-02-03T11:30:55.000Z
#include "REPlatform/Scene/Systems/EditorVegetationSystem.h" #include <Debug/DVAssert.h> #include <Entity/Component.h> #include <Render/Highlevel/RenderObject.h> #include <Render/Highlevel/Vegetation/VegetationRenderObject.h> #include <Scene3D/Components/ComponentHelpers.h> #include <Scene3D/Components/RenderComponent.h> #include <Scene3D/Entity.h> #include <Scene3D/Scene.h> namespace DAVA { EditorVegetationSystem::EditorVegetationSystem(Scene* scene) : SceneSystem(scene) { } void EditorVegetationSystem::AddEntity(Entity* entity) { DVASSERT(HasComponent(entity, Type::Instance<RenderComponent>())); VegetationRenderObject* vro = GetVegetation(entity); if (vro != nullptr) { DVASSERT(std::find(vegetationObjects.begin(), vegetationObjects.end(), vro) == vegetationObjects.end()); vegetationObjects.push_back(vro); } } void EditorVegetationSystem::RemoveEntity(Entity* entity) { DVASSERT(DAVA::HasComponent(entity, Type::Instance<RenderComponent>())); VegetationRenderObject* vro = GetVegetation(entity); if (vro != nullptr) { DVASSERT(std::find(vegetationObjects.begin(), vegetationObjects.end(), vro) != vegetationObjects.end()); FindAndRemoveExchangingWithLast(vegetationObjects, vro); } } void EditorVegetationSystem::PrepareForRemove() { vegetationObjects.clear(); } void EditorVegetationSystem::GetActiveVegetation(Vector<VegetationRenderObject*>& activeVegetationObjects) { static const uint32 VISIBILITY_CRITERIA = RenderObject::VISIBLE | RenderObject::VISIBLE_QUALITY; for (VegetationRenderObject* ro : vegetationObjects) { if ((ro->GetFlags() & VISIBILITY_CRITERIA) == VISIBILITY_CRITERIA) { activeVegetationObjects.push_back(ro); } } } void EditorVegetationSystem::ReloadVegetation() { for (VegetationRenderObject* ro : vegetationObjects) { ro->Rebuild(); } } } // namespace DAVA
28.362319
112
0.729688
stinvi
ee83b226b0bab9d284ba20e45397de2342f52711
529
cpp
C++
src/L/L1338.cpp
wlhcode/lscct
7fd112a9d1851ddcf41886d3084381a52e84a3ce
[ "MIT" ]
null
null
null
src/L/L1338.cpp
wlhcode/lscct
7fd112a9d1851ddcf41886d3084381a52e84a3ce
[ "MIT" ]
null
null
null
src/L/L1338.cpp
wlhcode/lscct
7fd112a9d1851ddcf41886d3084381a52e84a3ce
[ "MIT" ]
null
null
null
#include<bits/stdc++.h> #define int long long #define double long double using namespace std; int digitsum(int a){ if(a==0) return 0; return a%10+digitsum(a/10); } bool prime(int n){ if(n==1) return false; int m=sqrt(n); for(int i=2;i<=m;i++){ if(n%i==0) return false; } return true; } main(){ ios::sync_with_stdio(false); cin.tie(0); int a,b,t,q; double c=0,h; cin>>a>>b; for(int i=0;i<a*b;i++){ cin>>t; c+=t; } cin>>h>>q; for(int i=0;i<q;i++) c*=1+h/100; cout<<setprecision(0)<<fixed<<round(c)<<endl; }
16.53125
46
0.603025
wlhcode
ee84b193983e035a20452ea38a8474309ada0906
654,902
cpp
C++
openconfig/ydk/models/openconfig/fragmented/openconfig_network_instance_3.cpp
CiscoDevNet/ydk-cpp
ef7d75970f2ef1154100e0f7b0a2ee823609b481
[ "ECL-2.0", "Apache-2.0" ]
17
2016-12-02T05:45:49.000Z
2022-02-10T19:32:54.000Z
openconfig/ydk/models/openconfig/fragmented/openconfig_network_instance_3.cpp
CiscoDevNet/ydk-cpp
ef7d75970f2ef1154100e0f7b0a2ee823609b481
[ "ECL-2.0", "Apache-2.0" ]
2
2017-03-27T15:22:38.000Z
2019-11-05T08:30:16.000Z
openconfig/ydk/models/openconfig/fragmented/openconfig_network_instance_3.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 "openconfig_network_instance_3.hpp" #include "openconfig_network_instance_4.hpp" using namespace ydk; namespace openconfig { namespace openconfig_network_instance { NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::Config::Config() : allow_multiple_as{YType::boolean, "allow-multiple-as"} { yang_name = "config"; yang_parent_name = "ebgp"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::Config::has_data() const { if (is_presence_container) return true; return allow_multiple_as.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(allow_multiple_as.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (allow_multiple_as.is_set || is_set(allow_multiple_as.yfilter)) leaf_name_data.push_back(allow_multiple_as.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "allow-multiple-as") { allow_multiple_as = value; allow_multiple_as.value_namespace = name_space; allow_multiple_as.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "allow-multiple-as") { allow_multiple_as.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allow-multiple-as") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::State::State() : allow_multiple_as{YType::boolean, "allow-multiple-as"} { yang_name = "state"; yang_parent_name = "ebgp"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::State::has_data() const { if (is_presence_container) return true; return allow_multiple_as.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::State::has_operation() const { return is_set(yfilter) || ydk::is_set(allow_multiple_as.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (allow_multiple_as.is_set || is_set(allow_multiple_as.yfilter)) leaf_name_data.push_back(allow_multiple_as.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::State::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 == "allow-multiple-as") { allow_multiple_as = value; allow_multiple_as.value_namespace = name_space; allow_multiple_as.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "allow-multiple-as") { allow_multiple_as.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::UseMultiplePaths::Ebgp::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allow-multiple-as") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::ApplyPolicy() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::State>()) { config->parent = this; state->parent = this; yang_name = "apply-policy"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::~ApplyPolicy() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "apply-policy"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::Config::Config() : import_policy{YType::str, "import-policy"}, default_import_policy{YType::enumeration, "default-import-policy"}, export_policy{YType::str, "export-policy"}, default_export_policy{YType::enumeration, "default-export-policy"} { yang_name = "config"; yang_parent_name = "apply-policy"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::Config::has_data() const { if (is_presence_container) return true; for (auto const & leaf : import_policy.getYLeafs()) { if(leaf.is_set) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(leaf.is_set) return true; } return default_import_policy.is_set || default_export_policy.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::Config::has_operation() const { for (auto const & leaf : import_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(import_policy.yfilter) || ydk::is_set(default_import_policy.yfilter) || ydk::is_set(export_policy.yfilter) || ydk::is_set(default_export_policy.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (default_import_policy.is_set || is_set(default_import_policy.yfilter)) leaf_name_data.push_back(default_import_policy.get_name_leafdata()); if (default_export_policy.is_set || is_set(default_export_policy.yfilter)) leaf_name_data.push_back(default_export_policy.get_name_leafdata()); auto import_policy_name_datas = import_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), import_policy_name_datas.begin(), import_policy_name_datas.end()); auto export_policy_name_datas = export_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), export_policy_name_datas.begin(), export_policy_name_datas.end()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "import-policy") { import_policy.append(value); } if(value_path == "default-import-policy") { default_import_policy = value; default_import_policy.value_namespace = name_space; default_import_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "export-policy") { export_policy.append(value); } if(value_path == "default-export-policy") { default_export_policy = value; default_export_policy.value_namespace = name_space; default_export_policy.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "import-policy") { import_policy.yfilter = yfilter; } if(value_path == "default-import-policy") { default_import_policy.yfilter = yfilter; } if(value_path == "export-policy") { export_policy.yfilter = yfilter; } if(value_path == "default-export-policy") { default_export_policy.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "import-policy" || name == "default-import-policy" || name == "export-policy" || name == "default-export-policy") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::State::State() : import_policy{YType::str, "import-policy"}, default_import_policy{YType::enumeration, "default-import-policy"}, export_policy{YType::str, "export-policy"}, default_export_policy{YType::enumeration, "default-export-policy"} { yang_name = "state"; yang_parent_name = "apply-policy"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::State::has_data() const { if (is_presence_container) return true; for (auto const & leaf : import_policy.getYLeafs()) { if(leaf.is_set) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(leaf.is_set) return true; } return default_import_policy.is_set || default_export_policy.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::State::has_operation() const { for (auto const & leaf : import_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(import_policy.yfilter) || ydk::is_set(default_import_policy.yfilter) || ydk::is_set(export_policy.yfilter) || ydk::is_set(default_export_policy.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (default_import_policy.is_set || is_set(default_import_policy.yfilter)) leaf_name_data.push_back(default_import_policy.get_name_leafdata()); if (default_export_policy.is_set || is_set(default_export_policy.yfilter)) leaf_name_data.push_back(default_export_policy.get_name_leafdata()); auto import_policy_name_datas = import_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), import_policy_name_datas.begin(), import_policy_name_datas.end()); auto export_policy_name_datas = export_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), export_policy_name_datas.begin(), export_policy_name_datas.end()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::State::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 == "import-policy") { import_policy.append(value); } if(value_path == "default-import-policy") { default_import_policy = value; default_import_policy.value_namespace = name_space; default_import_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "export-policy") { export_policy.append(value); } if(value_path == "default-export-policy") { default_export_policy = value; default_export_policy.value_namespace = name_space; default_export_policy.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "import-policy") { import_policy.yfilter = yfilter; } if(value_path == "default-import-policy") { default_import_policy.yfilter = yfilter; } if(value_path == "export-policy") { export_policy.yfilter = yfilter; } if(value_path == "default-export-policy") { default_export_policy.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::ApplyPolicy::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "import-policy" || name == "default-import-policy" || name == "export-policy" || name == "default-export-policy") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafis() : afi_safi(this, {"afi_safi_name"}) { yang_name = "afi-safis"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::~AfiSafis() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<afi_safi.len(); index++) { if(afi_safi[index]->has_data()) return true; } return false; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::has_operation() const { for (std::size_t index=0; index<afi_safi.len(); index++) { if(afi_safi[index]->has_operation()) return true; } return is_set(yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "afi-safis"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "afi-safi") { auto ent_ = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi>(); ent_->parent = this; afi_safi.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : afi_safi.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 NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::has_leaf_or_child_of_name(const std::string & name) const { if(name == "afi-safi") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::AfiSafi() : afi_safi_name{YType::identityref, "afi-safi-name"} , config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State>()) , graceful_restart(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart>()) , apply_policy(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy>()) , ipv4_unicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast>()) , ipv6_unicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast>()) , ipv4_labeled_unicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast>()) , ipv6_labeled_unicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast>()) , l3vpn_ipv4_unicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast>()) , l3vpn_ipv6_unicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast>()) , l3vpn_ipv4_multicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast>()) , l3vpn_ipv6_multicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast>()) , l2vpn_vpls(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls>()) , l2vpn_evpn(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn>()) , use_multiple_paths(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths>()) { config->parent = this; state->parent = this; graceful_restart->parent = this; apply_policy->parent = this; ipv4_unicast->parent = this; ipv6_unicast->parent = this; ipv4_labeled_unicast->parent = this; ipv6_labeled_unicast->parent = this; l3vpn_ipv4_unicast->parent = this; l3vpn_ipv6_unicast->parent = this; l3vpn_ipv4_multicast->parent = this; l3vpn_ipv6_multicast->parent = this; l2vpn_vpls->parent = this; l2vpn_evpn->parent = this; use_multiple_paths->parent = this; yang_name = "afi-safi"; yang_parent_name = "afi-safis"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::~AfiSafi() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::has_data() const { if (is_presence_container) return true; return afi_safi_name.is_set || (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()) || (graceful_restart != nullptr && graceful_restart->has_data()) || (apply_policy != nullptr && apply_policy->has_data()) || (ipv4_unicast != nullptr && ipv4_unicast->has_data()) || (ipv6_unicast != nullptr && ipv6_unicast->has_data()) || (ipv4_labeled_unicast != nullptr && ipv4_labeled_unicast->has_data()) || (ipv6_labeled_unicast != nullptr && ipv6_labeled_unicast->has_data()) || (l3vpn_ipv4_unicast != nullptr && l3vpn_ipv4_unicast->has_data()) || (l3vpn_ipv6_unicast != nullptr && l3vpn_ipv6_unicast->has_data()) || (l3vpn_ipv4_multicast != nullptr && l3vpn_ipv4_multicast->has_data()) || (l3vpn_ipv6_multicast != nullptr && l3vpn_ipv6_multicast->has_data()) || (l2vpn_vpls != nullptr && l2vpn_vpls->has_data()) || (l2vpn_evpn != nullptr && l2vpn_evpn->has_data()) || (use_multiple_paths != nullptr && use_multiple_paths->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::has_operation() const { return is_set(yfilter) || ydk::is_set(afi_safi_name.yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()) || (graceful_restart != nullptr && graceful_restart->has_operation()) || (apply_policy != nullptr && apply_policy->has_operation()) || (ipv4_unicast != nullptr && ipv4_unicast->has_operation()) || (ipv6_unicast != nullptr && ipv6_unicast->has_operation()) || (ipv4_labeled_unicast != nullptr && ipv4_labeled_unicast->has_operation()) || (ipv6_labeled_unicast != nullptr && ipv6_labeled_unicast->has_operation()) || (l3vpn_ipv4_unicast != nullptr && l3vpn_ipv4_unicast->has_operation()) || (l3vpn_ipv6_unicast != nullptr && l3vpn_ipv6_unicast->has_operation()) || (l3vpn_ipv4_multicast != nullptr && l3vpn_ipv4_multicast->has_operation()) || (l3vpn_ipv6_multicast != nullptr && l3vpn_ipv6_multicast->has_operation()) || (l2vpn_vpls != nullptr && l2vpn_vpls->has_operation()) || (l2vpn_evpn != nullptr && l2vpn_evpn->has_operation()) || (use_multiple_paths != nullptr && use_multiple_paths->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "afi-safi"; ADD_KEY_TOKEN(afi_safi_name, "afi-safi-name"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (afi_safi_name.is_set || is_set(afi_safi_name.yfilter)) leaf_name_data.push_back(afi_safi_name.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State>(); } return state; } if(child_yang_name == "graceful-restart") { if(graceful_restart == nullptr) { graceful_restart = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart>(); } return graceful_restart; } if(child_yang_name == "apply-policy") { if(apply_policy == nullptr) { apply_policy = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy>(); } return apply_policy; } if(child_yang_name == "ipv4-unicast") { if(ipv4_unicast == nullptr) { ipv4_unicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast>(); } return ipv4_unicast; } if(child_yang_name == "ipv6-unicast") { if(ipv6_unicast == nullptr) { ipv6_unicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast>(); } return ipv6_unicast; } if(child_yang_name == "ipv4-labeled-unicast") { if(ipv4_labeled_unicast == nullptr) { ipv4_labeled_unicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast>(); } return ipv4_labeled_unicast; } if(child_yang_name == "ipv6-labeled-unicast") { if(ipv6_labeled_unicast == nullptr) { ipv6_labeled_unicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast>(); } return ipv6_labeled_unicast; } if(child_yang_name == "l3vpn-ipv4-unicast") { if(l3vpn_ipv4_unicast == nullptr) { l3vpn_ipv4_unicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast>(); } return l3vpn_ipv4_unicast; } if(child_yang_name == "l3vpn-ipv6-unicast") { if(l3vpn_ipv6_unicast == nullptr) { l3vpn_ipv6_unicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast>(); } return l3vpn_ipv6_unicast; } if(child_yang_name == "l3vpn-ipv4-multicast") { if(l3vpn_ipv4_multicast == nullptr) { l3vpn_ipv4_multicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast>(); } return l3vpn_ipv4_multicast; } if(child_yang_name == "l3vpn-ipv6-multicast") { if(l3vpn_ipv6_multicast == nullptr) { l3vpn_ipv6_multicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast>(); } return l3vpn_ipv6_multicast; } if(child_yang_name == "l2vpn-vpls") { if(l2vpn_vpls == nullptr) { l2vpn_vpls = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls>(); } return l2vpn_vpls; } if(child_yang_name == "l2vpn-evpn") { if(l2vpn_evpn == nullptr) { l2vpn_evpn = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn>(); } return l2vpn_evpn; } if(child_yang_name == "use-multiple-paths") { if(use_multiple_paths == nullptr) { use_multiple_paths = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths>(); } return use_multiple_paths; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } if(graceful_restart != nullptr) { _children["graceful-restart"] = graceful_restart; } if(apply_policy != nullptr) { _children["apply-policy"] = apply_policy; } if(ipv4_unicast != nullptr) { _children["ipv4-unicast"] = ipv4_unicast; } if(ipv6_unicast != nullptr) { _children["ipv6-unicast"] = ipv6_unicast; } if(ipv4_labeled_unicast != nullptr) { _children["ipv4-labeled-unicast"] = ipv4_labeled_unicast; } if(ipv6_labeled_unicast != nullptr) { _children["ipv6-labeled-unicast"] = ipv6_labeled_unicast; } if(l3vpn_ipv4_unicast != nullptr) { _children["l3vpn-ipv4-unicast"] = l3vpn_ipv4_unicast; } if(l3vpn_ipv6_unicast != nullptr) { _children["l3vpn-ipv6-unicast"] = l3vpn_ipv6_unicast; } if(l3vpn_ipv4_multicast != nullptr) { _children["l3vpn-ipv4-multicast"] = l3vpn_ipv4_multicast; } if(l3vpn_ipv6_multicast != nullptr) { _children["l3vpn-ipv6-multicast"] = l3vpn_ipv6_multicast; } if(l2vpn_vpls != nullptr) { _children["l2vpn-vpls"] = l2vpn_vpls; } if(l2vpn_evpn != nullptr) { _children["l2vpn-evpn"] = l2vpn_evpn; } if(use_multiple_paths != nullptr) { _children["use-multiple-paths"] = use_multiple_paths; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::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 == "afi-safi-name") { afi_safi_name = value; afi_safi_name.value_namespace = name_space; afi_safi_name.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "afi-safi-name") { afi_safi_name.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state" || name == "graceful-restart" || name == "apply-policy" || name == "ipv4-unicast" || name == "ipv6-unicast" || name == "ipv4-labeled-unicast" || name == "ipv6-labeled-unicast" || name == "l3vpn-ipv4-unicast" || name == "l3vpn-ipv6-unicast" || name == "l3vpn-ipv4-multicast" || name == "l3vpn-ipv6-multicast" || name == "l2vpn-vpls" || name == "l2vpn-evpn" || name == "use-multiple-paths" || name == "afi-safi-name") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Config::Config() : afi_safi_name{YType::identityref, "afi-safi-name"}, enabled{YType::boolean, "enabled"} { yang_name = "config"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Config::has_data() const { if (is_presence_container) return true; return afi_safi_name.is_set || enabled.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(afi_safi_name.yfilter) || ydk::is_set(enabled.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (afi_safi_name.is_set || is_set(afi_safi_name.yfilter)) leaf_name_data.push_back(afi_safi_name.get_name_leafdata()); if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "afi-safi-name") { afi_safi_name = value; afi_safi_name.value_namespace = name_space; afi_safi_name.value_namespace_prefix = name_space_prefix; } if(value_path == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "afi-safi-name") { afi_safi_name.yfilter = yfilter; } if(value_path == "enabled") { enabled.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "afi-safi-name" || name == "enabled") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::State() : afi_safi_name{YType::identityref, "afi-safi-name"}, enabled{YType::boolean, "enabled"}, active{YType::boolean, "active"} , prefixes(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::Prefixes>()) { prefixes->parent = this; yang_name = "state"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::has_data() const { if (is_presence_container) return true; return afi_safi_name.is_set || enabled.is_set || active.is_set || (prefixes != nullptr && prefixes->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::has_operation() const { return is_set(yfilter) || ydk::is_set(afi_safi_name.yfilter) || ydk::is_set(enabled.yfilter) || ydk::is_set(active.yfilter) || (prefixes != nullptr && prefixes->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (afi_safi_name.is_set || is_set(afi_safi_name.yfilter)) leaf_name_data.push_back(afi_safi_name.get_name_leafdata()); if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); if (active.is_set || is_set(active.yfilter)) leaf_name_data.push_back(active.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefixes") { if(prefixes == nullptr) { prefixes = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::Prefixes>(); } return prefixes; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefixes != nullptr) { _children["prefixes"] = prefixes; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::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 == "afi-safi-name") { afi_safi_name = value; afi_safi_name.value_namespace = name_space; afi_safi_name.value_namespace_prefix = name_space_prefix; } if(value_path == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "active") { active = value; active.value_namespace = name_space; active.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "afi-safi-name") { afi_safi_name.yfilter = yfilter; } if(value_path == "enabled") { enabled.yfilter = yfilter; } if(value_path == "active") { active.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefixes" || name == "afi-safi-name" || name == "enabled" || name == "active") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::Prefixes::Prefixes() : received{YType::uint32, "received"}, sent{YType::uint32, "sent"}, installed{YType::uint32, "installed"} { yang_name = "prefixes"; yang_parent_name = "state"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::Prefixes::~Prefixes() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::Prefixes::has_data() const { if (is_presence_container) return true; return received.is_set || sent.is_set || installed.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::Prefixes::has_operation() const { return is_set(yfilter) || ydk::is_set(received.yfilter) || ydk::is_set(sent.yfilter) || ydk::is_set(installed.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::Prefixes::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefixes"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::Prefixes::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (received.is_set || is_set(received.yfilter)) leaf_name_data.push_back(received.get_name_leafdata()); if (sent.is_set || is_set(sent.yfilter)) leaf_name_data.push_back(sent.get_name_leafdata()); if (installed.is_set || is_set(installed.yfilter)) leaf_name_data.push_back(installed.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::Prefixes::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::Prefixes::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::Prefixes::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 == "received") { received = value; received.value_namespace = name_space; received.value_namespace_prefix = name_space_prefix; } if(value_path == "sent") { sent = value; sent.value_namespace = name_space; sent.value_namespace_prefix = name_space_prefix; } if(value_path == "installed") { installed = value; installed.value_namespace = name_space; installed.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::Prefixes::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "received") { received.yfilter = yfilter; } if(value_path == "sent") { sent.yfilter = yfilter; } if(value_path == "installed") { installed.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::State::Prefixes::has_leaf_or_child_of_name(const std::string & name) const { if(name == "received" || name == "sent" || name == "installed") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::GracefulRestart() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::State>()) { config->parent = this; state->parent = this; yang_name = "graceful-restart"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::~GracefulRestart() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "graceful-restart"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::Config::Config() : enabled{YType::boolean, "enabled"} { yang_name = "config"; yang_parent_name = "graceful-restart"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::Config::has_data() const { if (is_presence_container) return true; return enabled.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::State::State() : enabled{YType::boolean, "enabled"}, received{YType::boolean, "received"}, advertised{YType::boolean, "advertised"} { yang_name = "state"; yang_parent_name = "graceful-restart"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::State::has_data() const { if (is_presence_container) return true; return enabled.is_set || received.is_set || advertised.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::State::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter) || ydk::is_set(received.yfilter) || ydk::is_set(advertised.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); if (received.is_set || is_set(received.yfilter)) leaf_name_data.push_back(received.get_name_leafdata()); if (advertised.is_set || is_set(advertised.yfilter)) leaf_name_data.push_back(advertised.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::State::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 == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "received") { received = value; received.value_namespace = name_space; received.value_namespace_prefix = name_space_prefix; } if(value_path == "advertised") { advertised = value; advertised.value_namespace = name_space; advertised.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } if(value_path == "received") { received.yfilter = yfilter; } if(value_path == "advertised") { advertised.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::GracefulRestart::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled" || name == "received" || name == "advertised") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::ApplyPolicy() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::State>()) { config->parent = this; state->parent = this; yang_name = "apply-policy"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::~ApplyPolicy() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "apply-policy"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::Config::Config() : import_policy{YType::str, "import-policy"}, default_import_policy{YType::enumeration, "default-import-policy"}, export_policy{YType::str, "export-policy"}, default_export_policy{YType::enumeration, "default-export-policy"} { yang_name = "config"; yang_parent_name = "apply-policy"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::Config::has_data() const { if (is_presence_container) return true; for (auto const & leaf : import_policy.getYLeafs()) { if(leaf.is_set) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(leaf.is_set) return true; } return default_import_policy.is_set || default_export_policy.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::Config::has_operation() const { for (auto const & leaf : import_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(import_policy.yfilter) || ydk::is_set(default_import_policy.yfilter) || ydk::is_set(export_policy.yfilter) || ydk::is_set(default_export_policy.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (default_import_policy.is_set || is_set(default_import_policy.yfilter)) leaf_name_data.push_back(default_import_policy.get_name_leafdata()); if (default_export_policy.is_set || is_set(default_export_policy.yfilter)) leaf_name_data.push_back(default_export_policy.get_name_leafdata()); auto import_policy_name_datas = import_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), import_policy_name_datas.begin(), import_policy_name_datas.end()); auto export_policy_name_datas = export_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), export_policy_name_datas.begin(), export_policy_name_datas.end()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "import-policy") { import_policy.append(value); } if(value_path == "default-import-policy") { default_import_policy = value; default_import_policy.value_namespace = name_space; default_import_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "export-policy") { export_policy.append(value); } if(value_path == "default-export-policy") { default_export_policy = value; default_export_policy.value_namespace = name_space; default_export_policy.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "import-policy") { import_policy.yfilter = yfilter; } if(value_path == "default-import-policy") { default_import_policy.yfilter = yfilter; } if(value_path == "export-policy") { export_policy.yfilter = yfilter; } if(value_path == "default-export-policy") { default_export_policy.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "import-policy" || name == "default-import-policy" || name == "export-policy" || name == "default-export-policy") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::State::State() : import_policy{YType::str, "import-policy"}, default_import_policy{YType::enumeration, "default-import-policy"}, export_policy{YType::str, "export-policy"}, default_export_policy{YType::enumeration, "default-export-policy"} { yang_name = "state"; yang_parent_name = "apply-policy"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::State::has_data() const { if (is_presence_container) return true; for (auto const & leaf : import_policy.getYLeafs()) { if(leaf.is_set) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(leaf.is_set) return true; } return default_import_policy.is_set || default_export_policy.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::State::has_operation() const { for (auto const & leaf : import_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(import_policy.yfilter) || ydk::is_set(default_import_policy.yfilter) || ydk::is_set(export_policy.yfilter) || ydk::is_set(default_export_policy.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (default_import_policy.is_set || is_set(default_import_policy.yfilter)) leaf_name_data.push_back(default_import_policy.get_name_leafdata()); if (default_export_policy.is_set || is_set(default_export_policy.yfilter)) leaf_name_data.push_back(default_export_policy.get_name_leafdata()); auto import_policy_name_datas = import_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), import_policy_name_datas.begin(), import_policy_name_datas.end()); auto export_policy_name_datas = export_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), export_policy_name_datas.begin(), export_policy_name_datas.end()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::State::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 == "import-policy") { import_policy.append(value); } if(value_path == "default-import-policy") { default_import_policy = value; default_import_policy.value_namespace = name_space; default_import_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "export-policy") { export_policy.append(value); } if(value_path == "default-export-policy") { default_export_policy = value; default_export_policy.value_namespace = name_space; default_export_policy.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "import-policy") { import_policy.yfilter = yfilter; } if(value_path == "default-import-policy") { default_import_policy.yfilter = yfilter; } if(value_path == "export-policy") { export_policy.yfilter = yfilter; } if(value_path == "default-export-policy") { default_export_policy.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::ApplyPolicy::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "import-policy" || name == "default-import-policy" || name == "export-policy" || name == "default-export-policy") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Ipv4Unicast() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit>()) , config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::State>()) { prefix_limit->parent = this; config->parent = this; state->parent = this; yang_name = "ipv4-unicast"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::~Ipv4Unicast() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()) || (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv4-unicast"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit>(); } return prefix_limit; } if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit" || name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "ipv4-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::State() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "state"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Config::Config() : send_default_route{YType::boolean, "send-default-route"} { yang_name = "config"; yang_parent_name = "ipv4-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Config::has_data() const { if (is_presence_container) return true; return send_default_route.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(send_default_route.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_default_route.is_set || is_set(send_default_route.yfilter)) leaf_name_data.push_back(send_default_route.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "send-default-route") { send_default_route = value; send_default_route.value_namespace = name_space; send_default_route.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-default-route") { send_default_route.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-default-route") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::State::State() : send_default_route{YType::boolean, "send-default-route"} { yang_name = "state"; yang_parent_name = "ipv4-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::State::has_data() const { if (is_presence_container) return true; return send_default_route.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::State::has_operation() const { return is_set(yfilter) || ydk::is_set(send_default_route.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_default_route.is_set || is_set(send_default_route.yfilter)) leaf_name_data.push_back(send_default_route.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "send-default-route") { send_default_route = value; send_default_route.value_namespace = name_space; send_default_route.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-default-route") { send_default_route.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4Unicast::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-default-route") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Ipv6Unicast() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit>()) , config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::State>()) { prefix_limit->parent = this; config->parent = this; state->parent = this; yang_name = "ipv6-unicast"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::~Ipv6Unicast() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()) || (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv6-unicast"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit>(); } return prefix_limit; } if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit" || name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "ipv6-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::State() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "state"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Config::Config() : send_default_route{YType::boolean, "send-default-route"} { yang_name = "config"; yang_parent_name = "ipv6-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Config::has_data() const { if (is_presence_container) return true; return send_default_route.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(send_default_route.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_default_route.is_set || is_set(send_default_route.yfilter)) leaf_name_data.push_back(send_default_route.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "send-default-route") { send_default_route = value; send_default_route.value_namespace = name_space; send_default_route.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-default-route") { send_default_route.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-default-route") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::State::State() : send_default_route{YType::boolean, "send-default-route"} { yang_name = "state"; yang_parent_name = "ipv6-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::State::has_data() const { if (is_presence_container) return true; return send_default_route.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::State::has_operation() const { return is_set(yfilter) || ydk::is_set(send_default_route.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_default_route.is_set || is_set(send_default_route.yfilter)) leaf_name_data.push_back(send_default_route.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "send-default-route") { send_default_route = value; send_default_route.value_namespace = name_space; send_default_route.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-default-route") { send_default_route.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6Unicast::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-default-route") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::Ipv4LabeledUnicast() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit>()) { prefix_limit->parent = this; yang_name = "ipv4-labeled-unicast"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::~Ipv4LabeledUnicast() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv4-labeled-unicast"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit>(); } return prefix_limit; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "ipv4-labeled-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::State() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "state"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::Ipv6LabeledUnicast() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit>()) { prefix_limit->parent = this; yang_name = "ipv6-labeled-unicast"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::~Ipv6LabeledUnicast() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv6-labeled-unicast"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit>(); } return prefix_limit; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "ipv6-labeled-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State::State() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "state"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::L3vpnIpv4Unicast() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit>()) { prefix_limit->parent = this; yang_name = "l3vpn-ipv4-unicast"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::~L3vpnIpv4Unicast() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "l3vpn-ipv4-unicast"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit>(); } return prefix_limit; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "l3vpn-ipv4-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::State::State() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "state"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::State::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::State::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Unicast::PrefixLimit::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::L3vpnIpv6Unicast() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit>()) { prefix_limit->parent = this; yang_name = "l3vpn-ipv6-unicast"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::~L3vpnIpv6Unicast() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "l3vpn-ipv6-unicast"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit>(); } return prefix_limit; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "l3vpn-ipv6-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::State::State() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "state"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::State::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::State::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Unicast::PrefixLimit::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::L3vpnIpv4Multicast() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit>()) { prefix_limit->parent = this; yang_name = "l3vpn-ipv4-multicast"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::~L3vpnIpv4Multicast() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "l3vpn-ipv4-multicast"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit>(); } return prefix_limit; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "l3vpn-ipv4-multicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::State::State() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "state"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::State::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::State::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv4Multicast::PrefixLimit::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::L3vpnIpv6Multicast() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit>()) { prefix_limit->parent = this; yang_name = "l3vpn-ipv6-multicast"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::~L3vpnIpv6Multicast() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "l3vpn-ipv6-multicast"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit>(); } return prefix_limit; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "l3vpn-ipv6-multicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::State::State() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "state"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::State::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::State::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L3vpnIpv6Multicast::PrefixLimit::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::L2vpnVpls() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit>()) { prefix_limit->parent = this; yang_name = "l2vpn-vpls"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::~L2vpnVpls() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "l2vpn-vpls"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit>(); } return prefix_limit; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "l2vpn-vpls"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::State::State() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "state"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::State::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::State::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnVpls::PrefixLimit::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::L2vpnEvpn() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit>()) { prefix_limit->parent = this; yang_name = "l2vpn-evpn"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::~L2vpnEvpn() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "l2vpn-evpn"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit>(); } return prefix_limit; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "l2vpn-evpn"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::State::State() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "state"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::State::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::State::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::L2vpnEvpn::PrefixLimit::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::UseMultiplePaths() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::State>()) , ebgp(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp>()) { config->parent = this; state->parent = this; ebgp->parent = this; yang_name = "use-multiple-paths"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::~UseMultiplePaths() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()) || (ebgp != nullptr && ebgp->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()) || (ebgp != nullptr && ebgp->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "use-multiple-paths"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::State>(); } return state; } if(child_yang_name == "ebgp") { if(ebgp == nullptr) { ebgp = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp>(); } return ebgp; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } if(ebgp != nullptr) { _children["ebgp"] = ebgp; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state" || name == "ebgp") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Config::Config() : enabled{YType::boolean, "enabled"} { yang_name = "config"; yang_parent_name = "use-multiple-paths"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Config::has_data() const { if (is_presence_container) return true; return enabled.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::State::State() : enabled{YType::boolean, "enabled"} { yang_name = "state"; yang_parent_name = "use-multiple-paths"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::State::has_data() const { if (is_presence_container) return true; return enabled.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::State::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::State::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 == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Ebgp() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State>()) { config->parent = this; state->parent = this; yang_name = "ebgp"; yang_parent_name = "use-multiple-paths"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::~Ebgp() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ebgp"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::Config() : allow_multiple_as{YType::boolean, "allow-multiple-as"} { yang_name = "config"; yang_parent_name = "ebgp"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::has_data() const { if (is_presence_container) return true; return allow_multiple_as.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(allow_multiple_as.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (allow_multiple_as.is_set || is_set(allow_multiple_as.yfilter)) leaf_name_data.push_back(allow_multiple_as.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "allow-multiple-as") { allow_multiple_as = value; allow_multiple_as.value_namespace = name_space; allow_multiple_as.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "allow-multiple-as") { allow_multiple_as.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allow-multiple-as") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::State() : allow_multiple_as{YType::boolean, "allow-multiple-as"} { yang_name = "state"; yang_parent_name = "ebgp"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::has_data() const { if (is_presence_container) return true; return allow_multiple_as.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::has_operation() const { return is_set(yfilter) || ydk::is_set(allow_multiple_as.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (allow_multiple_as.is_set || is_set(allow_multiple_as.yfilter)) leaf_name_data.push_back(allow_multiple_as.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::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 == "allow-multiple-as") { allow_multiple_as = value; allow_multiple_as.value_namespace = name_space; allow_multiple_as.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "allow-multiple-as") { allow_multiple_as.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::Neighbors::Neighbor::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allow-multiple-as") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroups() : peer_group(this, {"peer_group_name"}) { yang_name = "peer-groups"; yang_parent_name = "bgp"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::~PeerGroups() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<peer_group.len(); index++) { if(peer_group[index]->has_data()) return true; } return false; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::has_operation() const { for (std::size_t index=0; index<peer_group.len(); index++) { if(peer_group[index]->has_operation()) return true; } return is_set(yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "peer-groups"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "peer-group") { auto ent_ = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup>(); ent_->parent = this; peer_group.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : peer_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_; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::has_leaf_or_child_of_name(const std::string & name) const { if(name == "peer-group") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::PeerGroup() : peer_group_name{YType::str, "peer-group-name"} , config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::State>()) , timers(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers>()) , transport(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport>()) , error_handling(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling>()) , graceful_restart(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart>()) , logging_options(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions>()) , ebgp_multihop(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop>()) , route_reflector(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector>()) , as_path_options(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions>()) , add_paths(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths>()) , use_multiple_paths(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths>()) , apply_policy(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy>()) , afi_safis(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis>()) { config->parent = this; state->parent = this; timers->parent = this; transport->parent = this; error_handling->parent = this; graceful_restart->parent = this; logging_options->parent = this; ebgp_multihop->parent = this; route_reflector->parent = this; as_path_options->parent = this; add_paths->parent = this; use_multiple_paths->parent = this; apply_policy->parent = this; afi_safis->parent = this; yang_name = "peer-group"; yang_parent_name = "peer-groups"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::~PeerGroup() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::has_data() const { if (is_presence_container) return true; return peer_group_name.is_set || (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()) || (timers != nullptr && timers->has_data()) || (transport != nullptr && transport->has_data()) || (error_handling != nullptr && error_handling->has_data()) || (graceful_restart != nullptr && graceful_restart->has_data()) || (logging_options != nullptr && logging_options->has_data()) || (ebgp_multihop != nullptr && ebgp_multihop->has_data()) || (route_reflector != nullptr && route_reflector->has_data()) || (as_path_options != nullptr && as_path_options->has_data()) || (add_paths != nullptr && add_paths->has_data()) || (use_multiple_paths != nullptr && use_multiple_paths->has_data()) || (apply_policy != nullptr && apply_policy->has_data()) || (afi_safis != nullptr && afi_safis->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::has_operation() const { return is_set(yfilter) || ydk::is_set(peer_group_name.yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()) || (timers != nullptr && timers->has_operation()) || (transport != nullptr && transport->has_operation()) || (error_handling != nullptr && error_handling->has_operation()) || (graceful_restart != nullptr && graceful_restart->has_operation()) || (logging_options != nullptr && logging_options->has_operation()) || (ebgp_multihop != nullptr && ebgp_multihop->has_operation()) || (route_reflector != nullptr && route_reflector->has_operation()) || (as_path_options != nullptr && as_path_options->has_operation()) || (add_paths != nullptr && add_paths->has_operation()) || (use_multiple_paths != nullptr && use_multiple_paths->has_operation()) || (apply_policy != nullptr && apply_policy->has_operation()) || (afi_safis != nullptr && afi_safis->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "peer-group"; ADD_KEY_TOKEN(peer_group_name, "peer-group-name"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (peer_group_name.is_set || is_set(peer_group_name.yfilter)) leaf_name_data.push_back(peer_group_name.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::State>(); } return state; } if(child_yang_name == "timers") { if(timers == nullptr) { timers = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers>(); } return timers; } if(child_yang_name == "transport") { if(transport == nullptr) { transport = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport>(); } return transport; } if(child_yang_name == "error-handling") { if(error_handling == nullptr) { error_handling = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling>(); } return error_handling; } if(child_yang_name == "graceful-restart") { if(graceful_restart == nullptr) { graceful_restart = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart>(); } return graceful_restart; } if(child_yang_name == "logging-options") { if(logging_options == nullptr) { logging_options = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions>(); } return logging_options; } if(child_yang_name == "ebgp-multihop") { if(ebgp_multihop == nullptr) { ebgp_multihop = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop>(); } return ebgp_multihop; } if(child_yang_name == "route-reflector") { if(route_reflector == nullptr) { route_reflector = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector>(); } return route_reflector; } if(child_yang_name == "as-path-options") { if(as_path_options == nullptr) { as_path_options = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions>(); } return as_path_options; } if(child_yang_name == "add-paths") { if(add_paths == nullptr) { add_paths = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths>(); } return add_paths; } if(child_yang_name == "use-multiple-paths") { if(use_multiple_paths == nullptr) { use_multiple_paths = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths>(); } return use_multiple_paths; } if(child_yang_name == "apply-policy") { if(apply_policy == nullptr) { apply_policy = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy>(); } return apply_policy; } if(child_yang_name == "afi-safis") { if(afi_safis == nullptr) { afi_safis = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis>(); } return afi_safis; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } if(timers != nullptr) { _children["timers"] = timers; } if(transport != nullptr) { _children["transport"] = transport; } if(error_handling != nullptr) { _children["error-handling"] = error_handling; } if(graceful_restart != nullptr) { _children["graceful-restart"] = graceful_restart; } if(logging_options != nullptr) { _children["logging-options"] = logging_options; } if(ebgp_multihop != nullptr) { _children["ebgp-multihop"] = ebgp_multihop; } if(route_reflector != nullptr) { _children["route-reflector"] = route_reflector; } if(as_path_options != nullptr) { _children["as-path-options"] = as_path_options; } if(add_paths != nullptr) { _children["add-paths"] = add_paths; } if(use_multiple_paths != nullptr) { _children["use-multiple-paths"] = use_multiple_paths; } if(apply_policy != nullptr) { _children["apply-policy"] = apply_policy; } if(afi_safis != nullptr) { _children["afi-safis"] = afi_safis; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "peer-group-name") { peer_group_name = value; peer_group_name.value_namespace = name_space; peer_group_name.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "peer-group-name") { peer_group_name.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state" || name == "timers" || name == "transport" || name == "error-handling" || name == "graceful-restart" || name == "logging-options" || name == "ebgp-multihop" || name == "route-reflector" || name == "as-path-options" || name == "add-paths" || name == "use-multiple-paths" || name == "apply-policy" || name == "afi-safis" || name == "peer-group-name") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Config::Config() : peer_group_name{YType::str, "peer-group-name"}, peer_as{YType::uint32, "peer-as"}, local_as{YType::uint32, "local-as"}, peer_type{YType::enumeration, "peer-type"}, auth_password{YType::str, "auth-password"}, remove_private_as{YType::identityref, "remove-private-as"}, route_flap_damping{YType::boolean, "route-flap-damping"}, send_community{YType::enumeration, "send-community"}, description{YType::str, "description"} { yang_name = "config"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Config::has_data() const { if (is_presence_container) return true; return peer_group_name.is_set || peer_as.is_set || local_as.is_set || peer_type.is_set || auth_password.is_set || remove_private_as.is_set || route_flap_damping.is_set || send_community.is_set || description.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(peer_group_name.yfilter) || ydk::is_set(peer_as.yfilter) || ydk::is_set(local_as.yfilter) || ydk::is_set(peer_type.yfilter) || ydk::is_set(auth_password.yfilter) || ydk::is_set(remove_private_as.yfilter) || ydk::is_set(route_flap_damping.yfilter) || ydk::is_set(send_community.yfilter) || ydk::is_set(description.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (peer_group_name.is_set || is_set(peer_group_name.yfilter)) leaf_name_data.push_back(peer_group_name.get_name_leafdata()); if (peer_as.is_set || is_set(peer_as.yfilter)) leaf_name_data.push_back(peer_as.get_name_leafdata()); if (local_as.is_set || is_set(local_as.yfilter)) leaf_name_data.push_back(local_as.get_name_leafdata()); if (peer_type.is_set || is_set(peer_type.yfilter)) leaf_name_data.push_back(peer_type.get_name_leafdata()); if (auth_password.is_set || is_set(auth_password.yfilter)) leaf_name_data.push_back(auth_password.get_name_leafdata()); if (remove_private_as.is_set || is_set(remove_private_as.yfilter)) leaf_name_data.push_back(remove_private_as.get_name_leafdata()); if (route_flap_damping.is_set || is_set(route_flap_damping.yfilter)) leaf_name_data.push_back(route_flap_damping.get_name_leafdata()); if (send_community.is_set || is_set(send_community.yfilter)) leaf_name_data.push_back(send_community.get_name_leafdata()); if (description.is_set || is_set(description.yfilter)) leaf_name_data.push_back(description.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "peer-group-name") { peer_group_name = value; peer_group_name.value_namespace = name_space; peer_group_name.value_namespace_prefix = name_space_prefix; } if(value_path == "peer-as") { peer_as = value; peer_as.value_namespace = name_space; peer_as.value_namespace_prefix = name_space_prefix; } if(value_path == "local-as") { local_as = value; local_as.value_namespace = name_space; local_as.value_namespace_prefix = name_space_prefix; } if(value_path == "peer-type") { peer_type = value; peer_type.value_namespace = name_space; peer_type.value_namespace_prefix = name_space_prefix; } if(value_path == "auth-password") { auth_password = value; auth_password.value_namespace = name_space; auth_password.value_namespace_prefix = name_space_prefix; } if(value_path == "remove-private-as") { remove_private_as = value; remove_private_as.value_namespace = name_space; remove_private_as.value_namespace_prefix = name_space_prefix; } if(value_path == "route-flap-damping") { route_flap_damping = value; route_flap_damping.value_namespace = name_space; route_flap_damping.value_namespace_prefix = name_space_prefix; } if(value_path == "send-community") { send_community = value; send_community.value_namespace = name_space; send_community.value_namespace_prefix = name_space_prefix; } if(value_path == "description") { description = value; description.value_namespace = name_space; description.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "peer-group-name") { peer_group_name.yfilter = yfilter; } if(value_path == "peer-as") { peer_as.yfilter = yfilter; } if(value_path == "local-as") { local_as.yfilter = yfilter; } if(value_path == "peer-type") { peer_type.yfilter = yfilter; } if(value_path == "auth-password") { auth_password.yfilter = yfilter; } if(value_path == "remove-private-as") { remove_private_as.yfilter = yfilter; } if(value_path == "route-flap-damping") { route_flap_damping.yfilter = yfilter; } if(value_path == "send-community") { send_community.yfilter = yfilter; } if(value_path == "description") { description.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "peer-group-name" || name == "peer-as" || name == "local-as" || name == "peer-type" || name == "auth-password" || name == "remove-private-as" || name == "route-flap-damping" || name == "send-community" || name == "description") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::State::State() : peer_group_name{YType::str, "peer-group-name"}, peer_as{YType::uint32, "peer-as"}, local_as{YType::uint32, "local-as"}, peer_type{YType::enumeration, "peer-type"}, auth_password{YType::str, "auth-password"}, remove_private_as{YType::identityref, "remove-private-as"}, route_flap_damping{YType::boolean, "route-flap-damping"}, send_community{YType::enumeration, "send-community"}, description{YType::str, "description"}, total_paths{YType::uint32, "total-paths"}, total_prefixes{YType::uint32, "total-prefixes"} { yang_name = "state"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::State::has_data() const { if (is_presence_container) return true; return peer_group_name.is_set || peer_as.is_set || local_as.is_set || peer_type.is_set || auth_password.is_set || remove_private_as.is_set || route_flap_damping.is_set || send_community.is_set || description.is_set || total_paths.is_set || total_prefixes.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::State::has_operation() const { return is_set(yfilter) || ydk::is_set(peer_group_name.yfilter) || ydk::is_set(peer_as.yfilter) || ydk::is_set(local_as.yfilter) || ydk::is_set(peer_type.yfilter) || ydk::is_set(auth_password.yfilter) || ydk::is_set(remove_private_as.yfilter) || ydk::is_set(route_flap_damping.yfilter) || ydk::is_set(send_community.yfilter) || ydk::is_set(description.yfilter) || ydk::is_set(total_paths.yfilter) || ydk::is_set(total_prefixes.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (peer_group_name.is_set || is_set(peer_group_name.yfilter)) leaf_name_data.push_back(peer_group_name.get_name_leafdata()); if (peer_as.is_set || is_set(peer_as.yfilter)) leaf_name_data.push_back(peer_as.get_name_leafdata()); if (local_as.is_set || is_set(local_as.yfilter)) leaf_name_data.push_back(local_as.get_name_leafdata()); if (peer_type.is_set || is_set(peer_type.yfilter)) leaf_name_data.push_back(peer_type.get_name_leafdata()); if (auth_password.is_set || is_set(auth_password.yfilter)) leaf_name_data.push_back(auth_password.get_name_leafdata()); if (remove_private_as.is_set || is_set(remove_private_as.yfilter)) leaf_name_data.push_back(remove_private_as.get_name_leafdata()); if (route_flap_damping.is_set || is_set(route_flap_damping.yfilter)) leaf_name_data.push_back(route_flap_damping.get_name_leafdata()); if (send_community.is_set || is_set(send_community.yfilter)) leaf_name_data.push_back(send_community.get_name_leafdata()); if (description.is_set || is_set(description.yfilter)) leaf_name_data.push_back(description.get_name_leafdata()); if (total_paths.is_set || is_set(total_paths.yfilter)) leaf_name_data.push_back(total_paths.get_name_leafdata()); if (total_prefixes.is_set || is_set(total_prefixes.yfilter)) leaf_name_data.push_back(total_prefixes.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "peer-group-name") { peer_group_name = value; peer_group_name.value_namespace = name_space; peer_group_name.value_namespace_prefix = name_space_prefix; } if(value_path == "peer-as") { peer_as = value; peer_as.value_namespace = name_space; peer_as.value_namespace_prefix = name_space_prefix; } if(value_path == "local-as") { local_as = value; local_as.value_namespace = name_space; local_as.value_namespace_prefix = name_space_prefix; } if(value_path == "peer-type") { peer_type = value; peer_type.value_namespace = name_space; peer_type.value_namespace_prefix = name_space_prefix; } if(value_path == "auth-password") { auth_password = value; auth_password.value_namespace = name_space; auth_password.value_namespace_prefix = name_space_prefix; } if(value_path == "remove-private-as") { remove_private_as = value; remove_private_as.value_namespace = name_space; remove_private_as.value_namespace_prefix = name_space_prefix; } if(value_path == "route-flap-damping") { route_flap_damping = value; route_flap_damping.value_namespace = name_space; route_flap_damping.value_namespace_prefix = name_space_prefix; } if(value_path == "send-community") { send_community = value; send_community.value_namespace = name_space; send_community.value_namespace_prefix = name_space_prefix; } if(value_path == "description") { description = value; description.value_namespace = name_space; description.value_namespace_prefix = name_space_prefix; } if(value_path == "total-paths") { total_paths = value; total_paths.value_namespace = name_space; total_paths.value_namespace_prefix = name_space_prefix; } if(value_path == "total-prefixes") { total_prefixes = value; total_prefixes.value_namespace = name_space; total_prefixes.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "peer-group-name") { peer_group_name.yfilter = yfilter; } if(value_path == "peer-as") { peer_as.yfilter = yfilter; } if(value_path == "local-as") { local_as.yfilter = yfilter; } if(value_path == "peer-type") { peer_type.yfilter = yfilter; } if(value_path == "auth-password") { auth_password.yfilter = yfilter; } if(value_path == "remove-private-as") { remove_private_as.yfilter = yfilter; } if(value_path == "route-flap-damping") { route_flap_damping.yfilter = yfilter; } if(value_path == "send-community") { send_community.yfilter = yfilter; } if(value_path == "description") { description.yfilter = yfilter; } if(value_path == "total-paths") { total_paths.yfilter = yfilter; } if(value_path == "total-prefixes") { total_prefixes.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "peer-group-name" || name == "peer-as" || name == "local-as" || name == "peer-type" || name == "auth-password" || name == "remove-private-as" || name == "route-flap-damping" || name == "send-community" || name == "description" || name == "total-paths" || name == "total-prefixes") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Timers() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::State>()) { config->parent = this; state->parent = this; yang_name = "timers"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::~Timers() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "timers"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Config::Config() : connect_retry{YType::str, "connect-retry"}, hold_time{YType::str, "hold-time"}, keepalive_interval{YType::str, "keepalive-interval"}, minimum_advertisement_interval{YType::str, "minimum-advertisement-interval"} { yang_name = "config"; yang_parent_name = "timers"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Config::has_data() const { if (is_presence_container) return true; return connect_retry.is_set || hold_time.is_set || keepalive_interval.is_set || minimum_advertisement_interval.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(connect_retry.yfilter) || ydk::is_set(hold_time.yfilter) || ydk::is_set(keepalive_interval.yfilter) || ydk::is_set(minimum_advertisement_interval.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (connect_retry.is_set || is_set(connect_retry.yfilter)) leaf_name_data.push_back(connect_retry.get_name_leafdata()); if (hold_time.is_set || is_set(hold_time.yfilter)) leaf_name_data.push_back(hold_time.get_name_leafdata()); if (keepalive_interval.is_set || is_set(keepalive_interval.yfilter)) leaf_name_data.push_back(keepalive_interval.get_name_leafdata()); if (minimum_advertisement_interval.is_set || is_set(minimum_advertisement_interval.yfilter)) leaf_name_data.push_back(minimum_advertisement_interval.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "connect-retry") { connect_retry = value; connect_retry.value_namespace = name_space; connect_retry.value_namespace_prefix = name_space_prefix; } if(value_path == "hold-time") { hold_time = value; hold_time.value_namespace = name_space; hold_time.value_namespace_prefix = name_space_prefix; } if(value_path == "keepalive-interval") { keepalive_interval = value; keepalive_interval.value_namespace = name_space; keepalive_interval.value_namespace_prefix = name_space_prefix; } if(value_path == "minimum-advertisement-interval") { minimum_advertisement_interval = value; minimum_advertisement_interval.value_namespace = name_space; minimum_advertisement_interval.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "connect-retry") { connect_retry.yfilter = yfilter; } if(value_path == "hold-time") { hold_time.yfilter = yfilter; } if(value_path == "keepalive-interval") { keepalive_interval.yfilter = yfilter; } if(value_path == "minimum-advertisement-interval") { minimum_advertisement_interval.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "connect-retry" || name == "hold-time" || name == "keepalive-interval" || name == "minimum-advertisement-interval") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::State::State() : connect_retry{YType::str, "connect-retry"}, hold_time{YType::str, "hold-time"}, keepalive_interval{YType::str, "keepalive-interval"}, minimum_advertisement_interval{YType::str, "minimum-advertisement-interval"} { yang_name = "state"; yang_parent_name = "timers"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::State::has_data() const { if (is_presence_container) return true; return connect_retry.is_set || hold_time.is_set || keepalive_interval.is_set || minimum_advertisement_interval.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::State::has_operation() const { return is_set(yfilter) || ydk::is_set(connect_retry.yfilter) || ydk::is_set(hold_time.yfilter) || ydk::is_set(keepalive_interval.yfilter) || ydk::is_set(minimum_advertisement_interval.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (connect_retry.is_set || is_set(connect_retry.yfilter)) leaf_name_data.push_back(connect_retry.get_name_leafdata()); if (hold_time.is_set || is_set(hold_time.yfilter)) leaf_name_data.push_back(hold_time.get_name_leafdata()); if (keepalive_interval.is_set || is_set(keepalive_interval.yfilter)) leaf_name_data.push_back(keepalive_interval.get_name_leafdata()); if (minimum_advertisement_interval.is_set || is_set(minimum_advertisement_interval.yfilter)) leaf_name_data.push_back(minimum_advertisement_interval.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::State::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 == "connect-retry") { connect_retry = value; connect_retry.value_namespace = name_space; connect_retry.value_namespace_prefix = name_space_prefix; } if(value_path == "hold-time") { hold_time = value; hold_time.value_namespace = name_space; hold_time.value_namespace_prefix = name_space_prefix; } if(value_path == "keepalive-interval") { keepalive_interval = value; keepalive_interval.value_namespace = name_space; keepalive_interval.value_namespace_prefix = name_space_prefix; } if(value_path == "minimum-advertisement-interval") { minimum_advertisement_interval = value; minimum_advertisement_interval.value_namespace = name_space; minimum_advertisement_interval.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "connect-retry") { connect_retry.yfilter = yfilter; } if(value_path == "hold-time") { hold_time.yfilter = yfilter; } if(value_path == "keepalive-interval") { keepalive_interval.yfilter = yfilter; } if(value_path == "minimum-advertisement-interval") { minimum_advertisement_interval.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Timers::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "connect-retry" || name == "hold-time" || name == "keepalive-interval" || name == "minimum-advertisement-interval") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Transport() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::State>()) { config->parent = this; state->parent = this; yang_name = "transport"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::~Transport() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "transport"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Config::Config() : tcp_mss{YType::uint16, "tcp-mss"}, mtu_discovery{YType::boolean, "mtu-discovery"}, passive_mode{YType::boolean, "passive-mode"}, local_address{YType::str, "local-address"} { yang_name = "config"; yang_parent_name = "transport"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Config::has_data() const { if (is_presence_container) return true; return tcp_mss.is_set || mtu_discovery.is_set || passive_mode.is_set || local_address.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(tcp_mss.yfilter) || ydk::is_set(mtu_discovery.yfilter) || ydk::is_set(passive_mode.yfilter) || ydk::is_set(local_address.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (tcp_mss.is_set || is_set(tcp_mss.yfilter)) leaf_name_data.push_back(tcp_mss.get_name_leafdata()); if (mtu_discovery.is_set || is_set(mtu_discovery.yfilter)) leaf_name_data.push_back(mtu_discovery.get_name_leafdata()); if (passive_mode.is_set || is_set(passive_mode.yfilter)) leaf_name_data.push_back(passive_mode.get_name_leafdata()); if (local_address.is_set || is_set(local_address.yfilter)) leaf_name_data.push_back(local_address.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "tcp-mss") { tcp_mss = value; tcp_mss.value_namespace = name_space; tcp_mss.value_namespace_prefix = name_space_prefix; } if(value_path == "mtu-discovery") { mtu_discovery = value; mtu_discovery.value_namespace = name_space; mtu_discovery.value_namespace_prefix = name_space_prefix; } if(value_path == "passive-mode") { passive_mode = value; passive_mode.value_namespace = name_space; passive_mode.value_namespace_prefix = name_space_prefix; } if(value_path == "local-address") { local_address = value; local_address.value_namespace = name_space; local_address.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "tcp-mss") { tcp_mss.yfilter = yfilter; } if(value_path == "mtu-discovery") { mtu_discovery.yfilter = yfilter; } if(value_path == "passive-mode") { passive_mode.yfilter = yfilter; } if(value_path == "local-address") { local_address.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "tcp-mss" || name == "mtu-discovery" || name == "passive-mode" || name == "local-address") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::State::State() : tcp_mss{YType::uint16, "tcp-mss"}, mtu_discovery{YType::boolean, "mtu-discovery"}, passive_mode{YType::boolean, "passive-mode"}, local_address{YType::str, "local-address"} { yang_name = "state"; yang_parent_name = "transport"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::State::has_data() const { if (is_presence_container) return true; return tcp_mss.is_set || mtu_discovery.is_set || passive_mode.is_set || local_address.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::State::has_operation() const { return is_set(yfilter) || ydk::is_set(tcp_mss.yfilter) || ydk::is_set(mtu_discovery.yfilter) || ydk::is_set(passive_mode.yfilter) || ydk::is_set(local_address.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (tcp_mss.is_set || is_set(tcp_mss.yfilter)) leaf_name_data.push_back(tcp_mss.get_name_leafdata()); if (mtu_discovery.is_set || is_set(mtu_discovery.yfilter)) leaf_name_data.push_back(mtu_discovery.get_name_leafdata()); if (passive_mode.is_set || is_set(passive_mode.yfilter)) leaf_name_data.push_back(passive_mode.get_name_leafdata()); if (local_address.is_set || is_set(local_address.yfilter)) leaf_name_data.push_back(local_address.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::State::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 == "tcp-mss") { tcp_mss = value; tcp_mss.value_namespace = name_space; tcp_mss.value_namespace_prefix = name_space_prefix; } if(value_path == "mtu-discovery") { mtu_discovery = value; mtu_discovery.value_namespace = name_space; mtu_discovery.value_namespace_prefix = name_space_prefix; } if(value_path == "passive-mode") { passive_mode = value; passive_mode.value_namespace = name_space; passive_mode.value_namespace_prefix = name_space_prefix; } if(value_path == "local-address") { local_address = value; local_address.value_namespace = name_space; local_address.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "tcp-mss") { tcp_mss.yfilter = yfilter; } if(value_path == "mtu-discovery") { mtu_discovery.yfilter = yfilter; } if(value_path == "passive-mode") { passive_mode.yfilter = yfilter; } if(value_path == "local-address") { local_address.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::Transport::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "tcp-mss" || name == "mtu-discovery" || name == "passive-mode" || name == "local-address") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::ErrorHandling() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::State>()) { config->parent = this; state->parent = this; yang_name = "error-handling"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::~ErrorHandling() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "error-handling"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::Config::Config() : treat_as_withdraw{YType::boolean, "treat-as-withdraw"} { yang_name = "config"; yang_parent_name = "error-handling"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::Config::has_data() const { if (is_presence_container) return true; return treat_as_withdraw.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(treat_as_withdraw.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (treat_as_withdraw.is_set || is_set(treat_as_withdraw.yfilter)) leaf_name_data.push_back(treat_as_withdraw.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "treat-as-withdraw") { treat_as_withdraw = value; treat_as_withdraw.value_namespace = name_space; treat_as_withdraw.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "treat-as-withdraw") { treat_as_withdraw.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "treat-as-withdraw") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::State::State() : treat_as_withdraw{YType::boolean, "treat-as-withdraw"} { yang_name = "state"; yang_parent_name = "error-handling"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::State::has_data() const { if (is_presence_container) return true; return treat_as_withdraw.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::State::has_operation() const { return is_set(yfilter) || ydk::is_set(treat_as_withdraw.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (treat_as_withdraw.is_set || is_set(treat_as_withdraw.yfilter)) leaf_name_data.push_back(treat_as_withdraw.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::State::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 == "treat-as-withdraw") { treat_as_withdraw = value; treat_as_withdraw.value_namespace = name_space; treat_as_withdraw.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "treat-as-withdraw") { treat_as_withdraw.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ErrorHandling::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "treat-as-withdraw") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::GracefulRestart() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::State>()) { config->parent = this; state->parent = this; yang_name = "graceful-restart"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::~GracefulRestart() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "graceful-restart"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::Config::Config() : enabled{YType::boolean, "enabled"}, restart_time{YType::uint16, "restart-time"}, stale_routes_time{YType::str, "stale-routes-time"}, helper_only{YType::boolean, "helper-only"} { yang_name = "config"; yang_parent_name = "graceful-restart"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::Config::has_data() const { if (is_presence_container) return true; return enabled.is_set || restart_time.is_set || stale_routes_time.is_set || helper_only.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter) || ydk::is_set(restart_time.yfilter) || ydk::is_set(stale_routes_time.yfilter) || ydk::is_set(helper_only.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); if (restart_time.is_set || is_set(restart_time.yfilter)) leaf_name_data.push_back(restart_time.get_name_leafdata()); if (stale_routes_time.is_set || is_set(stale_routes_time.yfilter)) leaf_name_data.push_back(stale_routes_time.get_name_leafdata()); if (helper_only.is_set || is_set(helper_only.yfilter)) leaf_name_data.push_back(helper_only.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-time") { restart_time = value; restart_time.value_namespace = name_space; restart_time.value_namespace_prefix = name_space_prefix; } if(value_path == "stale-routes-time") { stale_routes_time = value; stale_routes_time.value_namespace = name_space; stale_routes_time.value_namespace_prefix = name_space_prefix; } if(value_path == "helper-only") { helper_only = value; helper_only.value_namespace = name_space; helper_only.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } if(value_path == "restart-time") { restart_time.yfilter = yfilter; } if(value_path == "stale-routes-time") { stale_routes_time.yfilter = yfilter; } if(value_path == "helper-only") { helper_only.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled" || name == "restart-time" || name == "stale-routes-time" || name == "helper-only") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::State::State() : enabled{YType::boolean, "enabled"}, restart_time{YType::uint16, "restart-time"}, stale_routes_time{YType::str, "stale-routes-time"}, helper_only{YType::boolean, "helper-only"} { yang_name = "state"; yang_parent_name = "graceful-restart"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::State::has_data() const { if (is_presence_container) return true; return enabled.is_set || restart_time.is_set || stale_routes_time.is_set || helper_only.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::State::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter) || ydk::is_set(restart_time.yfilter) || ydk::is_set(stale_routes_time.yfilter) || ydk::is_set(helper_only.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); if (restart_time.is_set || is_set(restart_time.yfilter)) leaf_name_data.push_back(restart_time.get_name_leafdata()); if (stale_routes_time.is_set || is_set(stale_routes_time.yfilter)) leaf_name_data.push_back(stale_routes_time.get_name_leafdata()); if (helper_only.is_set || is_set(helper_only.yfilter)) leaf_name_data.push_back(helper_only.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::State::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 == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-time") { restart_time = value; restart_time.value_namespace = name_space; restart_time.value_namespace_prefix = name_space_prefix; } if(value_path == "stale-routes-time") { stale_routes_time = value; stale_routes_time.value_namespace = name_space; stale_routes_time.value_namespace_prefix = name_space_prefix; } if(value_path == "helper-only") { helper_only = value; helper_only.value_namespace = name_space; helper_only.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } if(value_path == "restart-time") { restart_time.yfilter = yfilter; } if(value_path == "stale-routes-time") { stale_routes_time.yfilter = yfilter; } if(value_path == "helper-only") { helper_only.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::GracefulRestart::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled" || name == "restart-time" || name == "stale-routes-time" || name == "helper-only") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::LoggingOptions() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::State>()) { config->parent = this; state->parent = this; yang_name = "logging-options"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::~LoggingOptions() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "logging-options"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::Config::Config() : log_neighbor_state_changes{YType::boolean, "log-neighbor-state-changes"} { yang_name = "config"; yang_parent_name = "logging-options"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::Config::has_data() const { if (is_presence_container) return true; return log_neighbor_state_changes.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(log_neighbor_state_changes.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (log_neighbor_state_changes.is_set || is_set(log_neighbor_state_changes.yfilter)) leaf_name_data.push_back(log_neighbor_state_changes.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "log-neighbor-state-changes") { log_neighbor_state_changes = value; log_neighbor_state_changes.value_namespace = name_space; log_neighbor_state_changes.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "log-neighbor-state-changes") { log_neighbor_state_changes.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "log-neighbor-state-changes") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::State::State() : log_neighbor_state_changes{YType::boolean, "log-neighbor-state-changes"} { yang_name = "state"; yang_parent_name = "logging-options"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::State::has_data() const { if (is_presence_container) return true; return log_neighbor_state_changes.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::State::has_operation() const { return is_set(yfilter) || ydk::is_set(log_neighbor_state_changes.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (log_neighbor_state_changes.is_set || is_set(log_neighbor_state_changes.yfilter)) leaf_name_data.push_back(log_neighbor_state_changes.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::State::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 == "log-neighbor-state-changes") { log_neighbor_state_changes = value; log_neighbor_state_changes.value_namespace = name_space; log_neighbor_state_changes.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "log-neighbor-state-changes") { log_neighbor_state_changes.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::LoggingOptions::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "log-neighbor-state-changes") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::EbgpMultihop() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::State>()) { config->parent = this; state->parent = this; yang_name = "ebgp-multihop"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::~EbgpMultihop() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ebgp-multihop"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::Config::Config() : enabled{YType::boolean, "enabled"}, multihop_ttl{YType::uint8, "multihop-ttl"} { yang_name = "config"; yang_parent_name = "ebgp-multihop"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::Config::has_data() const { if (is_presence_container) return true; return enabled.is_set || multihop_ttl.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter) || ydk::is_set(multihop_ttl.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); if (multihop_ttl.is_set || is_set(multihop_ttl.yfilter)) leaf_name_data.push_back(multihop_ttl.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "multihop-ttl") { multihop_ttl = value; multihop_ttl.value_namespace = name_space; multihop_ttl.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } if(value_path == "multihop-ttl") { multihop_ttl.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled" || name == "multihop-ttl") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::State::State() : enabled{YType::boolean, "enabled"}, multihop_ttl{YType::uint8, "multihop-ttl"} { yang_name = "state"; yang_parent_name = "ebgp-multihop"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::State::has_data() const { if (is_presence_container) return true; return enabled.is_set || multihop_ttl.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::State::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter) || ydk::is_set(multihop_ttl.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); if (multihop_ttl.is_set || is_set(multihop_ttl.yfilter)) leaf_name_data.push_back(multihop_ttl.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::State::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 == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "multihop-ttl") { multihop_ttl = value; multihop_ttl.value_namespace = name_space; multihop_ttl.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } if(value_path == "multihop-ttl") { multihop_ttl.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::EbgpMultihop::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled" || name == "multihop-ttl") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::RouteReflector() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::State>()) { config->parent = this; state->parent = this; yang_name = "route-reflector"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::~RouteReflector() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "route-reflector"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::Config::Config() : route_reflector_cluster_id{YType::str, "route-reflector-cluster-id"}, route_reflector_client{YType::boolean, "route-reflector-client"} { yang_name = "config"; yang_parent_name = "route-reflector"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::Config::has_data() const { if (is_presence_container) return true; return route_reflector_cluster_id.is_set || route_reflector_client.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(route_reflector_cluster_id.yfilter) || ydk::is_set(route_reflector_client.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (route_reflector_cluster_id.is_set || is_set(route_reflector_cluster_id.yfilter)) leaf_name_data.push_back(route_reflector_cluster_id.get_name_leafdata()); if (route_reflector_client.is_set || is_set(route_reflector_client.yfilter)) leaf_name_data.push_back(route_reflector_client.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "route-reflector-cluster-id") { route_reflector_cluster_id = value; route_reflector_cluster_id.value_namespace = name_space; route_reflector_cluster_id.value_namespace_prefix = name_space_prefix; } if(value_path == "route-reflector-client") { route_reflector_client = value; route_reflector_client.value_namespace = name_space; route_reflector_client.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "route-reflector-cluster-id") { route_reflector_cluster_id.yfilter = yfilter; } if(value_path == "route-reflector-client") { route_reflector_client.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "route-reflector-cluster-id" || name == "route-reflector-client") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::State::State() : route_reflector_cluster_id{YType::str, "route-reflector-cluster-id"}, route_reflector_client{YType::boolean, "route-reflector-client"} { yang_name = "state"; yang_parent_name = "route-reflector"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::State::has_data() const { if (is_presence_container) return true; return route_reflector_cluster_id.is_set || route_reflector_client.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::State::has_operation() const { return is_set(yfilter) || ydk::is_set(route_reflector_cluster_id.yfilter) || ydk::is_set(route_reflector_client.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (route_reflector_cluster_id.is_set || is_set(route_reflector_cluster_id.yfilter)) leaf_name_data.push_back(route_reflector_cluster_id.get_name_leafdata()); if (route_reflector_client.is_set || is_set(route_reflector_client.yfilter)) leaf_name_data.push_back(route_reflector_client.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "route-reflector-cluster-id") { route_reflector_cluster_id = value; route_reflector_cluster_id.value_namespace = name_space; route_reflector_cluster_id.value_namespace_prefix = name_space_prefix; } if(value_path == "route-reflector-client") { route_reflector_client = value; route_reflector_client.value_namespace = name_space; route_reflector_client.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "route-reflector-cluster-id") { route_reflector_cluster_id.yfilter = yfilter; } if(value_path == "route-reflector-client") { route_reflector_client.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::RouteReflector::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "route-reflector-cluster-id" || name == "route-reflector-client") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::AsPathOptions() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::State>()) { config->parent = this; state->parent = this; yang_name = "as-path-options"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::~AsPathOptions() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "as-path-options"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::Config::Config() : allow_own_as{YType::uint8, "allow-own-as"}, replace_peer_as{YType::boolean, "replace-peer-as"} { yang_name = "config"; yang_parent_name = "as-path-options"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::Config::has_data() const { if (is_presence_container) return true; return allow_own_as.is_set || replace_peer_as.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(allow_own_as.yfilter) || ydk::is_set(replace_peer_as.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (allow_own_as.is_set || is_set(allow_own_as.yfilter)) leaf_name_data.push_back(allow_own_as.get_name_leafdata()); if (replace_peer_as.is_set || is_set(replace_peer_as.yfilter)) leaf_name_data.push_back(replace_peer_as.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "allow-own-as") { allow_own_as = value; allow_own_as.value_namespace = name_space; allow_own_as.value_namespace_prefix = name_space_prefix; } if(value_path == "replace-peer-as") { replace_peer_as = value; replace_peer_as.value_namespace = name_space; replace_peer_as.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "allow-own-as") { allow_own_as.yfilter = yfilter; } if(value_path == "replace-peer-as") { replace_peer_as.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allow-own-as" || name == "replace-peer-as") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::State::State() : allow_own_as{YType::uint8, "allow-own-as"}, replace_peer_as{YType::boolean, "replace-peer-as"} { yang_name = "state"; yang_parent_name = "as-path-options"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::State::has_data() const { if (is_presence_container) return true; return allow_own_as.is_set || replace_peer_as.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::State::has_operation() const { return is_set(yfilter) || ydk::is_set(allow_own_as.yfilter) || ydk::is_set(replace_peer_as.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (allow_own_as.is_set || is_set(allow_own_as.yfilter)) leaf_name_data.push_back(allow_own_as.get_name_leafdata()); if (replace_peer_as.is_set || is_set(replace_peer_as.yfilter)) leaf_name_data.push_back(replace_peer_as.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::State::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 == "allow-own-as") { allow_own_as = value; allow_own_as.value_namespace = name_space; allow_own_as.value_namespace_prefix = name_space_prefix; } if(value_path == "replace-peer-as") { replace_peer_as = value; replace_peer_as.value_namespace = name_space; replace_peer_as.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "allow-own-as") { allow_own_as.yfilter = yfilter; } if(value_path == "replace-peer-as") { replace_peer_as.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AsPathOptions::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allow-own-as" || name == "replace-peer-as") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::AddPaths() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::State>()) { config->parent = this; state->parent = this; yang_name = "add-paths"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::~AddPaths() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "add-paths"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::Config::Config() : receive{YType::boolean, "receive"}, send_max{YType::uint8, "send-max"}, eligible_prefix_policy{YType::str, "eligible-prefix-policy"} { yang_name = "config"; yang_parent_name = "add-paths"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::Config::has_data() const { if (is_presence_container) return true; return receive.is_set || send_max.is_set || eligible_prefix_policy.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(receive.yfilter) || ydk::is_set(send_max.yfilter) || ydk::is_set(eligible_prefix_policy.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (receive.is_set || is_set(receive.yfilter)) leaf_name_data.push_back(receive.get_name_leafdata()); if (send_max.is_set || is_set(send_max.yfilter)) leaf_name_data.push_back(send_max.get_name_leafdata()); if (eligible_prefix_policy.is_set || is_set(eligible_prefix_policy.yfilter)) leaf_name_data.push_back(eligible_prefix_policy.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "receive") { receive = value; receive.value_namespace = name_space; receive.value_namespace_prefix = name_space_prefix; } if(value_path == "send-max") { send_max = value; send_max.value_namespace = name_space; send_max.value_namespace_prefix = name_space_prefix; } if(value_path == "eligible-prefix-policy") { eligible_prefix_policy = value; eligible_prefix_policy.value_namespace = name_space; eligible_prefix_policy.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "receive") { receive.yfilter = yfilter; } if(value_path == "send-max") { send_max.yfilter = yfilter; } if(value_path == "eligible-prefix-policy") { eligible_prefix_policy.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "receive" || name == "send-max" || name == "eligible-prefix-policy") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::State::State() : receive{YType::boolean, "receive"}, send_max{YType::uint8, "send-max"}, eligible_prefix_policy{YType::str, "eligible-prefix-policy"} { yang_name = "state"; yang_parent_name = "add-paths"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::State::has_data() const { if (is_presence_container) return true; return receive.is_set || send_max.is_set || eligible_prefix_policy.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::State::has_operation() const { return is_set(yfilter) || ydk::is_set(receive.yfilter) || ydk::is_set(send_max.yfilter) || ydk::is_set(eligible_prefix_policy.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (receive.is_set || is_set(receive.yfilter)) leaf_name_data.push_back(receive.get_name_leafdata()); if (send_max.is_set || is_set(send_max.yfilter)) leaf_name_data.push_back(send_max.get_name_leafdata()); if (eligible_prefix_policy.is_set || is_set(eligible_prefix_policy.yfilter)) leaf_name_data.push_back(eligible_prefix_policy.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "receive") { receive = value; receive.value_namespace = name_space; receive.value_namespace_prefix = name_space_prefix; } if(value_path == "send-max") { send_max = value; send_max.value_namespace = name_space; send_max.value_namespace_prefix = name_space_prefix; } if(value_path == "eligible-prefix-policy") { eligible_prefix_policy = value; eligible_prefix_policy.value_namespace = name_space; eligible_prefix_policy.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "receive") { receive.yfilter = yfilter; } if(value_path == "send-max") { send_max.yfilter = yfilter; } if(value_path == "eligible-prefix-policy") { eligible_prefix_policy.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AddPaths::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "receive" || name == "send-max" || name == "eligible-prefix-policy") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::UseMultiplePaths() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::State>()) , ebgp(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp>()) , ibgp(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp>()) { config->parent = this; state->parent = this; ebgp->parent = this; ibgp->parent = this; yang_name = "use-multiple-paths"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::~UseMultiplePaths() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()) || (ebgp != nullptr && ebgp->has_data()) || (ibgp != nullptr && ibgp->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()) || (ebgp != nullptr && ebgp->has_operation()) || (ibgp != nullptr && ibgp->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "use-multiple-paths"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::State>(); } return state; } if(child_yang_name == "ebgp") { if(ebgp == nullptr) { ebgp = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp>(); } return ebgp; } if(child_yang_name == "ibgp") { if(ibgp == nullptr) { ibgp = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp>(); } return ibgp; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } if(ebgp != nullptr) { _children["ebgp"] = ebgp; } if(ibgp != nullptr) { _children["ibgp"] = ibgp; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state" || name == "ebgp" || name == "ibgp") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Config::Config() : enabled{YType::boolean, "enabled"} { yang_name = "config"; yang_parent_name = "use-multiple-paths"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Config::has_data() const { if (is_presence_container) return true; return enabled.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::State::State() : enabled{YType::boolean, "enabled"} { yang_name = "state"; yang_parent_name = "use-multiple-paths"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::State::has_data() const { if (is_presence_container) return true; return enabled.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::State::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::State::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 == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Ebgp() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::State>()) { config->parent = this; state->parent = this; yang_name = "ebgp"; yang_parent_name = "use-multiple-paths"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::~Ebgp() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ebgp"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Config::Config() : allow_multiple_as{YType::boolean, "allow-multiple-as"}, maximum_paths{YType::uint32, "maximum-paths"} { yang_name = "config"; yang_parent_name = "ebgp"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Config::has_data() const { if (is_presence_container) return true; return allow_multiple_as.is_set || maximum_paths.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(allow_multiple_as.yfilter) || ydk::is_set(maximum_paths.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (allow_multiple_as.is_set || is_set(allow_multiple_as.yfilter)) leaf_name_data.push_back(allow_multiple_as.get_name_leafdata()); if (maximum_paths.is_set || is_set(maximum_paths.yfilter)) leaf_name_data.push_back(maximum_paths.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "allow-multiple-as") { allow_multiple_as = value; allow_multiple_as.value_namespace = name_space; allow_multiple_as.value_namespace_prefix = name_space_prefix; } if(value_path == "maximum-paths") { maximum_paths = value; maximum_paths.value_namespace = name_space; maximum_paths.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "allow-multiple-as") { allow_multiple_as.yfilter = yfilter; } if(value_path == "maximum-paths") { maximum_paths.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allow-multiple-as" || name == "maximum-paths") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::State::State() : allow_multiple_as{YType::boolean, "allow-multiple-as"}, maximum_paths{YType::uint32, "maximum-paths"} { yang_name = "state"; yang_parent_name = "ebgp"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::State::has_data() const { if (is_presence_container) return true; return allow_multiple_as.is_set || maximum_paths.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::State::has_operation() const { return is_set(yfilter) || ydk::is_set(allow_multiple_as.yfilter) || ydk::is_set(maximum_paths.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (allow_multiple_as.is_set || is_set(allow_multiple_as.yfilter)) leaf_name_data.push_back(allow_multiple_as.get_name_leafdata()); if (maximum_paths.is_set || is_set(maximum_paths.yfilter)) leaf_name_data.push_back(maximum_paths.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::State::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 == "allow-multiple-as") { allow_multiple_as = value; allow_multiple_as.value_namespace = name_space; allow_multiple_as.value_namespace_prefix = name_space_prefix; } if(value_path == "maximum-paths") { maximum_paths = value; maximum_paths.value_namespace = name_space; maximum_paths.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "allow-multiple-as") { allow_multiple_as.yfilter = yfilter; } if(value_path == "maximum-paths") { maximum_paths.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ebgp::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allow-multiple-as" || name == "maximum-paths") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Ibgp() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::State>()) { config->parent = this; state->parent = this; yang_name = "ibgp"; yang_parent_name = "use-multiple-paths"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::~Ibgp() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ibgp"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Config::Config() : maximum_paths{YType::uint32, "maximum-paths"} { yang_name = "config"; yang_parent_name = "ibgp"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Config::has_data() const { if (is_presence_container) return true; return maximum_paths.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(maximum_paths.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (maximum_paths.is_set || is_set(maximum_paths.yfilter)) leaf_name_data.push_back(maximum_paths.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "maximum-paths") { maximum_paths = value; maximum_paths.value_namespace = name_space; maximum_paths.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "maximum-paths") { maximum_paths.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "maximum-paths") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::State::State() : maximum_paths{YType::uint32, "maximum-paths"} { yang_name = "state"; yang_parent_name = "ibgp"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::State::has_data() const { if (is_presence_container) return true; return maximum_paths.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::State::has_operation() const { return is_set(yfilter) || ydk::is_set(maximum_paths.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (maximum_paths.is_set || is_set(maximum_paths.yfilter)) leaf_name_data.push_back(maximum_paths.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::State::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 == "maximum-paths") { maximum_paths = value; maximum_paths.value_namespace = name_space; maximum_paths.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "maximum-paths") { maximum_paths.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::UseMultiplePaths::Ibgp::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "maximum-paths") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::ApplyPolicy() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::State>()) { config->parent = this; state->parent = this; yang_name = "apply-policy"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::~ApplyPolicy() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "apply-policy"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::Config::Config() : import_policy{YType::str, "import-policy"}, default_import_policy{YType::enumeration, "default-import-policy"}, export_policy{YType::str, "export-policy"}, default_export_policy{YType::enumeration, "default-export-policy"} { yang_name = "config"; yang_parent_name = "apply-policy"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::Config::has_data() const { if (is_presence_container) return true; for (auto const & leaf : import_policy.getYLeafs()) { if(leaf.is_set) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(leaf.is_set) return true; } return default_import_policy.is_set || default_export_policy.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::Config::has_operation() const { for (auto const & leaf : import_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(import_policy.yfilter) || ydk::is_set(default_import_policy.yfilter) || ydk::is_set(export_policy.yfilter) || ydk::is_set(default_export_policy.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (default_import_policy.is_set || is_set(default_import_policy.yfilter)) leaf_name_data.push_back(default_import_policy.get_name_leafdata()); if (default_export_policy.is_set || is_set(default_export_policy.yfilter)) leaf_name_data.push_back(default_export_policy.get_name_leafdata()); auto import_policy_name_datas = import_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), import_policy_name_datas.begin(), import_policy_name_datas.end()); auto export_policy_name_datas = export_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), export_policy_name_datas.begin(), export_policy_name_datas.end()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "import-policy") { import_policy.append(value); } if(value_path == "default-import-policy") { default_import_policy = value; default_import_policy.value_namespace = name_space; default_import_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "export-policy") { export_policy.append(value); } if(value_path == "default-export-policy") { default_export_policy = value; default_export_policy.value_namespace = name_space; default_export_policy.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "import-policy") { import_policy.yfilter = yfilter; } if(value_path == "default-import-policy") { default_import_policy.yfilter = yfilter; } if(value_path == "export-policy") { export_policy.yfilter = yfilter; } if(value_path == "default-export-policy") { default_export_policy.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "import-policy" || name == "default-import-policy" || name == "export-policy" || name == "default-export-policy") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::State::State() : import_policy{YType::str, "import-policy"}, default_import_policy{YType::enumeration, "default-import-policy"}, export_policy{YType::str, "export-policy"}, default_export_policy{YType::enumeration, "default-export-policy"} { yang_name = "state"; yang_parent_name = "apply-policy"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::State::has_data() const { if (is_presence_container) return true; for (auto const & leaf : import_policy.getYLeafs()) { if(leaf.is_set) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(leaf.is_set) return true; } return default_import_policy.is_set || default_export_policy.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::State::has_operation() const { for (auto const & leaf : import_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(import_policy.yfilter) || ydk::is_set(default_import_policy.yfilter) || ydk::is_set(export_policy.yfilter) || ydk::is_set(default_export_policy.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (default_import_policy.is_set || is_set(default_import_policy.yfilter)) leaf_name_data.push_back(default_import_policy.get_name_leafdata()); if (default_export_policy.is_set || is_set(default_export_policy.yfilter)) leaf_name_data.push_back(default_export_policy.get_name_leafdata()); auto import_policy_name_datas = import_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), import_policy_name_datas.begin(), import_policy_name_datas.end()); auto export_policy_name_datas = export_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), export_policy_name_datas.begin(), export_policy_name_datas.end()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::State::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 == "import-policy") { import_policy.append(value); } if(value_path == "default-import-policy") { default_import_policy = value; default_import_policy.value_namespace = name_space; default_import_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "export-policy") { export_policy.append(value); } if(value_path == "default-export-policy") { default_export_policy = value; default_export_policy.value_namespace = name_space; default_export_policy.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "import-policy") { import_policy.yfilter = yfilter; } if(value_path == "default-import-policy") { default_import_policy.yfilter = yfilter; } if(value_path == "export-policy") { export_policy.yfilter = yfilter; } if(value_path == "default-export-policy") { default_export_policy.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::ApplyPolicy::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "import-policy" || name == "default-import-policy" || name == "export-policy" || name == "default-export-policy") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafis() : afi_safi(this, {"afi_safi_name"}) { yang_name = "afi-safis"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::~AfiSafis() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<afi_safi.len(); index++) { if(afi_safi[index]->has_data()) return true; } return false; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::has_operation() const { for (std::size_t index=0; index<afi_safi.len(); index++) { if(afi_safi[index]->has_operation()) return true; } return is_set(yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "afi-safis"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "afi-safi") { auto ent_ = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi>(); ent_->parent = this; afi_safi.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : afi_safi.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 NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::has_leaf_or_child_of_name(const std::string & name) const { if(name == "afi-safi") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::AfiSafi() : afi_safi_name{YType::identityref, "afi-safi-name"} , config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::State>()) , graceful_restart(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart>()) , route_selection_options(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions>()) , use_multiple_paths(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths>()) , apply_policy(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy>()) , ipv4_unicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast>()) , ipv6_unicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast>()) , ipv4_labeled_unicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast>()) , ipv6_labeled_unicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast>()) , l3vpn_ipv4_unicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::L3vpnIpv4Unicast>()) , l3vpn_ipv6_unicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::L3vpnIpv6Unicast>()) , l3vpn_ipv4_multicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::L3vpnIpv4Multicast>()) , l3vpn_ipv6_multicast(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::L3vpnIpv6Multicast>()) , l2vpn_vpls(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::L2vpnVpls>()) , l2vpn_evpn(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::L2vpnEvpn>()) { config->parent = this; state->parent = this; graceful_restart->parent = this; route_selection_options->parent = this; use_multiple_paths->parent = this; apply_policy->parent = this; ipv4_unicast->parent = this; ipv6_unicast->parent = this; ipv4_labeled_unicast->parent = this; ipv6_labeled_unicast->parent = this; l3vpn_ipv4_unicast->parent = this; l3vpn_ipv6_unicast->parent = this; l3vpn_ipv4_multicast->parent = this; l3vpn_ipv6_multicast->parent = this; l2vpn_vpls->parent = this; l2vpn_evpn->parent = this; yang_name = "afi-safi"; yang_parent_name = "afi-safis"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::~AfiSafi() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::has_data() const { if (is_presence_container) return true; return afi_safi_name.is_set || (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()) || (graceful_restart != nullptr && graceful_restart->has_data()) || (route_selection_options != nullptr && route_selection_options->has_data()) || (use_multiple_paths != nullptr && use_multiple_paths->has_data()) || (apply_policy != nullptr && apply_policy->has_data()) || (ipv4_unicast != nullptr && ipv4_unicast->has_data()) || (ipv6_unicast != nullptr && ipv6_unicast->has_data()) || (ipv4_labeled_unicast != nullptr && ipv4_labeled_unicast->has_data()) || (ipv6_labeled_unicast != nullptr && ipv6_labeled_unicast->has_data()) || (l3vpn_ipv4_unicast != nullptr && l3vpn_ipv4_unicast->has_data()) || (l3vpn_ipv6_unicast != nullptr && l3vpn_ipv6_unicast->has_data()) || (l3vpn_ipv4_multicast != nullptr && l3vpn_ipv4_multicast->has_data()) || (l3vpn_ipv6_multicast != nullptr && l3vpn_ipv6_multicast->has_data()) || (l2vpn_vpls != nullptr && l2vpn_vpls->has_data()) || (l2vpn_evpn != nullptr && l2vpn_evpn->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::has_operation() const { return is_set(yfilter) || ydk::is_set(afi_safi_name.yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()) || (graceful_restart != nullptr && graceful_restart->has_operation()) || (route_selection_options != nullptr && route_selection_options->has_operation()) || (use_multiple_paths != nullptr && use_multiple_paths->has_operation()) || (apply_policy != nullptr && apply_policy->has_operation()) || (ipv4_unicast != nullptr && ipv4_unicast->has_operation()) || (ipv6_unicast != nullptr && ipv6_unicast->has_operation()) || (ipv4_labeled_unicast != nullptr && ipv4_labeled_unicast->has_operation()) || (ipv6_labeled_unicast != nullptr && ipv6_labeled_unicast->has_operation()) || (l3vpn_ipv4_unicast != nullptr && l3vpn_ipv4_unicast->has_operation()) || (l3vpn_ipv6_unicast != nullptr && l3vpn_ipv6_unicast->has_operation()) || (l3vpn_ipv4_multicast != nullptr && l3vpn_ipv4_multicast->has_operation()) || (l3vpn_ipv6_multicast != nullptr && l3vpn_ipv6_multicast->has_operation()) || (l2vpn_vpls != nullptr && l2vpn_vpls->has_operation()) || (l2vpn_evpn != nullptr && l2vpn_evpn->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "afi-safi"; ADD_KEY_TOKEN(afi_safi_name, "afi-safi-name"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (afi_safi_name.is_set || is_set(afi_safi_name.yfilter)) leaf_name_data.push_back(afi_safi_name.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::State>(); } return state; } if(child_yang_name == "graceful-restart") { if(graceful_restart == nullptr) { graceful_restart = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart>(); } return graceful_restart; } if(child_yang_name == "route-selection-options") { if(route_selection_options == nullptr) { route_selection_options = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions>(); } return route_selection_options; } if(child_yang_name == "use-multiple-paths") { if(use_multiple_paths == nullptr) { use_multiple_paths = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths>(); } return use_multiple_paths; } if(child_yang_name == "apply-policy") { if(apply_policy == nullptr) { apply_policy = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy>(); } return apply_policy; } if(child_yang_name == "ipv4-unicast") { if(ipv4_unicast == nullptr) { ipv4_unicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast>(); } return ipv4_unicast; } if(child_yang_name == "ipv6-unicast") { if(ipv6_unicast == nullptr) { ipv6_unicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast>(); } return ipv6_unicast; } if(child_yang_name == "ipv4-labeled-unicast") { if(ipv4_labeled_unicast == nullptr) { ipv4_labeled_unicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast>(); } return ipv4_labeled_unicast; } if(child_yang_name == "ipv6-labeled-unicast") { if(ipv6_labeled_unicast == nullptr) { ipv6_labeled_unicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast>(); } return ipv6_labeled_unicast; } if(child_yang_name == "l3vpn-ipv4-unicast") { if(l3vpn_ipv4_unicast == nullptr) { l3vpn_ipv4_unicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::L3vpnIpv4Unicast>(); } return l3vpn_ipv4_unicast; } if(child_yang_name == "l3vpn-ipv6-unicast") { if(l3vpn_ipv6_unicast == nullptr) { l3vpn_ipv6_unicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::L3vpnIpv6Unicast>(); } return l3vpn_ipv6_unicast; } if(child_yang_name == "l3vpn-ipv4-multicast") { if(l3vpn_ipv4_multicast == nullptr) { l3vpn_ipv4_multicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::L3vpnIpv4Multicast>(); } return l3vpn_ipv4_multicast; } if(child_yang_name == "l3vpn-ipv6-multicast") { if(l3vpn_ipv6_multicast == nullptr) { l3vpn_ipv6_multicast = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::L3vpnIpv6Multicast>(); } return l3vpn_ipv6_multicast; } if(child_yang_name == "l2vpn-vpls") { if(l2vpn_vpls == nullptr) { l2vpn_vpls = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::L2vpnVpls>(); } return l2vpn_vpls; } if(child_yang_name == "l2vpn-evpn") { if(l2vpn_evpn == nullptr) { l2vpn_evpn = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::L2vpnEvpn>(); } return l2vpn_evpn; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } if(graceful_restart != nullptr) { _children["graceful-restart"] = graceful_restart; } if(route_selection_options != nullptr) { _children["route-selection-options"] = route_selection_options; } if(use_multiple_paths != nullptr) { _children["use-multiple-paths"] = use_multiple_paths; } if(apply_policy != nullptr) { _children["apply-policy"] = apply_policy; } if(ipv4_unicast != nullptr) { _children["ipv4-unicast"] = ipv4_unicast; } if(ipv6_unicast != nullptr) { _children["ipv6-unicast"] = ipv6_unicast; } if(ipv4_labeled_unicast != nullptr) { _children["ipv4-labeled-unicast"] = ipv4_labeled_unicast; } if(ipv6_labeled_unicast != nullptr) { _children["ipv6-labeled-unicast"] = ipv6_labeled_unicast; } if(l3vpn_ipv4_unicast != nullptr) { _children["l3vpn-ipv4-unicast"] = l3vpn_ipv4_unicast; } if(l3vpn_ipv6_unicast != nullptr) { _children["l3vpn-ipv6-unicast"] = l3vpn_ipv6_unicast; } if(l3vpn_ipv4_multicast != nullptr) { _children["l3vpn-ipv4-multicast"] = l3vpn_ipv4_multicast; } if(l3vpn_ipv6_multicast != nullptr) { _children["l3vpn-ipv6-multicast"] = l3vpn_ipv6_multicast; } if(l2vpn_vpls != nullptr) { _children["l2vpn-vpls"] = l2vpn_vpls; } if(l2vpn_evpn != nullptr) { _children["l2vpn-evpn"] = l2vpn_evpn; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::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 == "afi-safi-name") { afi_safi_name = value; afi_safi_name.value_namespace = name_space; afi_safi_name.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "afi-safi-name") { afi_safi_name.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state" || name == "graceful-restart" || name == "route-selection-options" || name == "use-multiple-paths" || name == "apply-policy" || name == "ipv4-unicast" || name == "ipv6-unicast" || name == "ipv4-labeled-unicast" || name == "ipv6-labeled-unicast" || name == "l3vpn-ipv4-unicast" || name == "l3vpn-ipv6-unicast" || name == "l3vpn-ipv4-multicast" || name == "l3vpn-ipv6-multicast" || name == "l2vpn-vpls" || name == "l2vpn-evpn" || name == "afi-safi-name") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Config::Config() : afi_safi_name{YType::identityref, "afi-safi-name"}, enabled{YType::boolean, "enabled"} { yang_name = "config"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Config::has_data() const { if (is_presence_container) return true; return afi_safi_name.is_set || enabled.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(afi_safi_name.yfilter) || ydk::is_set(enabled.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (afi_safi_name.is_set || is_set(afi_safi_name.yfilter)) leaf_name_data.push_back(afi_safi_name.get_name_leafdata()); if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "afi-safi-name") { afi_safi_name = value; afi_safi_name.value_namespace = name_space; afi_safi_name.value_namespace_prefix = name_space_prefix; } if(value_path == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "afi-safi-name") { afi_safi_name.yfilter = yfilter; } if(value_path == "enabled") { enabled.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "afi-safi-name" || name == "enabled") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::State::State() : afi_safi_name{YType::identityref, "afi-safi-name"}, enabled{YType::boolean, "enabled"} { yang_name = "state"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::State::has_data() const { if (is_presence_container) return true; return afi_safi_name.is_set || enabled.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::State::has_operation() const { return is_set(yfilter) || ydk::is_set(afi_safi_name.yfilter) || ydk::is_set(enabled.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (afi_safi_name.is_set || is_set(afi_safi_name.yfilter)) leaf_name_data.push_back(afi_safi_name.get_name_leafdata()); if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::State::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 == "afi-safi-name") { afi_safi_name = value; afi_safi_name.value_namespace = name_space; afi_safi_name.value_namespace_prefix = name_space_prefix; } if(value_path == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "afi-safi-name") { afi_safi_name.yfilter = yfilter; } if(value_path == "enabled") { enabled.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "afi-safi-name" || name == "enabled") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::GracefulRestart() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::State>()) { config->parent = this; state->parent = this; yang_name = "graceful-restart"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::~GracefulRestart() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "graceful-restart"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::Config::Config() : enabled{YType::boolean, "enabled"} { yang_name = "config"; yang_parent_name = "graceful-restart"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::Config::has_data() const { if (is_presence_container) return true; return enabled.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::State::State() : enabled{YType::boolean, "enabled"} { yang_name = "state"; yang_parent_name = "graceful-restart"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::State::has_data() const { if (is_presence_container) return true; return enabled.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::State::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::State::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 == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::GracefulRestart::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::RouteSelectionOptions() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::State>()) { config->parent = this; state->parent = this; yang_name = "route-selection-options"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::~RouteSelectionOptions() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "route-selection-options"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::Config::Config() : always_compare_med{YType::boolean, "always-compare-med"}, ignore_as_path_length{YType::boolean, "ignore-as-path-length"}, external_compare_router_id{YType::boolean, "external-compare-router-id"}, advertise_inactive_routes{YType::boolean, "advertise-inactive-routes"}, enable_aigp{YType::boolean, "enable-aigp"}, ignore_next_hop_igp_metric{YType::boolean, "ignore-next-hop-igp-metric"} { yang_name = "config"; yang_parent_name = "route-selection-options"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::Config::has_data() const { if (is_presence_container) return true; return always_compare_med.is_set || ignore_as_path_length.is_set || external_compare_router_id.is_set || advertise_inactive_routes.is_set || enable_aigp.is_set || ignore_next_hop_igp_metric.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(always_compare_med.yfilter) || ydk::is_set(ignore_as_path_length.yfilter) || ydk::is_set(external_compare_router_id.yfilter) || ydk::is_set(advertise_inactive_routes.yfilter) || ydk::is_set(enable_aigp.yfilter) || ydk::is_set(ignore_next_hop_igp_metric.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (always_compare_med.is_set || is_set(always_compare_med.yfilter)) leaf_name_data.push_back(always_compare_med.get_name_leafdata()); if (ignore_as_path_length.is_set || is_set(ignore_as_path_length.yfilter)) leaf_name_data.push_back(ignore_as_path_length.get_name_leafdata()); if (external_compare_router_id.is_set || is_set(external_compare_router_id.yfilter)) leaf_name_data.push_back(external_compare_router_id.get_name_leafdata()); if (advertise_inactive_routes.is_set || is_set(advertise_inactive_routes.yfilter)) leaf_name_data.push_back(advertise_inactive_routes.get_name_leafdata()); if (enable_aigp.is_set || is_set(enable_aigp.yfilter)) leaf_name_data.push_back(enable_aigp.get_name_leafdata()); if (ignore_next_hop_igp_metric.is_set || is_set(ignore_next_hop_igp_metric.yfilter)) leaf_name_data.push_back(ignore_next_hop_igp_metric.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "always-compare-med") { always_compare_med = value; always_compare_med.value_namespace = name_space; always_compare_med.value_namespace_prefix = name_space_prefix; } if(value_path == "ignore-as-path-length") { ignore_as_path_length = value; ignore_as_path_length.value_namespace = name_space; ignore_as_path_length.value_namespace_prefix = name_space_prefix; } if(value_path == "external-compare-router-id") { external_compare_router_id = value; external_compare_router_id.value_namespace = name_space; external_compare_router_id.value_namespace_prefix = name_space_prefix; } if(value_path == "advertise-inactive-routes") { advertise_inactive_routes = value; advertise_inactive_routes.value_namespace = name_space; advertise_inactive_routes.value_namespace_prefix = name_space_prefix; } if(value_path == "enable-aigp") { enable_aigp = value; enable_aigp.value_namespace = name_space; enable_aigp.value_namespace_prefix = name_space_prefix; } if(value_path == "ignore-next-hop-igp-metric") { ignore_next_hop_igp_metric = value; ignore_next_hop_igp_metric.value_namespace = name_space; ignore_next_hop_igp_metric.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "always-compare-med") { always_compare_med.yfilter = yfilter; } if(value_path == "ignore-as-path-length") { ignore_as_path_length.yfilter = yfilter; } if(value_path == "external-compare-router-id") { external_compare_router_id.yfilter = yfilter; } if(value_path == "advertise-inactive-routes") { advertise_inactive_routes.yfilter = yfilter; } if(value_path == "enable-aigp") { enable_aigp.yfilter = yfilter; } if(value_path == "ignore-next-hop-igp-metric") { ignore_next_hop_igp_metric.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "always-compare-med" || name == "ignore-as-path-length" || name == "external-compare-router-id" || name == "advertise-inactive-routes" || name == "enable-aigp" || name == "ignore-next-hop-igp-metric") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::State::State() : always_compare_med{YType::boolean, "always-compare-med"}, ignore_as_path_length{YType::boolean, "ignore-as-path-length"}, external_compare_router_id{YType::boolean, "external-compare-router-id"}, advertise_inactive_routes{YType::boolean, "advertise-inactive-routes"}, enable_aigp{YType::boolean, "enable-aigp"}, ignore_next_hop_igp_metric{YType::boolean, "ignore-next-hop-igp-metric"} { yang_name = "state"; yang_parent_name = "route-selection-options"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::State::has_data() const { if (is_presence_container) return true; return always_compare_med.is_set || ignore_as_path_length.is_set || external_compare_router_id.is_set || advertise_inactive_routes.is_set || enable_aigp.is_set || ignore_next_hop_igp_metric.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::State::has_operation() const { return is_set(yfilter) || ydk::is_set(always_compare_med.yfilter) || ydk::is_set(ignore_as_path_length.yfilter) || ydk::is_set(external_compare_router_id.yfilter) || ydk::is_set(advertise_inactive_routes.yfilter) || ydk::is_set(enable_aigp.yfilter) || ydk::is_set(ignore_next_hop_igp_metric.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (always_compare_med.is_set || is_set(always_compare_med.yfilter)) leaf_name_data.push_back(always_compare_med.get_name_leafdata()); if (ignore_as_path_length.is_set || is_set(ignore_as_path_length.yfilter)) leaf_name_data.push_back(ignore_as_path_length.get_name_leafdata()); if (external_compare_router_id.is_set || is_set(external_compare_router_id.yfilter)) leaf_name_data.push_back(external_compare_router_id.get_name_leafdata()); if (advertise_inactive_routes.is_set || is_set(advertise_inactive_routes.yfilter)) leaf_name_data.push_back(advertise_inactive_routes.get_name_leafdata()); if (enable_aigp.is_set || is_set(enable_aigp.yfilter)) leaf_name_data.push_back(enable_aigp.get_name_leafdata()); if (ignore_next_hop_igp_metric.is_set || is_set(ignore_next_hop_igp_metric.yfilter)) leaf_name_data.push_back(ignore_next_hop_igp_metric.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::State::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 == "always-compare-med") { always_compare_med = value; always_compare_med.value_namespace = name_space; always_compare_med.value_namespace_prefix = name_space_prefix; } if(value_path == "ignore-as-path-length") { ignore_as_path_length = value; ignore_as_path_length.value_namespace = name_space; ignore_as_path_length.value_namespace_prefix = name_space_prefix; } if(value_path == "external-compare-router-id") { external_compare_router_id = value; external_compare_router_id.value_namespace = name_space; external_compare_router_id.value_namespace_prefix = name_space_prefix; } if(value_path == "advertise-inactive-routes") { advertise_inactive_routes = value; advertise_inactive_routes.value_namespace = name_space; advertise_inactive_routes.value_namespace_prefix = name_space_prefix; } if(value_path == "enable-aigp") { enable_aigp = value; enable_aigp.value_namespace = name_space; enable_aigp.value_namespace_prefix = name_space_prefix; } if(value_path == "ignore-next-hop-igp-metric") { ignore_next_hop_igp_metric = value; ignore_next_hop_igp_metric.value_namespace = name_space; ignore_next_hop_igp_metric.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "always-compare-med") { always_compare_med.yfilter = yfilter; } if(value_path == "ignore-as-path-length") { ignore_as_path_length.yfilter = yfilter; } if(value_path == "external-compare-router-id") { external_compare_router_id.yfilter = yfilter; } if(value_path == "advertise-inactive-routes") { advertise_inactive_routes.yfilter = yfilter; } if(value_path == "enable-aigp") { enable_aigp.yfilter = yfilter; } if(value_path == "ignore-next-hop-igp-metric") { ignore_next_hop_igp_metric.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::RouteSelectionOptions::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "always-compare-med" || name == "ignore-as-path-length" || name == "external-compare-router-id" || name == "advertise-inactive-routes" || name == "enable-aigp" || name == "ignore-next-hop-igp-metric") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::UseMultiplePaths() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::State>()) , ebgp(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp>()) , ibgp(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp>()) { config->parent = this; state->parent = this; ebgp->parent = this; ibgp->parent = this; yang_name = "use-multiple-paths"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::~UseMultiplePaths() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()) || (ebgp != nullptr && ebgp->has_data()) || (ibgp != nullptr && ibgp->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()) || (ebgp != nullptr && ebgp->has_operation()) || (ibgp != nullptr && ibgp->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "use-multiple-paths"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::State>(); } return state; } if(child_yang_name == "ebgp") { if(ebgp == nullptr) { ebgp = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp>(); } return ebgp; } if(child_yang_name == "ibgp") { if(ibgp == nullptr) { ibgp = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp>(); } return ibgp; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } if(ebgp != nullptr) { _children["ebgp"] = ebgp; } if(ibgp != nullptr) { _children["ibgp"] = ibgp; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state" || name == "ebgp" || name == "ibgp") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Config::Config() : enabled{YType::boolean, "enabled"} { yang_name = "config"; yang_parent_name = "use-multiple-paths"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Config::has_data() const { if (is_presence_container) return true; return enabled.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::State::State() : enabled{YType::boolean, "enabled"} { yang_name = "state"; yang_parent_name = "use-multiple-paths"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::State::has_data() const { if (is_presence_container) return true; return enabled.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::State::has_operation() const { return is_set(yfilter) || ydk::is_set(enabled.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (enabled.is_set || is_set(enabled.yfilter)) leaf_name_data.push_back(enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::State::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 == "enabled") { enabled = value; enabled.value_namespace = name_space; enabled.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "enabled") { enabled.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "enabled") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Ebgp() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State>()) { config->parent = this; state->parent = this; yang_name = "ebgp"; yang_parent_name = "use-multiple-paths"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::~Ebgp() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ebgp"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::Config() : allow_multiple_as{YType::boolean, "allow-multiple-as"}, maximum_paths{YType::uint32, "maximum-paths"} { yang_name = "config"; yang_parent_name = "ebgp"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::has_data() const { if (is_presence_container) return true; return allow_multiple_as.is_set || maximum_paths.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(allow_multiple_as.yfilter) || ydk::is_set(maximum_paths.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (allow_multiple_as.is_set || is_set(allow_multiple_as.yfilter)) leaf_name_data.push_back(allow_multiple_as.get_name_leafdata()); if (maximum_paths.is_set || is_set(maximum_paths.yfilter)) leaf_name_data.push_back(maximum_paths.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "allow-multiple-as") { allow_multiple_as = value; allow_multiple_as.value_namespace = name_space; allow_multiple_as.value_namespace_prefix = name_space_prefix; } if(value_path == "maximum-paths") { maximum_paths = value; maximum_paths.value_namespace = name_space; maximum_paths.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "allow-multiple-as") { allow_multiple_as.yfilter = yfilter; } if(value_path == "maximum-paths") { maximum_paths.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allow-multiple-as" || name == "maximum-paths") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::State() : allow_multiple_as{YType::boolean, "allow-multiple-as"}, maximum_paths{YType::uint32, "maximum-paths"} { yang_name = "state"; yang_parent_name = "ebgp"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::has_data() const { if (is_presence_container) return true; return allow_multiple_as.is_set || maximum_paths.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::has_operation() const { return is_set(yfilter) || ydk::is_set(allow_multiple_as.yfilter) || ydk::is_set(maximum_paths.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (allow_multiple_as.is_set || is_set(allow_multiple_as.yfilter)) leaf_name_data.push_back(allow_multiple_as.get_name_leafdata()); if (maximum_paths.is_set || is_set(maximum_paths.yfilter)) leaf_name_data.push_back(maximum_paths.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::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 == "allow-multiple-as") { allow_multiple_as = value; allow_multiple_as.value_namespace = name_space; allow_multiple_as.value_namespace_prefix = name_space_prefix; } if(value_path == "maximum-paths") { maximum_paths = value; maximum_paths.value_namespace = name_space; maximum_paths.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "allow-multiple-as") { allow_multiple_as.yfilter = yfilter; } if(value_path == "maximum-paths") { maximum_paths.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ebgp::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allow-multiple-as" || name == "maximum-paths") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Ibgp() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::State>()) { config->parent = this; state->parent = this; yang_name = "ibgp"; yang_parent_name = "use-multiple-paths"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::~Ibgp() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ibgp"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Config::Config() : maximum_paths{YType::uint32, "maximum-paths"} { yang_name = "config"; yang_parent_name = "ibgp"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Config::has_data() const { if (is_presence_container) return true; return maximum_paths.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(maximum_paths.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (maximum_paths.is_set || is_set(maximum_paths.yfilter)) leaf_name_data.push_back(maximum_paths.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "maximum-paths") { maximum_paths = value; maximum_paths.value_namespace = name_space; maximum_paths.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "maximum-paths") { maximum_paths.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "maximum-paths") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::State::State() : maximum_paths{YType::uint32, "maximum-paths"} { yang_name = "state"; yang_parent_name = "ibgp"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::State::has_data() const { if (is_presence_container) return true; return maximum_paths.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::State::has_operation() const { return is_set(yfilter) || ydk::is_set(maximum_paths.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (maximum_paths.is_set || is_set(maximum_paths.yfilter)) leaf_name_data.push_back(maximum_paths.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::State::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 == "maximum-paths") { maximum_paths = value; maximum_paths.value_namespace = name_space; maximum_paths.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "maximum-paths") { maximum_paths.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::UseMultiplePaths::Ibgp::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "maximum-paths") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::ApplyPolicy() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::State>()) { config->parent = this; state->parent = this; yang_name = "apply-policy"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::~ApplyPolicy() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "apply-policy"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::Config::Config() : import_policy{YType::str, "import-policy"}, default_import_policy{YType::enumeration, "default-import-policy"}, export_policy{YType::str, "export-policy"}, default_export_policy{YType::enumeration, "default-export-policy"} { yang_name = "config"; yang_parent_name = "apply-policy"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::Config::has_data() const { if (is_presence_container) return true; for (auto const & leaf : import_policy.getYLeafs()) { if(leaf.is_set) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(leaf.is_set) return true; } return default_import_policy.is_set || default_export_policy.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::Config::has_operation() const { for (auto const & leaf : import_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(import_policy.yfilter) || ydk::is_set(default_import_policy.yfilter) || ydk::is_set(export_policy.yfilter) || ydk::is_set(default_export_policy.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (default_import_policy.is_set || is_set(default_import_policy.yfilter)) leaf_name_data.push_back(default_import_policy.get_name_leafdata()); if (default_export_policy.is_set || is_set(default_export_policy.yfilter)) leaf_name_data.push_back(default_export_policy.get_name_leafdata()); auto import_policy_name_datas = import_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), import_policy_name_datas.begin(), import_policy_name_datas.end()); auto export_policy_name_datas = export_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), export_policy_name_datas.begin(), export_policy_name_datas.end()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "import-policy") { import_policy.append(value); } if(value_path == "default-import-policy") { default_import_policy = value; default_import_policy.value_namespace = name_space; default_import_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "export-policy") { export_policy.append(value); } if(value_path == "default-export-policy") { default_export_policy = value; default_export_policy.value_namespace = name_space; default_export_policy.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "import-policy") { import_policy.yfilter = yfilter; } if(value_path == "default-import-policy") { default_import_policy.yfilter = yfilter; } if(value_path == "export-policy") { export_policy.yfilter = yfilter; } if(value_path == "default-export-policy") { default_export_policy.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "import-policy" || name == "default-import-policy" || name == "export-policy" || name == "default-export-policy") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::State::State() : import_policy{YType::str, "import-policy"}, default_import_policy{YType::enumeration, "default-import-policy"}, export_policy{YType::str, "export-policy"}, default_export_policy{YType::enumeration, "default-export-policy"} { yang_name = "state"; yang_parent_name = "apply-policy"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::State::has_data() const { if (is_presence_container) return true; for (auto const & leaf : import_policy.getYLeafs()) { if(leaf.is_set) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(leaf.is_set) return true; } return default_import_policy.is_set || default_export_policy.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::State::has_operation() const { for (auto const & leaf : import_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } for (auto const & leaf : export_policy.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(import_policy.yfilter) || ydk::is_set(default_import_policy.yfilter) || ydk::is_set(export_policy.yfilter) || ydk::is_set(default_export_policy.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (default_import_policy.is_set || is_set(default_import_policy.yfilter)) leaf_name_data.push_back(default_import_policy.get_name_leafdata()); if (default_export_policy.is_set || is_set(default_export_policy.yfilter)) leaf_name_data.push_back(default_export_policy.get_name_leafdata()); auto import_policy_name_datas = import_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), import_policy_name_datas.begin(), import_policy_name_datas.end()); auto export_policy_name_datas = export_policy.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), export_policy_name_datas.begin(), export_policy_name_datas.end()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::State::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 == "import-policy") { import_policy.append(value); } if(value_path == "default-import-policy") { default_import_policy = value; default_import_policy.value_namespace = name_space; default_import_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "export-policy") { export_policy.append(value); } if(value_path == "default-export-policy") { default_export_policy = value; default_export_policy.value_namespace = name_space; default_export_policy.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "import-policy") { import_policy.yfilter = yfilter; } if(value_path == "default-import-policy") { default_import_policy.yfilter = yfilter; } if(value_path == "export-policy") { export_policy.yfilter = yfilter; } if(value_path == "default-export-policy") { default_export_policy.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::ApplyPolicy::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "import-policy" || name == "default-import-policy" || name == "export-policy" || name == "default-export-policy") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Ipv4Unicast() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit>()) , config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::State>()) { prefix_limit->parent = this; config->parent = this; state->parent = this; yang_name = "ipv4-unicast"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::~Ipv4Unicast() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()) || (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv4-unicast"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit>(); } return prefix_limit; } if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit" || name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "ipv4-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::State() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "state"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::PrefixLimit::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Config::Config() : send_default_route{YType::boolean, "send-default-route"} { yang_name = "config"; yang_parent_name = "ipv4-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Config::has_data() const { if (is_presence_container) return true; return send_default_route.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(send_default_route.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_default_route.is_set || is_set(send_default_route.yfilter)) leaf_name_data.push_back(send_default_route.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "send-default-route") { send_default_route = value; send_default_route.value_namespace = name_space; send_default_route.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-default-route") { send_default_route.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-default-route") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::State::State() : send_default_route{YType::boolean, "send-default-route"} { yang_name = "state"; yang_parent_name = "ipv4-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::State::has_data() const { if (is_presence_container) return true; return send_default_route.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::State::has_operation() const { return is_set(yfilter) || ydk::is_set(send_default_route.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_default_route.is_set || is_set(send_default_route.yfilter)) leaf_name_data.push_back(send_default_route.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "send-default-route") { send_default_route = value; send_default_route.value_namespace = name_space; send_default_route.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-default-route") { send_default_route.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4Unicast::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-default-route") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Ipv6Unicast() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit>()) , config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::State>()) { prefix_limit->parent = this; config->parent = this; state->parent = this; yang_name = "ipv6-unicast"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::~Ipv6Unicast() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()) || (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv6-unicast"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit>(); } return prefix_limit; } if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit" || name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "ipv6-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::State() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "state"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::PrefixLimit::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Config::Config() : send_default_route{YType::boolean, "send-default-route"} { yang_name = "config"; yang_parent_name = "ipv6-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Config::has_data() const { if (is_presence_container) return true; return send_default_route.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(send_default_route.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_default_route.is_set || is_set(send_default_route.yfilter)) leaf_name_data.push_back(send_default_route.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "send-default-route") { send_default_route = value; send_default_route.value_namespace = name_space; send_default_route.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-default-route") { send_default_route.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-default-route") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::State::State() : send_default_route{YType::boolean, "send-default-route"} { yang_name = "state"; yang_parent_name = "ipv6-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::State::has_data() const { if (is_presence_container) return true; return send_default_route.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::State::has_operation() const { return is_set(yfilter) || ydk::is_set(send_default_route.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_default_route.is_set || is_set(send_default_route.yfilter)) leaf_name_data.push_back(send_default_route.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "send-default-route") { send_default_route = value; send_default_route.value_namespace = name_space; send_default_route.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-default-route") { send_default_route.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6Unicast::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-default-route") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::Ipv4LabeledUnicast() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit>()) { prefix_limit->parent = this; yang_name = "ipv4-labeled-unicast"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::~Ipv4LabeledUnicast() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv4-labeled-unicast"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit>(); } return prefix_limit; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "ipv4-labeled-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::State() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "state"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::~State() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "state"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::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>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv4LabeledUnicast::PrefixLimit::State::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::Ipv6LabeledUnicast() : prefix_limit(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit>()) { prefix_limit->parent = this; yang_name = "ipv6-labeled-unicast"; yang_parent_name = "afi-safi"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::~Ipv6LabeledUnicast() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::has_data() const { if (is_presence_container) return true; return (prefix_limit != nullptr && prefix_limit->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::has_operation() const { return is_set(yfilter) || (prefix_limit != nullptr && prefix_limit->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv6-labeled-unicast"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prefix-limit") { if(prefix_limit == nullptr) { prefix_limit = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit>(); } return prefix_limit; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(prefix_limit != nullptr) { _children["prefix-limit"] = prefix_limit; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-limit") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::PrefixLimit() : config(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config>()) , state(std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State>()) { config->parent = this; state->parent = this; yang_name = "prefix-limit"; yang_parent_name = "ipv6-labeled-unicast"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::~PrefixLimit() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::has_data() const { if (is_presence_container) return true; return (config != nullptr && config->has_data()) || (state != nullptr && state->has_data()); } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::has_operation() const { return is_set(yfilter) || (config != nullptr && config->has_operation()) || (state != nullptr && state->has_operation()); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-limit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "config") { if(config == nullptr) { config = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config>(); } return config; } if(child_yang_name == "state") { if(state == nullptr) { state = std::make_shared<NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::State>(); } return state; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(config != nullptr) { _children["config"] = config; } if(state != nullptr) { _children["state"] = state; } return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "config" || name == "state") return true; return false; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::Config() : max_prefixes{YType::uint32, "max-prefixes"}, prevent_teardown{YType::boolean, "prevent-teardown"}, shutdown_threshold_pct{YType::uint8, "shutdown-threshold-pct"}, restart_timer{YType::str, "restart-timer"} { yang_name = "config"; yang_parent_name = "prefix-limit"; is_top_level_class = false; has_list_ancestor = true; } NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::~Config() { } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::has_data() const { if (is_presence_container) return true; return max_prefixes.is_set || prevent_teardown.is_set || shutdown_threshold_pct.is_set || restart_timer.is_set; } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefixes.yfilter) || ydk::is_set(prevent_teardown.yfilter) || ydk::is_set(shutdown_threshold_pct.yfilter) || ydk::is_set(restart_timer.yfilter); } std::string NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "config"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefixes.is_set || is_set(max_prefixes.yfilter)) leaf_name_data.push_back(max_prefixes.get_name_leafdata()); if (prevent_teardown.is_set || is_set(prevent_teardown.yfilter)) leaf_name_data.push_back(prevent_teardown.get_name_leafdata()); if (shutdown_threshold_pct.is_set || is_set(shutdown_threshold_pct.yfilter)) leaf_name_data.push_back(shutdown_threshold_pct.get_name_leafdata()); if (restart_timer.is_set || is_set(restart_timer.yfilter)) leaf_name_data.push_back(restart_timer.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "max-prefixes") { max_prefixes = value; max_prefixes.value_namespace = name_space; max_prefixes.value_namespace_prefix = name_space_prefix; } if(value_path == "prevent-teardown") { prevent_teardown = value; prevent_teardown.value_namespace = name_space; prevent_teardown.value_namespace_prefix = name_space_prefix; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct = value; shutdown_threshold_pct.value_namespace = name_space; shutdown_threshold_pct.value_namespace_prefix = name_space_prefix; } if(value_path == "restart-timer") { restart_timer = value; restart_timer.value_namespace = name_space; restart_timer.value_namespace_prefix = name_space_prefix; } } void NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefixes") { max_prefixes.yfilter = yfilter; } if(value_path == "prevent-teardown") { prevent_teardown.yfilter = yfilter; } if(value_path == "shutdown-threshold-pct") { shutdown_threshold_pct.yfilter = yfilter; } if(value_path == "restart-timer") { restart_timer.yfilter = yfilter; } } bool NetworkInstances::NetworkInstance::Protocols::Protocol::Bgp::PeerGroups::PeerGroup::AfiSafis::AfiSafi::Ipv6LabeledUnicast::PrefixLimit::Config::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefixes" || name == "prevent-teardown" || name == "shutdown-threshold-pct" || name == "restart-timer") return true; return false; } } }
40.205169
495
0.726898
CiscoDevNet
ee85b17c677c5a923ca6f8f0e30e43f6f6c21a77
847
cpp
C++
luogu/cxx/src/P1551.cpp
HoshinoTented/Solutions
96fb200c7eb5bce17938aec5ae6efdc43b3fe494
[ "WTFPL" ]
1
2019-09-13T13:06:27.000Z
2019-09-13T13:06:27.000Z
luogu/cxx/src/P1551.cpp
HoshinoTented/Solutions
96fb200c7eb5bce17938aec5ae6efdc43b3fe494
[ "WTFPL" ]
null
null
null
luogu/cxx/src/P1551.cpp
HoshinoTented/Solutions
96fb200c7eb5bce17938aec5ae6efdc43b3fe494
[ "WTFPL" ]
null
null
null
#include <iostream> struct union_find { int *arr; const int length; union_find(const int &len): arr(new int[len]), length(len) { for (size_t i = 0; i < len; ++ i) { arr[i] = i; } } auto ask(const int &x) -> int { if (arr[x] == x) return x; return arr[x] = ask(arr[x]); } auto concat(const int &x, const int &y) -> void { arr[ask(x)] = ask(y); } }; auto main(int, char **) -> int { int n, m, p; std::cin >> n >> m >> p; union_find uf = {n + 1}; for (size_t i = 0; i < m; ++ i) { int x, y; std::cin >> x >> y; uf.concat(x, y); } for (size_t i = 0; i < p; ++ i) { int x, y; std::cin >> x >> y; std::cout << (uf.ask(x) == uf.ask(y) ? "Yes" : "No") << std::endl; } return 0; }
18.822222
74
0.420307
HoshinoTented
ee87c6ead491a6fd9f4ae0d17bfe195c8c15039b
39,084
cpp
C++
tests/src/astro/propagators/unitTestHybridArcVariationalEquations.cpp
kimonito98/tudat
c28f2a3e78b8492e2e054ad5e0d1f9ad785cd092
[ "BSD-3-Clause" ]
null
null
null
tests/src/astro/propagators/unitTestHybridArcVariationalEquations.cpp
kimonito98/tudat
c28f2a3e78b8492e2e054ad5e0d1f9ad785cd092
[ "BSD-3-Clause" ]
null
null
null
tests/src/astro/propagators/unitTestHybridArcVariationalEquations.cpp
kimonito98/tudat
c28f2a3e78b8492e2e054ad5e0d1f9ad785cd092
[ "BSD-3-Clause" ]
null
null
null
/* Copyright (c) 2010-2019, Delft University of Technology * All rigths reserved * * This file is part of the Tudat. Redistribution and use in source and * binary forms, with or without modification, are permitted exclusively * under the terms of the Modified BSD license. You should have received * a copy of the license with this file. If not, please or visit: * http://tudat.tudelft.nl/LICENSE. */ #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN #include <string> #include <thread> #include <boost/test/unit_test.hpp> #include <boost/make_shared.hpp> #include "tudat/basics/testMacros.h" #include "tudat/math/basic/linearAlgebra.h" #include "tudat/astro/basic_astro/physicalConstants.h" #include "tudat/astro/basic_astro/unitConversions.h" #include "tudat/interface/spice/spiceInterface.h" #include "tudat/math/integrators/rungeKuttaCoefficients.h" #include "tudat/astro/basic_astro/accelerationModel.h" #include "tudat/io/basicInputOutput.h" #include "tudat/simulation/environment_setup/body.h" #include "tudat/simulation/estimation_setup/variationalEquationsSolver.h" #include "tudat/simulation/environment_setup/defaultBodies.h" #include "tudat/simulation/environment_setup/createBodies.h" #include "tudat/simulation/estimation_setup/createNumericalSimulator.h" #include "tudat/simulation/estimation_setup/createEstimatableParameters.h" namespace tudat { namespace unit_tests { //Using declarations. using namespace tudat; using namespace tudat::estimatable_parameters; using namespace tudat::orbit_determination; using namespace tudat::interpolators; using namespace tudat::numerical_integrators; using namespace tudat::spice_interface; using namespace tudat::simulation_setup; using namespace tudat::basic_astrodynamics; using namespace tudat::orbital_element_conversions; using namespace tudat::ephemerides; using namespace tudat::propagators; using namespace tudat::unit_conversions; BOOST_AUTO_TEST_SUITE( test_hybrid_arc_variational_equation_calculation ) template< typename TimeType = double , typename StateScalarType = double > std::pair< std::vector< Eigen::Matrix< StateScalarType, Eigen::Dynamic, Eigen::Dynamic > >, std::vector< Eigen::Matrix< StateScalarType, Eigen::Dynamic, 1 > > > executeHybridArcMarsAndOrbiterSensitivitySimulation( const Eigen::Matrix< StateScalarType, 12, 1 > initialStateDifference = Eigen::Matrix< StateScalarType, 12, 1 >::Zero( ), const Eigen::VectorXd parameterPerturbation = Eigen::VectorXd::Zero( 2 ), const bool propagateVariationalEquations = 1, const bool patchMultiArcs = 0, const std::vector< Eigen::Matrix< StateScalarType, Eigen::Dynamic, 1 > > forcedMultiArcInitialStates = std::vector< Eigen::Matrix< StateScalarType, Eigen::Dynamic, 1 > >( ), const double arcDuration = 0.5 * 86400.0, const double arcOverlap = 5.0E3 ) { //Load spice kernels. spice_interface::loadStandardSpiceKernels( ); std::vector< std::string > bodyNames; bodyNames.push_back( "Sun" ); bodyNames.push_back( "Mars" ); bodyNames.push_back( "Jupiter" ); bodyNames.push_back( "Earth" ); // Specify initial time double initialEphemerisTime = 1.0E7; double finalEphemerisTime = initialEphemerisTime + 2.0 * 86400.0; double maximumTimeStep = 3600.0; double buffer = 5.0 * maximumTimeStep; // Create bodies needed in simulation BodyListSettings bodySettings = getDefaultBodySettings( bodyNames, initialEphemerisTime - buffer, finalEphemerisTime + buffer ); SystemOfBodies bodies = createSystemOfBodies( bodySettings ); bodies.createEmptyBody( "Orbiter" ); bodies.at( "Orbiter" )->setConstantBodyMass( 5.0E3 ); bodies.at( "Orbiter" )->setEphemeris( std::make_shared< MultiArcEphemeris >( std::map< double, std::shared_ptr< Ephemeris > >( ), "Mars", "ECLIPJ2000" ) ); bodies.processBodyFrameDefinitions( ); double referenceAreaRadiation = 4.0; double radiationPressureCoefficient = 1.2; std::vector< std::string > occultingBodies; occultingBodies.push_back( "Earth" ); std::shared_ptr< RadiationPressureInterfaceSettings > orbiterRadiationPressureSettings = std::make_shared< CannonBallRadiationPressureInterfaceSettings >( "Sun", referenceAreaRadiation, radiationPressureCoefficient, occultingBodies ); // Create and set radiation pressure settings bodies.at( "Orbiter" )->setRadiationPressureInterface( "Sun", createRadiationPressureInterface( orbiterRadiationPressureSettings, "Orbiter", bodies ) ); // Set accelerations between bodies that are to be taken into account. SelectedAccelerationMap singleArcAccelerationMap; std::map< std::string, std::vector< std::shared_ptr< AccelerationSettings > > > accelerationsOfMars; accelerationsOfMars[ "Earth" ].push_back( std::make_shared< AccelerationSettings >( point_mass_gravity ) ); accelerationsOfMars[ "Sun" ].push_back( std::make_shared< AccelerationSettings >( point_mass_gravity ) ); accelerationsOfMars[ "Jupiter" ].push_back( std::make_shared< AccelerationSettings >( point_mass_gravity ) ); singleArcAccelerationMap[ "Mars" ] = accelerationsOfMars; std::vector< std::string > singleArcBodiesToIntegrate, singleArcCentralBodies; singleArcBodiesToIntegrate.push_back( "Mars" ); singleArcCentralBodies.push_back( "SSB" ); AccelerationMap singleArcAccelerationModelMap = createAccelerationModelsMap( bodies, singleArcAccelerationMap, singleArcBodiesToIntegrate, singleArcCentralBodies ); Eigen::VectorXd singleArcInitialStates = getInitialStatesOfBodies( singleArcBodiesToIntegrate, singleArcCentralBodies, bodies, initialEphemerisTime ); singleArcInitialStates += initialStateDifference.segment( 0, singleArcInitialStates.rows( ) ); std::shared_ptr< TranslationalStatePropagatorSettings< > > singleArcPropagatorSettings = std::make_shared< TranslationalStatePropagatorSettings< > >( singleArcCentralBodies, singleArcAccelerationModelMap, singleArcBodiesToIntegrate, singleArcInitialStates, finalEphemerisTime ); SelectedAccelerationMap multiArcAccelerationMap; std::map< std::string, std::vector< std::shared_ptr< AccelerationSettings > > > accelerationsOfOrbiter; accelerationsOfOrbiter[ "Mars" ].push_back( std::make_shared< SphericalHarmonicAccelerationSettings >( 2, 2 ) ); accelerationsOfOrbiter[ "Sun" ].push_back( std::make_shared< AccelerationSettings >( point_mass_gravity ) ); accelerationsOfOrbiter[ "Sun" ].push_back( std::make_shared< AccelerationSettings >( cannon_ball_radiation_pressure ) ); accelerationsOfOrbiter[ "Jupiter" ].push_back( std::make_shared< AccelerationSettings >( point_mass_gravity ) ); multiArcAccelerationMap[ "Orbiter" ] = accelerationsOfOrbiter; std::vector< std::string > multiArcBodiesToIntegrate, multiArcCentralBodies; multiArcBodiesToIntegrate.push_back( "Orbiter" ); multiArcCentralBodies.push_back( "Mars" ); AccelerationMap multiArcAccelerationModelMap = createAccelerationModelsMap( bodies, multiArcAccelerationMap, multiArcBodiesToIntegrate, multiArcCentralBodies ); // Creater arc times std::vector< double > integrationArcStarts, integrationArcEnds; // double integrationStartTime = initialEphemerisTime; // double integrationEndTime = finalEphemerisTime - 1.0E4; // double currentStartTime = integrationStartTime; // double currentEndTime = integrationStartTime + arcDuration; // do // { // integrationArcStarts.push_back( currentStartTime ); // integrationArcEnds.push_back( currentEndTime ); // currentStartTime = currentEndTime - arcOverlap; // currentEndTime = currentStartTime + arcDuration; // } double timeBetweenArcs = 86400.0; // double arcDuration = 0.5E6; double currentStartTime = initialEphemerisTime; double currentEndTime = initialEphemerisTime + arcDuration; do { integrationArcStarts.push_back( currentStartTime ); integrationArcEnds.push_back( currentEndTime ); currentEndTime = currentStartTime + timeBetweenArcs + arcDuration; currentStartTime = currentStartTime + timeBetweenArcs; } while( currentEndTime < finalEphemerisTime ); // Create list of multi-arc initial states unsigned int numberOfIntegrationArcs = integrationArcStarts.size( ); std::vector< Eigen::VectorXd > multiArcSystemInitialStates; multiArcSystemInitialStates.resize( numberOfIntegrationArcs ); // Define (quasi-arbitrary) arc initial states double marsGravitationalParameter = bodies.at( "Mars" )->getGravityFieldModel( )->getGravitationalParameter( ); if( forcedMultiArcInitialStates.size( ) == 0 ) { for( unsigned int j = 0; j < numberOfIntegrationArcs; j++ ) { Eigen::Vector6d orbiterInitialStateInKeplerianElements; orbiterInitialStateInKeplerianElements( semiMajorAxisIndex ) = 6000.0E3; orbiterInitialStateInKeplerianElements( eccentricityIndex ) = 0.05; orbiterInitialStateInKeplerianElements( inclinationIndex ) = convertDegreesToRadians( 85.3 ); orbiterInitialStateInKeplerianElements( argumentOfPeriapsisIndex ) = convertDegreesToRadians( 235.7 - j ); orbiterInitialStateInKeplerianElements( longitudeOfAscendingNodeIndex ) = convertDegreesToRadians( 23.4 + j ); orbiterInitialStateInKeplerianElements( trueAnomalyIndex ) = convertDegreesToRadians( 139.87 + j * 10.0 ); // Convert state from Keplerian elements to Cartesian elements. multiArcSystemInitialStates[ j ] = convertKeplerianToCartesianElements( orbiterInitialStateInKeplerianElements, marsGravitationalParameter ) + initialStateDifference.segment( singleArcInitialStates.rows( ), 6 ); } } else { for( unsigned int j = 0; j < numberOfIntegrationArcs; j++ ) { multiArcSystemInitialStates[ j ] = forcedMultiArcInitialStates.at( j ) + initialStateDifference.segment( singleArcInitialStates.rows( ), 6 ); } } // Create propagation settings for each arc std::vector< std::shared_ptr< SingleArcPropagatorSettings< double > > > arcPropagationSettingsList; for( unsigned int i = 0; i < numberOfIntegrationArcs; i++ ) { arcPropagationSettingsList.push_back( std::make_shared< TranslationalStatePropagatorSettings< double > > ( multiArcCentralBodies, multiArcAccelerationModelMap, multiArcBodiesToIntegrate, multiArcSystemInitialStates.at( i ), integrationArcEnds.at( i ) ) ); } std::shared_ptr< MultiArcPropagatorSettings< > > multiArcPropagatorSettings = std::make_shared< MultiArcPropagatorSettings< > >( arcPropagationSettingsList, patchMultiArcs ); std::shared_ptr< HybridArcPropagatorSettings< > > hybridArcPropagatorSettings = std::make_shared< HybridArcPropagatorSettings< > >( singleArcPropagatorSettings, multiArcPropagatorSettings ); std::shared_ptr< IntegratorSettings< > > singleArcIntegratorSettings = std::make_shared< IntegratorSettings< > > ( rungeKutta4, initialEphemerisTime, 60.0 ); std::shared_ptr< IntegratorSettings< > > multiArcIntegratorSettings = std::make_shared< IntegratorSettings< > > ( rungeKutta4, initialEphemerisTime, 45.0 ); // Define parameters. std::vector< std::shared_ptr< EstimatableParameterSettings > > parameterNames; { parameterNames = getInitialStateParameterSettings< double >( hybridArcPropagatorSettings, bodies, integrationArcStarts ); parameterNames.push_back( std::make_shared< EstimatableParameterSettings >( "Sun", gravitational_parameter ) ); parameterNames.push_back( std::make_shared< EstimatableParameterSettings >( "Mars", gravitational_parameter ) ); } // Create parameters std::shared_ptr< estimatable_parameters::EstimatableParameterSet< StateScalarType > > parametersToEstimate = createParametersToEstimate( parameterNames, bodies ); // Perturb parameters. Eigen::Matrix< StateScalarType, Eigen::Dynamic, 1 > parameterVector = parametersToEstimate->template getFullParameterValues< StateScalarType >( ); parameterVector.block( parameterVector.rows( ) - 2, 0, 2, 1 ) += parameterPerturbation; parametersToEstimate->resetParameterValues( parameterVector ); std::pair< std::vector< Eigen::Matrix< StateScalarType, Eigen::Dynamic, Eigen::Dynamic > >, std::vector< Eigen::Matrix< StateScalarType, Eigen::Dynamic, 1 > > > results; { // Create dynamics simulator HybridArcVariationalEquationsSolver< StateScalarType, TimeType > variationalEquations = HybridArcVariationalEquationsSolver< StateScalarType, TimeType >( bodies, singleArcIntegratorSettings, multiArcIntegratorSettings, hybridArcPropagatorSettings, parametersToEstimate, integrationArcStarts ); // Propagate requested equations. if( propagateVariationalEquations ) { variationalEquations.integrateVariationalAndDynamicalEquations( variationalEquations.getPropagatorSettings( )->getInitialStates( ), 1 ); } else { variationalEquations.integrateDynamicalEquationsOfMotionOnly( variationalEquations.getPropagatorSettings( )->getInitialStates( ) ); } // Retrieve test data for( unsigned int arc = 0; arc < integrationArcEnds.size( ); arc++ ) { double testEpoch = integrationArcEnds.at( arc ) - 2.0E4; Eigen::Matrix< StateScalarType, Eigen::Dynamic, 1 > testStates = Eigen::Matrix< StateScalarType, Eigen::Dynamic, 1 >::Zero( 12 ); testStates.block( 0, 0, 6, 1 ) = bodies.at( "Mars" )->getStateInBaseFrameFromEphemeris( testEpoch ); testStates.block( 6, 0, 6, 1 ) = bodies.at( "Orbiter" )->getStateInBaseFrameFromEphemeris( testEpoch );/* - testStates.block( 0, 0, 6, 1 );*/ if( propagateVariationalEquations ) { results.first.push_back( variationalEquations.getStateTransitionMatrixInterface( )-> getCombinedStateTransitionAndSensitivityMatrix( testEpoch ) ); results.second.push_back( hybridArcPropagatorSettings->getMultiArcPropagatorSettings( )->getInitialStateList( ).at( arc ) ); Eigen::MatrixXd testMatrixDirect = variationalEquations.getStateTransitionMatrixInterface( )-> getCombinedStateTransitionAndSensitivityMatrix( testEpoch ); Eigen::MatrixXd testMatrixFull= variationalEquations.getStateTransitionMatrixInterface( )-> getFullCombinedStateTransitionAndSensitivityMatrix( testEpoch ); TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testMatrixDirect.block( 0, 0, 12, 6 ), testMatrixFull.block( 0, 0, 12, 6 ), std::numeric_limits< double >::epsilon( ) ); TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testMatrixDirect.block( 0, 6, 12, 6 ), testMatrixFull.block( 0, 6 * ( arc + 1 ), 12, 6 ), std::numeric_limits< double >::epsilon( ) ); TUDAT_CHECK_MATRIX_CLOSE_FRACTION( testMatrixDirect.block( 0, 12, 12, 2 ), testMatrixFull.block( 0, 18, 12, 2 ), std::numeric_limits< double >::epsilon( ) ); } else { results.second.push_back( testStates ); } } } return results; } BOOST_AUTO_TEST_CASE( testMarsAndOrbiterHybridArcVariationalEquationCalculation ) { std::pair< std::vector< Eigen::MatrixXd >, std::vector< Eigen::VectorXd > > currentOutput; // Define variables for numerical differentiation Eigen::Matrix< double, 12, 1> perturbedState; Eigen::Vector2d perturbedParameter; Eigen::Matrix< double, 12, 1> statePerturbation; Eigen::VectorXd parameterPerturbation; // Define parameter perturbation parameterPerturbation = ( Eigen::VectorXd( 2 ) << 1.0E20, 1.0E10 ).finished( ); statePerturbation = ( Eigen::Matrix< double, 12, 1>( )<< 1.0E10, 1.0E10, 1.0E10, 5.0E4, 5.0E4, 10.0E4, 10.0, 10.0, 10.0, 0.1, 0.1, 0.1 ).finished( ); for( unsigned int patchArcs = 0; patchArcs < 1; patchArcs++ ) { // Test for all requested propagator types. for( unsigned int k = 0; k < 1; k++ ) { std::cout<<"Propagating state transition: "<<patchArcs<<" "<<" "<<k<<std::endl; // Compute state transition and sensitivity matrices currentOutput = executeHybridArcMarsAndOrbiterSensitivitySimulation < double, double >( Eigen::Matrix< double, 12, 1 >::Zero( ), Eigen::VectorXd::Zero( 2 ), true, patchArcs ); std::vector< Eigen::MatrixXd > stateTransitionAndSensitivityMatrixAtEpoch = currentOutput.first; std::vector< Eigen::VectorXd > nominalArcStartStates; if( patchArcs ) { nominalArcStartStates = currentOutput.second; } std::vector< Eigen::MatrixXd > manualPartial; manualPartial.resize( stateTransitionAndSensitivityMatrixAtEpoch.size( ) ); for( unsigned int arc = 0; arc < manualPartial.size( ); arc++ ) { manualPartial[ arc ] = Eigen::MatrixXd::Zero( 12, 14 ); } // Numerically compute state transition matrix for( unsigned int j = 0; j < 12; j++ ) { // std::cout<<"Propagating perturbation "<<j<<std::endl; std::vector< Eigen::VectorXd > upPerturbedState, upPerturbedState2, downPerturbedState2, downPerturbedState; perturbedState.setZero( ); perturbedState( j ) += statePerturbation( j ); upPerturbedState = executeHybridArcMarsAndOrbiterSensitivitySimulation< double, double >( perturbedState, Eigen::VectorXd::Zero( 2 ), false, false, nominalArcStartStates ).second; perturbedState.setZero( ); perturbedState( j ) += 0.5 * statePerturbation( j ); upPerturbedState2 = executeHybridArcMarsAndOrbiterSensitivitySimulation< double, double >( perturbedState, Eigen::VectorXd::Zero( 2 ), false, false, nominalArcStartStates ).second; perturbedState.setZero( ); perturbedState( j ) -= 0.5 * statePerturbation( j ); downPerturbedState2 = executeHybridArcMarsAndOrbiterSensitivitySimulation< double, double >( perturbedState, Eigen::VectorXd::Zero( 2 ), false, false, nominalArcStartStates ).second; perturbedState.setZero( ); perturbedState( j ) -= statePerturbation( j ); downPerturbedState = executeHybridArcMarsAndOrbiterSensitivitySimulation< double, double >( perturbedState, Eigen::VectorXd::Zero( 2 ), false, false, nominalArcStartStates ).second; for( unsigned int arc = 0; arc < upPerturbedState.size( ); arc++ ) { manualPartial[ arc ].block( 0, j, 12, 1 ) = ( -upPerturbedState[ arc ] + 8.0 * upPerturbedState2[ arc ] - 8.0 * downPerturbedState2[ arc ] + downPerturbedState[ arc ] ) / ( 6.0 * statePerturbation( j ) ); } } //Numerically compute sensitivity matrix for( unsigned int j = 0; j < 2; j ++ ) { std::vector< Eigen::VectorXd > upPerturbedState, upPerturbedState2, downPerturbedState2, downPerturbedState; perturbedState.setZero( ); Eigen::Vector2d upPerturbedParameter, downPerturbedParameter; perturbedParameter.setZero( ); perturbedParameter( j ) += parameterPerturbation( j ); upPerturbedState = executeHybridArcMarsAndOrbiterSensitivitySimulation< double, double >( perturbedState, perturbedParameter, false, false, nominalArcStartStates).second; perturbedParameter.setZero( ); perturbedParameter( j ) += 0.5 * parameterPerturbation( j ); upPerturbedState2 = executeHybridArcMarsAndOrbiterSensitivitySimulation< double, double >( perturbedState, perturbedParameter, false, false, nominalArcStartStates ).second; perturbedParameter.setZero( ); perturbedParameter( j ) -= 0.5 * parameterPerturbation( j ); downPerturbedState2 = executeHybridArcMarsAndOrbiterSensitivitySimulation< double, double >( perturbedState, perturbedParameter, false, false, nominalArcStartStates ).second; perturbedParameter.setZero( ); perturbedParameter( j ) -= parameterPerturbation( j ); downPerturbedState = executeHybridArcMarsAndOrbiterSensitivitySimulation< double, double >( perturbedState, perturbedParameter, false, false, nominalArcStartStates ).second; for( unsigned int arc = 0; arc < upPerturbedState.size( ); arc++ ) { manualPartial[ arc ].block( 0, j + 12, 12, 1 ) = ( -upPerturbedState[ arc ] + 8.0 * upPerturbedState2[ arc ] - 8.0 * downPerturbedState2[ arc ] + downPerturbedState[ arc ] ) / ( 6.0 * parameterPerturbation( j ) ); } } for( unsigned int arc = 0; arc < manualPartial.size( ); arc++ ) { TUDAT_CHECK_MATRIX_CLOSE_FRACTION( stateTransitionAndSensitivityMatrixAtEpoch.at( arc ).block( 0, 0, 6, 6 ), manualPartial.at( arc ).block( 0, 0, 6, 6 ), 5.0E-5 ); TUDAT_CHECK_MATRIX_CLOSE_FRACTION( stateTransitionAndSensitivityMatrixAtEpoch.at( arc ).block( 6, 6, 6, 6 ), manualPartial.at( arc ).block( 6, 6, 6, 6 ), 5.0E-5 ); double couplingTolerance; if( arc == 0 ) { couplingTolerance = 5.0E-1; } else if( arc == 1 || patchArcs ) { couplingTolerance = 5.0E-2; } else { couplingTolerance = 1.0E-2; } // One component is, by chance, not computed to within relative precision (due to small numerical value), // next lines mitigate if( patchArcs == 0 ) { stateTransitionAndSensitivityMatrixAtEpoch[ arc ]( 7, 4 ) = 0.0; manualPartial[ arc ]( 7, 4 ) = 0.0; } TUDAT_CHECK_MATRIX_CLOSE_FRACTION( stateTransitionAndSensitivityMatrixAtEpoch.at( arc ).block( 6, 0, 6, 6 ), manualPartial.at( arc ).block( 6, 0, 6, 6 ), couplingTolerance ); TUDAT_CHECK_MATRIX_CLOSE_FRACTION( stateTransitionAndSensitivityMatrixAtEpoch.at( arc ).block( 0, 12, 6, 1 ), manualPartial.at( arc ).block( 0, 12, 6, 1 ), 5.0E-5 ); TUDAT_CHECK_MATRIX_CLOSE_FRACTION( stateTransitionAndSensitivityMatrixAtEpoch.at( arc ).block( 6, 12, 6, 1 ), manualPartial.at( arc ).block( 6, 12, 6, 1 ), 5.0E-3 ); TUDAT_CHECK_MATRIX_CLOSE_FRACTION( stateTransitionAndSensitivityMatrixAtEpoch.at( arc ).block( 6, 13, 6, 1 ), manualPartial.at( arc ).block( 6, 13, 6, 1 ), 5.0E-5 ); // std::cout<<"Arc: "<<arc<<std::endl<<stateTransitionAndSensitivityMatrixAtEpoch.at( arc ).block( 6, 0, 6, 6 )<<std::endl<<std::endl<< // manualPartial.at( arc ).block( 6, 0, 6, 6 )<<std::endl<<std::endl<< // ( stateTransitionAndSensitivityMatrixAtEpoch.at( arc ) - manualPartial.at( arc ) ).block( 6, 0, 6, 6 ).cwiseQuotient( // manualPartial.at( arc ).block( 6, 0, 6, 6 ) )<<std::endl<<std::endl; // std::cout<<"Arc: "<<arc<<std::endl<<stateTransitionAndSensitivityMatrixAtEpoch.at( arc ).block( 0, 12, 12, 2 )<<std::endl<<std::endl<< // manualPartial.at( arc ).block( 0, 12, 12, 2 )<<std::endl<<std::endl<< // ( stateTransitionAndSensitivityMatrixAtEpoch.at( arc ) - manualPartial.at( arc ) ).block( 0, 12, 12, 2 ).cwiseQuotient( // manualPartial.at( arc ).block( 0, 12, 12, 2 ) )<<std::endl<<std::endl; } } } } BOOST_AUTO_TEST_CASE( testVaryingCentralBodyHybridArcVariationalEquations ) { // Load spice kernels. spice_interface::loadStandardSpiceKernels( ); // Create list of bodies to create. std::vector< std::string > bodyNames; bodyNames.push_back( "Jupiter" ); bodyNames.push_back( "Io" ); bodyNames.push_back( "Europa" ); bodyNames.push_back( "Ganymede" ); // Specify initial time double initialTime = 0.0; double finalTime = 4.0 * 86400.0; // Get body settings. BodyListSettings bodySettings = getDefaultBodySettings( bodyNames, initialTime - 3600.0, finalTime + 3600.0, "Jupiter", "ECLIPJ2000" ); // Create bodies needed in simulation SystemOfBodies bodies = createSystemOfBodies( bodySettings ); bodies.createEmptyBody( "Spacecraft" ); bodies.at( "Spacecraft" )->setEphemeris( std::make_shared< MultiArcEphemeris >( std::map< double, std::shared_ptr< Ephemeris > >( ), "Jupiter", "ECLIPJ2000" ) ); bodies.processBodyFrameDefinitions( ); SelectedAccelerationMap singleArcAccelerationMap; std::vector< std::string > singleArcBodiesToPropagate = { "Io", "Europa", "Ganymede" }; std::vector< std::string > singleArcCentralBodies = { "Jupiter", "Jupiter", "Jupiter" }; for( unsigned int i = 0; i < singleArcBodiesToPropagate.size( ); i++ ) { singleArcAccelerationMap[ singleArcBodiesToPropagate.at( i ) ][ "Jupiter" ].push_back( std::make_shared< AccelerationSettings >( basic_astrodynamics::point_mass_gravity ) ); for( unsigned int j = 0; j < singleArcBodiesToPropagate.size( ); j++ ) { if( i != j ) { singleArcAccelerationMap[ singleArcBodiesToPropagate.at( i ) ][ singleArcBodiesToPropagate.at( j ) ].push_back( std::make_shared< AccelerationSettings >( basic_astrodynamics::point_mass_gravity ) ); } } } basic_astrodynamics::AccelerationMap singleArcAccelerationModelMap = createAccelerationModelsMap( bodies, singleArcAccelerationMap, singleArcBodiesToPropagate, singleArcCentralBodies ); Eigen::VectorXd singleArcInitialState = getInitialStatesOfBodies( singleArcBodiesToPropagate, singleArcCentralBodies, bodies, initialTime ); std::shared_ptr< TranslationalStatePropagatorSettings< double > > singleArcPropagatorSettings = std::make_shared< TranslationalStatePropagatorSettings< double > > ( singleArcCentralBodies, singleArcAccelerationModelMap, singleArcBodiesToPropagate,singleArcInitialState, finalTime ); std::vector< std::string > multiArcBodiesToPropagate = { "Spacecraft", "Spacecraft", "Spacecraft", "Spacecraft", "Spacecraft", "Spacecraft" }; std::vector< std::string > multiArcCentralBodies = { "Io", "Ganymede", "Europa", "Ganymede", "Io", "Europa" }; std::vector< double > arcStartTimes = { 3600.0, 3.0 * 3600, 5.0 * 3600.0, 7.0 * 3600.0, 9.0 * 3600.0, 11.0 * 3600.0 }; std::map< std::string, std::vector< double > > arcStartTimesPerBody; for( unsigned int i = 0; i < arcStartTimes.size( ); i++ ) { arcStartTimesPerBody[ multiArcCentralBodies.at( i ) ].push_back( arcStartTimes.at( i ) ); } double arcDuration = 3600.0; std::vector< Eigen::VectorXd > multiArcSystemInitialStates; std::vector< std::shared_ptr< SingleArcPropagatorSettings< double > > > multiArcPropagationSettingsList; std::map< std::string, std::vector< std::shared_ptr< SingleArcPropagatorSettings< double > > > > multiArcPropagationSettingsListPerCentralBody; std::map< std::string, std::vector< int > > perBodyIndicesInFullPropagation; for( unsigned int i = 0; i < arcStartTimes.size( ); i++ ) { Eigen::Vector6d spacecraftInitialStateInKeplerianElements; spacecraftInitialStateInKeplerianElements( semiMajorAxisIndex ) = 3500.0E3; spacecraftInitialStateInKeplerianElements( eccentricityIndex ) = 0.1; spacecraftInitialStateInKeplerianElements( inclinationIndex ) = unit_conversions::convertDegreesToRadians( static_cast< double >( i * 30 ) ); spacecraftInitialStateInKeplerianElements( argumentOfPeriapsisIndex ) = unit_conversions::convertDegreesToRadians( static_cast< double >( i * 30 ) ); spacecraftInitialStateInKeplerianElements( longitudeOfAscendingNodeIndex ) = unit_conversions::convertDegreesToRadians( static_cast< double >( i * 30 ) ); spacecraftInitialStateInKeplerianElements( trueAnomalyIndex ) = unit_conversions::convertDegreesToRadians( static_cast< double >( i * 30 ) ); double centralBodyGravitationalParameter = bodies.at( multiArcCentralBodies.at( i ) )->getGravityFieldModel( )->getGravitationalParameter( ); multiArcSystemInitialStates.push_back( convertKeplerianToCartesianElements( spacecraftInitialStateInKeplerianElements, centralBodyGravitationalParameter ) ); SelectedAccelerationMap multiArcAccelerationMap; multiArcAccelerationMap[ "Spacecraft" ][ "Jupiter" ].push_back( std::make_shared< AccelerationSettings >( basic_astrodynamics::point_mass_gravity ) ); for( unsigned int i = 0; i < singleArcBodiesToPropagate.size( ); i++ ) { multiArcAccelerationMap[ "Spacecraft" ][ singleArcBodiesToPropagate.at( i ) ].push_back( std::make_shared< AccelerationSettings >( basic_astrodynamics::point_mass_gravity ) ); } basic_astrodynamics::AccelerationMap multiArcAccelerationModelMap = createAccelerationModelsMap( bodies, multiArcAccelerationMap, { multiArcBodiesToPropagate.at( i ) }, { multiArcCentralBodies.at( i ) } ); multiArcPropagationSettingsList.push_back( std::make_shared< TranslationalStatePropagatorSettings< double > > ( std::vector< std::string >{ multiArcCentralBodies.at( i ) }, multiArcAccelerationModelMap, std::vector< std::string >{ multiArcBodiesToPropagate.at( i ) }, multiArcSystemInitialStates.at( i ), arcStartTimes.at( i ) + arcDuration ) ); multiArcPropagationSettingsListPerCentralBody[ multiArcCentralBodies.at( i ) ].push_back( std::make_shared< TranslationalStatePropagatorSettings< double > > ( std::vector< std::string >{ multiArcCentralBodies.at( i ) }, multiArcAccelerationModelMap, std::vector< std::string >{ multiArcBodiesToPropagate.at( i ) }, multiArcSystemInitialStates.at( i ), arcStartTimes.at( i ) + arcDuration ) ); perBodyIndicesInFullPropagation[ multiArcCentralBodies.at( i ) ].push_back( i ); } std::shared_ptr< MultiArcPropagatorSettings< > > multiArcPropagationSettings = std::make_shared< MultiArcPropagatorSettings< > >( multiArcPropagationSettingsList ); std::shared_ptr< HybridArcPropagatorSettings< > > hybridArcPropagatorSettings = std::make_shared< HybridArcPropagatorSettings< > >( singleArcPropagatorSettings, multiArcPropagationSettings ); std::vector< std::shared_ptr< EstimatableParameterSettings > > parameterNames; parameterNames = getInitialHybridArcParameterSettings< >( hybridArcPropagatorSettings, bodies, arcStartTimes ); for( unsigned int i = 0; i < singleArcBodiesToPropagate.size( ); i++ ) { parameterNames.push_back( std::make_shared< EstimatableParameterSettings >( singleArcBodiesToPropagate.at( i ), gravitational_parameter ) ); } std::shared_ptr< estimatable_parameters::EstimatableParameterSet< double > > parametersToEstimate = createParametersToEstimate< double >( parameterNames, bodies, hybridArcPropagatorSettings ); printEstimatableParameterEntries( parametersToEstimate ); std::shared_ptr< IntegratorSettings< > > singleArcIntegratorSettings = std::make_shared< IntegratorSettings< > > ( rungeKutta4, initialTime, 60.0 ); std::shared_ptr< IntegratorSettings< > > multiArcIntegratorSettings = std::make_shared< IntegratorSettings< > > ( rungeKutta4, TUDAT_NAN, 15.0 ); // Create dynamics simulator HybridArcVariationalEquationsSolver< > variationalEquations = HybridArcVariationalEquationsSolver< >( bodies, singleArcIntegratorSettings, multiArcIntegratorSettings, hybridArcPropagatorSettings, parametersToEstimate, arcStartTimes, true, false, true ); std::vector< std::vector< std::map< double, Eigen::MatrixXd > > > fullMultiArcVariationalSolution = variationalEquations.getMultiArcSolver( )->getNumericalVariationalEquationsSolution( ); std::vector< std::map< double, Eigen::VectorXd > > fullMultiArcStateSolution = variationalEquations.getMultiArcSolver( )->getDynamicsSimulator( )->getEquationsOfMotionNumericalSolution( ); for( unsigned int i = 0; i < singleArcBodiesToPropagate.size( ); i++ ) { std::shared_ptr< MultiArcPropagatorSettings< > > multiArcPerBodyPropagationSettings = std::make_shared< MultiArcPropagatorSettings< > >( multiArcPropagationSettingsListPerCentralBody.at( singleArcBodiesToPropagate.at( i ) ) ); std::shared_ptr< HybridArcPropagatorSettings< > > hybridArcPerBodyPropagatorSettings = std::make_shared< HybridArcPropagatorSettings< > >( singleArcPropagatorSettings, multiArcPerBodyPropagationSettings ); std::vector< std::shared_ptr< EstimatableParameterSettings > > parameterNamesPerBody; parameterNamesPerBody = getInitialHybridArcParameterSettings< >( hybridArcPerBodyPropagatorSettings, bodies, arcStartTimesPerBody.at( singleArcBodiesToPropagate.at( i ) ) ); for( unsigned int j = 0; j < singleArcBodiesToPropagate.size( ); j++ ) { parameterNamesPerBody.push_back( std::make_shared< EstimatableParameterSettings >( singleArcBodiesToPropagate.at( j ), gravitational_parameter ) ); } std::shared_ptr< estimatable_parameters::EstimatableParameterSet< double > > parametersToEstimatePerBody = createParametersToEstimate< double >( parameterNamesPerBody, bodies, hybridArcPerBodyPropagatorSettings ); printEstimatableParameterEntries( parametersToEstimatePerBody ); HybridArcVariationalEquationsSolver< > perCentralBodyVariationalEquations = HybridArcVariationalEquationsSolver< >( bodies, singleArcIntegratorSettings, multiArcIntegratorSettings, hybridArcPerBodyPropagatorSettings, parametersToEstimatePerBody, arcStartTimesPerBody.at( singleArcBodiesToPropagate.at( i ) ), true, false, true ); std::vector< std::vector< std::map< double, Eigen::MatrixXd > > > perBodyMultiArcVariationalSolution = perCentralBodyVariationalEquations.getMultiArcSolver( )->getNumericalVariationalEquationsSolution( ); std::vector< std::map< double, Eigen::VectorXd > > perBodyMultiArcStateSolution = perCentralBodyVariationalEquations.getMultiArcSolver( )->getDynamicsSimulator( )->getEquationsOfMotionNumericalSolution( ); for( unsigned int j = 0; j < perBodyIndicesInFullPropagation.at( singleArcBodiesToPropagate.at( i ) ).size( ); j++ ) { for( unsigned int k = 0; k < 2; k++ ) { std::map< double, Eigen::MatrixXd > fullMultiArcMatrixHistory = fullMultiArcVariationalSolution.at( perBodyIndicesInFullPropagation.at( singleArcBodiesToPropagate.at( i ) ).at( j ) ).at( k ); std::map< double, Eigen::MatrixXd > perBodyMultiMatrixHistory = perBodyMultiArcVariationalSolution.at( j ).at( k ); auto fullIterator = fullMultiArcMatrixHistory.begin( ); auto perBodyIterator = perBodyMultiMatrixHistory.begin( ); BOOST_CHECK_EQUAL( fullMultiArcMatrixHistory.size( ), perBodyMultiMatrixHistory.size( ) ); for( unsigned int i = 0; i < fullMultiArcMatrixHistory.size( ); i++ ) { BOOST_CHECK_CLOSE_FRACTION( fullIterator->first, perBodyIterator->first, std::numeric_limits< double >::epsilon( ) ); TUDAT_CHECK_MATRIX_CLOSE_FRACTION( fullIterator->second, perBodyIterator->second, std::numeric_limits< double >::epsilon( ) ); fullIterator++; perBodyIterator++; } } } } } BOOST_AUTO_TEST_SUITE_END( ) } }
52.391421
170
0.647426
kimonito98
ee8ab28b4c34f9b1e139f140a46912e4b7e09cee
2,387
cpp
C++
FreeNOS/lib/libnet/ICMPSocket.cpp
magic428/src_code_read
2db267cb86bfb62f7343ac7590a0ab1fe43f9b2a
[ "MIT" ]
null
null
null
FreeNOS/lib/libnet/ICMPSocket.cpp
magic428/src_code_read
2db267cb86bfb62f7343ac7590a0ab1fe43f9b2a
[ "MIT" ]
null
null
null
FreeNOS/lib/libnet/ICMPSocket.cpp
magic428/src_code_read
2db267cb86bfb62f7343ac7590a0ab1fe43f9b2a
[ "MIT" ]
1
2018-11-18T06:41:11.000Z
2018-11-18T06:41:11.000Z
/* * Copyright (C) 2015 Niek Linnenbank * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <FreeNOS/System.h> #include "Ethernet.h" #include "IPV4.h" #include "ICMP.h" #include "ICMPSocket.h" #include "NetworkClient.h" ICMPSocket::ICMPSocket(ICMP *icmp) : NetworkSocket(icmp->getMaximumPacketSize()) { m_icmp = icmp; m_gotReply = false; MemoryBlock::set(&m_info, 0, sizeof(m_info)); } ICMPSocket::~ICMPSocket() { } const IPV4::Address ICMPSocket::getAddress() const { return m_info.address; } Error ICMPSocket::read(IOBuffer & buffer, Size size, Size offset) { DEBUG(""); //if (offset >= sizeof(ICMP::Header)) // return 0; // TODO: use a timeout on the ICMP socket if (!m_gotReply) return EAGAIN; m_gotReply = false; buffer.write(&m_reply, sizeof(m_reply)); return sizeof(m_reply); } Error ICMPSocket::write(IOBuffer & buffer, Size size, Size offset) { DEBUG(""); // Receive socket information first? if (!m_info.address) { buffer.read(&m_info, sizeof(m_info)); return size; } else { ICMP::Header header; buffer.read(&header, sizeof(header)); Error r = m_icmp->sendPacket(m_info.address, &header); if (r != ESUCCESS) return r; } return size; } Error ICMPSocket::process(NetworkQueue::Packet *pkt) { DEBUG(""); return ESUCCESS; } void ICMPSocket::error(Error err) { DEBUG(""); // Set the ethernet reply result code // The read operation uses the result code // m_ethResult = err; } void ICMPSocket::setReply(ICMP::Header *header) { DEBUG(""); if (!m_gotReply) { MemoryBlock::copy(&m_reply, header, sizeof(ICMP::Header)); m_gotReply = true; } }
22.518868
72
0.654378
magic428
ee8c871c1518234b8f19b592978657bff6813768
1,786
hpp
C++
bindings/python/crocoddyl/multibody/data/multibody.hpp
imaroger/crocoddyl
3d3b9470563e6b7c860679d72ee220642658cc68
[ "BSD-3-Clause" ]
1
2020-04-25T13:17:23.000Z
2020-04-25T13:17:23.000Z
bindings/python/crocoddyl/multibody/data/multibody.hpp
Capri2014/crocoddyl
341874fbad4507d6ed4e05e18e4a9cedf5470d01
[ "BSD-3-Clause" ]
null
null
null
bindings/python/crocoddyl/multibody/data/multibody.hpp
Capri2014/crocoddyl
341874fbad4507d6ed4e05e18e4a9cedf5470d01
[ "BSD-3-Clause" ]
null
null
null
/////////////////////////////////////////////////////////////////////////////// // BSD 3-Clause License // // Copyright (C) 2018-2020, University of Edinburgh // Copyright note valid unless otherwise stated in individual files. // All rights reserved. /////////////////////////////////////////////////////////////////////////////// #ifndef BINDINGS_PYTHON_CROCODDYL_MULTIBODY_DATA_MULTIBODY_HPP_ #define BINDINGS_PYTHON_CROCODDYL_MULTIBODY_DATA_MULTIBODY_HPP_ #include "crocoddyl/multibody/data/multibody.hpp" namespace crocoddyl { namespace python { void exposeDataCollectorMultibody() { bp::class_<DataCollectorMultibody, bp::bases<DataCollectorAbstract> >( "DataCollectorMultibody", "Data collector for multibody systems.\n\n", bp::init<pinocchio::Data*>(bp::args("self", "pinocchio"), "Create multibody data collection.\n\n" ":param data: Pinocchio data")[bp::with_custodian_and_ward<1, 2>()]) .add_property("pinocchio", bp::make_getter(&DataCollectorMultibody::pinocchio, bp::return_internal_reference<>()), "pinocchio data"); bp::class_<DataCollectorActMultibody, bp::bases<DataCollectorMultibody, DataCollectorActuation> >( "DataCollectorActMultibody", "Data collector for actuated multibody systems.\n\n", bp::init<pinocchio::Data*, boost::shared_ptr<ActuationDataAbstract> >( bp::args("self", "pinocchio", "actuation"), "Create multibody data collection.\n\n" ":param pinocchio: Pinocchio data\n" ":param actuation: actuation data")[bp::with_custodian_and_ward<1, 2>()]); } } // namespace python } // namespace crocoddyl #endif // BINDINGS_PYTHON_CROCODDYL_MULTIBODY_DATA_MULTIBODY_HPP_
44.65
107
0.634938
imaroger
ee8cc82e9f122e8699662d2dcb490b093cd614d1
2,484
cpp
C++
Uva/Uva_AC/11063 - B2-Sequence.cpp
Saikat-S/acm-problems-solutions
921c0f3e508e1ee8cd14be867587952d5f67bbb9
[ "MIT" ]
3
2018-05-11T07:33:20.000Z
2020-08-30T11:02:02.000Z
Uva/Uva_AC/11063 - B2-Sequence.cpp
Saikat-S/acm-problems-solutions
921c0f3e508e1ee8cd14be867587952d5f67bbb9
[ "MIT" ]
1
2018-05-11T18:10:26.000Z
2018-05-12T18:00:28.000Z
Uva/Uva_AC/11063 - B2-Sequence.cpp
Saikat-S/acm-problems-solutions
921c0f3e508e1ee8cd14be867587952d5f67bbb9
[ "MIT" ]
null
null
null
/*************************************************** * Problem name : 11063 - B2-Sequence.cpp * Problem Link : https://uva.onlinejudge.org/external/110/11063.pdf * OJ : Uva * Verdict : AC * Date : 2017-07-29 * Problem Type : AdHoc * Author Name : Saikat Sharma * University : CSE,MBSTU ***************************************************/ #include<iostream> #include<cstdio> #include<algorithm> #include<climits> #include<cstring> #include<string> #include<sstream> #include<cmath> #include<vector> #include<queue> #include<cstdlib> #include<deque> #include<stack> #include<map> #include<set> #define __FastIO ios_base::sync_with_stdio(false); cin.tie(0) #define SET(a) memset(a,-1,sizeof(a)) #define pii pair<int,int> #define pll pair <int, int> #define debug printf("#########\n") #define nl printf("\n") #define sl(n) scanf("%lld", &n) #define sf(n) scanf("%lf", &n) #define si(n) scanf("%d", &n) #define ss(n) scanf("%s", n) #define pb push_back #define MAX 1000 using namespace std; typedef long long ll; typedef unsigned long long ull; template <typename T> std::string NumberToString ( T Number ) { std::ostringstream ss; ss << Number; return ss.str(); } ll gcd(ll a, ll b) { if (a % b == 0) return b; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } /************************************ Code Start Here ******************************************************/ int main () { int n, ar[MAX], t = 1; while (scanf("%d", &n) == 1) { int chk = 0, f = 0; for (int i = 0; i < n; i++) { scanf("%d", &ar[i]); if (chk < ar[i]) { chk = ar[i]; } else { f = 1; } } if (f == 1) { printf("Case #%d: It is not a B2-Sequence.\n", t++); nl; continue; } map<int, int>mp; bool flag = false; for (int i = 0; i < n - 1; i++) { for (int j = i; j < n; j++) { int x = ar[i] + ar[j]; //~ printf("%d ", x); if (mp[x] != 0) { flag = true; break; } else { mp[x] = 1; } } } if (!flag) printf("Case #%d: It is a B2-Sequence.\n", t++); else printf("Case #%d: It is not a B2-Sequence.\n", t++); nl; mp.clear(); } return 0; }
26.147368
109
0.449678
Saikat-S
ee8fddf09fb08b761d3fb16e4c3c586edd1e6435
5,448
cpp
C++
Plain/src/Runtime/Rendering/Techniques/Bloom.cpp
Gaukler/PlainRenderer
cf0f41a2300bee9f29a886230c061776cb29ba5e
[ "MIT" ]
9
2021-04-09T14:07:45.000Z
2022-03-06T07:51:14.000Z
Plain/src/Runtime/Rendering/Techniques/Bloom.cpp
Gaukler/PlainRenderer
cf0f41a2300bee9f29a886230c061776cb29ba5e
[ "MIT" ]
14
2021-04-10T11:06:06.000Z
2021-05-07T14:20:34.000Z
Plain/src/Runtime/Rendering/Techniques/Bloom.cpp
Gaukler/PlainRenderer
cf0f41a2300bee9f29a886230c061776cb29ba5e
[ "MIT" ]
null
null
null
#include "pch.h" #include "Bloom.h" #include "Utilities/GeneralUtils.h" #include "Utilities/MathUtils.h" const int bloomMipCount = 6; void Bloom::init(const int textureWidth, const int textureHeight) { // bloom downsample for (int i = 0; i < bloomMipCount - 1; i++) { ComputePassDescription desc; const int mip = i + 1; desc.name = "Bloom downsample mip " + std::to_string(mip); desc.shaderDescription.srcPathRelative = "bloomDownsample.comp"; m_bloomDownsamplePasses.push_back(gRenderBackend.createComputePass(desc)); } // bloom upsample for (int i = 0; i < bloomMipCount - 1; i++) { ComputePassDescription desc; const int mip = bloomMipCount - 2 - i; desc.name = "Bloom Upsample mip " + std::to_string(mip); desc.shaderDescription.srcPathRelative = "bloomUpsample.comp"; const bool isLowestMip = i == 0; desc.shaderDescription.specialisationConstants = { SpecialisationConstant{ 0, //location dataToCharArray((void*)&isLowestMip, sizeof(isLowestMip))} //value }; m_bloomUpsamplePasses.push_back(gRenderBackend.createComputePass(desc)); } // apply bloom pass { ComputePassDescription desc; desc.name = "Apply bloom"; desc.shaderDescription.srcPathRelative = "applyBloom.comp"; m_applyBloomPass = gRenderBackend.createComputePass(desc); } } ImageDescription getBloomImageDescription(const uint32_t width, const uint32_t height) { ImageDescription desc; desc.width = width; desc.height = height; desc.depth = 1; desc.type = ImageType::Type2D; desc.format = ImageFormat::R11G11B10_uFloat; desc.usageFlags = ImageUsageFlags::Sampled | ImageUsageFlags::Storage; desc.mipCount = MipCount::Manual; desc.manualMipCount = bloomMipCount; desc.autoCreateMips = false; return desc; } void Bloom::computeBloom(const ImageHandle targetImage, const BloomSettings& settings) const { const ImageDescription bloomImageDescription = gRenderBackend.getImageDescription(targetImage); const int width = bloomImageDescription.width; const int height = bloomImageDescription.height; ImageDescription desc = getBloomImageDescription(width, height); const ImageHandle downscaleTexture = gRenderBackend.createTemporaryImage(desc); // downscale for (int i = 0; i < m_bloomDownsamplePasses.size(); i++) { ComputePassExecution exe; exe.genericInfo.handle = m_bloomDownsamplePasses[i]; const int sourceMip = i; const int targetMip = i + 1; const ImageHandle srcTexture = i == 0 ? targetImage : downscaleTexture; exe.genericInfo.resources.storageImages = { ImageResource(downscaleTexture, targetMip, 0) }; exe.genericInfo.resources.sampledImages = { ImageResource(srcTexture, sourceMip, 1) }; const glm::ivec2 baseResolution = glm::ivec2(width, height); const glm::ivec2 targetResolution = resolutionFromMip(glm::ivec3(baseResolution, 1), targetMip); const int groupSize = 8; exe.dispatchCount[0] = (uint32_t)glm::ceil(targetResolution.x / float(groupSize)); exe.dispatchCount[1] = (uint32_t)glm::ceil(targetResolution.y / float(groupSize)); exe.dispatchCount[2] = 1; gRenderBackend.setComputePassExecution(exe); } const ImageHandle upscaleTexture = gRenderBackend.createTemporaryImage(desc); // upscale for (int i = 0; i < m_bloomUpsamplePasses.size(); i++) { ComputePassExecution exe; exe.genericInfo.handle = m_bloomUpsamplePasses[i]; const int targetMip = bloomMipCount - 2 - i; const int sourceMip = targetMip + 1; exe.genericInfo.resources.storageImages = { ImageResource(upscaleTexture, targetMip, 0) }; exe.genericInfo.resources.sampledImages = { ImageResource(upscaleTexture, sourceMip, 1), ImageResource(downscaleTexture, sourceMip, 2) }; const glm::ivec2 baseResolution = glm::ivec2(width, height); const glm::ivec2 targetResolution = resolutionFromMip(glm::ivec3(baseResolution, 1), targetMip); const int groupSize = 8; exe.dispatchCount[0] = (uint32_t)glm::ceil(targetResolution.x / float(groupSize)); exe.dispatchCount[1] = (uint32_t)glm::ceil(targetResolution.y / float(groupSize)); exe.dispatchCount[2] = 1; exe.pushConstants = dataToCharArray((void*)&settings.radius, sizeof(settings.radius)); gRenderBackend.setComputePassExecution(exe); } // apply bloom { ComputePassExecution exe; exe.genericInfo.handle = m_applyBloomPass; exe.genericInfo.resources.storageImages = { ImageResource(targetImage, 0, 0) }; exe.genericInfo.resources.sampledImages = { ImageResource(upscaleTexture, 0, 1) }; const int groupSize = 8; exe.dispatchCount[0] = (uint32_t)glm::ceil(width / float(groupSize)); exe.dispatchCount[1] = (uint32_t)glm::ceil(height / float(groupSize)); exe.dispatchCount[2] = 1; exe.pushConstants = dataToCharArray((void*)&settings.strength, sizeof(settings.strength)); gRenderBackend.setComputePassExecution(exe); } }
37.833333
104
0.66116
Gaukler
ee90319edee5692142accdcca88e9493ac3c307f
283
cpp
C++
Part1/Chapter1/L1-9.cpp
HarmioneF/LuoguBook_Base
65637085e951574823749ef2b2584d08aa8e08d6
[ "MIT" ]
null
null
null
Part1/Chapter1/L1-9.cpp
HarmioneF/LuoguBook_Base
65637085e951574823749ef2b2584d08aa8e08d6
[ "MIT" ]
null
null
null
Part1/Chapter1/L1-9.cpp
HarmioneF/LuoguBook_Base
65637085e951574823749ef2b2584d08aa8e08d6
[ "MIT" ]
null
null
null
#include <iostream> #include <cmath> using namespace std; int main() { double r = 5; const double PI = 3.141593; // # define PI 3.14125953 cout << 2 * PI * r << endl; cout << PI * pow(r, 2) << endl; cout << 4.0 / 3 * PI * pow(r, 3) << endl; return 0; }
18.866667
45
0.522968
HarmioneF
ee904debfddbf375b39451bbbe8cb470f732d65e
108
cpp
C++
src/OpenCvSharpExtern/stitching.cpp
kakashasha/opencvsharp
c1f6652cec7ae211e642ae66d17c19b77abc52e7
[ "BSD-3-Clause" ]
3,886
2015-01-02T15:12:37.000Z
2022-03-31T02:30:51.000Z
src/OpenCvSharpExtern/stitching.cpp
kakashasha/opencvsharp
c1f6652cec7ae211e642ae66d17c19b77abc52e7
[ "BSD-3-Clause" ]
1,110
2015-01-15T06:18:25.000Z
2022-03-30T14:57:26.000Z
src/OpenCvSharpExtern/stitching.cpp
kakashasha/opencvsharp
c1f6652cec7ae211e642ae66d17c19b77abc52e7
[ "BSD-3-Clause" ]
1,047
2015-01-08T07:14:48.000Z
2022-03-30T08:54:30.000Z
// ReSharper disable CppUnusedIncludeDirective #include "stitching.h" #include "stitching_detail_Matchers.h"
36
46
0.842593
kakashasha
ee909d77451d31374898118b7f80a71723d2f0f3
5,955
hpp
C++
include/GlobalNamespace/LiteNetLibConnectionManager_LiteNetLibConnectionParamsBase.hpp
RedBrumbler/BeatSaber-Quest-Codegen
73dda50b5a3e51f10d86b766dcaa24b0c6226e25
[ "Unlicense" ]
null
null
null
include/GlobalNamespace/LiteNetLibConnectionManager_LiteNetLibConnectionParamsBase.hpp
RedBrumbler/BeatSaber-Quest-Codegen
73dda50b5a3e51f10d86b766dcaa24b0c6226e25
[ "Unlicense" ]
null
null
null
include/GlobalNamespace/LiteNetLibConnectionManager_LiteNetLibConnectionParamsBase.hpp
RedBrumbler/BeatSaber-Quest-Codegen
73dda50b5a3e51f10d86b766dcaa24b0c6226e25
[ "Unlicense" ]
null
null
null
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include "beatsaber-hook/shared/utils/typedefs.h" #include "beatsaber-hook/shared/utils/byref.hpp" // Including type: LiteNetLibConnectionManager #include "GlobalNamespace/LiteNetLibConnectionManager.hpp" // Including type: IConnectionInitParams`1 #include "GlobalNamespace/IConnectionInitParams_1.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp" #include "beatsaber-hook/shared/utils/utils.h" // Completed includes // Begin forward declares // Forward declaring namespace: GlobalNamespace namespace GlobalNamespace { // Forward declaring type: IConnectionRequestHandler class IConnectionRequestHandler; } // Completed forward declares #include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp" NEED_NO_BOX(::GlobalNamespace::LiteNetLibConnectionManager::LiteNetLibConnectionParamsBase); DEFINE_IL2CPP_ARG_TYPE(::GlobalNamespace::LiteNetLibConnectionManager::LiteNetLibConnectionParamsBase*, "", "LiteNetLibConnectionManager/LiteNetLibConnectionParamsBase"); // Type namespace: namespace GlobalNamespace { // Size: 0x24 #pragma pack(push, 1) // Autogenerated type: LiteNetLibConnectionManager/LiteNetLibConnectionParamsBase // [TokenAttribute] Offset: FFFFFFFF class LiteNetLibConnectionManager::LiteNetLibConnectionParamsBase : public ::Il2CppObject/*, public ::GlobalNamespace::IConnectionInitParams_1<::GlobalNamespace::LiteNetLibConnectionManager*>*/ { public: #ifdef USE_CODEGEN_FIELDS public: #else #ifdef CODEGEN_FIELD_ACCESSIBILITY CODEGEN_FIELD_ACCESSIBILITY: #else protected: #endif #endif // public IConnectionRequestHandler connectionRequestHandler // Size: 0x8 // Offset: 0x10 ::GlobalNamespace::IConnectionRequestHandler* connectionRequestHandler; // Field size check static_assert(sizeof(::GlobalNamespace::IConnectionRequestHandler*) == 0x8); // public System.Int32 port // Size: 0x4 // Offset: 0x18 int port; // Field size check static_assert(sizeof(int) == 0x4); // public System.Boolean filterUnencryptedTraffic // Size: 0x1 // Offset: 0x1C bool filterUnencryptedTraffic; // Field size check static_assert(sizeof(bool) == 0x1); // public System.Boolean enableUnconnectedMessages // Size: 0x1 // Offset: 0x1D bool enableUnconnectedMessages; // Field size check static_assert(sizeof(bool) == 0x1); // public System.Boolean enableBackgroundSentry // Size: 0x1 // Offset: 0x1E bool enableBackgroundSentry; // Field size check static_assert(sizeof(bool) == 0x1); // public System.Boolean enableStatistics // Size: 0x1 // Offset: 0x1F bool enableStatistics; // Field size check static_assert(sizeof(bool) == 0x1); // public System.Int32 disconnectTimeoutMs // Size: 0x4 // Offset: 0x20 int disconnectTimeoutMs; // Field size check static_assert(sizeof(int) == 0x4); public: // Creating interface conversion operator: operator ::GlobalNamespace::IConnectionInitParams_1<::GlobalNamespace::LiteNetLibConnectionManager*> operator ::GlobalNamespace::IConnectionInitParams_1<::GlobalNamespace::LiteNetLibConnectionManager*>() noexcept { return *reinterpret_cast<::GlobalNamespace::IConnectionInitParams_1<::GlobalNamespace::LiteNetLibConnectionManager*>*>(this); } // Get instance field reference: public IConnectionRequestHandler connectionRequestHandler ::GlobalNamespace::IConnectionRequestHandler*& dyn_connectionRequestHandler(); // Get instance field reference: public System.Int32 port int& dyn_port(); // Get instance field reference: public System.Boolean filterUnencryptedTraffic bool& dyn_filterUnencryptedTraffic(); // Get instance field reference: public System.Boolean enableUnconnectedMessages bool& dyn_enableUnconnectedMessages(); // Get instance field reference: public System.Boolean enableBackgroundSentry bool& dyn_enableBackgroundSentry(); // Get instance field reference: public System.Boolean enableStatistics bool& dyn_enableStatistics(); // Get instance field reference: public System.Int32 disconnectTimeoutMs int& dyn_disconnectTimeoutMs(); // protected System.Void .ctor() // Offset: 0x164BD74 // Implemented from: System.Object // Base method: System.Void Object::.ctor() template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary> static LiteNetLibConnectionManager::LiteNetLibConnectionParamsBase* New_ctor() { static auto ___internal__logger = ::Logger::get().WithContext("::GlobalNamespace::LiteNetLibConnectionManager::LiteNetLibConnectionParamsBase::.ctor"); return THROW_UNLESS((::il2cpp_utils::New<LiteNetLibConnectionManager::LiteNetLibConnectionParamsBase*, creationType>())); } }; // LiteNetLibConnectionManager/LiteNetLibConnectionParamsBase #pragma pack(pop) static check_size<sizeof(LiteNetLibConnectionManager::LiteNetLibConnectionParamsBase), 32 + sizeof(int)> __GlobalNamespace_LiteNetLibConnectionManager_LiteNetLibConnectionParamsBaseSizeCheck; static_assert(sizeof(LiteNetLibConnectionManager::LiteNetLibConnectionParamsBase) == 0x24); } #include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" // Writing MetadataGetter for method: GlobalNamespace::LiteNetLibConnectionManager::LiteNetLibConnectionParamsBase::New_ctor // Il2CppName: .ctor // Cannot get method pointer of value based method overload from template for constructor! // Try using FindMethod instead!
48.024194
198
0.743913
RedBrumbler
ee91dc1e388d4dc31cfdcddda141e1f95f92952f
3,793
cpp
C++
modules/box2d/shiva/box2d/system-box2d.cpp
Milerius/rs_engine
d25b54147f2f9a4710e3015c4eed7d076e3de04b
[ "MIT" ]
176
2018-06-06T12:20:21.000Z
2022-01-27T02:54:34.000Z
modules/box2d/shiva/box2d/system-box2d.cpp
Milerius/rs_engine
d25b54147f2f9a4710e3015c4eed7d076e3de04b
[ "MIT" ]
11
2018-06-09T21:30:02.000Z
2019-09-14T16:03:12.000Z
modules/box2d/shiva/box2d/system-box2d.cpp
Milerius/rs_engine
d25b54147f2f9a4710e3015c4eed7d076e3de04b
[ "MIT" ]
19
2018-08-15T11:40:02.000Z
2020-08-31T11:00:44.000Z
// // Created by roman Sztergbaum on 16/08/2018. // #include <boost/dll.hpp> #include <shiva/box2d/system-box2d.hpp> #include <shiva/ecs/components/physics_2d.hpp> #include "system-box2d.hpp" #include "box2d_component.hpp" namespace shiva::plugins { //! Constructor box2d_system::box2d_system(shiva::entt::dispatcher &dispatcher, shiva::entt::entity_registry &registry, const float &fixed_delta_time) noexcept : system(dispatcher, registry, fixed_delta_time, true), listener_(dispatcher) { world_.SetContactListener(&listener_); } //! Public static functions std::unique_ptr<shiva::ecs::base_system> box2d_system::system_creator(entt::dispatcher &dispatcher, entt::entity_registry &registry, const float &fixed_delta_time) noexcept { return std::make_unique<shiva::plugins::box2d_system>(dispatcher, registry, fixed_delta_time); } //! Public member function overriden void box2d_system::update() noexcept { auto update_functor = []([[maybe_unused]] auto entity, auto &&transform, auto &&physics) { auto body = std::static_pointer_cast<shiva::box2d::box2d_component>(physics.physics_)->body; body->SetTransform(b2Vec2(transform.x, transform.y), body->GetAngle()); }; entity_registry_.view<shiva::ecs::transform_2d, shiva::ecs::physics_2d>().each(update_functor); this->world_.Step(this->fixed_delta_time_, 6, 2); } //! Reflection constexpr auto box2d_system::reflected_functions() noexcept { return meta::makeMap(); } constexpr auto box2d_system::reflected_members() noexcept { return meta::makeMap(); } void box2d_system::on_set_user_data_() noexcept { state_ = static_cast<sol::state *>(user_data_); assert(state_ != nullptr); shiva::lua::register_type<box2d_system>(*state_, log_); (*state_).new_enum<b2BodyType>("body_type", { {"dynamic", b2BodyType::b2_dynamicBody}, {"static", b2BodyType::b2_staticBody}, {"kinematic", b2BodyType::b2_kinematicBody} }); (*state_)[box2d_system::class_name()]["add_physics"] = [this]([[maybe_unused]] box2d_system &self, shiva::entt::entity_registry::entity_type entity, b2BodyType body_type) { if (!entity_registry_.has<shiva::ecs::transform_2d>(entity)) return; const auto &box = entity_registry_.get<shiva::ecs::transform_2d>(entity); b2BodyDef def; def.type = body_type; def.userData = &entity; const auto body = world_.CreateBody(&def); entity_registry_.assign<shiva::ecs::physics_2d>(entity, std::make_shared<shiva::box2d::box2d_component>(body)); b2PolygonShape shape; shape.SetAsBox(box.width / 30.f, box.height / 30.f); b2FixtureDef fixture_def; fixture_def.shape = &shape; fixture_def.density = 1.0f; fixture_def.friction = 1.0f; body->CreateFixture(&fixture_def); body->SetTransform(b2Vec2(box.y, box.x), body->GetAngle()); }; } } BOOST_DLL_ALIAS( shiva::plugins::box2d_system::system_creator, // <-- this function is exported with... create_plugin // <-- ...this alias name )
38.704082
119
0.568416
Milerius
ee91e8b7868a10b400c49927434077d2a90b87f4
1,258
cpp
C++
Source/ViewRoutes.cpp
DhirajWishal/DeliveryPlanningTool
6715f7c4a661bbbd4fa2cdafa14e708e74c2d65e
[ "MIT" ]
null
null
null
Source/ViewRoutes.cpp
DhirajWishal/DeliveryPlanningTool
6715f7c4a661bbbd4fa2cdafa14e708e74c2d65e
[ "MIT" ]
null
null
null
Source/ViewRoutes.cpp
DhirajWishal/DeliveryPlanningTool
6715f7c4a661bbbd4fa2cdafa14e708e74c2d65e
[ "MIT" ]
null
null
null
// Copyright (c) 2021 Dhiraj Wishal // Copyright (c) 2021 Scopic Software #include "ViewRoutes.h" #include "../ui_ViewRoutes.h" #include "ManageRoutes.h" ViewRoutes::ViewRoutes(const std::shared_ptr<ApplicationState>& pApplicationState, QWidget* parent) : QWidget(parent) , pApplicationState(pApplicationState) , pViewRoutes(std::make_unique<Ui::ViewRoutes>()) { pViewRoutes->setupUi(this); // Setup callbacks. QObject::connect(pViewRoutes->manage, &QPushButton::pressed, this, &ViewRoutes::HandleManage); // Setup routes. const auto routes = pApplicationState->GetRoutes(); for (const auto route : routes) pViewRoutes->routeList->addItem(("Route number: " + std::to_string(route.GetNumber()) + " ").c_str() + route.GetFormattedDateString()); } void ViewRoutes::HandleManage() { ManageRoutes* pRoutes = new ManageRoutes(pApplicationState, this); pRoutes->show(); } void ViewRoutes::DeleteChild(QMainWindow* pChildWindow) { delete pChildWindow; } void ViewRoutes::Refresh() { pViewRoutes->routeList->clear(); const auto routes = pApplicationState->GetRoutes(); for (const auto route : routes) pViewRoutes->routeList->addItem(("Route number: " + std::to_string(route.GetNumber()) + " ").c_str() + route.GetFormattedDateString()); }
28.590909
137
0.736884
DhirajWishal
ee92657535fbdba39d2e31b5aaf073fac1ae2bc4
1,844
cc
C++
blimp/client/core/contents/blimp_contents_view_impl_android.cc
xzhan96/chromium.src
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1
2021-01-07T18:51:03.000Z
2021-01-07T18:51:03.000Z
blimp/client/core/contents/blimp_contents_view_impl_android.cc
emilio/chromium.src
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
blimp/client/core/contents/blimp_contents_view_impl_android.cc
emilio/chromium.src
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
// Copyright 2016 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 "blimp/client/core/contents/blimp_contents_view_impl_android.h" #include "base/memory/ptr_util.h" #include "blimp/client/core/contents/android/blimp_view.h" #include "blimp/client/core/contents/android/ime_helper_dialog.h" #include "blimp/client/core/contents/blimp_contents_impl.h" #include "cc/layers/layer.h" #include "ui/android/window_android.h" namespace blimp { namespace client { // static std::unique_ptr<BlimpContentsViewImpl> BlimpContentsViewImpl::Create( BlimpContentsImpl* blimp_contents, scoped_refptr<cc::Layer> contents_layer) { return base::MakeUnique<BlimpContentsViewImplAndroid>(blimp_contents, contents_layer); } BlimpContentsViewImplAndroid::BlimpContentsViewImplAndroid( BlimpContentsImpl* blimp_contents, scoped_refptr<cc::Layer> contents_layer) : BlimpContentsViewImpl(blimp_contents, contents_layer), ime_dialog_(new ImeHelperDialog(blimp_contents->GetNativeWindow())) { blimp_view_ = base::MakeUnique<BlimpView>(blimp_contents->GetNativeWindow(), this); view_ = base::MakeUnique<ui::ViewAndroid>( blimp_view_->CreateViewAndroidDelegate()); view_->SetLayer(contents_layer); blimp_contents->GetNativeWindow()->AddChild(view_.get()); } BlimpContentsViewImplAndroid::~BlimpContentsViewImplAndroid() = default; gfx::NativeView BlimpContentsViewImplAndroid::GetNativeView() { return view_.get(); } BlimpView* BlimpContentsViewImplAndroid::GetBlimpView() { return blimp_view_.get(); } ImeFeature::Delegate* BlimpContentsViewImplAndroid::GetImeDelegate() { return ime_dialog_.get(); } } // namespace client } // namespace blimp
34.148148
75
0.759219
xzhan96
ee970101ada6acb51203aae3f54385a5da9b3f8d
57
hpp
C++
tests/core/generator.hpp
jschmold/icarus-prototype
162a180dc9b9f7db5695480f5b3adff37de8248a
[ "Apache-2.0" ]
null
null
null
tests/core/generator.hpp
jschmold/icarus-prototype
162a180dc9b9f7db5695480f5b3adff37de8248a
[ "Apache-2.0" ]
null
null
null
tests/core/generator.hpp
jschmold/icarus-prototype
162a180dc9b9f7db5695480f5b3adff37de8248a
[ "Apache-2.0" ]
null
null
null
#pragma once namespace GeneratorTests { void run(); }
9.5
26
0.701754
jschmold
ee9f115c374b83c4f3ca07d27df3c7d285e7ed7a
6,402
cc
C++
chrome/browser/web_applications/components/policy/web_app_policy_manager.cc
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/web_applications/components/policy/web_app_policy_manager.cc
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/web_applications/components/policy/web_app_policy_manager.cc
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/web_applications/components/policy/web_app_policy_manager.h" #include <algorithm> #include <utility> #include <vector> #include "base/bind.h" #include "base/bind_helpers.h" #include "base/task/post_task.h" #include "base/values.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/web_applications/components/external_install_options.h" #include "chrome/browser/web_applications/components/policy/web_app_policy_constants.h" #include "chrome/browser/web_applications/components/web_app_constants.h" #include "chrome/browser/web_applications/components/web_app_install_utils.h" #include "chrome/common/pref_names.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/prefs/pref_service.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" namespace web_app { namespace { ExternalInstallOptions ParseInstallOptionsFromPolicyEntry( const base::Value& entry) { const base::Value& url = *entry.FindKey(kUrlKey); const base::Value* default_launch_container = entry.FindKey(kDefaultLaunchContainerKey); const base::Value* create_desktop_shortcut = entry.FindKey(kCreateDesktopShorcutKey); DCHECK(!default_launch_container || default_launch_container->GetString() == kDefaultLaunchContainerWindowValue || default_launch_container->GetString() == kDefaultLaunchContainerTabValue); DisplayMode user_display_mode; if (!default_launch_container) { user_display_mode = DisplayMode::kBrowser; } else if (default_launch_container->GetString() == kDefaultLaunchContainerTabValue) { user_display_mode = DisplayMode::kBrowser; } else { user_display_mode = DisplayMode::kStandalone; } ExternalInstallOptions install_options{ GURL(url.GetString()), user_display_mode, ExternalInstallSource::kExternalPolicy}; install_options.add_to_applications_menu = true; install_options.add_to_desktop = create_desktop_shortcut ? create_desktop_shortcut->GetBool() : false; // Pinning apps to the ChromeOS shelf is done through the PinnedLauncherApps // policy. install_options.add_to_quick_launch_bar = false; return install_options; } } // namespace const char WebAppPolicyManager::kInstallResultHistogramName[]; WebAppPolicyManager::WebAppPolicyManager(Profile* profile) : profile_(profile), pref_service_(profile_->GetPrefs()) {} WebAppPolicyManager::~WebAppPolicyManager() = default; void WebAppPolicyManager::SetSubsystems( PendingAppManager* pending_app_manager) { pending_app_manager_ = pending_app_manager; } void WebAppPolicyManager::Start() { base::PostTask( FROM_HERE, {content::BrowserThread::UI, base::TaskPriority::BEST_EFFORT}, base::BindOnce(&WebAppPolicyManager:: InitChangeRegistrarAndRefreshPolicyInstalledApps, weak_ptr_factory_.GetWeakPtr())); } void WebAppPolicyManager::ReinstallPlaceholderAppIfNecessary(const GURL& url) { const base::Value* web_apps = pref_service_->GetList(prefs::kWebAppInstallForceList); const auto& web_apps_list = web_apps->GetList(); const auto it = std::find_if(web_apps_list.begin(), web_apps_list.end(), [&url](const base::Value& entry) { return entry.FindKey(kUrlKey)->GetString() == url.spec(); }); if (it == web_apps_list.end()) return; ExternalInstallOptions install_options = ParseInstallOptionsFromPolicyEntry(*it); // No need to install a placeholder because there should be one already. install_options.wait_for_windows_closed = true; install_options.reinstall_placeholder = true; // If the app is not a placeholder app, PendingAppManager will ignore the // request. pending_app_manager_->Install(std::move(install_options), base::DoNothing()); } // static void WebAppPolicyManager::RegisterProfilePrefs( user_prefs::PrefRegistrySyncable* registry) { registry->RegisterListPref(prefs::kWebAppInstallForceList); } void WebAppPolicyManager::InitChangeRegistrarAndRefreshPolicyInstalledApps() { pref_change_registrar_.Init(pref_service_); pref_change_registrar_.Add( prefs::kWebAppInstallForceList, base::BindRepeating(&WebAppPolicyManager::RefreshPolicyInstalledApps, weak_ptr_factory_.GetWeakPtr())); RefreshPolicyInstalledApps(); } void WebAppPolicyManager::RefreshPolicyInstalledApps() { // If this is called again while in progress, we will run it again once the // |SynchronizeInstalledApps| call is finished. if (is_refreshing_) { needs_refresh_ = true; return; } is_refreshing_ = true; needs_refresh_ = false; const base::Value* web_apps = pref_service_->GetList(prefs::kWebAppInstallForceList); std::vector<ExternalInstallOptions> install_options_list; // No need to validate the types or values of the policy members because we // are using a SimpleSchemaValidatingPolicyHandler which should validate them // for us. for (const base::Value& entry : web_apps->GetList()) { ExternalInstallOptions install_options = ParseInstallOptionsFromPolicyEntry(entry); install_options.install_placeholder = true; // When the policy gets refreshed, we should try to reinstall placeholder // apps but only if they are not being used. install_options.wait_for_windows_closed = true; install_options.reinstall_placeholder = true; install_options_list.push_back(std::move(install_options)); } pending_app_manager_->SynchronizeInstalledApps( std::move(install_options_list), ExternalInstallSource::kExternalPolicy, base::BindOnce(&WebAppPolicyManager::OnAppsSynchronized, weak_ptr_factory_.GetWeakPtr())); } void WebAppPolicyManager::OnAppsSynchronized( std::map<GURL, InstallResultCode> install_results, std::map<GURL, bool> uninstall_results) { is_refreshing_ = false; if (needs_refresh_) RefreshPolicyInstalledApps(); RecordExternalAppInstallResultCode(kInstallResultHistogramName, install_results); } } // namespace web_app
35.566667
87
0.749297
sarang-apps
eea0321ca981c8b59873da342e9c902423b2cac2
885
cpp
C++
docs/examples/SampleMapping.cpp
Aschratt/Texturize
bba688d1afd60363f03e02d28e642a63845591d6
[ "MIT" ]
11
2019-05-17T12:23:12.000Z
2020-11-12T14:03:23.000Z
docs/examples/SampleMapping.cpp
crud89/Texturize
bba688d1afd60363f03e02d28e642a63845591d6
[ "MIT" ]
2
2019-04-01T08:37:36.000Z
2019-04-01T08:49:15.000Z
docs/examples/SampleMapping.cpp
crud89/Texturize
bba688d1afd60363f03e02d28e642a63845591d6
[ "MIT" ]
1
2019-06-25T01:04:35.000Z
2019-06-25T01:04:35.000Z
#include <analysis.hpp> int main(int argc, const char** argv) { // Read an image using OpenCV. The name of the image is provided within the first command line parameter. cv::Mat img = cv::imread(argv[0]); // Read the uv map, provided by the second command line parameter. Note that uv maps must contain 2 channels. cv::Mat uv = cv::imread(argv[1]); TEXTURIZE_ASSERT(uv.depth() == 2); // Create a sample for the sample and uv map. // Note that both images may differ in size. Texturize::Sample exemplar(img); Texturize::Sample uvMap(uv); // Apply the uv map to the image and store the result to a new sample. Texturize::Sample result; exemplar.sample(uv, result); // Display the result. It will have the same size as the uv map and the same depth as the image. cv::imshow("Result", (cv::Mat)result); cv::waitKey(1); }
36.875
113
0.671186
Aschratt
eea12b353475f283a6f93b54e0ba46fd6b845413
67
hpp
C++
src/boost_geometry_strategies_concepts_distance_concept.hpp
miathedev/BoostForArduino
919621dcd0c157094bed4df752b583ba6ea6409e
[ "BSL-1.0" ]
10
2018-03-17T00:58:42.000Z
2021-07-06T02:48:49.000Z
src/boost_geometry_strategies_concepts_distance_concept.hpp
miathedev/BoostForArduino
919621dcd0c157094bed4df752b583ba6ea6409e
[ "BSL-1.0" ]
2
2021-03-26T15:17:35.000Z
2021-05-20T23:55:08.000Z
src/boost_geometry_strategies_concepts_distance_concept.hpp
miathedev/BoostForArduino
919621dcd0c157094bed4df752b583ba6ea6409e
[ "BSL-1.0" ]
4
2019-05-28T21:06:37.000Z
2021-07-06T03:06:52.000Z
#include <boost/geometry/strategies/concepts/distance_concept.hpp>
33.5
66
0.850746
miathedev
eea725725d18401a09d00238ffb1578ad1e4c11a
493
cpp
C++
my_work/10_sayidan_tek_cift.cpp
korayyalcin1903/c-_work
1a5f6103aa68ae9a16077d972bfeba1a4272789f
[ "MIT" ]
null
null
null
my_work/10_sayidan_tek_cift.cpp
korayyalcin1903/c-_work
1a5f6103aa68ae9a16077d972bfeba1a4272789f
[ "MIT" ]
null
null
null
my_work/10_sayidan_tek_cift.cpp
korayyalcin1903/c-_work
1a5f6103aa68ae9a16077d972bfeba1a4272789f
[ "MIT" ]
null
null
null
#include <iostream> #include <math.h> using namespace std; int main(int argc, char const *argv[]) { int sayi,teksayac=0,ciftsayac=0; for(int i=1;i<=10;i++) { cout << "Sayi Giriniz="; cin >> sayi; if(sayi%2==0) { ciftsayac++; } else { teksayac++; } } cout << "Çift Sayisi adeti=" << ciftsayac << endl; cout << "Tek Sayi adeti=" << teksayac; return 0; }
19.72
55
0.452333
korayyalcin1903
eea83bc0e81c47b91791c9600adca502cc4921d3
4,950
cpp
C++
src/libs/object/object.cpp
kamranshamaei/tarsim
dcb0f28f7b1422ba125c85cd53a1420d69d466eb
[ "Apache-2.0" ]
22
2019-03-01T01:41:53.000Z
2022-02-28T03:57:40.000Z
src/libs/object/object.cpp
kamranshamaei/tarsim
dcb0f28f7b1422ba125c85cd53a1420d69d466eb
[ "Apache-2.0" ]
5
2020-01-08T19:21:48.000Z
2021-07-15T20:39:17.000Z
src/libs/object/object.cpp
kamranshamaei/tarsim
dcb0f28f7b1422ba125c85cd53a1420d69d466eb
[ "Apache-2.0" ]
7
2019-03-01T02:59:11.000Z
2022-02-17T14:08:11.000Z
/** * @file: object.cpp * * @Created on: March 31, 2018 * @Author: Kamran Shamaei * * * @brief - * <Requirement Doc Reference> * <Design Doc Reference> * * @copyright Copyright [2017-2018] Kamran Shamaei . * All Rights Reserved. * * This file is subject to the terms and conditions defined in * file 'LICENSE', which is part of this source code package. */ //INCLUDES #include "object.h" #include <algorithm> #include "logClient.h" namespace tarsim { // FORWARD DECLARATIONS // TYPEDEFS AND DEFINES // ENUMS // NAMESPACES AND STRUCTS // CLASS DEFINITION Object::Object( const ExternalObject& externalObject, const std::string &configFolderName): Node(configFolderName), m_externalObject(externalObject) { m_isLocked = false; m_indexRigidBody = 0; m_xfmObjectToRb = Matrix4d::Identity(); Xfm xfm = externalObject.xfm_object_to_world(); Matrix4d xfm_world_object; xfm_world_object << xfm.rxx(), xfm.rxy(), xfm.rxz(), xfm.tx(), xfm.ryx(), xfm.ryy(), xfm.ryz(), xfm.ty(), xfm.rzx(), xfm.rzy(), xfm.rzz(), xfm.tz(), 0.0, 0.0, 0.0, 1.0; m_xfm = xfm_world_object; if (setExternalObject(externalObject) != NO_ERR) { throw std::invalid_argument("No rigid body specified for current object"); } if (setName(m_externalObject.name()) != NO_ERR) { throw std::invalid_argument("No name specified for current object"); } for (size_t i = 0; i < m_externalObject.appearance().lines_size(); i++) { double collisionDetectionDistance = m_externalObject.appearance().lines(i).collision_detection_distance(); if (collisionDetectionDistance > 1.0e-6) { std::vector<Vector4d> vertices; Vector4d u, v; u << m_externalObject.appearance().lines(i).from().x(), m_externalObject.appearance().lines(i).from().y(), m_externalObject.appearance().lines(i).from().z(), 1.0; v << m_externalObject.appearance().lines(i).to().x(), m_externalObject.appearance().lines(i).to().y(), m_externalObject.appearance().lines(i).to().z(), 1.0; vertices.push_back(u); vertices.push_back(v); BoundingBoxCapsule* bb = new BoundingBoxCapsule( collisionDetectionDistance, vertices); m_bbs.push_back(bb); } } } Object::~Object() { for (size_t i = 0; i < m_bbs.size(); i++) { delete m_bbs[i]; m_bbs[i] = nullptr; } m_bbs.clear(); } ExternalObject Object::getExternalObject() const { return m_externalObject; } Errors Object::setExternalObject(const ExternalObject& externalObject) { if (verifyExternalObject(externalObject) != NO_ERR) { LOG_FAILURE("Failed to verify rigid body"); return ERR_SET; } m_externalObject = externalObject; m_frames.resize(m_externalObject.frames_size()); m_coordinateFrames.resize(m_externalObject.frames_size()); for (size_t i = 0; i < m_externalObject.frames_size(); i++) { m_coordinateFrames[i] = m_externalObject.frames(i); } return NO_ERR; } Errors Object::verifyExternalObject(const ExternalObject& externalObject) { if (!externalObject.has_appearance()) { LOG_FAILURE("Rigid body does not have appearance"); return ERR_INVALID; } else { if (verifyAppearance(externalObject.appearance()) != NO_ERR) { LOG_FAILURE("Failed to verify rigid body appearance"); return ERR_INVALID; } } if (!externalObject.has_xfm_object_to_world()) { LOG_FAILURE("Base rigid body does not have transformation matrix"); return ERR_INVALID; } return NO_ERR; } bool Object::getIsLocked(int& rb) { if (m_isLocked) { rb = m_indexRigidBody; } return m_isLocked; } void Object::setIsLocked(bool isLocked, int indexRigidBody) { m_isLocked = isLocked; m_indexRigidBody = indexRigidBody; } void Object::setXfmObjectToRb(const Matrix4d &m) { m_xfmObjectToRb = m; } Matrix4d Object::getXfmObjectToRb() { return m_xfmObjectToRb; } RigidBodyAppearance Object::getRigidBodyAppearance() const { return m_externalObject.appearance(); } std::vector<BoundingBoxBase*>* Object::getBbs() { return &m_bbs; } void Object::updateFrames(const Matrix4d &m) { for (int i = 0; i < m_externalObject.frames_size(); i++) { Xfm xfm = m_externalObject.frames(i).xfm(); Matrix4d n; n << xfm.rxx(), xfm.rxy(), xfm.rxz(), xfm.tx(), xfm.ryx(), xfm.ryy(), xfm.ryz(), xfm.ty(), xfm.rzx(), xfm.rzy(), xfm.rzz(), xfm.tz(), 0.0, 0.0, 0.0, 1.0; m_frames[i] = m * n; } } } // end of namespace tarsim
26.052632
82
0.611313
kamranshamaei
eeaa82546c579db997933219ce1d466c1bf0d147
11,230
cpp
C++
applications/ParticlesEditor/src/Objects/EmitterObject.cpp
AluminiumRat/mtt
3052f8ad0ffabead05a1033e1d714a61e77d0aa8
[ "MIT" ]
null
null
null
applications/ParticlesEditor/src/Objects/EmitterObject.cpp
AluminiumRat/mtt
3052f8ad0ffabead05a1033e1d714a61e77d0aa8
[ "MIT" ]
null
null
null
applications/ParticlesEditor/src/Objects/EmitterObject.cpp
AluminiumRat/mtt
3052f8ad0ffabead05a1033e1d714a61e77d0aa8
[ "MIT" ]
null
null
null
#include <chrono> #include <Objects/EmitterObject.h> const std::map<EmitterObject::Shape, QString> EmitterObject::shapeNames = { {EmitterObject::CIRCLE_SHAPE, QT_TR_NOOP("Circle")}, {EmitterObject::SPHERE_SHAPE, QT_TR_NOOP("Sphere")}}; const std::map<EmitterObject::Distribution, QString> EmitterObject::distributionNames = { {EmitterObject::UNIFORM_DISTRIBUTION, QT_TR_NOOP("Uniform")}, {EmitterObject::SMOOTH_DISTRIBUTION, QT_TR_NOOP("Smooth")}}; EmitterObject::EmitterObject( const QString& name, bool canBeRenamed, const mtt::UID& id) : HierarhicalObject(name, canBeRenamed, id), _enabled(true), _typeMask(1), _fieldRef(*this), _intensity(0.f), _size(1.f), _shape(SPHERE_SHAPE), _distribution(UNIFORM_DISTRIBUTION), _directionAngle(2.f * glm::pi<float>()), _speedRange(0.f, 0.f), _sizeRange(1.f, 1.f), _rotationRange(-glm::pi<float>(), glm::pi<float>()), _rotationSpeedRange(.0f, .0f), _firstAlbedo(1.f, 1.f, 1.f), _secondAlbedo(1.f, 1.f, 1.f), _opacityRange(1.f, 1.f), _emissionColor(1.f), _emissionBrightness(0.f), _textureIndex(0), _tileIndex(0), _lifetimeRange(mtt::second, mtt::second), _massRange(0.f, 0.f), _frictionFactorRange(0.f, 0.f), _randomEngine( unsigned int(std::chrono::system_clock::now().time_since_epoch().count())), _symmetricalDistribution(-1.f, 1.f), _displacedDistribution(0.f, 1.f) { } void EmitterObject::_connectToField(ParticleField& field) { field.registerEmitter(*this); } void EmitterObject::_disconnectFromField(ParticleField& field) noexcept { field.unregisterEmitter(*this); } void EmitterObject::setEnabled(bool newValue) noexcept { if (_enabled == newValue) return; _enabled = newValue; emit enabledChanged(newValue); } void EmitterObject::setTypeMask(uint32_t newValue) noexcept { if (_typeMask == newValue) return; _typeMask = newValue; emit typeMaskChanged(newValue); } void EmitterObject::setIntensity(float newValue) noexcept { if(_intensity == newValue) return; _intensity = newValue; emit intensityChanged(newValue); } void EmitterObject::setSize(float newValue) noexcept { if(_size == newValue) return; _size = newValue; emit sizeChanged(newValue); } void EmitterObject::setShape(Shape newValue) noexcept { if(_shape == newValue) return; _shape = newValue; emit shapeChanged(newValue); } void EmitterObject::setDistribution(Distribution newValue) noexcept { if(_distribution == newValue) return; _distribution = newValue; emit distributionChanged(newValue); } void EmitterObject::setDirectionAngle(float newValue) noexcept { if(_directionAngle == newValue) return; _directionAngle = newValue; emit directionAngleChanged(newValue); } void EmitterObject::setSpeedRange(const mtt::Range<float>& newValue) noexcept { if(!newValue.isValid()) return; if(_speedRange == newValue) return; _speedRange = newValue; emit speedRangeChanged(newValue); } void EmitterObject::setSizeRange(const mtt::Range<float>& newValue) noexcept { if(!newValue.isValid()) return; if(_sizeRange == newValue) return; _sizeRange = newValue; emit sizeRangeChanged(newValue); } void EmitterObject::setRotationRange(const mtt::Range<float>& newValue) noexcept { if(!newValue.isValid()) return; if(_rotationRange == newValue) return; _rotationRange = newValue; emit rotationRangeChanged(newValue); } void EmitterObject::setRotationSpeedRange( const mtt::Range<float>& newValue) noexcept { if(!newValue.isValid()) return; if(_rotationSpeedRange == newValue) return; _rotationSpeedRange = newValue; emit rotationSpeedRangeChanged(newValue); } void EmitterObject::setFirstAlbedo(const glm::vec3& newValue) noexcept { glm::vec3 newColor = glm::max(newValue, glm::vec3(0.f)); if(_firstAlbedo == newColor) return; _firstAlbedo = newColor; emit firstAlbedoChanged(newColor); } void EmitterObject::setSecondAlbedo(const glm::vec3& newValue) noexcept { glm::vec3 newColor = glm::max(newValue, glm::vec3(0.f)); if(_secondAlbedo == newColor) return; _secondAlbedo = newColor; emit secondAlbedoChanged(newColor); } void EmitterObject::setOpacityRange(const mtt::Range<float>& newValue) noexcept { if(!newValue.isValid()) return; if(_opacityRange == newValue) return; _opacityRange = newValue; emit opacityRangeChanged(newValue); } void EmitterObject::setEmissionColor(const glm::vec3& newValue) noexcept { glm::vec3 newColor = glm::max(newValue, glm::vec3(0.f)); if(_emissionColor == newColor) return; _emissionColor = newColor; emit emissionColorChanged(newColor); } void EmitterObject::setEmissionBrightness(float newValue) noexcept { newValue = glm::max(newValue, 0.f); if(_emissionBrightness == newValue) return; _emissionBrightness = newValue; emit emissionBrightnessChanged(newValue); } void EmitterObject::setTextureIndex(uint8_t newValue) noexcept { if(_textureIndex == newValue) return; _textureIndex = newValue; emit textureIndexChanged(newValue); } void EmitterObject::setTileIndex(uint8_t newValue) noexcept { if(_tileIndex == newValue) return; _tileIndex = newValue; emit tileIndexChanged(newValue); } void EmitterObject::setLifetimeRange(const mtt::TimeRange& newValue) noexcept { if(!newValue.isValid()) return; if(_lifetimeRange == newValue) return; _lifetimeRange = newValue; emit lifetimeRangeChanged(newValue); } void EmitterObject::setMassRange(const mtt::Range<float>& newValue) noexcept { if(!newValue.isValid()) return; if(_massRange == newValue) return; _massRange = newValue; emit massRangeChanged(newValue); } void EmitterObject::setFrictionFactorRange( const mtt::Range<float>& newValue) noexcept { if(!newValue.isValid()) return; if(_frictionFactorRange == newValue) return; _frictionFactorRange = newValue; emit frictionFactorRangeChanged(newValue); } void EmitterObject::simulationStep(mtt::TimeRange time) { if(_intensity <= 0.f) return; float floatDelta = mtt::toFloatTime(time.length()); float floatParticlesNumber = _intensity * floatDelta; emitParticles(floatParticlesNumber); } glm::vec4 EmitterObject::_getParticlePosition() const noexcept { if(_shape == CIRCLE_SHAPE) { float angle = glm::pi<float>() * _symmetricalDistribution(_randomEngine); float radius = sqrt(_displacedDistribution(_randomEngine)); if (_distribution == SMOOTH_DISTRIBUTION) { radius = 1.f - sqrt(1.f - radius); } radius *= _size / 2.f; return glm::vec4( sin(angle) * radius, cos(angle) * radius, 0.f, 1.f); } else { float angle1 = glm::pi<float>() * _symmetricalDistribution(_randomEngine); float height = _symmetricalDistribution(_randomEngine); float angle2 = asin(height); float radius = pow(_displacedDistribution(_randomEngine), 1.f / 3.f); if (_distribution == SMOOTH_DISTRIBUTION) { radius = 1.f - sqrt(1.f - radius); } radius *= _size / 2.f; return glm::vec4( sin(angle1) * cos(angle2) * radius, cos(angle1) * cos(angle2) * radius, height * radius, 1.f); } } glm::vec4 EmitterObject::_getParticleSpeed() const noexcept { float angle1 = glm::pi<float>() * _symmetricalDistribution(_randomEngine); float startZ = cos(_directionAngle / 2.f); float zValue = glm::mix(startZ, 1.f, _displacedDistribution(_randomEngine)); float angle2 = asin(zValue); float length = glm::mix(_speedRange.min(), _speedRange.max(), _displacedDistribution(_randomEngine)); return glm::vec4( sin(angle1) * cos(angle2) * length, cos(angle1) * cos(angle2) * length, zValue * length, 0.f); } void EmitterObject::emitParticles(float floatParticlesNumber) noexcept { if(!_enabled) return; size_t particlesNumber = size_t(floatParticlesNumber); float remainder = floatParticlesNumber - particlesNumber; if (_displacedDistribution(_randomEngine) < remainder) particlesNumber++; if (particlesNumber == 0) return; ParticleField* field = _fieldRef.get(); if(field == nullptr) return; glm::mat4x4 toField = glm::inverse(field->localToWorldTransform()) * localToWorldTransform(); float xScale = glm::length(glm::vec3(toField[0])); float yScale = glm::length(glm::vec3(toField[1])); float zScale = glm::length(glm::vec3(toField[2])); float uniformScale = (xScale + yScale + zScale) / 3.f; std::uniform_int_distribution<mtt::TimeT::rep> timeDistribution( glm::max(_lifetimeRange.min().count(), 0), glm::max(_lifetimeRange.max().count(), 0)); for (size_t i = 0; i < particlesNumber; i++) { ParticleField::ParticleData newParticle; newParticle.typeMask = _typeMask; newParticle.position = toField * _getParticlePosition(); newParticle.speed = toField * _getParticleSpeed(); newParticle.size = glm::mix(_sizeRange.min(), _sizeRange.max(), _displacedDistribution(_randomEngine)); newParticle.size *= uniformScale; newParticle.size = glm::max(newParticle.size, 0.f); newParticle.rotation = glm::mix(_rotationRange.min(), _rotationRange.max(), _displacedDistribution(_randomEngine)); newParticle.rotationSpeed = glm::mix( _rotationSpeedRange.min(), _rotationSpeedRange.max(), _displacedDistribution(_randomEngine)); glm::vec3 albedo = glm::mix(_firstAlbedo, _secondAlbedo, _displacedDistribution(_randomEngine)); float opacity = glm::mix( _opacityRange.min(), _opacityRange.max(), _displacedDistribution(_randomEngine)); newParticle.albedo = glm::vec4(albedo, opacity); newParticle.emission = glm::vec4(_emissionColor * _emissionBrightness, 0.f); newParticle.visibilityFactor = 1.f; newParticle.textureIndex = _textureIndex; newParticle.tileIndex = _tileIndex; newParticle.currentTime = mtt::TimeT(0); newParticle.maxTime = mtt::TimeT(timeDistribution(_randomEngine)); newParticle.mass = glm::mix(_massRange.min(), _massRange.max(), _displacedDistribution(_randomEngine)); newParticle.mass = glm::max(0.f, newParticle.mass); newParticle.frictionFactor = glm::mix( _frictionFactorRange.min(), _frictionFactorRange.max(), _displacedDistribution(_randomEngine)); newParticle.frictionFactor = glm::max(0.f, newParticle.frictionFactor); field->addParticle(newParticle); } }
32.085714
80
0.664648
AluminiumRat
eeac7c521bbafd63790d785ccef9fec00aaeb23d
8,242
cpp
C++
TFLcam/file.cpp
maarten-pennings/TFLcam
ebdb7755789f36edf854b570086c6d7fc3a4570e
[ "MIT" ]
4
2021-09-24T19:36:19.000Z
2022-01-21T11:47:41.000Z
TFLcam/file.cpp
maarten-pennings/TFLcam
ebdb7755789f36edf854b570086c6d7fc3a4570e
[ "MIT" ]
null
null
null
TFLcam/file.cpp
maarten-pennings/TFLcam
ebdb7755789f36edf854b570086c6d7fc3a4570e
[ "MIT" ]
null
null
null
// file.cpp - operations on sd card files // See eg https://randomnerdtutorials.com/esp32-microsd-card-arduino/ #include "SD_MMC.h" #include "cmd.h" // for run command #include "file.h" // Prints SD card properties to Serial. void file_sdprops() { Serial.printf("card: type "); sdcard_type_t cardtype=SD_MMC.cardType(); switch( cardtype ) { case CARD_NONE : Serial.printf("none"); break; case CARD_MMC : Serial.printf("MMC"); break; case CARD_SD : Serial.printf("SD"); break; case CARD_SDHC : Serial.printf("SDHC"); break; case CARD_UNKNOWN : Serial.printf("unknown"); break; default : Serial.printf("error"); break; } if( cardtype!=CARD_NONE ) Serial.printf(" size %llu", SD_MMC.cardSize()); Serial.printf("\n"); } // The buffer to load the TFLu model in static uint8_t * file_load_buf; // Configure the file library (SD card access). Returns success status. Prints problems also to Serial. esp_err_t file_setup() { bool ok = SD_MMC.begin("/sdcard", true); // true makes sd card not use DATA1 line, which is shared with flash light if( !ok ) { Serial.printf("file: FAIL to connect to sd\n"); return ESP_FAIL; } sdcard_type_t cardtype=SD_MMC.cardType(); ok = cardtype==CARD_MMC || cardtype==CARD_SD || cardtype==CARD_SDHC; if( !ok ) { Serial.printf("file: FAIL (no sd card)\n"); return ESP_FAIL; } file_load_buf = (uint8_t*)malloc(FILE_LOAD_BUFSIZE); // we could maybe use ps_malloc(FILE_LOAD_BUFSIZE); if( file_load_buf==0 ) { Serial.printf("file: FAIL (no mem buf for load)\n"); return ESP_FAIL; } // Serial.printf("heap free=%d\n",ESP.getFreeHeap()); // Hack alert: somehow is helps to allocate the memory on startup (then it is stail avail) // Serial.printf("file: success\n"); return ESP_OK; } // Prints a directory listing to Serial. // `dirpath` is a _full_ path leading to a directory (there is no current working directory, so start with /). // Will recurse for sub-directories up to `levels` deep. // The indent is used during recursion: the number of spaces (*2) to indent void file_dir(const char * dirpath, uint8_t levels, int indent ) { File root = SD_MMC.open(dirpath); if( !root ) { Serial.printf("ERROR: could not open '%s' (root slash missing?)\n",dirpath); return; } if( !root.isDirectory() ){ Serial.println("ERROR: not a directory"); return; } if( indent==0 ) Serial.printf("dir: '%s'\n", dirpath); File file = root.openNextFile(); int filecount=0; int dircount=0; while( file ){ if( file.isDirectory() ){ dircount++; Serial.printf("%*c %s\n", indent*2+1,' ', file.name() ); if( levels ) file_dir(file.name(), levels-1, indent+1); } else { filecount++; Serial.printf("%*c %s (%u)\n", indent*2+1,' ', file.name(), file.size() ); } file = root.openNextFile(); } Serial.printf("%*c (%s has %d files, %d dirs)\n", indent*2+1,' ', dirpath, filecount, dircount); root.close(); } // Print the content of file `filepath` to Serial. // `filepath` is a full file path leading to a file (there is no current working directory, so start with /). void file_show(const char * filepath) { File file = SD_MMC.open(filepath); if( !file ) { Serial.printf("ERROR: could not open '%s' (root slash missing?)\n", filepath); return; } if( file.isDirectory() ){ Serial.println("ERROR: is a directory"); return; } while(file.available()){ Serial.write( file.read() ); // one byte at a time } file.close(); } // Feeds the content of file `filepath` to the command interpreter. // `filepath` is a full file path leading to a file (there is no current working directory, so start with /). void file_run(const char * filepath) { File file = SD_MMC.open(filepath); if( !file ) { Serial.printf("ERROR: could not open '%s' (root slash missing?)\n", filepath); return; } if( file.isDirectory() ){ Serial.printf("ERROR: is a directory\n"); return; } cmd_add('\n'); // Give a prompt for the first line of the script while(file.available()){ cmd_add( file.read() ); } if( cmd_pendingschars()>0 ) cmd_add('\n'); file.close(); } // Loads the content of file `filepath` into a local buffer; the pointer to the buffer is returned. // `filepath` is a full file path leading to a file (there is no current working directory, so start with /). const uint8_t * file_load(const char * filepath) { File file = SD_MMC.open(filepath); if( !file ) { Serial.printf("ERROR: could not open '%s' (root slash missing?)\n", filepath); return 0; } if( file.isDirectory() ){ Serial.printf("ERROR: is a directory\n"); return 0; } // Check buffer with the file size size_t size = file.size(); if( size>FILE_LOAD_BUFSIZE ) { Serial.printf("ERROR: model (%d) to big for buffer (%d)\n",size,FILE_LOAD_BUFSIZE); return 0; } for( int i=0; i<size; i++ ) file_load_buf[i] = file.read(); file.close(); return file_load_buf; } // Writes the image `img` (resolution `width` by `height`) to file `filepath`. // `filepath` is a full file path leading to a file (there is no current working directory, so start with /). esp_err_t file_imgwrite(const char * filepath, const uint8_t * img, int width, int height) { File file = SD_MMC.open(filepath, FILE_WRITE); if( file.isDirectory() ){ Serial.printf("ERROR: is a directory\n"); return 0; } if( !file ) { Serial.printf("ERROR: could not open '%s' (root slash missing?)\n", filepath); return ESP_FAIL; } bool ok = true; // http://netpbm.sourceforge.net/doc/pgm.html ok &= 0<file.printf("P2 # TFLcam: %s\n",filepath); ok &= 0<file.printf("%d %d # width height\n",width,height); ok &= 0<file.printf("255 # max gray\n"); if( !ok ) { Serial.printf("ERROR: image header write failed\n"); goto fail; } for( int y=0; y<height; y++ ) { int count=0; for( int x=0; x<width; x++ ) { ok &= 0<file.printf(" %3d",img[x+y*width]); count+=4; if( count+4>70 ) { ok &= 0<file.printf("\n"); count=0; } } if( count>0 ) ok &= 0<file.printf("\n"); if( !ok ) { Serial.printf("ERROR: image data write failed\n"); goto fail; } } file.close(); return ESP_OK; fail: file.close(); return ESP_FAIL; } // Returns 0 when`path` is not a file/dir on the SD card. // Returns 1 when it is a file and 2 when it is a dir. int file_exists(const char * path) { File file = SD_MMC.open(path); int exists; if( !file ) { exists=0; } else if( !file.isDirectory() ) { exists=1; } else { exists=2; } file.close(); return exists; } // Creates a directory `path`. // `path` is a full path leading to a (new) dir (there is no current working directory, so start with /). // Returns if successful (see below for examples), prints errors to serial. bool file_mkdir(const char * path) { if( path==0 || strlen(path)==0 ) { Serial.printf("ERROR: path missing\n"); return false; } if( path[strlen(path)-1]=='/' ) { Serial.printf("ERROR: path '%s' ends in '/'\n",path); return false; } bool ok= SD_MMC.mkdir(path); if( !ok ) { Serial.printf("ERROR: mkdir '%s' failed (root slash missing? parent exists?)\n",path); return false; } return ok; } // mkdir new fails (no root slash) // mkdir /new success // mkdir /new.ext success (extensions allowed in dir name) // mkdir /existingfile fails (can not overwrite file) // mkdir /existingdir success (just a no-op) // mkdir /existingfile/new fails (can not use file as dir) // mkdir /existingdir/new success (works for subdirs) // mkdir /absent/new fails (does not create missing parent dirs) /* // rmdir existsemptydir.ext fail // rmdir /existingemptydir success // rmdir /existsemptydir.ext success // rmdir /existingnonemptydir fail // rmdir /dir/existingemptydir success // rmdir /existingfile fail void file_rmdir(const char * path) { if(SD_MMC.rmdir(path)){ Serial.printf("rmdir '%s' success\n",path); } else { Serial.printf("rmdir '%s' failed\n",path); } } */
38.877358
147
0.634433
maarten-pennings
eeafbd7ec7d5309edc6a0a7eec8f79befd5c3a3f
13,536
cpp
C++
lib/src/AMRElliptic/PetscCompGridVTO.cpp
rmrsk/Chombo-3.3
f2119e396460c1bb19638effd55eb71c2b35119e
[ "BSD-3-Clause-LBNL" ]
10
2018-02-01T20:57:36.000Z
2022-03-17T02:57:49.000Z
lib/src/AMRElliptic/PetscCompGridVTO.cpp
rmrsk/Chombo-3.3
f2119e396460c1bb19638effd55eb71c2b35119e
[ "BSD-3-Clause-LBNL" ]
19
2018-10-04T21:37:18.000Z
2022-02-25T16:20:11.000Z
lib/src/AMRElliptic/PetscCompGridVTO.cpp
rmrsk/Chombo-3.3
f2119e396460c1bb19638effd55eb71c2b35119e
[ "BSD-3-Clause-LBNL" ]
11
2019-01-12T23:33:32.000Z
2021-08-09T15:19:50.000Z
#ifdef CH_LANG_CC /* * _______ __ * / ___/ / ___ __ _ / / ___ * / /__/ _ \/ _ \/ V \/ _ \/ _ \ * \___/_//_/\___/_/_/_/_.__/\___/ * Please refer to Copyright.txt, in Chombo's root directory. */ #endif #include "PetscCompGridVTO.H" #include "FluxBox.H" #include "IntVectSet.H" #include "NamespaceHeader.H" // derived ViscousTensor Operator class #ifdef CH_USE_PETSC void PetscCompGridVTO::clean() { PetscCompGrid::clean(); } void PetscCompGridVTO::createOpStencil(IntVect a_iv, int a_ilev,const DataIndex &a_di, StencilTensor &a_sten) { CH_TIME("PetscCompGridVTO::createOpStencil"); Real dx=m_dxs[a_ilev][0],idx2=1./(dx*dx); Real eta_x0,eta_x1,lam_x0,lam_x1,eta_y0,eta_y1,lam_y0,lam_y1; IntVect ivwst=IntVect::Zero,ivest=IntVect::Zero,ivsth=IntVect::Zero,ivnth=IntVect::Zero; //IntVect ivSW(-1,-1),ivSE(1,-1),ivNE(1,1),ivNW(-1,1); IntVect ivSW(IntVect::Unit),ivSE(IntVect::Unit),ivNE(IntVect::Unit),ivNW(IntVect::Unit); ivSW[1] = ivSW[0] = -1; // >= 2D ivSE[1] = -1; // >= 2D ivNW[0] = -1; ivwst[0] = -1; ivest[0] = 1; ivsth[1] = -1; ivnth[1] = 1; { // get stencil coeficients Real beta_hinv2=m_beta*idx2; const FluxBox &etaFab = (*m_eta[a_ilev])[a_di]; const FArrayBox &eta_x = etaFab[0]; const FArrayBox &eta_y = etaFab[1]; const FluxBox &lamFab = (*m_lamb[a_ilev])[a_di]; const FArrayBox &lam_x = lamFab[0]; const FArrayBox &lam_y = lamFab[1]; eta_x0 = beta_hinv2*eta_x(a_iv,0); eta_y0 = beta_hinv2*eta_y(a_iv,0); eta_x1 = beta_hinv2*eta_x(ivest+a_iv,0); eta_y1 = beta_hinv2*eta_y(ivnth+a_iv,0); lam_x0 = beta_hinv2*lam_x(a_iv,0); lam_y0 = beta_hinv2*lam_y(a_iv,0); lam_x1 = beta_hinv2*lam_x(ivest+a_iv,0); lam_y1 = beta_hinv2*lam_y(ivnth+a_iv,0); } // loop over two equations, should probably just hard wire this for (int kk=0,vv=1;kk<2;kk++,vv--) { Real vd; // add one eta everywhere -- same for u and v vd = eta_x0; { StencilTensorValue &v1 = a_sten[IndexML(ivwst+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,kk,vd); } vd = eta_x1; { StencilTensorValue &v1 = a_sten[IndexML(ivest+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,kk,vd); } vd = eta_y0; { StencilTensorValue &v1 = a_sten[IndexML(ivsth+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,kk,vd); } vd = eta_y1; { StencilTensorValue &v1 = a_sten[IndexML(ivnth+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,kk,vd); } vd = -(eta_x0 + eta_y0 + eta_x1 + eta_y1); { StencilTensorValue &v1 = a_sten[IndexML(a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,kk,vd); } // add extra eta and the lambda for each direction if (kk==0) { vd = eta_x0 + lam_x0; { StencilTensorValue &v1 = a_sten[IndexML(ivwst+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,kk,vd); } vd = eta_x1 + lam_x1; { StencilTensorValue &v1 = a_sten[IndexML(ivest+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,kk,vd); } vd = -(eta_x0 + eta_x1 + lam_x0 + lam_x1); { StencilTensorValue &v1 = a_sten[IndexML(a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,kk,vd); } } else { vd = eta_y0 + lam_y0; { StencilTensorValue &v1 = a_sten[IndexML(ivsth+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,kk,vd); } vd = eta_y1 + lam_y1; { StencilTensorValue &v1 = a_sten[IndexML(ivnth+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,kk,vd); } vd = -(eta_y0 + eta_y1 + lam_y0 + lam_y1); { StencilTensorValue &v1 = a_sten[IndexML(a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,kk,vd); } } // u -- v coupling terms -- 8 point stencil // S if (kk==0) vd = 0.25*(-lam_x1 + lam_x0); else vd = 0.25*(-eta_x1 + eta_x0); { StencilTensorValue &v1 = a_sten[IndexML(ivsth+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,vv,vd); } // S.W. if (kk==0) vd = 0.25*(eta_y0 + lam_x0); else vd = 0.25*(eta_x0 + lam_y0); { StencilTensorValue &v1 = a_sten[IndexML(ivSW+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,vv,vd); } // S.E. if (kk==0) vd = 0.25*(-lam_x1 - eta_y0); else vd = 0.25*(-lam_y0 - eta_x1); { StencilTensorValue &v1 = a_sten[IndexML(ivSE+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,vv,vd); } // W if (kk==0) vd = 0.25*(-eta_y1 + eta_y0); else vd = 0.25*(-lam_y1 + lam_y0); { StencilTensorValue &v1 = a_sten[IndexML(ivwst+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,vv,vd); } // E if (kk==0) vd = 0.25*(eta_y1 - eta_y0); else vd = 0.25*(lam_y1 - lam_y0); { StencilTensorValue &v1 = a_sten[IndexML(ivest+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,vv,vd); } // N.W. if (kk==0) vd = 0.25*(-lam_x0 - eta_y1); else vd = 0.25*(-lam_y1 - eta_x0); { StencilTensorValue &v1 = a_sten[IndexML(ivNW+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,vv,vd); } // N if (kk==0) vd = 0.25*(lam_x1 - lam_x0); else vd = 0.25*(eta_x1 - eta_x0); { StencilTensorValue &v1 = a_sten[IndexML(ivnth+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,vv,vd); } // N.E. if (kk==0) vd = 0.25*(eta_y1 + lam_x1); else vd = 0.25*(eta_x1 + lam_y1); { StencilTensorValue &v1 = a_sten[IndexML(ivNE+a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,vv,vd); } // diagonal alpha term vd = m_alpha * (!(m_a[a_ilev]) ? 1. : (*m_a[a_ilev])[a_di](a_iv,0)); { StencilTensorValue &v1 = a_sten[IndexML(a_iv,a_ilev)]; v1.define(CH_SPACEDIM); v1.addValue(kk,kk,vd); } } // kk=1:2 loop if (0) { Real summ=0.; StencilTensor::const_iterator end = a_sten.end(); for ( StencilTensor::const_iterator it = a_sten.begin(); it != end; ++it) { for (int i=0; i<CH_SPACEDIM; ++i) { for (int j=0; j<CH_SPACEDIM; ++j) { summ += it->second.value(i,j); } } } if (abs(summ)>1.e-10) { for (StencilTensor::const_iterator it = a_sten.begin(); it != end; ++it) { pout() << it->first << " ERROR: \n"; for (int i=0; i<CH_SPACEDIM; ++i) { pout() << "\t\t"; for (int j=0; j<CH_SPACEDIM; ++j) { pout() << it->second.value(i,j) << ", "; } pout() << endl; } } pout() << "\t ERROR summ: " << summ << endl; } } } // clean out BC from stencil of cell a_iv void PetscCompGridVTO::applyBCs( IntVect a_iv, int a_ilev, const DataIndex &di_dummy, Box a_dombox, StencilTensor &a_sten ) { CH_TIME("PetscCompGridVTO::applyBCs"); Vector<Vector<StencilNode> > new_vals; // StencilTensorValue RefCountedPtr<BCFunction> bc = m_bc.getBCFunction(); CompGridVTOBC *mybc = dynamic_cast<CompGridVTOBC*>(&(*bc)); // count degrees, add to 'corners' Vector<IntVectSet> corners(CH_SPACEDIM); StencilTensor::const_iterator end2 = a_sten.end(); for (StencilTensor::const_iterator it = a_sten.begin(); it != end2; ++it) { const IntVect &jiv = it->first.iv(); if (!a_dombox.contains(jiv) && it->first.level()==a_ilev) // a BC { int degree = CH_SPACEDIM-1; for (int dir=0;dir<CH_SPACEDIM;++dir) { if (jiv[dir] >= a_dombox.smallEnd(dir) && jiv[dir] <= a_dombox.bigEnd(dir)) degree--; } CH_assert(degree>=0); corners[degree] |= jiv; } } // move ghosts starting at with high degree corners and cascade to lower degree for (int ideg=CH_SPACEDIM-1;ideg>=0;ideg--) { // iterate through list for (IVSIterator ivit(corners[ideg]); ivit.ok(); ++ivit) { const IntVect &jiv = ivit(); // get rid of this bc ghost // get layer of ghost Box gbox(IntVect::Zero,IntVect::Zero); gbox.shift(jiv); Box inter = a_dombox & gbox; CH_assert(inter.numPts()==0); int igid = -1; // find which layer of ghost I am do{ igid++; gbox.grow(1); inter = a_dombox & gbox; }while (inter.numPts()==0); if (igid!=0) MayDay::Error("PetscCompGridVTO::applyBCs layer???"); for (int dir=0;dir<CH_SPACEDIM;++dir) { if (jiv[dir] < a_dombox.smallEnd(dir) || jiv[dir] > a_dombox.bigEnd(dir)) { // have a BC, get coefs on demand int iside = 1; // hi int isign = 1; if (jiv[dir] < a_dombox.smallEnd(dir)) isign = -1; if (jiv[dir] < a_dombox.smallEnd(dir)) iside = 0; // lo if (!mybc) MayDay::Error("PetscCompGridVTO::applyBCs: wrong BC!!!!"); new_vals.resize(1); new_vals[0].resize(1); //new_vals[i][j].second.setValue(mybc->getCoef(j,i)); for (int comp=0; comp<SpaceDim; comp++) { new_vals[0][0].second.define(1); if (mybc->m_bcDiri[dir][iside][comp]) new_vals[0][0].second.setValue(comp,comp,-1.); // simple diagonal else new_vals[0][0].second.setValue(comp,comp,1.); } // end loop over components new_vals[0][0].first.setLevel(a_ilev); IndexML kill(jiv,a_ilev); IntVect biv = jiv; biv.shift(dir,-isign*(igid+1)); new_vals[igid][0].first.setIV(biv); if (ideg>0 && !a_dombox.contains(biv)) // this could be a new stencil value for high order BCs { corners[ideg-1] |= biv; // send down to lower list for later removal } else CH_assert(a_dombox.contains(biv)); StencilProject(kill,new_vals[igid],a_sten); int nrm = a_sten.erase(kill); CH_assert(nrm==1); break; } // BC } // spacedim } // ghosts } // degree } #endif // ifdef petsc // CompGridVTOBC void CompGridVTOBC::createCoefs() { m_isDefined=true; // is this needed ? m_Rcoefs[0] = -1.; } // void CompGridVTOBC::operator()( FArrayBox& a_state, const Box& a_valid, const ProblemDomain& a_domain, Real a_dx, bool a_homogeneous) { const Box& domainBox = a_domain.domainBox(); for (int idir = 0; idir < SpaceDim; idir++) { if (!a_domain.isPeriodic(idir)) { for (SideIterator sit; sit.ok(); ++sit) { Side::LoHiSide side = sit(); if (a_valid.sideEnd(side)[idir] == domainBox.sideEnd(side)[idir]) { // Dirichlet BC int isign = sign(side); Box toRegion = adjCellBox(a_valid, idir, side, 1); // include corner cells if possible by growing toRegion in transverse direction toRegion.grow(1); toRegion.grow(idir, -1); toRegion &= a_state.box(); for (BoxIterator bit(toRegion); bit.ok(); ++bit) { IntVect ivTo = bit(); IntVect ivClose = ivTo - isign*BASISV(idir); for (int ighost=0;ighost<m_nGhosts[0];ighost++,ivTo += isign*BASISV(idir)) { //for (int icomp = 0; icomp < a_state.nComp(); icomp++) a_state(ivTo, icomp) = 0.0; IntVect ivFrom = ivClose; // hardwire to linear BCs for now for (int icomp = 0; icomp < a_state.nComp() ; icomp++) { if (m_bcDiri[idir][side][icomp]) { a_state(ivTo, icomp) = (-1.0)*a_state(ivFrom, icomp); } else { a_state(ivTo, icomp) = (1.0)*a_state(ivFrom, icomp); } } } } // end loop over cells } // if ends match } // end loop over sides } // if not periodic in this direction } // end loop over directions } #include "NamespaceFooter.H" #ifdef CH_USE_PETSC #endif
36.192513
126
0.507018
rmrsk
eeb4c7525e77153e9597c4d9737d1b6da2e99324
9,657
hpp
C++
src/cola/parser/AstBuilder.hpp
Wolff09/seal
c0560204743d1c5f602cfc206ffac32531ea2c06
[ "MIT" ]
7
2019-10-18T07:24:13.000Z
2022-01-07T14:01:17.000Z
src/cola/parser/AstBuilder.hpp
Wolff09/seal
c0560204743d1c5f602cfc206ffac32531ea2c06
[ "MIT" ]
null
null
null
src/cola/parser/AstBuilder.hpp
Wolff09/seal
c0560204743d1c5f602cfc206ffac32531ea2c06
[ "MIT" ]
1
2019-11-30T01:45:41.000Z
2019-11-30T01:45:41.000Z
#pragma once #include <memory> #include <deque> #include <unordered_map> // TODO: import string #include "antlr4-runtime.h" #include "CoLaVisitor.h" #include "cola/ast.hpp" namespace cola { class AstBuilder : public cola::CoLaVisitor { // TODO: should this be a private subclass to avoid misuse? private: const std::string INIT_NAME = "init"; enum struct Modifier { NONE, INLINE, EXTERN }; enum struct ExprForm { NOPTR, PTR, DEREF, NESTED }; struct ExprTrans { ExprForm form; std::vector<Statement*> helper; Expression* expr; std::size_t num_shared; ExprTrans() {} ExprTrans(ExprForm form, Expression* expr) : form(form), expr(expr), num_shared(0) {} ExprTrans(ExprForm form, Expression* expr, std::size_t num_shared) : form(form), expr(expr), num_shared(num_shared) {} }; using TypeMap = std::unordered_map<std::string, std::reference_wrapper<const Type>>; using VariableMap = std::unordered_map<std::string, std::unique_ptr<VariableDeclaration>>; using FunctionMap = std::unordered_map<std::string, Function&>; using ArgDeclList = std::vector<std::pair<std::string, std::string>>; std::shared_ptr<Program> _program = nullptr; std::deque<VariableMap> _scope; TypeMap _types; FunctionMap _functions; bool _inside_loop = false; std::unique_ptr<Invariant> _cmdInvariant; const Function* _currentFunction; void pushScope(); std::vector<std::unique_ptr<VariableDeclaration>> popScope(); void addVariable(std::unique_ptr<VariableDeclaration> variable); bool isVariableDeclared(std::string variableName); const VariableDeclaration& lookupVariable(std::string variableName); bool isTypeDeclared(std::string typeName); const Type& lookupType(std::string typeName); std::unique_ptr<Statement> mk_stmt_from_list(std::vector<cola::CoLaParser::StatementContext*> stmts); std::unique_ptr<Statement> mk_stmt_from_list(std::vector<Statement*> stmts); // claims ownership of stmts Statement* as_command(Statement* stmt, AnnotatedStatement* cmd); Statement* as_command(AnnotatedStatement* stmt) { return as_command(stmt, stmt); } public: static std::shared_ptr<Program> buildFrom(cola::CoLaParser::ProgramContext* parseTree); antlrcpp::Any visitProgram(cola::CoLaParser::ProgramContext* context) override; antlrcpp::Any visitStruct_decl(cola::CoLaParser::Struct_declContext* context) override; antlrcpp::Any visitNameVoid(cola::CoLaParser::NameVoidContext* context) override; antlrcpp::Any visitNameBool(cola::CoLaParser::NameBoolContext* context) override; antlrcpp::Any visitNameInt(cola::CoLaParser::NameIntContext* context) override; antlrcpp::Any visitNameData(cola::CoLaParser::NameDataContext* context) override; antlrcpp::Any visitNameIdentifier(cola::CoLaParser::NameIdentifierContext* context) override; antlrcpp::Any visitTypeValue(cola::CoLaParser::TypeValueContext* context) override; antlrcpp::Any visitTypePointer(cola::CoLaParser::TypePointerContext* context) override; antlrcpp::Any visitField_decl(cola::CoLaParser::Field_declContext* context) override; antlrcpp::Any visitVar_decl(cola::CoLaParser::Var_declContext* context) override; antlrcpp::Any visitFunction(cola::CoLaParser::FunctionContext* context) override; antlrcpp::Any visitArgDeclList(cola::CoLaParser::ArgDeclListContext *context) override; antlrcpp::Any visitBlockStmt(cola::CoLaParser::BlockStmtContext* context) override; antlrcpp::Any visitBlockScope(cola::CoLaParser::BlockScopeContext* context) override; antlrcpp::Any visitScope(cola::CoLaParser::ScopeContext* context) override; antlrcpp::Any visitStmtIf(cola::CoLaParser::StmtIfContext* context) override; antlrcpp::Any visitStmtWhile(cola::CoLaParser::StmtWhileContext* context) override; antlrcpp::Any visitStmtDo(cola::CoLaParser::StmtDoContext* context) override; antlrcpp::Any visitStmtChoose(cola::CoLaParser::StmtChooseContext* context) override; antlrcpp::Any visitStmtLoop(cola::CoLaParser::StmtLoopContext* context) override; antlrcpp::Any visitStmtAtomic(cola::CoLaParser::StmtAtomicContext* context) override; antlrcpp::Any visitStmtCom(cola::CoLaParser::StmtComContext* context) override; antlrcpp::Any visitAnnotation(cola::CoLaParser::AnnotationContext* context) override; antlrcpp::Any visitCmdSkip(cola::CoLaParser::CmdSkipContext* context) override; antlrcpp::Any visitCmdAssign(cola::CoLaParser::CmdAssignContext* context) override; antlrcpp::Any visitCmdMalloc(cola::CoLaParser::CmdMallocContext* context) override; antlrcpp::Any visitCmdAssume(cola::CoLaParser::CmdAssumeContext* context) override; antlrcpp::Any visitCmdAssert(cola::CoLaParser::CmdAssertContext* context) override; antlrcpp::Any visitCmdAngel(cola::CoLaParser::CmdAngelContext* context) override; antlrcpp::Any visitCmdCall(cola::CoLaParser::CmdCallContext* context) override; antlrcpp::Any visitCmdContinue(cola::CoLaParser::CmdContinueContext* context) override; antlrcpp::Any visitCmdBreak(cola::CoLaParser::CmdBreakContext* context) override; antlrcpp::Any visitCmdReturn(cola::CoLaParser::CmdReturnContext* context) override; antlrcpp::Any visitCmdCas(cola::CoLaParser::CmdCasContext* context) override; antlrcpp::Any visitArgList(cola::CoLaParser::ArgListContext* context) override; antlrcpp::Any visitCas(cola::CoLaParser::CasContext* context) override; antlrcpp::Any visitOpEq(cola::CoLaParser::OpEqContext* context) override; antlrcpp::Any visitOpNeq(cola::CoLaParser::OpNeqContext* context) override; antlrcpp::Any visitOpLt(cola::CoLaParser::OpLtContext* context) override; antlrcpp::Any visitOpLte(cola::CoLaParser::OpLteContext* context) override; antlrcpp::Any visitOpGt(cola::CoLaParser::OpGtContext* context) override; antlrcpp::Any visitOpGte(cola::CoLaParser::OpGteContext* context) override; antlrcpp::Any visitOpAnd(cola::CoLaParser::OpAndContext* context) override; antlrcpp::Any visitOpOr(cola::CoLaParser::OpOrContext* context) override; antlrcpp::Any visitValueNull(cola::CoLaParser::ValueNullContext* context) override; antlrcpp::Any visitValueTrue(cola::CoLaParser::ValueTrueContext* context) override; antlrcpp::Any visitValueFalse(cola::CoLaParser::ValueFalseContext* context) override; antlrcpp::Any visitValueNDet(cola::CoLaParser::ValueNDetContext* context) override; antlrcpp::Any visitValueEmpty(cola::CoLaParser::ValueEmptyContext* context) override; antlrcpp::Any visitValueMin(cola::CoLaParser::ValueMinContext* context) override; antlrcpp::Any visitValueMax(cola::CoLaParser::ValueMaxContext* context) override; antlrcpp::Any visitExprValue(cola::CoLaParser::ExprValueContext* context) override; antlrcpp::Any visitExprBinary(cola::CoLaParser::ExprBinaryContext* context) override; antlrcpp::Any visitExprIdentifier(cola::CoLaParser::ExprIdentifierContext* context) override; antlrcpp::Any visitExprParens(cola::CoLaParser::ExprParensContext* context) override; antlrcpp::Any visitExprDeref(cola::CoLaParser::ExprDerefContext* context) override; antlrcpp::Any visitExprCas(cola::CoLaParser::ExprCasContext* context) override; antlrcpp::Any visitExprNegation(cola::CoLaParser::ExprNegationContext* context) override; antlrcpp::Any visitInvExpr(cola::CoLaParser::InvExprContext* context) override; antlrcpp::Any visitInvActive(cola::CoLaParser::InvActiveContext* context) override; antlrcpp::Any visitAngelChoose(cola::CoLaParser::AngelChooseContext* context) override; antlrcpp::Any visitAngelActive(cola::CoLaParser::AngelActiveContext* context) override; antlrcpp::Any visitAngelChooseActive(cola::CoLaParser::AngelChooseActiveContext* context) override; antlrcpp::Any visitAngelContains(cola::CoLaParser::AngelContainsContext* context) override; antlrcpp::Any visitOption(cola::CoLaParser::OptionContext* context) override; antlrcpp::Any visitObserverList(cola::CoLaParser::ObserverListContext* /*context*/) override { throw std::logic_error("not implemented"); } antlrcpp::Any visitObserverDefinition(cola::CoLaParser::ObserverDefinitionContext* /*context*/) override { throw std::logic_error("not implemented"); } antlrcpp::Any visitObserverVariableList(cola::CoLaParser::ObserverVariableListContext* /*context*/) override { throw std::logic_error("not implemented"); } antlrcpp::Any visitObserverVariable(cola::CoLaParser::ObserverVariableContext* /*context*/) override { throw std::logic_error("not implemented"); } antlrcpp::Any visitObserverStateList(cola::CoLaParser::ObserverStateListContext* /*context*/) override { throw std::logic_error("not implemented"); } antlrcpp::Any visitObserverState(cola::CoLaParser::ObserverStateContext* /*context*/) override { throw std::logic_error("not implemented"); } antlrcpp::Any visitObserverTransitionList(cola::CoLaParser::ObserverTransitionListContext* /*context*/) override { throw std::logic_error("not implemented"); } antlrcpp::Any visitObserverTransition(cola::CoLaParser::ObserverTransitionContext* /*context*/) override { throw std::logic_error("not implemented"); } antlrcpp::Any visitObserverGuardTrue(cola::CoLaParser::ObserverGuardTrueContext* /*context*/) override { throw std::logic_error("not implemented"); } antlrcpp::Any visitObserverGuardIdentifierEq(cola::CoLaParser::ObserverGuardIdentifierEqContext* /*context*/) override { throw std::logic_error("not implemented"); } antlrcpp::Any visitObserverGuardIdentifierNeq(cola::CoLaParser::ObserverGuardIdentifierNeqContext* /*context*/) override { throw std::logic_error("not implemented"); } }; } // namespace cola
68.007042
170
0.780988
Wolff09
eeb8135a7ed1b1e4f17369e512764a2c50870acc
1,092
cpp
C++
0213/test0213.cpp
Insofan/ExerciseRepo
6ab830c30a8863078699d4f0c8bf28db2140495c
[ "BSD-3-Clause" ]
null
null
null
0213/test0213.cpp
Insofan/ExerciseRepo
6ab830c30a8863078699d4f0c8bf28db2140495c
[ "BSD-3-Clause" ]
null
null
null
0213/test0213.cpp
Insofan/ExerciseRepo
6ab830c30a8863078699d4f0c8bf28db2140495c
[ "BSD-3-Clause" ]
null
null
null
// // @ClassName test0213 // @Description TODO // @Date 2019/2/13 3:09 PM // @Created by Insomnia // #include <iostream> #include <vector> #include <algorithm> using namespace std; class Solution { public: string largestNumber(vector<int>& nums) { string res; if (nums.empty()) { return "0"; } sort(nums.begin(), nums.end(), [](int x, int y) { return to_string(x) + to_string(y) > to_string(y) + to_string(x); }); for (int i = 0; i < nums.size(); i++) { res += to_string(nums[i]); } return res[0] == '0' ? "0" : res; } }; vector<int> randomVec(int len, int maxNum) { vector<int> tempVec; srand((unsigned) time(NULL)); for (int i = 0; i < len; ++i) { int x = rand() % maxNum; tempVec.push_back(x); } return tempVec; } int main() { int arr[] = {32, 3, 321}; vector<int> vec(&arr[0], &arr[3]); Solution solution; // cout << solution.minNumOffer(vec) << endl; // cout << solution.minNumOffer2(vec) << endl; return 0; }
19.854545
77
0.529304
Insofan
eebe45928db19e68e33f304681ba250d82f9c2fb
2,280
cpp
C++
exercises/Perception-Driven_Manipulation/solution_ws/src/collision_avoidance_pick_and_place/src/tasks/detect_box_pick.cpp
JonathanPlasse/industrial_training
2de2ecbc8d1f7d2b4b724cc6badd003ca2d653d7
[ "Apache-2.0" ]
324
2015-01-31T07:35:37.000Z
2022-03-27T09:30:14.000Z
exercises/Perception-Driven_Manipulation/ros1/solution_ws/src/collision_avoidance_pick_and_place/src/tasks/detect_box_pick.cpp
AhmedMounir/industrial_training
e6761c7bee65d3802fee6cf7c99e3113d3dc1af2
[ "Apache-2.0" ]
226
2015-01-20T17:15:56.000Z
2022-01-19T04:55:23.000Z
exercises/Perception-Driven_Manipulation/ros1/solution_ws/src/collision_avoidance_pick_and_place/src/tasks/detect_box_pick.cpp
AhmedMounir/industrial_training
e6761c7bee65d3802fee6cf7c99e3113d3dc1af2
[ "Apache-2.0" ]
219
2015-03-29T03:05:11.000Z
2022-03-23T11:12:43.000Z
#include <collision_avoidance_pick_and_place/pick_and_place.h> /* DETECTING BOX PICK POSE Goal: - Find the box's position in the world frame using the transform listener. * this transform is published by the kinect AR-tag perception node - Save the pose into 'box_pose'. */ geometry_msgs::Pose collision_avoidance_pick_and_place::PickAndPlace::detect_box_pick() { //ROS_ERROR_STREAM("detect_box_pick is not implemented yet. Aborting."); exit(1); // creating shape for recognition shape_msgs::SolidPrimitive shape; shape.type = shape_msgs::SolidPrimitive::BOX; shape.dimensions.resize(3); shape.dimensions[0] = cfg.BOX_SIZE.getX(); shape.dimensions[1] = cfg.BOX_SIZE.getY(); shape.dimensions[2] = cfg.BOX_SIZE.getZ(); // creating request object collision_avoidance_pick_and_place::GetTargetPose srv; srv.request.shape = shape; srv.request.world_frame_id = cfg.WORLD_FRAME_ID; srv.request.ar_tag_frame_id = cfg.AR_TAG_FRAME_ID; geometry_msgs::Pose place_pose; tf::poseTFToMsg(cfg.BOX_PLACE_TF,place_pose); srv.request.remove_at_poses.push_back(place_pose); /* Fill Code: * Goal: * - Call target recognition service and save results. * Hint: * - Use the service response member to access the * detected pose "srv.response.target_pose". * - Assign the target_pose in the response to the box_pose variable in * order to save the results. */ geometry_msgs::Pose box_pose; if(target_recognition_client.call(srv)) { if(srv.response.succeeded) { box_pose = srv.response.target_pose; ROS_INFO_STREAM("target recognition succeeded"); } else { ROS_ERROR_STREAM("target recognition failed"); exit(0); } } else { ROS_ERROR_STREAM("Service call for target recognition failed with response '"<< (srv.response.succeeded ?"SUCCESS":"FAILURE") <<"', exiting"); exit(0); } // updating box marker for visualization in rviz visualization_msgs::Marker marker = cfg.MARKER_MESSAGE; cfg.MARKER_MESSAGE.header.frame_id = cfg.WORLD_FRAME_ID; cfg.MARKER_MESSAGE.pose = box_pose; cfg.MARKER_MESSAGE.pose.position.z = box_pose.position.z - 0.5f*cfg.BOX_SIZE.z(); show_box(true); return box_pose; }
31.232877
87
0.710965
JonathanPlasse
eec0672afc0d69351a2c4dff6f4edaed157d62e5
4,490
hpp
C++
include/ensmallen_bits/scd/scd_impl.hpp
ElianeBriand/ensmallen
0f634056d054d100b2a70cb8f15ea9fa38680d10
[ "BSL-1.0", "BSD-3-Clause" ]
1
2020-04-07T18:50:10.000Z
2020-04-07T18:50:10.000Z
include/ensmallen_bits/scd/scd_impl.hpp
ElianeBriand/ensmallen
0f634056d054d100b2a70cb8f15ea9fa38680d10
[ "BSL-1.0", "BSD-3-Clause" ]
null
null
null
include/ensmallen_bits/scd/scd_impl.hpp
ElianeBriand/ensmallen
0f634056d054d100b2a70cb8f15ea9fa38680d10
[ "BSL-1.0", "BSD-3-Clause" ]
1
2019-01-16T16:21:59.000Z
2019-01-16T16:21:59.000Z
/** * @file scd_impl.hpp * @author Shikhar Bhardwaj * * Implementation of stochastic coordinate descent. * * ensmallen is free software; you may redistribute it and/or modify it under * the terms of the 3-clause BSD license. You should have received a copy of * the 3-clause BSD license along with ensmallen. If not, see * http://www.opensource.org/licenses/BSD-3-Clause for more information. */ #ifndef ENSMALLEN_SCD_SCD_IMPL_HPP #define ENSMALLEN_SCD_SCD_IMPL_HPP // In case it hasn't been included yet. #include "scd.hpp" #include <ensmallen_bits/function.hpp> namespace ens { template <typename DescentPolicyType> SCD<DescentPolicyType>::SCD( const double stepSize, const size_t maxIterations, const double tolerance, const size_t updateInterval, const DescentPolicyType descentPolicy) : stepSize(stepSize), maxIterations(maxIterations), tolerance(tolerance), updateInterval(updateInterval), descentPolicy(descentPolicy) { /* Nothing to do */ } //! Optimize the function (minimize). template <typename DescentPolicyType> template <typename ResolvableFunctionType, typename MatType, typename GradType, typename... CallbackTypes> typename std::enable_if<IsArmaType<GradType>::value, typename MatType::elem_type>::type SCD<DescentPolicyType>::Optimize( ResolvableFunctionType& function, MatType& iterateIn, CallbackTypes&&... callbacks) { // Convenience typedefs. typedef typename MatType::elem_type ElemType; typedef typename MatTypeTraits<MatType>::BaseMatType BaseMatType; typedef typename MatTypeTraits<GradType>::BaseMatType BaseGradType; // Make sure we have the methods that we need. traits::CheckResolvableFunctionTypeAPI<ResolvableFunctionType, BaseMatType, BaseGradType>(); RequireFloatingPointType<BaseMatType>(); RequireFloatingPointType<BaseGradType>(); ElemType overallObjective = 0; ElemType lastObjective = std::numeric_limits<ElemType>::max(); BaseMatType& iterate = (BaseMatType&) iterateIn; BaseGradType gradient; // Controls early termination of the optimization process. bool terminate = false; // Start iterating. terminate |= Callback::BeginOptimization(*this, function, iterate, callbacks...); for (size_t i = 1; i != maxIterations && !terminate; ++i) { // Get the coordinate to descend on. size_t featureIdx = descentPolicy.template DescentFeature< ResolvableFunctionType, BaseMatType, BaseGradType>(i, iterate, function); // Get the partial gradient with respect to this feature. function.PartialGradient(iterate, featureIdx, gradient); terminate |= Callback::Gradient(*this, function, iterate, overallObjective, gradient, callbacks...); // Update the decision variable with the partial gradient. iterate.col(featureIdx) -= stepSize * gradient.col(featureIdx); terminate |= Callback::StepTaken(*this, function, iterate, callbacks...); // Check for convergence. if (i % updateInterval == 0) { overallObjective = function.Evaluate(iterate); terminate |= Callback::Evaluate(*this, function, iterate, overallObjective, callbacks...); // Output current objective function. Info << "SCD: iteration " << i << ", objective " << overallObjective << "." << std::endl; if (std::isnan(overallObjective) || std::isinf(overallObjective)) { Warn << "SCD: converged to " << overallObjective << "; terminating" << " with failure. Try a smaller step size?" << std::endl; Callback::EndOptimization(*this, function, iterate, callbacks...); return overallObjective; } if (std::abs(lastObjective - overallObjective) < tolerance) { Info << "SCD: minimized within tolerance " << tolerance << "; " << "terminating optimization." << std::endl; Callback::EndOptimization(*this, function, iterate, callbacks...); return overallObjective; } lastObjective = overallObjective; } } Info << "SCD: maximum iterations (" << maxIterations << ") reached; " << "terminating optimization." << std::endl; // Calculate and return final objective. const ElemType objective = function.Evaluate(iterate); Callback::Evaluate(*this, function, iterate, objective, callbacks...); Callback::EndOptimization(*this, function, iterate, callbacks...); return objective; } } // namespace ens #endif
33.014706
79
0.69755
ElianeBriand
eec071a2cbddfd37d6f8b4116d2e6ad8fd4b5f75
15,143
cpp
C++
adaptors/emscripten/egl-implementation-emscripten.cpp
pwisbey/dali-adaptor
21d5e77316e53285fa1e210a93b13cf9889e3b54
[ "Apache-2.0" ]
null
null
null
adaptors/emscripten/egl-implementation-emscripten.cpp
pwisbey/dali-adaptor
21d5e77316e53285fa1e210a93b13cf9889e3b54
[ "Apache-2.0" ]
null
null
null
adaptors/emscripten/egl-implementation-emscripten.cpp
pwisbey/dali-adaptor
21d5e77316e53285fa1e210a93b13cf9889e3b54
[ "Apache-2.0" ]
null
null
null
/* Copyright (c) 2000-2013 Samsung Electronics Co., Ltd All Rights Reserved This file is part of Dali Adaptor PROPRIETARY/CONFIDENTIAL This software is the confidential and proprietary information of SAMSUNG ELECTRONICS ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only in accordance with the terms of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG make no representations or warranties about the suitability of the software, either express or implied, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAMSUNG shall not be liable for any damages suffered by licensee as a result of using, modifying or distributing this software or its derivatives. */ // CLASS HEADER #include <gl/egl-implementation.h> // EXTERNAL INCLUDES #include <iostream> #include <dali/integration-api/debug.h> #include <dali/public-api/common/dali-common.h> #include <dali/public-api/common/dali-vector.h> // INTERNAL INCLUDES namespace { #if defined(DEBUG_ENABLED) void PrintConfigs(EGLDisplay d) { EGLint numConfigs; eglGetConfigs(d, NULL, 0, &numConfigs); EGLConfig *configs = new EGLConfig[numConfigs]; eglGetConfigs(d, configs, numConfigs, &numConfigs); printf("Configurations: N=%d\n", numConfigs); printf(" - config id\n"); printf(" - buffer size\n"); printf(" - level\n"); printf(" - double buffer\n"); printf(" - stereo\n"); printf(" - r, g, b\n"); printf(" - depth\n"); printf(" - stencil\n"); printf(" bf lv d st colorbuffer dp st supported \n"); printf(" id sz l b ro r g b a th cl surfaces \n"); printf("----------------------------------------------\n"); for (EGLint i = 0; i < numConfigs; i++) { EGLint id, size, level; EGLint red, green, blue, alpha; EGLint depth, stencil; EGLint surfaces; EGLint doubleBuf = 1, stereo = 0; char surfString[100] = ""; eglGetConfigAttrib(d, configs[i], EGL_CONFIG_ID, &id); eglGetConfigAttrib(d, configs[i], EGL_BUFFER_SIZE, &size); eglGetConfigAttrib(d, configs[i], EGL_LEVEL, &level); eglGetConfigAttrib(d, configs[i], EGL_RED_SIZE, &red); eglGetConfigAttrib(d, configs[i], EGL_GREEN_SIZE, &green); eglGetConfigAttrib(d, configs[i], EGL_BLUE_SIZE, &blue); eglGetConfigAttrib(d, configs[i], EGL_ALPHA_SIZE, &alpha); eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth); eglGetConfigAttrib(d, configs[i], EGL_STENCIL_SIZE, &stencil); eglGetConfigAttrib(d, configs[i], EGL_SURFACE_TYPE, &surfaces); if (surfaces & EGL_WINDOW_BIT) strcat(surfString, "win,"); if (surfaces & EGL_PBUFFER_BIT) strcat(surfString, "pb,"); if (surfaces & EGL_PIXMAP_BIT) strcat(surfString, "pix,"); if (strlen(surfString) > 0) surfString[strlen(surfString) - 1] = 0; printf("0x%02x %2d %2d %c %c %2d %2d %2d %2d %2d %2d %-12s\n", id, size, level, doubleBuf ? 'y' : '.', stereo ? 'y' : '.', red, green, blue, alpha, depth, stencil, surfString); } delete [] configs; } #endif } // namespace anon namespace Dali { namespace Internal { namespace Adaptor { #define TEST_EGL_ERROR(lastCommand) \ { \ EGLint err = eglGetError(); \ if (err != EGL_SUCCESS) \ { \ printf("EGL error after %s code=%x\n", lastCommand, err); \ DALI_LOG_ERROR("EGL error after %s code=%x\n", lastCommand,err); \ DALI_ASSERT_ALWAYS(0 && "EGL error"); \ } \ } EglImplementation::EglImplementation() : mEglNativeDisplay(0), mCurrentEglNativePixmap(0), mEglDisplay(0), mEglConfig(0), mEglContext(0), mCurrentEglSurface(0), mGlesInitialized(false), mIsOwnSurface(true), mContextCurrent(false), mIsWindow(true), mColorDepth(COLOR_DEPTH_24) { } EglImplementation::~EglImplementation() { TerminateGles(); } bool EglImplementation::InitializeGles( EGLNativeDisplayType display, bool isOwnSurface ) { if ( !mGlesInitialized ) { mEglNativeDisplay = display; //@todo see if we can just EGL_DEFAULT_DISPLAY instead mEglDisplay = eglGetDisplay(mEglNativeDisplay); EGLint majorVersion = 0; EGLint minorVersion = 0; if ( !eglInitialize( mEglDisplay, &majorVersion, &minorVersion ) ) { return false; } eglBindAPI(EGL_OPENGL_ES_API); #if defined(DEBUG_ENABLED) PrintConfigs(mEglDisplay); #endif mContextAttribs.Clear(); #if DALI_GLES_VERSION >= 30 mContextAttribs.Reserve(5); mContextAttribs.PushBack( EGL_CONTEXT_MAJOR_VERSION_KHR ); mContextAttribs.PushBack( 3 ); mContextAttribs.PushBack( EGL_CONTEXT_MINOR_VERSION_KHR ); mContextAttribs.PushBack( 0 ); #else // DALI_GLES_VERSION >= 30 mContextAttribs.Reserve(3); mContextAttribs.PushBack( EGL_CONTEXT_CLIENT_VERSION ); mContextAttribs.PushBack( 2 ); #endif // DALI_GLES_VERSION >= 30 mContextAttribs.PushBack( EGL_NONE ); mGlesInitialized = true; mIsOwnSurface = isOwnSurface; } return mGlesInitialized; } bool EglImplementation::CreateContext() { // make sure a context isn't created twice DALI_ASSERT_ALWAYS( (mEglContext == 0) && "EGL context recreated" ); DALI_ASSERT_ALWAYS( mGlesInitialized ); mEglContext = eglCreateContext(mEglDisplay, mEglConfig, NULL, &(mContextAttribs[0])); // if emscripten ignore this (egl spec says non gles2 implementation must return EGL_BAD_MATCH if it doesnt support gles2) // so just ignore error for now.... // TEST_EGL_ERROR("eglCreateContext render thread"); // DALI_ASSERT_ALWAYS( EGL_NO_CONTEXT != mEglContext && "EGL context not created" ); return true; } void EglImplementation::DestroyContext() { DALI_ASSERT_ALWAYS( mEglContext && "no EGL context" ); eglDestroyContext( mEglDisplay, mEglContext ); mEglContext = 0; } void EglImplementation::DestroySurface() { if(mIsOwnSurface && mCurrentEglSurface) { eglDestroySurface( mEglDisplay, mCurrentEglSurface ); mCurrentEglSurface = 0; } } void EglImplementation::MakeContextCurrent() { mContextCurrent = true; if(mIsOwnSurface) { eglMakeCurrent( mEglDisplay, mCurrentEglSurface, mCurrentEglSurface, mEglContext ); } EGLint error = eglGetError(); if ( error != EGL_SUCCESS ) { switch (error) { case EGL_BAD_DISPLAY: { DALI_LOG_ERROR("EGL_BAD_DISPLAY : Display is not an EGL display connection\n"); break; } case EGL_NOT_INITIALIZED: { DALI_LOG_ERROR("EGL_NOT_INITIALIZED : Display has not been initialized\n"); break; } case EGL_BAD_SURFACE: { DALI_LOG_ERROR("EGL_BAD_SURFACE : Draw or read is not an EGL surface\n"); break; } case EGL_BAD_CONTEXT: { DALI_LOG_ERROR("EGL_BAD_CONTEXT : Context is not an EGL rendering context\n"); break; } case EGL_BAD_MATCH: { DALI_LOG_ERROR("EGL_BAD_MATCH : Draw or read are not compatible with context, or if context is set to EGL_NO_CONTEXT and draw or read are not set to EGL_NO_SURFACE, or if draw or read are set to EGL_NO_SURFACE and context is not set to EGL_NO_CONTEXT\n"); break; } case EGL_BAD_ACCESS: { DALI_LOG_ERROR("EGL_BAD_ACCESS : Context is current to some other thread\n"); break; } case EGL_BAD_NATIVE_PIXMAP: { DALI_LOG_ERROR("EGL_BAD_NATIVE_PIXMAP : A native pixmap underlying either draw or read is no longer valid.\n"); break; } case EGL_BAD_NATIVE_WINDOW: { DALI_LOG_ERROR("EGL_BAD_NATIVE_WINDOW : A native window underlying either draw or read is no longer valid.\n"); break; } case EGL_BAD_CURRENT_SURFACE: { DALI_LOG_ERROR("EGL_BAD_CURRENT_SURFACE : The previous context has unflushed commands and the previous surface is no longer valid.\n"); break; } case EGL_BAD_ALLOC: { DALI_LOG_ERROR("EGL_BAD_ALLOC : Allocation of ancillary buffers for draw or read were delayed until eglMakeCurrent is called, and there are not enough resources to allocate them\n"); break; } case EGL_CONTEXT_LOST: { DALI_LOG_ERROR("EGL_CONTEXT_LOST : If a power management event has occurred. The application must destroy all contexts and reinitialise OpenGL ES state and objects to continue rendering\n"); break; } default: { DALI_LOG_ERROR("Unknown error\n"); break; } } DALI_ASSERT_ALWAYS(false && "MakeContextCurrent failed!"); } DALI_LOG_WARNING("- EGL Information\nVendor: %s\nVersion: %s\nClient APIs: %s\nExtensions: %s\n", eglQueryString(mEglDisplay, EGL_VENDOR), eglQueryString(mEglDisplay, EGL_VERSION), eglQueryString(mEglDisplay, EGL_CLIENT_APIS), eglQueryString(mEglDisplay, EGL_EXTENSIONS)); } void EglImplementation::MakeContextNull() { mContextCurrent = false; // clear the current context eglMakeCurrent( mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); } void EglImplementation::TerminateGles() { if ( mGlesInitialized ) { // in latest Mali DDK (r2p3 ~ r3p0 in April, 2012), // MakeContextNull should be called before eglDestroy surface // to prevent crash in _mali_surface_destroy_callback MakeContextNull(); if(mIsOwnSurface && mCurrentEglSurface) { eglDestroySurface(mEglDisplay, mCurrentEglSurface); } eglDestroyContext(mEglDisplay, mEglContext); eglTerminate(mEglDisplay); mEglDisplay = NULL; mEglConfig = NULL; mEglContext = NULL; mCurrentEglSurface = NULL; mGlesInitialized = false; } } bool EglImplementation::IsGlesInitialized() const { return mGlesInitialized; } void EglImplementation::SwapBuffers() { eglSwapBuffers( mEglDisplay, mCurrentEglSurface ); } void EglImplementation::CopyBuffers() { eglCopyBuffers( mEglDisplay, mCurrentEglSurface, mCurrentEglNativePixmap ); } void EglImplementation::WaitGL() { eglWaitGL(); } void EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth ) { if(mEglConfig && isWindowType == mIsWindow && mColorDepth == depth) { return; } mIsWindow = isWindowType; EGLint numConfigs; Vector<EGLint> configAttribs; configAttribs.Reserve(31); if(isWindowType) { configAttribs.PushBack( EGL_SURFACE_TYPE ); configAttribs.PushBack( EGL_WINDOW_BIT ); } else { DALI_ASSERT_ALWAYS(!"uninplemented"); configAttribs.PushBack( EGL_SURFACE_TYPE ); configAttribs.PushBack( EGL_PIXMAP_BIT ); } configAttribs.PushBack( EGL_RENDERABLE_TYPE ); #if DALI_GLES_VERSION >= 30 DALI_ASSERT_ALWAYS(!"uninplemented"); #ifdef _ARCH_ARM_ configAttribs.PushBack( EGL_OPENGL_ES3_BIT_KHR ); #else // There is a bug in the desktop emulator // Requesting for ES3 causes eglCreateContext even though it allows to ask // for a configuration that supports GLES 3.0 configAttribs.PushBack( EGL_OPENGL_ES2_BIT ); #endif // _ARCH_ARM_ #else // DALI_GLES_VERSION >= 30 configAttribs.PushBack( EGL_OPENGL_ES2_BIT ); #endif //DALI_GLES_VERSION >= 30 configAttribs.PushBack( EGL_RED_SIZE ); configAttribs.PushBack( 8 ); configAttribs.PushBack( EGL_GREEN_SIZE ); configAttribs.PushBack( 8 ); configAttribs.PushBack( EGL_BLUE_SIZE ); configAttribs.PushBack( 8 ); // // Setting the alpha crashed .... need SDL_SetVideo(...) with alpha somehow?? // configAttribs.PushBack( EGL_ALPHA_SIZE ); configAttribs.PushBack( 8 ); configAttribs.PushBack( EGL_DEPTH_SIZE ); configAttribs.PushBack( 24 ); configAttribs.PushBack( EGL_NONE ); if ( eglChooseConfig( mEglDisplay, &(configAttribs[0]), &mEglConfig, 1, &numConfigs ) != EGL_TRUE ) { EGLint error = eglGetError(); switch (error) { case EGL_BAD_DISPLAY: { DALI_LOG_ERROR("Display is not an EGL display connection\n"); break; } case EGL_BAD_ATTRIBUTE: { DALI_LOG_ERROR("The parameter confirAttribs contains an invalid frame buffer configuration attribute or an attribute value that is unrecognized or out of range\n"); break; } case EGL_NOT_INITIALIZED: { DALI_LOG_ERROR("Display has not been initialized\n"); break; } case EGL_BAD_PARAMETER: { DALI_LOG_ERROR("The parameter numConfig is NULL\n"); break; } default: { DALI_LOG_ERROR("Unknown error\n"); } } DALI_ASSERT_ALWAYS(false && "eglChooseConfig failed!"); } if ( numConfigs != 1 ) { DALI_LOG_ERROR("No configurations found.\n"); TEST_EGL_ERROR("eglChooseConfig"); } } void EglImplementation::CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth ) { DALI_ASSERT_ALWAYS( ( mCurrentEglSurface == 0 ) && "EGL surface already exists" ); mColorDepth = depth; mIsWindow = true; // egl choose config static_cast<void>(window); EGLNativeWindowType dummyWindow = NULL; mCurrentEglSurface = eglCreateWindowSurface( mEglDisplay, mEglConfig, dummyWindow, NULL ); TEST_EGL_ERROR("eglCreateWindowSurface"); DALI_ASSERT_ALWAYS( mCurrentEglSurface && "Create window surface failed" ); } EGLSurface EglImplementation::CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth ) { DALI_ASSERT_ALWAYS( mCurrentEglSurface == 0 && "Cannot create more than one instance of surface pixmap" ); mCurrentEglNativePixmap = pixmap; mColorDepth = depth; mIsWindow = false; // egl choose config ChooseConfig(mIsWindow, mColorDepth); mCurrentEglSurface = eglCreatePixmapSurface( mEglDisplay, mEglConfig, mCurrentEglNativePixmap, NULL ); TEST_EGL_ERROR("eglCreatePixmapSurface"); DALI_ASSERT_ALWAYS( mCurrentEglSurface && "Create pixmap surface failed" ); return mCurrentEglSurface; } bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window ) { DALI_ASSERT_ALWAYS(!"Unimplemented"); bool contextLost = false; // the surface is bound to the context, so set the context to null MakeContextNull(); // destroy the surface DestroySurface(); // create the EGL surface CreateSurfaceWindow( window, mColorDepth ); // set the context to be current with the new surface MakeContextCurrent(); return contextLost; } bool EglImplementation::ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLSurface& eglSurface ) { bool contextLost = false; // the surface is bound to the context, so set the context to null MakeContextNull(); // destroy the surface DestroySurface(); // create the EGL surface eglSurface = CreateSurfacePixmap( pixmap, mColorDepth ); // set the context to be current with the new surface MakeContextCurrent(); return contextLost; } EGLDisplay EglImplementation::GetDisplay() const { return mEglDisplay; } EGLDisplay EglImplementation::GetContext() const { return mEglContext; } } // namespace Adaptor } // namespace Internal } // namespace Dali
26.94484
263
0.695107
pwisbey
eec15276b1aab1e9f2edefa5349c45b7307fc894
8,553
cpp
C++
ivs/src/v2/IvsClient.cpp
huaweicloud/huaweicloud-sdk-cpp-v3
d3b5e07b0ee8367d1c7f6dad17be0212166d959c
[ "Apache-2.0" ]
5
2021-03-03T08:23:43.000Z
2022-02-16T02:16:39.000Z
ivs/src/v2/IvsClient.cpp
ChenwxJay/huaweicloud-sdk-cpp-v3
f821ec6d269b50203e0c1638571ee1349c503c41
[ "Apache-2.0" ]
null
null
null
ivs/src/v2/IvsClient.cpp
ChenwxJay/huaweicloud-sdk-cpp-v3
f821ec6d269b50203e0c1638571ee1349c503c41
[ "Apache-2.0" ]
7
2021-02-26T13:53:35.000Z
2022-03-18T02:36:43.000Z
#include <huaweicloud/ivs/v2/IvsClient.h> #include <huaweicloud/core/utils/MultipartFormData.h> #include <unordered_set> #include <boost/algorithm/string/replace.hpp> template <typename T> std::string toString(const T value) { std::ostringstream out; out << std::setprecision(std::numeric_limits<T>::digits10) << std::fixed << value; return out.str(); } namespace HuaweiCloud { namespace Sdk { namespace Ivs { namespace V2 { using namespace HuaweiCloud::Sdk::Ivs::V2::Model; IvsClient::IvsClient() { } IvsClient::~IvsClient() { } ClientBuilder<IvsClient> IvsClient::newBuilder() { return ClientBuilder<IvsClient>("BasicCredentials"); } std::shared_ptr<DetectExtentionByIdCardImageResponse> IvsClient::detectExtentionByIdCardImage(DetectExtentionByIdCardImageRequest &request) { std::string localVarPath = "/v2.0/ivs-idcard-extention"; std::map<std::string, std::string> localVarQueryParams; std::map<std::string, std::string> localVarHeaderParams; std::map<std::string, std::string> localVarFormParams; std::map<std::string, std::string> localVarPathParams; std::map<std::string, std::shared_ptr<HttpContent>> localVarFileParams; bool isJson = false; bool isMultiPart = false; std::string contentType = getContentType("application/json", isJson, isMultiPart); localVarHeaderParams["Content-Type"] = contentType; std::string localVarHttpBody; if (isJson) { web::json::value localVarJson; localVarJson = ModelBase::toJson(request.getBody()); localVarHttpBody = utility::conversions::to_utf8string(localVarJson.serialize()); } std::unique_ptr<HttpResponse> res = callApi("POST", localVarPath, localVarPathParams, localVarQueryParams, localVarHeaderParams, localVarHttpBody); std::shared_ptr<DetectExtentionByIdCardImageResponse> localVarResult = std::make_shared<DetectExtentionByIdCardImageResponse>(); if (!res->getHttpBody().empty()) { utility::string_t localVarResponse = utility::conversions::to_string_t(res->getHttpBody()); web::json::value localVarJson = web::json::value::parse(localVarResponse); localVarResult->fromJson(localVarJson); } localVarResult->setStatusCode(res->getStatusCode()); localVarResult->setHeaderParams(res->getHeaderParams()); localVarResult->setHttpBody(res->getHttpBody()); return localVarResult; } std::shared_ptr<DetectExtentionByNameAndIdResponse> IvsClient::detectExtentionByNameAndId(DetectExtentionByNameAndIdRequest &request) { std::string localVarPath = "/v2.0/ivs-idcard-extention"; std::map<std::string, std::string> localVarQueryParams; std::map<std::string, std::string> localVarHeaderParams; std::map<std::string, std::string> localVarFormParams; std::map<std::string, std::string> localVarPathParams; std::map<std::string, std::shared_ptr<HttpContent>> localVarFileParams; bool isJson = false; bool isMultiPart = false; std::string contentType = getContentType("application/json", isJson, isMultiPart); localVarHeaderParams["Content-Type"] = contentType; std::string localVarHttpBody; if (isJson) { web::json::value localVarJson; localVarJson = ModelBase::toJson(request.getBody()); localVarHttpBody = utility::conversions::to_utf8string(localVarJson.serialize()); } std::unique_ptr<HttpResponse> res = callApi("POST", localVarPath, localVarPathParams, localVarQueryParams, localVarHeaderParams, localVarHttpBody); std::shared_ptr<DetectExtentionByNameAndIdResponse> localVarResult = std::make_shared<DetectExtentionByNameAndIdResponse>(); if (!res->getHttpBody().empty()) { utility::string_t localVarResponse = utility::conversions::to_string_t(res->getHttpBody()); web::json::value localVarJson = web::json::value::parse(localVarResponse); localVarResult->fromJson(localVarJson); } localVarResult->setStatusCode(res->getStatusCode()); localVarResult->setHeaderParams(res->getHeaderParams()); localVarResult->setHttpBody(res->getHttpBody()); return localVarResult; } std::shared_ptr<DetectStandardByIdCardImageResponse> IvsClient::detectStandardByIdCardImage(DetectStandardByIdCardImageRequest &request) { std::string localVarPath = "/v2.0/ivs-standard"; std::map<std::string, std::string> localVarQueryParams; std::map<std::string, std::string> localVarHeaderParams; std::map<std::string, std::string> localVarFormParams; std::map<std::string, std::string> localVarPathParams; std::map<std::string, std::shared_ptr<HttpContent>> localVarFileParams; bool isJson = false; bool isMultiPart = false; std::string contentType = getContentType("application/json", isJson, isMultiPart); localVarHeaderParams["Content-Type"] = contentType; std::string localVarHttpBody; if (isJson) { web::json::value localVarJson; localVarJson = ModelBase::toJson(request.getBody()); localVarHttpBody = utility::conversions::to_utf8string(localVarJson.serialize()); } std::unique_ptr<HttpResponse> res = callApi("POST", localVarPath, localVarPathParams, localVarQueryParams, localVarHeaderParams, localVarHttpBody); std::shared_ptr<DetectStandardByIdCardImageResponse> localVarResult = std::make_shared<DetectStandardByIdCardImageResponse>(); if (!res->getHttpBody().empty()) { utility::string_t localVarResponse = utility::conversions::to_string_t(res->getHttpBody()); web::json::value localVarJson = web::json::value::parse(localVarResponse); localVarResult->fromJson(localVarJson); } localVarResult->setStatusCode(res->getStatusCode()); localVarResult->setHeaderParams(res->getHeaderParams()); localVarResult->setHttpBody(res->getHttpBody()); return localVarResult; } std::shared_ptr<DetectStandardByNameAndIdResponse> IvsClient::detectStandardByNameAndId(DetectStandardByNameAndIdRequest &request) { std::string localVarPath = "/v2.0/ivs-standard"; std::map<std::string, std::string> localVarQueryParams; std::map<std::string, std::string> localVarHeaderParams; std::map<std::string, std::string> localVarFormParams; std::map<std::string, std::string> localVarPathParams; std::map<std::string, std::shared_ptr<HttpContent>> localVarFileParams; bool isJson = false; bool isMultiPart = false; std::string contentType = getContentType("application/json", isJson, isMultiPart); localVarHeaderParams["Content-Type"] = contentType; std::string localVarHttpBody; if (isJson) { web::json::value localVarJson; localVarJson = ModelBase::toJson(request.getBody()); localVarHttpBody = utility::conversions::to_utf8string(localVarJson.serialize()); } std::unique_ptr<HttpResponse> res = callApi("POST", localVarPath, localVarPathParams, localVarQueryParams, localVarHeaderParams, localVarHttpBody); std::shared_ptr<DetectStandardByNameAndIdResponse> localVarResult = std::make_shared<DetectStandardByNameAndIdResponse>(); if (!res->getHttpBody().empty()) { utility::string_t localVarResponse = utility::conversions::to_string_t(res->getHttpBody()); web::json::value localVarJson = web::json::value::parse(localVarResponse); localVarResult->fromJson(localVarJson); } localVarResult->setStatusCode(res->getStatusCode()); localVarResult->setHeaderParams(res->getHeaderParams()); localVarResult->setHttpBody(res->getHttpBody()); return localVarResult; } #if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) std::string IvsClient::parameterToString(utility::string_t value) { return utility::conversions::to_utf8string(value); } #endif std::string IvsClient::parameterToString(std::string value) { return value; } std::string IvsClient::parameterToString(int64_t value) { std::stringstream valueAsStringStream; valueAsStringStream << value; return valueAsStringStream.str(); } std::string IvsClient::parameterToString(int32_t value) { std::stringstream valueAsStringStream; valueAsStringStream << value; return valueAsStringStream.str(); } std::string IvsClient::parameterToString(float value) { return toString(value); } std::string IvsClient::parameterToString(double value) { return toString(value); } std::string IvsClient::parameterToString(const utility::datetime &value) { return utility::conversions::to_utf8string(value.to_string(utility::datetime::ISO_8601)); } } } } }
36.395745
151
0.736934
huaweicloud
eec2bae48f0462bba7ca403aec542caa2c837a6d
9,479
cpp
C++
tests/YGAlignSelfTest.cpp
emilsjolander/yoga
02a2309b2a8208e652e351cf8a195c17694b1f01
[ "MIT" ]
null
null
null
tests/YGAlignSelfTest.cpp
emilsjolander/yoga
02a2309b2a8208e652e351cf8a195c17694b1f01
[ "MIT" ]
null
null
null
tests/YGAlignSelfTest.cpp
emilsjolander/yoga
02a2309b2a8208e652e351cf8a195c17694b1f01
[ "MIT" ]
null
null
null
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html #include <gtest/gtest.h> #include <yoga/Yoga.h> TEST(YogaTest, align_self_center) { const YGConfigRef config = YGConfigNew(); const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); YGConfigFree(config); } TEST(YogaTest, align_self_flex_end) { const YGConfigRef config = YGConfigNew(); const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); YGConfigFree(config); } TEST(YogaTest, align_self_flex_start) { const YGConfigRef config = YGConfigNew(); const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexStart); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); YGConfigFree(config); } TEST(YogaTest, align_self_flex_end_override_flex_start) { const YGConfigRef config = YGConfigNew(); const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlignFlexStart); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); YGNodeFreeRecursive(root); YGConfigFree(config); } TEST(YogaTest, align_self_baseline) { const YGConfigRef config = YGConfigNew(); const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child0, YGAlignBaseline); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child1, YGAlignBaseline); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1_child0, 50); YGNodeStyleSetHeight(root_child1_child0, 10); YGNodeInsertChild(root_child1, root_child1_child0, 0); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); YGNodeFreeRecursive(root); YGConfigFree(config); }
37.916
78
0.805992
emilsjolander
eec324e25d1f9716216d09e009c391beb70f1f50
3,279
cpp
C++
src/caffe/layers/cudnn_batch_norm_layer.cpp
madiken/caffe-CUDNN-fork
6fdbbe9ae7fa0165feb864d122ac92a6a0d0a2f1
[ "BSD-2-Clause" ]
null
null
null
src/caffe/layers/cudnn_batch_norm_layer.cpp
madiken/caffe-CUDNN-fork
6fdbbe9ae7fa0165feb864d122ac92a6a0d0a2f1
[ "BSD-2-Clause" ]
null
null
null
src/caffe/layers/cudnn_batch_norm_layer.cpp
madiken/caffe-CUDNN-fork
6fdbbe9ae7fa0165feb864d122ac92a6a0d0a2f1
[ "BSD-2-Clause" ]
null
null
null
#ifdef USE_CUDNN #include <vector> #include "caffe/filler.hpp" #include "caffe/layer.hpp" #include "caffe/util/im2col.hpp" #include "caffe/util/math_functions.hpp" #include "caffe/vision_layers.hpp" namespace caffe { template <typename Dtype> void CuDNNBatchNormLayer<Dtype>::LayerSetUp( const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { BatchNormLayer<Dtype>::LayerSetUp(bottom, top); cudnn::createTensor4dDesc<Dtype>(&bottom_desc_); cudnn::createTensor4dDesc<Dtype>(&top_desc_); cudnn::createTensor4dDesc<Dtype>(&scale_bias_mean_var_desc_); // currently only SPATIAL mode is supported (most commonly used mode) // If there's enough demand we can implement CUDNN_BATCHNORM_PER_ACTIVATION // though it's not currently implemented for the CPU layer mode_ = CUDNN_BATCHNORM_SPATIAL; if (this->blobs_.size() > 5) { LOG(INFO) << "Skipping parameter initialization"; } else { this->blobs_.resize(5); this->blobs_[0].reset(new Blob<Dtype>(1, bottom[0]->channels(), 1, 1)); this->blobs_[1].reset(new Blob<Dtype>(1, bottom[0]->channels(), 1, 1)); this->blobs_[2].reset(new Blob<Dtype>(1, 1, 1, 1)); this->blobs_[3].reset(new Blob<Dtype>(1, bottom[0]->channels(), 1, 1)); this->blobs_[4].reset(new Blob<Dtype>(1, bottom[0]->channels(), 1, 1)); shared_ptr<Filler<Dtype> > scale_filler( GetFiller<Dtype>(this->layer_param_.batch_norm_param().scale_filler())); scale_filler->Fill(this->blobs_[0].get()); shared_ptr<Filler<Dtype> > bias_filler( GetFiller<Dtype>(this->layer_param_.batch_norm_param().bias_filler())); bias_filler->Fill(this->blobs_[1].get()); for (int i = 2; i < 5; i++) { caffe_set(this->blobs_[i]->count(), Dtype(0), this->blobs_[i]->mutable_cpu_data()); } } handles_setup_ = true; } template <typename Dtype> void CuDNNBatchNormLayer<Dtype>::Reshape( const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { BatchNormLayer<Dtype>::Reshape(bottom, top); // set up main tensors cudnn::setTensor4dDesc<Dtype>( &bottom_desc_, bottom[0]->num(), bottom[0]->channels(), bottom[0]->height(), bottom[0]->width()); cudnn::setTensor4dDesc<Dtype>( &top_desc_, bottom[0]->num(), bottom[0]->channels(), bottom[0]->height(), bottom[0]->width()); // aux tensors for caching mean & invVar from fwd to bwd pass int C = bottom[0]->channels(); int H = bottom[0]->height(); int W = bottom[0]->width(); if (mode_ == CUDNN_BATCHNORM_SPATIAL) { save_mean_.Reshape(1, C, 1, 1); save_inv_var_.Reshape(1, C, 1, 1); } else if (mode_ == CUDNN_BATCHNORM_PER_ACTIVATION) { save_mean_.Reshape(1, C, H, W); save_inv_var_.Reshape(1, C, H, W); } else { LOG(FATAL) << "Unknown cudnnBatchNormMode_t"; } CUDNN_CHECK(cudnnDeriveBNTensorDescriptor(scale_bias_mean_var_desc_, bottom_desc_, mode_)); } template <typename Dtype> CuDNNBatchNormLayer<Dtype>::~CuDNNBatchNormLayer() { if (!handles_setup_) return; cudnnDestroyTensorDescriptor(bottom_desc_); cudnnDestroyTensorDescriptor(top_desc_); cudnnDestroyTensorDescriptor(scale_bias_mean_var_desc_); } INSTANTIATE_CLASS(CuDNNBatchNormLayer); } // namespace caffe #endif
33.459184
78
0.681
madiken
eec60c3b6bb4f4c06d192c556d259874e31714e6
17,049
cpp
C++
rgcmidcpp/src/midi/smf.cpp
mdsitton/rhythmChartFormat
1e53aaff34603bee258582293d11d29e0bf53bde
[ "BSD-2-Clause" ]
8
2017-09-20T20:24:29.000Z
2019-08-10T22:55:13.000Z
rgcmidcpp/src/midi/smf.cpp
mdsitton/rhythmChartFormat
1e53aaff34603bee258582293d11d29e0bf53bde
[ "BSD-2-Clause" ]
null
null
null
rgcmidcpp/src/midi/smf.cpp
mdsitton/rhythmChartFormat
1e53aaff34603bee258582293d11d29e0bf53bde
[ "BSD-2-Clause" ]
1
2018-08-28T19:28:20.000Z
2018-08-28T19:28:20.000Z
// Copyright (c) 2015-2017 Matthew Sitton <matthewsitton@gmail.com> // See LICENSE in the RhythmGameChart root for license information. #include "smf.hpp" #include <iostream> #include <cstring> #include <cmath> namespace RGCCPP::Midi { SmfReader::SmfReader(std::string filename) :m_smfFile(filename, std::ios_base::ate | std::ios_base::binary) { if (m_smfFile) { init_tempo_ts(); read_file(); m_smfFile.close(); } else { throw std::runtime_error("Failed to load midi."); } } std::vector<SmfTrack>& SmfReader::get_tracks() { return m_tracks; } TempoTrack* SmfReader::get_tempo_track() { return &m_tempoTrack; } void SmfReader::release() { m_tracks.clear(); } void SmfReader::read_midi_event(const SmfEventInfo &event) { MidiEvent midiEvent; midiEvent.info = event; midiEvent.message = static_cast<MidiChannelMessage>(event.status & 0xF0); midiEvent.channel = static_cast<uint8_t>(event.status & 0xF); switch (midiEvent.message) { case NoteOff: // note off (2 more bytes) case NoteOn: // note on (2 more bytes) midiEvent.data1 = read_type<uint8_t>(m_smfFile); // note midiEvent.data2 = read_type<uint8_t>(m_smfFile); // velocity break; case KeyPressure: midiEvent.data1 = read_type<uint8_t>(m_smfFile); // note midiEvent.data2 = read_type<uint8_t>(m_smfFile); // pressure break; case ControlChange: midiEvent.data1 = read_type<uint8_t>(m_smfFile); // controller midiEvent.data2 = read_type<uint8_t>(m_smfFile); // cont_value break; case ProgramChange: midiEvent.data1 = read_type<uint8_t>(m_smfFile); // program midiEvent.data2 = 0; // no data break; case ChannelPressure: midiEvent.data1 = read_type<uint8_t>(m_smfFile); // pressure midiEvent.data2 = 0; // no data break; case PitchBend: midiEvent.data1 = read_type<uint8_t>(m_smfFile); // pitch_low midiEvent.data2 = read_type<uint8_t>(m_smfFile); // pitch_high break; default: break; } m_currentTrack->midiEvents.push_back(midiEvent); } void SmfReader::read_meta_event(const SmfEventInfo &eventInfo) { MetaEvent event {eventInfo, read_type<MidiMetaEvent>(m_smfFile), read_vlv<uint32_t>(m_smfFile)}; // In the cases where we dont implement an event type log it, and its data. switch(event.type) { case meta_SequenceNumber: { auto sequenceNumber = read_type<uint16_t>(m_smfFile); break; } case meta_Text: case meta_Copyright: case meta_InstrumentName: case meta_Lyrics: // TODO - Implement ruby parser for lyrics case meta_Marker: case meta_CuePoint: // RP-019 - SMF Device Name and Program Name Meta Events case meta_ProgramName: case meta_DeviceName: // The midi spec says the following text events exist and act the same as meta_Text. case meta_TextReserved3: case meta_TextReserved4: case meta_TextReserved5: case meta_TextReserved6: case meta_TextReserved7: case meta_TextReserved8: { auto textData = std::make_unique<char[]>(event.length+1); textData[event.length] = '\0'; read_type<char>(m_smfFile, textData.get(), event.length); m_currentTrack->textEvents.push_back({event, std::string(textData.get())}); break; } case meta_TrackName: { auto textData = std::make_unique<char[]>(event.length+1); textData[event.length] = '\0'; read_type<char>(m_smfFile, textData.get(), event.length); m_currentTrack->name = std::string(textData.get()); break; } case meta_MIDIChannelPrefix: { // TODO - Add channel auto midiChannel = read_type<uint8_t>(m_smfFile); break; } case meta_EndOfTrack: { m_currentTrack->endTime = event.info.pulseTime; break; } case meta_Tempo: { double absTime = 0.0; uint32_t qnLength = read_type<uint32_t>(m_smfFile, 3); double timePerTick = (qnLength / (m_header.division * 1'000'000.0)); // We calculate the absTime of each tempo event from the previous which will act as a base to calculate other events time. // This is good because it reduces the number of doubles we store reducing memory usage somewhat, and it also reduces // the rounding error overall allowing more accurate timestamps. Thanks FireFox of the RGC discord for this idea from his // .chart/midi parser that is used for his moonscraper project. if (eventInfo.pulseTime == 0 && m_tempoTrack.tempo.size() == 1) { m_tempoTrack.tempo[0] = {event, qnLength, absTime, timePerTick}; } else { auto lastTempo = m_tempoTrack.tempo.back(); absTime = lastTempo.absTime + delta_tick_to_delta_time(&lastTempo, eventInfo.pulseTime - lastTempo.info.info.pulseTime ); m_tempoTrack.tempoOrdering.push_back({TtOrderType::Tempo, static_cast<int>(m_tempoTrack.tempo.size())}); m_tempoTrack.tempo.push_back({event, qnLength, absTime, timePerTick}); } break; } case meta_TimeSignature: { TimeSignatureEvent tsEvent; tsEvent.info = event; tsEvent.numerator = read_type<uint8_t>(m_smfFile); // 4 default tsEvent.denominator = std::pow(2, read_type<uint8_t>(m_smfFile)); // 4 default // This is best described as a bad attempt at supporting meter and is basically useless. // The midi spec examples are also extremely misleading tsEvent.clocksPerBeat = read_type<uint8_t>(m_smfFile); // Standard is 24 // The number of 1/32nd notes per "MIDI quarter note" // This should be used in order to change the note value which a "MIDI quarter note" is considered. // For example changing it to be 0x0C(12) should change tempo to be // defined in. // Note "MIDI quarter note" is defined to always be 24 midi clocks therfor even if // changed to dotted quarter it should still be 24 midi clocks // // Later thoughts, this could also mean to change globally what a quarter note means which basically // would make it totally unrelated to ts... But i still stand by my original interpritation as I have // found a reference that contains the same interpritation as above: // // Beyond MIDI: The Handbook of Musical Codes page 54 tsEvent.thirtySecondPQN = read_type<uint8_t>(m_smfFile); // 8 default if (eventInfo.pulseTime == 0 && m_tempoTrack.timeSignature.size() == 1) { m_tempoTrack.timeSignature[0] = tsEvent; } else { m_tempoTrack.tempoOrdering.push_back({TtOrderType::TimeSignature, static_cast<int>(m_tempoTrack.timeSignature.size())}); m_tempoTrack.timeSignature.push_back(tsEvent); } break; } // These are mainly here to just represent them existing :P case meta_MIDIPort: // obsolete no longer used. case meta_SMPTEOffset: // Not currently implemented, maybe someday. case meta_KeySignature: // Not very useful for us case meta_XMFPatchType: // probably not used case meta_SequencerSpecific: default: { // store data for unused event for later save passthrough. std::vector<char> eventData; for (int i=0;i<event.length;++i) { eventData.emplace_back(read_type<char>(m_smfFile)); } m_currentTrack->miscMeta.push_back({event, eventData}); break; } } } void SmfReader::read_sysex_event(const SmfEventInfo &event) { // TODO - Actually implement sysex events, they arent currently saved anywhere. // This will be needed for open notes, or many of the phase shift midi extensions. auto length = read_vlv<uint32_t>(m_smfFile); std::vector<char> sysex; sysex.resize(length); read_type<char>(m_smfFile, &sysex[0], length); } // Convert from deltaPulses to deltaTime. double SmfReader::delta_tick_to_delta_time(TempoEvent* tempo, uint32_t deltaPulses) { return deltaPulses * tempo->timePerTick; } // Converts a absolute time in pulses to an absolute time in seconds double SmfReader::pulsetime_to_abstime(uint32_t pulseTime) { if (pulseTime == 0) { return 0.0; } // The basic idea here is to start from the most recent tempo event before this time. // Then calculate and add the time since that tempo to the tempo time. // To speed this up further we could store the result of the time per tick calculation in the tempo event and only use it here. TempoEvent* tempo = get_last_tempo_via_pulses(pulseTime); return tempo->absTime + ((pulseTime - tempo->info.info.pulseTime) * tempo->timePerTick); } void SmfReader::init_tempo_ts() { // We initialize the vectors in the tempo track to default 120BPM 4/4 ts as defined by the spec. // However these may be overwritten later. m_tempoTrack.tempoOrdering.push_back({TtOrderType::TimeSignature, 0}); m_tempoTrack.tempoOrdering.push_back({TtOrderType::Tempo, 0}); MetaEvent tsEvent {{meta_TimeSignature,0,0}, meta_Tempo, 3}; m_tempoTrack.timeSignature.push_back({tsEvent, 4, 4, 24, 8}); MetaEvent tempoEvent {{status_MetaEvent,0,0}, meta_Tempo, 3}; m_tempoTrack.tempo.push_back({tempoEvent, 500'000, 0.0}); // ppqn, absTime } TempoEvent* SmfReader::get_last_tempo_via_pulses(uint32_t pulseTime) { static unsigned int value = 0; static uint32_t lastPulseTime = 0; std::vector<TempoEvent> &tempos = m_tempoTrack.tempo; // Ignore the cached last tempo value if the new pulse time is older. if (lastPulseTime > pulseTime) { value = 0; } for (unsigned int i = value; i < tempos.size(); i++) { if (tempos[i].info.info.pulseTime > pulseTime) { value = i-1; lastPulseTime = pulseTime; return &tempos[value]; } } // return last value if nothing else is found return &tempos.back(); } SmfHeaderChunk* SmfReader::get_header() { return &m_header; } void SmfReader::read_events(uint32_t chunkEnd) { uint32_t pulseTime = 0; uint8_t oldRunningStatus = 0; bool runningStatusReset = false; // find a ballpark size estimate for the track uint32_t sizeGuess = (chunkEnd - m_smfFile.tellg()) / 3; m_currentTrack->midiEvents.reserve(sizeGuess); SmfEventInfo eventInfo; while (m_smfFile.tellg() < chunkEnd) { eventInfo.deltaPulses = read_vlv<uint32_t>(m_smfFile); // DO NOT use this for time calculations. // You must convert each deltaPulse to a time // within the currently active tempo. pulseTime += eventInfo.deltaPulses; eventInfo.pulseTime = pulseTime; auto status = peek_type<uint8_t>(m_smfFile); if (status == status_MetaEvent) { if (runningStatusReset == false) { runningStatusReset = true; oldRunningStatus = eventInfo.status; } eventInfo.status = read_type<uint8_t>(m_smfFile); read_meta_event(eventInfo); } else if (status == status_SysexEvent || status == status_SysexEvent2) { if (runningStatusReset == false) { runningStatusReset = true; oldRunningStatus = eventInfo.status; } eventInfo.status = read_type<uint8_t>(m_smfFile); read_sysex_event(eventInfo); } else { // Check if we should use the running status. if ((status & 0xF0) >= 0x80) { eventInfo.status = read_type<uint8_t>(m_smfFile); } else if (runningStatusReset) { eventInfo.status = oldRunningStatus; } runningStatusReset = false; read_midi_event(eventInfo); } } } void SmfReader::read_file() { uint32_t fileEnd = static_cast<uint32_t>(m_smfFile.tellg()); m_smfFile.seekg(0, std::ios::beg); uint32_t fileStart = m_smfFile.tellg(); uint32_t filePos = fileStart; uint32_t fileRemaining = fileEnd; SmfChunkInfo chunk; // set the intial chunk starting position at the beginning of the file. uint32_t chunkStart = fileStart; // The chunk end will be calculated after a chunk is loaded. uint32_t chunkEnd = 0; int trackChunkCount = 0; // We could loop through the number of track chunks given in the header. // However if there are any unknown chunk types inside the midi file // this will likely break. So we just loop until we hit the end of the // file instead... while (filePos < fileEnd) { read_type<char>(m_smfFile, chunk.chunkType, 4); chunk.length = read_type<uint32_t>(m_smfFile); chunkEnd = chunkStart + (8 + chunk.length); // 8 is the length of the type + length fields // MThd chunk is only in the beginning of the file. if (chunkStart == fileStart && strcmp(chunk.chunkType, "MThd") == 0) { // Load header chunk m_header.info = chunk; m_header.format = read_type<uint16_t>(m_smfFile); m_header.trackNum = read_type<uint16_t>(m_smfFile); m_header.division = read_type<int16_t>(m_smfFile); // Make sure we reserve enough space for m_tracks just in-case. m_tracks.reserve(sizeof(SmfTrack) * m_header.trackNum); if (m_header.format == smfType0 && m_header.trackNum != 1) { throw std::runtime_error("Not a valid type 0 midi."); } else if (m_header.format == smfType2) { throw std::runtime_error("Type 2 midi not supported."); } if ((m_header.division & 0x8000) != 0) { throw std::runtime_error("SMPTE time division not supported"); } } else if (strcmp(chunk.chunkType, "MTrk") == 0) { trackChunkCount += 1; m_tracks.emplace_back(); m_currentTrack = &m_tracks.back(); read_events(chunkEnd); } filePos = chunkEnd; chunkStart = filePos; // Make sure that we are in the correct location in the chunk // If not seek to the correct location and output an error in the log. if (static_cast<int>(m_smfFile.tellg()) != filePos) { m_smfFile.seekg(filePos); } fileRemaining = (fileEnd-filePos); if (fileRemaining != 0 && fileRemaining <= 8) { // Skip the rest of the file. break; } } } }
38.659864
141
0.557217
mdsitton
eec853019dbecfe80a98045780511b34cc572681
49,447
cc
C++
src/chirpstack_client.cc
chungphb/chirpstack-client
6a0f80f887776d6270ef821be1ccf99d87aca146
[ "MIT" ]
1
2022-01-20T02:44:29.000Z
2022-01-20T02:44:29.000Z
src/chirpstack_client.cc
chungphb/chirpstack-cpp-client
6a0f80f887776d6270ef821be1ccf99d87aca146
[ "MIT" ]
null
null
null
src/chirpstack_client.cc
chungphb/chirpstack-cpp-client
6a0f80f887776d6270ef821be1ccf99d87aca146
[ "MIT" ]
null
null
null
// // Created by chungphb on 2/6/21. // #include <chirpstack_client/chirpstack_client.h> #include <utility> using namespace api; using namespace grpc; namespace chirpstack_cpp_client { chirpstack_client::chirpstack_client(const std::string& server_address, chirpstack_client_config config) { _channel = CreateChannel(server_address, grpc::InsecureChannelCredentials()); _config = std::move(config); _application_service_stub = ApplicationService::NewStub(_channel); _device_service_stub = DeviceService::NewStub(_channel); _device_profile_service_stub = DeviceProfileService::NewStub(_channel); _device_queue_service_stub = DeviceQueueService::NewStub(_channel); _gateway_service_stub = GatewayService::NewStub(_channel); _gateway_profile_service_stub = GatewayProfileService::NewStub(_channel); _internal_service_stub = InternalService::NewStub(_channel); _multicast_group_service_stub = MulticastGroupService::NewStub(_channel); _network_server_service_stub = NetworkServerService::NewStub(_channel); _organization_service_stub = OrganizationService::NewStub(_channel); _service_profile_service_stub = ServiceProfileService::NewStub(_channel); _user_service_stub = UserService::NewStub(_channel); } // Application Service create_application_response chirpstack_client::create_application(const create_application_request& request) { create_application_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _application_service_stub->Create(&context, request, &response); if (!status.ok()) { log(status.error_message()); return create_application_response{status.error_code()}; } else { return create_application_response{std::move(response)}; } } get_application_response chirpstack_client::get_application(const get_application_request& request) { get_application_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _application_service_stub->Get(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_application_response{status.error_code()}; } else { return get_application_response{std::move(response)}; } } update_application_response chirpstack_client::update_application(const update_application_request& request) { update_application_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _application_service_stub->Update(&context, request, &response); if (!status.ok()) { log(status.error_message()); return update_application_response{status.error_code()}; } else { return update_application_response{std::move(response)}; } } delete_application_response chirpstack_client::delete_application(const delete_application_request& request) { delete_application_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _application_service_stub->Delete(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_application_response{status.error_code()}; } else { return delete_application_response{std::move(response)}; } } list_application_response chirpstack_client::list_application(const list_application_request& request) { list_application_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _application_service_stub->List(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_application_response{status.error_code()}; } else { return list_application_response{std::move(response)}; } } // Device Service create_device_response chirpstack_client::create_device(const create_device_request& request) { create_device_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_service_stub->Create(&context, request, &response); if (!status.ok()) { log(status.error_message()); return create_device_response{status.error_code()}; } else { return create_device_response{std::move(response)}; } } get_device_response chirpstack_client::get_device(const get_device_request& request) { get_device_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_service_stub->Get(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_device_response{status.error_code()}; } else { return get_device_response{std::move(response)}; } } update_device_response chirpstack_client::update_device(const update_device_request& request) { update_device_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_service_stub->Update(&context, request, &response); if (!status.ok()) { log(status.error_message()); return update_device_response{status.error_code()}; } else { return update_device_response{std::move(response)}; } } delete_device_response chirpstack_client::delete_device(const delete_device_request& request) { delete_device_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_service_stub->Delete(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_device_response{status.error_code()}; } else { return delete_device_response{std::move(response)}; } } list_device_response chirpstack_client::list_device(const list_device_request& request) { list_device_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_service_stub->List(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_device_response{status.error_code()}; } else { return list_device_response{std::move(response)}; } } create_device_keys_response chirpstack_client::create_device_keys(const create_device_keys_request& request) { create_device_keys_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_service_stub->CreateKeys(&context, request, &response); if (!status.ok()) { log(status.error_message()); return create_device_keys_response{status.error_code()}; } else { return create_device_keys_response{std::move(response)}; } } get_device_keys_response chirpstack_client::get_device_keys(const get_device_keys_request& request) { get_device_keys_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_service_stub->GetKeys(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_device_keys_response{status.error_code()}; } else { return get_device_keys_response{std::move(response)}; } } update_device_keys_response chirpstack_client::update_device_keys(const update_device_keys_request& request) { update_device_keys_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_service_stub->UpdateKeys(&context, request, &response); if (!status.ok()) { log(status.error_message()); return update_device_keys_response{status.error_code()}; } else { return update_device_keys_response{std::move(response)}; } } delete_device_keys_response chirpstack_client::delete_device_keys(const delete_device_keys_request& request) { delete_device_keys_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_service_stub->DeleteKeys(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_device_keys_response{status.error_code()}; } else { return delete_device_keys_response{std::move(response)}; } } activate_device_response chirpstack_client::activate_device(const activate_device_request& request) { activate_device_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_service_stub->Activate(&context, request, &response); if (!status.ok()) { log(status.error_message()); return activate_device_response{status.error_code()}; } else { return activate_device_response{std::move(response)}; } } deactivate_device_response chirpstack_client::deactivate_device(const deactivate_device_request& request) { delete_device_keys_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_service_stub->Deactivate(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_device_keys_response{status.error_code()}; } else { return delete_device_keys_response{std::move(response)}; } } get_device_activation_response chirpstack_client::get_device_activation(const get_device_activation_request& request) { get_device_activation_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_service_stub->GetActivation(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_device_activation_response{status.error_code()}; } else { return get_device_activation_response{std::move(response)}; } } get_random_dev_addr_response chirpstack_client::get_random_dev_addr(const get_random_dev_addr_request& request) { get_random_dev_addr_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_service_stub->GetRandomDevAddr(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_random_dev_addr_response{status.error_code()}; } else { return get_random_dev_addr_response{std::move(response)}; } } // Device Profile Service create_device_profile_response chirpstack_client::create_device_profile(const create_device_profile_request& request) { create_device_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_profile_service_stub->Create(&context, request, &response); if (!status.ok()) { log(status.error_message()); return create_device_profile_response{status.error_code()}; } else { return create_device_profile_response{std::move(response)}; } } get_device_profile_response chirpstack_client::get_device_profile(const get_device_profile_request& request) { get_device_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_profile_service_stub->Get(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_device_profile_response{status.error_code()}; } else { return get_device_profile_response{std::move(response)}; } } update_device_profile_response chirpstack_client::update_device_profile(const update_device_profile_request& request) { update_device_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_profile_service_stub->Update(&context, request, &response); if (!status.ok()) { log(status.error_message()); return update_device_profile_response{status.error_code()}; } else { return update_device_profile_response{std::move(response)}; } } delete_device_profile_response chirpstack_client::delete_device_profile(const delete_device_profile_request& request) { delete_device_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_profile_service_stub->Delete(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_device_profile_response{status.error_code()}; } else { return delete_device_profile_response{std::move(response)}; } } list_device_profile_response chirpstack_client::list_device_profile(const list_device_profile_request& request) { list_device_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_profile_service_stub->List(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_device_profile_response{status.error_code()}; } else { return list_device_profile_response{std::move(response)}; } } // Device Queue Service enqueue_device_queue_item_response chirpstack_client::enqueue_device_queue_item(const enqueue_device_queue_item_request& request) { enqueue_device_queue_item_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_queue_service_stub->Enqueue(&context, request, &response); if (!status.ok()) { log(status.error_message()); return enqueue_device_queue_item_response{status.error_code()}; } else { return enqueue_device_queue_item_response{std::move(response)}; } } flush_device_queue_response chirpstack_client::flush_device_queue(const flush_device_queue_request& request) { flush_device_queue_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_queue_service_stub->Flush(&context, request, &response); if (!status.ok()) { log(status.error_message()); return flush_device_queue_response{status.error_code()}; } else { return flush_device_queue_response{std::move(response)}; } } list_device_queue_items_response chirpstack_client::list_device_queue_items(const list_device_queue_items_request& request) { list_device_queue_items_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _device_queue_service_stub->List(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_device_queue_items_response{status.error_code()}; } else { return list_device_queue_items_response{std::move(response)}; } } // Gateway Service create_gateway_response chirpstack_client::create_gateway(const create_gateway_request& request) { create_gateway_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _gateway_service_stub->Create(&context, request, &response); if (!status.ok()) { log(status.error_message()); return create_gateway_response{status.error_code()}; } else { return create_gateway_response{std::move(response)}; } } get_gateway_response chirpstack_client::get_gateway(const get_gateway_request& request) { get_gateway_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _gateway_service_stub->Get(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_gateway_response{status.error_code()}; } else { return get_gateway_response{std::move(response)}; } } update_gateway_response chirpstack_client::update_gateway(const update_gateway_request& request) { create_gateway_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _gateway_service_stub->Update(&context, request, &response); if (!status.ok()) { log(status.error_message()); return update_gateway_response{status.error_code()}; } else { return update_gateway_response{std::move(response)}; } } delete_gateway_response chirpstack_client::delete_gateway(const delete_gateway_request& request) { delete_gateway_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _gateway_service_stub->Delete(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_gateway_response{status.error_code()}; } else { return delete_gateway_response{std::move(response)}; } } list_gateway_response chirpstack_client::list_gateway(const list_gateway_request& request) { list_gateway_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _gateway_service_stub->List(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_gateway_response{status.error_code()}; } else { return list_gateway_response{std::move(response)}; } } get_gateway_stats_response chirpstack_client::get_gateway_stats(const get_gateway_stats_request& request) { get_gateway_stats_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _gateway_service_stub->GetStats(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_gateway_stats_response{status.error_code()}; } else { return get_gateway_stats_response{std::move(response)}; } } get_last_ping_response chirpstack_client::get_last_ping(const get_last_ping_request& request) { get_last_ping_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _gateway_service_stub->GetLastPing(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_last_ping_response{status.error_code()}; } else { return get_last_ping_response{std::move(response)}; } } generate_gateway_client_certificate_response chirpstack_client::generate_gateway_client_certificate(const generate_gateway_client_certificate_request& request) { generate_gateway_client_certificate_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _gateway_service_stub->GenerateGatewayClientCertificate(&context, request, &response); if (!status.ok()) { log(status.error_message()); return generate_gateway_client_certificate_response{status.error_code()}; } else { return generate_gateway_client_certificate_response{std::move(response)}; } } // Gateway Profile Service create_gateway_profile_response chirpstack_client::create_gateway_profile(const create_gateway_profile_request& request) { create_gateway_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _gateway_profile_service_stub->Create(&context, request, &response); if (!status.ok()) { log(status.error_message()); return create_gateway_profile_response{status.error_code()}; } else { return create_gateway_profile_response{std::move(response)}; } } get_gateway_profile_response chirpstack_client::get_gateway_profile(const get_gateway_profile_request& request) { get_gateway_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _gateway_profile_service_stub->Get(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_gateway_profile_response{status.error_code()}; } else { return get_gateway_profile_response{std::move(response)}; } } update_gateway_profile_response chirpstack_client::update_gateway_profile(const update_gateway_profile_request& request) { update_gateway_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _gateway_profile_service_stub->Update(&context, request, &response); if (!status.ok()) { log(status.error_message()); return update_gateway_profile_response{status.error_code()}; } else { return update_gateway_profile_response{std::move(response)}; } } delete_gateway_profile_response chirpstack_client::delete_gateway_profile(const delete_gateway_profile_request& request) { delete_gateway_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _gateway_profile_service_stub->Delete(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_gateway_profile_response{status.error_code()}; } else { return delete_gateway_profile_response{std::move(response)}; } } list_gateway_profiles_response chirpstack_client::list_gateway_profiles(const list_gateway_profiles_request& request) { list_gateway_profiles_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _gateway_profile_service_stub->List(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_gateway_profiles_response{status.error_code()}; } else { return list_gateway_profiles_response{std::move(response)}; } } // Internal Service login_response chirpstack_client::login(const login_request& request) { login_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _internal_service_stub->Login(&context, request, &response); if (!status.ok()) { log(status.error_message()); return login_response{status.error_code()}; } else { return login_response{std::move(response)}; } } profile_response chirpstack_client::profile(const profile_request& request) { profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _internal_service_stub->Profile(&context, request, &response); if (!status.ok()) { log(status.error_message()); return profile_response{status.error_code()}; } else { return profile_response{std::move(response)}; } } global_search_response chirpstack_client::global_search(const global_search_request& request) { global_search_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _internal_service_stub->GlobalSearch(&context, request, &response); if (!status.ok()) { log(status.error_message()); return global_search_response{status.error_code()}; } else { return global_search_response{std::move(response)}; } } create_api_key_response chirpstack_client::create_api_key(const create_api_key_request& request) { create_api_key_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _internal_service_stub->CreateAPIKey(&context, request, &response); if (!status.ok()) { log(status.error_message()); return create_api_key_response{status.error_code()}; } else { return create_api_key_response{std::move(response)}; } } delete_api_key_response chirpstack_client::delete_api_key(const delete_api_key_request& request) { delete_api_key_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _internal_service_stub->DeleteAPIKey(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_api_key_response{status.error_code()}; } else { return delete_api_key_response{std::move(response)}; } } list_api_keys_response chirpstack_client::list_api_keys(const list_api_keys_request& request) { list_api_keys_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _internal_service_stub->ListAPIKeys(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_api_keys_response{status.error_code()}; } else { return list_api_keys_response{std::move(response)}; } } settings_response chirpstack_client::settings(const settings_request& request) { settings_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _internal_service_stub->Settings(&context, request, &response); if (!status.ok()) { log(status.error_message()); return settings_response{status.error_code()}; } else { return settings_response{std::move(response)}; } } open_id_connect_login_response chirpstack_client::open_id_connect_login(const open_id_connect_login_request& request) { open_id_connect_login_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _internal_service_stub->OpenIDConnectLogin(&context, request, &response); if (!status.ok()) { log(status.error_message()); return open_id_connect_login_response{status.error_code()}; } else { return open_id_connect_login_response{std::move(response)}; } } get_devices_summary_response chirpstack_client::get_devices_summary(const get_devices_summary_request& request) { get_devices_summary_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _internal_service_stub->GetDevicesSummary(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_devices_summary_response{status.error_code()}; } else { return get_devices_summary_response{std::move(response)}; } } get_gateways_summary_response chirpstack_client::get_gateways_summary(const get_gateways_summary_request& request) { get_gateways_summary_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _internal_service_stub->GetGatewaysSummary(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_gateways_summary_response{status.error_code()}; } else { return get_gateways_summary_response{std::move(response)}; } } // Multicast Group Service create_multicast_group_response chirpstack_client::create_multicast_group(const create_multicast_group_request& request) { create_multicast_group_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _multicast_group_service_stub->Create(&context, request, &response); if (!status.ok()) { log(status.error_message()); return create_multicast_group_response{status.error_code()}; } else { return create_multicast_group_response{std::move(response)}; } } get_multicast_group_response chirpstack_client::get_multicast_group(const get_multicast_group_request& request) { get_multicast_group_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _multicast_group_service_stub->Get(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_multicast_group_response{status.error_code()}; } else { return get_multicast_group_response{std::move(response)}; } } update_multicast_group_response chirpstack_client::update_multicast_group(const update_multicast_group_request& request) { update_multicast_group_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _multicast_group_service_stub->Update(&context, request, &response); if (!status.ok()) { log(status.error_message()); return update_multicast_group_response{status.error_code()}; } else { return update_multicast_group_response{std::move(response)}; } } delete_multicast_group_response chirpstack_client::delete_multicast_group(const delete_multicast_group_request& request) { delete_multicast_group_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _multicast_group_service_stub->Delete(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_multicast_group_response{status.error_code()}; } else { return delete_multicast_group_response{std::move(response)}; } } list_multicast_group_response chirpstack_client::list_multicast_group(const list_multicast_group_request& request) { list_multicast_group_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _multicast_group_service_stub->List(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_multicast_group_response{status.error_code()}; } else { return list_multicast_group_response{std::move(response)}; } } add_device_to_multicast_group_response chirpstack_client::add_device_to_multicast_group(const add_device_to_multicast_group_request& request) { add_device_to_multicast_group_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _multicast_group_service_stub->AddDevice(&context, request, &response); if (!status.ok()) { log(status.error_message()); return add_device_to_multicast_group_response{status.error_code()}; } else { return add_device_to_multicast_group_response{std::move(response)}; } } remove_device_from_multicast_group_response chirpstack_client::remove_device_from_multicast_group(const remove_device_from_multicast_group_request& request) { remove_device_from_multicast_group_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _multicast_group_service_stub->RemoveDevice(&context, request, &response); if (!status.ok()) { log(status.error_message()); return remove_device_from_multicast_group_response{status.error_code()}; } else { return remove_device_from_multicast_group_response{std::move(response)}; } } enqueue_multicast_queue_item_response chirpstack_client::enqueue_multicast_queue_item(const enqueue_multicast_queue_item_request& request) { enqueue_multicast_queue_item_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _multicast_group_service_stub->Enqueue(&context, request, &response); if (!status.ok()) { log(status.error_message()); return enqueue_multicast_queue_item_response{status.error_code()}; } else { return enqueue_multicast_queue_item_response{std::move(response)}; } } flush_multicast_group_queue_items_response chirpstack_client::flush_multicast_group_queue_items(const flush_multicast_group_queue_items_request& request) { flush_multicast_group_queue_items_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _multicast_group_service_stub->FlushQueue(&context, request, &response); if (!status.ok()) { log(status.error_message()); return flush_multicast_group_queue_items_response{status.error_code()}; } else { return flush_multicast_group_queue_items_response{std::move(response)}; } } list_multicast_group_queue_items_response chirpstack_client::list_multicast_group_queue_items(const list_multicast_group_queue_items_request& request) { list_multicast_group_queue_items_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _multicast_group_service_stub->ListQueue(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_multicast_group_queue_items_response{status.error_code()}; } else { return list_multicast_group_queue_items_response{std::move(response)}; } } // Network Server Service create_network_server_response chirpstack_client::create_network_server(const create_network_server_request& request) { create_network_server_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _network_server_service_stub->Create(&context, request, &response); if (!status.ok()) { log(status.error_message()); return create_network_server_response{status.error_code()}; } else { return create_network_server_response{std::move(response)}; } } get_network_server_response chirpstack_client::get_network_server(const get_network_server_request& request) { get_network_server_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _network_server_service_stub->Get(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_network_server_response{status.error_code()}; } else { return get_network_server_response{std::move(response)}; } } update_network_server_response chirpstack_client::update_network_server(const update_network_server_request& request) { update_network_server_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _network_server_service_stub->Update(&context, request, &response); if (!status.ok()) { log(status.error_message()); return update_network_server_response{status.error_code()}; } else { return update_network_server_response{std::move(response)}; } } delete_network_server_response chirpstack_client::delete_network_server(const delete_network_server_request& request) { delete_network_server_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _network_server_service_stub->Delete(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_network_server_response{status.error_code()}; } else { return delete_network_server_response{std::move(response)}; } } list_network_server_response chirpstack_client::list_network_server(const list_network_server_request& request) { list_network_server_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _network_server_service_stub->List(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_network_server_response{status.error_code()}; } else { return list_network_server_response{std::move(response)}; } } get_adr_algorithms_response chirpstack_client::get_adr_algorithms(const get_adr_algorithms_request& request) { get_adr_algorithms_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _network_server_service_stub->GetADRAlgorithms(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_adr_algorithms_response{status.error_code()}; } else { return get_adr_algorithms_response{std::move(response)}; } } // Organization Service create_organization_response chirpstack_client::create_organization(const create_organization_request& request) { create_organization_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _organization_service_stub->Create(&context, request, &response); if (!status.ok()) { log(status.error_message()); return create_organization_response{status.error_code()}; } else { return create_organization_response{std::move(response)}; } } get_organization_response chirpstack_client::get_organization(const get_organization_request& request) { get_organization_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _organization_service_stub->Get(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_organization_response{status.error_code()}; } else { return get_organization_response{std::move(response)}; } } update_organization_response chirpstack_client::update_organization(const update_organization_request& request) { update_organization_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _organization_service_stub->Update(&context, request, &response); if (!status.ok()) { log(status.error_message()); return update_organization_response{status.error_code()}; } else { return update_organization_response{std::move(response)}; } } delete_organization_response chirpstack_client::delete_organization(const delete_organization_request& request) { delete_organization_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _organization_service_stub->Delete(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_organization_response{status.error_code()}; } else { return delete_organization_response{std::move(response)}; } } list_organization_response chirpstack_client::list_organization(const list_organization_request& request) { list_organization_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _organization_service_stub->List(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_organization_response{status.error_code()}; } else { return list_organization_response{std::move(response)}; } } add_organization_user_response chirpstack_client::add_organization_user(const add_organization_user_request& request) { add_organization_user_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _organization_service_stub->AddUser(&context, request, &response); if (!status.ok()) { log(status.error_message()); return add_organization_user_response{status.error_code()}; } else { return add_organization_user_response{std::move(response)}; } } get_organization_user_response chirpstack_client::get_organization_user(const get_organization_user_request& request) { get_organization_user_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _organization_service_stub->GetUser(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_organization_user_response{status.error_code()}; } else { return get_organization_user_response{std::move(response)}; } } update_organization_user_response chirpstack_client::update_organization_user(const update_organization_user_request& request) { update_organization_user_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _organization_service_stub->UpdateUser(&context, request, &response); if (!status.ok()) { log(status.error_message()); return update_organization_user_response{status.error_code()}; } else { return update_organization_user_response{std::move(response)}; } } delete_organization_user_response chirpstack_client::delete_organization_user(const delete_organization_user_request& request) { delete_organization_user_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _organization_service_stub->DeleteUser(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_organization_user_response{status.error_code()}; } else { return delete_organization_user_response{std::move(response)}; } } list_organization_users_response chirpstack_client::list_organization_users(const list_organization_users_request& request) { list_organization_users_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _organization_service_stub->ListUsers(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_organization_users_response{status.error_code()}; } else { return list_organization_users_response{std::move(response)}; } } // Service Profile Service create_service_profile_response chirpstack_client::create_service_profile(const create_service_profile_request& request) { create_service_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _service_profile_service_stub->Create(&context, request, &response); if (!status.ok()) { log(status.error_message()); return create_service_profile_response{status.error_code()}; } else { return create_service_profile_response{std::move(response)}; } } get_service_profile_response chirpstack_client::get_service_profile(const get_service_profile_request& request) { get_service_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _service_profile_service_stub->Get(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_service_profile_response{status.error_code()}; } else { return get_service_profile_response{std::move(response)}; } } update_service_profile_response chirpstack_client::update_service_profile(const update_service_profile_request& request) { update_service_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _service_profile_service_stub->Update(&context, request, &response); if (!status.ok()) { log(status.error_message()); return update_service_profile_response{status.error_code()}; } else { return update_service_profile_response{std::move(response)}; } } delete_service_profile_response chirpstack_client::delete_service_profile(const delete_service_profile_request& request) { delete_service_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _service_profile_service_stub->Delete(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_service_profile_response{status.error_code()}; } else { return delete_service_profile_response{std::move(response)}; } } list_service_profile_response chirpstack_client::list_service_profile(const list_service_profile_request& request) { list_service_profile_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _service_profile_service_stub->List(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_service_profile_response{status.error_code()}; } else { return list_service_profile_response{std::move(response)}; } } // User Service create_user_response chirpstack_client::create_user(const create_user_request& request) { create_user_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _user_service_stub->Create(&context, request, &response); if (!status.ok()) { log(status.error_message()); return create_user_response{status.error_code()}; } else { return create_user_response{std::move(response)}; } } get_user_response chirpstack_client::get_user(const get_user_request& request) { get_user_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _user_service_stub->Get(&context, request, &response); if (!status.ok()) { log(status.error_message()); return get_user_response{status.error_code()}; } else { return get_user_response{std::move(response)}; } } update_user_response chirpstack_client::update_user(const update_user_request& request) { update_user_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _user_service_stub->Update(&context, request, &response); if (!status.ok()) { log(status.error_message()); return update_user_response{status.error_code()}; } else { return update_user_response{std::move(response)}; } } delete_user_response chirpstack_client::delete_user(const delete_user_request& request) { delete_user_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _user_service_stub->Delete(&context, request, &response); if (!status.ok()) { log(status.error_message()); return delete_user_response{status.error_code()}; } else { return delete_user_response{std::move(response)}; } } list_user_response chirpstack_client::list_user(const list_user_request& request) { list_user_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _user_service_stub->List(&context, request, &response); if (!status.ok()) { log(status.error_message()); return list_user_response{status.error_code()}; } else { return list_user_response{std::move(response)}; } } update_user_password_response chirpstack_client::update_user_password(const update_user_password_request& request) { update_user_password_response::value_type response; ClientContext context; context.AddMetadata("authorization", _config.jwt_token); auto status = _user_service_stub->UpdatePassword(&context, request, &response); if (!status.ok()) { log(status.error_message()); return update_user_password_response{status.error_code()}; } else { return update_user_password_response{std::move(response)}; } } void chirpstack_client::set_jwt_token(const std::string& jwt_token) { _config.jwt_token = jwt_token; } void chirpstack_client::enable_log() { _config.log_enabled = true; } void chirpstack_client::disable_log() { _config.log_enabled = false; } void chirpstack_client::log(const std::string& error_message) { if (_config.log_enabled) { printf("%s\n", error_message.c_str()); } } }
41.517212
161
0.745647
chungphb
eec9dd2390af11b86e3b6602d5e1f1a80813dcd1
8,315
cpp
C++
src/NIfValid.cpp
justinmann/sj
24d0a75723b024f17de6dab9070979a4f1bf1a60
[ "Apache-2.0" ]
2
2017-01-04T02:27:10.000Z
2017-01-22T05:36:41.000Z
src/NIfValid.cpp
justinmann/sj
24d0a75723b024f17de6dab9070979a4f1bf1a60
[ "Apache-2.0" ]
null
null
null
src/NIfValid.cpp
justinmann/sj
24d0a75723b024f17de6dab9070979a4f1bf1a60
[ "Apache-2.0" ]
1
2020-06-15T12:17:26.000Z
2020-06-15T12:17:26.000Z
#include <sjc.h> bool CIfValidVar::getReturnThis() { return false; } shared_ptr<CType> CIfValidVar::getType(Compiler* compiler) { if (ifVar && elseVar) { return ifVar->getType(compiler); } return compiler->typeVoid; } void CIfValidVar::transpile(Compiler* compiler, TrOutput* trOutput, TrBlock* trBlock, shared_ptr<TrValue> thisValue, shared_ptr<TrStoreValue> storeValue) { if (!storeValue->isVoid) { storeValue->getName(trBlock); // Force capture values to become named } auto ifStoreValue = storeValue; auto elseStoreValue = storeValue; if (ifVar && elseVar) { auto ifType = ifVar->getType(compiler); auto elseType = elseVar->getType(compiler); if (ifType != elseType) { if (!storeValue->isVoid) { compiler->addError(loc, CErrorCode::TypeMismatch, "if block return type '%s' does not match else block return type '%s'", ifType->fullName.c_str(), elseType->fullName.c_str()); return; } else { ifStoreValue = trBlock->createVoidStoreVariable(loc, ifType); elseStoreValue = trBlock->createVoidStoreVariable(loc, elseType); } } } bool isFirst = true; stringstream ifLine; ifLine << "if ("; auto type = getType(compiler); vector<shared_ptr<TrStoreValue>> isValidValues; for (auto optionalVar : optionalVars) { auto trValue = trBlock->createCaptureStoreVariable(loc, nullptr, compiler->typeBool); optionalVar.isValidVar->transpile(compiler, trOutput, trBlock, thisValue, trValue); if (!trValue->hasSetValue) { return; } if (isFirst) { isFirst = false; } else { ifLine << " && "; } ifLine << trValue->getCaptureText(); } ifLine << ")"; auto trIfBlock = make_shared<TrBlock>(trBlock); trIfBlock->hasThis = trBlock->hasThis; trIfBlock->localVarParent = ifLocalVarScope ? nullptr : trBlock; auto trStatement = TrStatement(loc, ifLine.str(), trIfBlock); scope.lock()->pushLocalVarScope(ifLocalVarScope); for (auto optionalVar : optionalVars) { auto localStoreValue = optionalVar.storeVar->getStoreValue(compiler, scope.lock(), trOutput, trIfBlock.get(), thisValue, AssignOp::immutableCreate); optionalVar.getValueVar->transpile(compiler, trOutput, trIfBlock.get(), thisValue, localStoreValue); } ifVar->transpile(compiler, trOutput, trIfBlock.get(), thisValue, ifStoreValue); scope.lock()->popLocalVarScope(ifLocalVarScope); if (elseVar) { auto trElseBlock = make_shared<TrBlock>(trBlock); trElseBlock->localVarParent = elseLocalVarScope ? nullptr : trBlock; trElseBlock->hasThis = trBlock->hasThis; trStatement.elseBlock = trElseBlock; scope.lock()->pushLocalVarScope(elseLocalVarScope); elseVar->transpile(compiler, trOutput, trElseBlock.get(), thisValue, elseStoreValue); scope.lock()->popLocalVarScope(elseLocalVarScope); } else { if (!storeValue->isVoid) { compiler->addError(loc, CErrorCode::NoDefaultValue, "if you store the result of an if clause then you must specify an else clause"); } } trBlock->statements.push_back(trStatement); } void CIfValidVar::dump(Compiler* compiler, map<shared_ptr<CBaseFunction>, string>& functions, stringstream& ss, int level) { ss << "ifValue "; if (ifVar) { ss << " "; scope.lock()->pushLocalVarScope(ifLocalVarScope); ifVar->dump(compiler, functions, ss, level); scope.lock()->popLocalVarScope(ifLocalVarScope); } if (elseVar) { ss << " elseEmpty "; scope.lock()->pushLocalVarScope(elseLocalVarScope); elseVar->dump(compiler, functions, ss, level); scope.lock()->popLocalVarScope(elseLocalVarScope); } } void NIfValid::initFunctionsImpl(Compiler* compiler, vector<pair<string, vector<string>>>& importNamespaces, vector<string>& packageNamespace, shared_ptr<CBaseFunctionDefinition> thisFunction) { if (elseBlock) { elseBlock->initFunctions(compiler, importNamespaces, packageNamespace, thisFunction); } if (ifBlock) { ifBlock->initFunctions(compiler, importNamespaces, packageNamespace, thisFunction); } } void NIfValid::initVarsImpl(Compiler* compiler, shared_ptr<CScope> scope, CTypeMode returnMode) { if (elseBlock) { elseBlock->initVars(compiler, scope, returnMode); } if (ifBlock) { ifBlock->initVars(compiler, scope, returnMode); } } shared_ptr<CVar> NIfValid::getVarImpl(Compiler* compiler, shared_ptr<CScope> scope, shared_ptr<CVar> dotVar, shared_ptr<CType> returnType, CTypeMode returnMode) { vector<CIfParameter> optionalVars; for (auto var : *vars) { if (var->nodeType == NodeType_Assignment) { CIfParameter param; auto cname = TrBlock::nextVarName("ifValue"); auto assignment = static_pointer_cast<NAssignment>(var); auto optionalVar = assignment->rightSide->getVar(compiler, scope, nullptr, CTM_Undefined); if (!optionalVar) { return nullptr; } param.isValidVar = make_shared<CIsEmptyOrValidVar>(loc, scope, optionalVar, false); param.getValueVar = make_shared<CGetValueVar>(loc, scope, optionalVar, true); auto storeType = param.getValueVar->getType(compiler); if (!storeType) { return nullptr; } if (storeType->typeMode == CTM_Stack) { storeType = storeType->getTempType(); } param.storeVar = make_shared<CNormalVar>(loc, scope, storeType, assignment->name, cname, false, CVarType::Var_Local, nullptr); optionalVars.push_back(param); } else if (var->nodeType == NodeType_Variable) { CIfParameter param; auto cname = TrBlock::nextVarName("ifValue"); auto variable = static_pointer_cast<NVariable>(var); auto optionalVar = variable->getVar(compiler, scope, nullptr, nullptr, CTM_Undefined); if (!optionalVar) { return nullptr; } param.isValidVar = make_shared<CIsEmptyOrValidVar>(loc, scope, optionalVar, false); param.getValueVar = make_shared<CGetValueVar>(loc, scope, optionalVar, true); auto storeType = param.getValueVar->getType(compiler); if (!storeType) { return nullptr; } if (storeType->typeMode == CTM_Stack) { storeType = storeType->getTempType(); } param.storeVar = make_shared<CNormalVar>(loc, scope, storeType, variable->name, cname, false, CVarType::Var_Local, nullptr); optionalVars.push_back(param); } else { compiler->addError(loc, CErrorCode::Internal, "ifValue can only have var or assignment"); return nullptr; } } shared_ptr<LocalVarScope> elseLocalVarScope; shared_ptr<CVar> elseVar; if (elseBlock) { elseLocalVarScope = make_shared<LocalVarScope>(); scope->pushLocalVarScope(elseLocalVarScope); elseVar = elseBlock->getVar(compiler, scope, returnType, returnMode); scope->popLocalVarScope(elseLocalVarScope); } shared_ptr<LocalVarScope> ifLocalVarScope; shared_ptr<CVar> ifVar; ifLocalVarScope = make_shared<LocalVarScope>(); scope->pushLocalVarScope(ifLocalVarScope); for (auto optionalVar : optionalVars) { scope->setLocalVar(compiler, loc, optionalVar.storeVar, true); } ifVar = ifBlock->getVar(compiler, scope, returnType, returnMode); scope->popLocalVarScope(ifLocalVarScope); if (ifVar == nullptr) { return nullptr; } auto ifType = ifVar->getType(compiler); if (!ifType) { return nullptr; } if (elseVar) { auto elseType = elseVar->getType(compiler); if (!elseType) { return nullptr; } } return make_shared<CIfValidVar>(loc, ifVar->scope.lock(), optionalVars, ifVar, ifLocalVarScope, elseVar, elseLocalVarScope); }
37.968037
194
0.638364
justinmann
eecb4134aea370716825d9bada28733a869d85bc
214
cpp
C++
Ejercicio 17 by Braulio.cpp
Charlie-Ramirez-Animation-Studios-de-MX/Proyecto-Final
2f9b823dc1ba2a5276472b4c850f25e7b39b830d
[ "MIT" ]
null
null
null
Ejercicio 17 by Braulio.cpp
Charlie-Ramirez-Animation-Studios-de-MX/Proyecto-Final
2f9b823dc1ba2a5276472b4c850f25e7b39b830d
[ "MIT" ]
null
null
null
Ejercicio 17 by Braulio.cpp
Charlie-Ramirez-Animation-Studios-de-MX/Proyecto-Final
2f9b823dc1ba2a5276472b4c850f25e7b39b830d
[ "MIT" ]
null
null
null
#include <stdio.h> #include <iostream> float cal; int main(){ printf("Digite su calificacion: "); scanf("%f",&cal); if(cal>=8){ puts("Aprobado"); } else{ puts("Reprobado"); } return 0; }
13.375
55
0.560748
Charlie-Ramirez-Animation-Studios-de-MX
eed0022b11768f6e55a13ec9bb78d4c45a30cee6
19,556
cpp
C++
test/json_printer_stream_test.cpp
gsbecerrag/cppagent
f64b1906be32b43656b905e1f5d17c4e7ccbf094
[ "Apache-2.0" ]
null
null
null
test/json_printer_stream_test.cpp
gsbecerrag/cppagent
f64b1906be32b43656b905e1f5d17c4e7ccbf094
[ "Apache-2.0" ]
null
null
null
test/json_printer_stream_test.cpp
gsbecerrag/cppagent
f64b1906be32b43656b905e1f5d17c4e7ccbf094
[ "Apache-2.0" ]
null
null
null
// // Copyright Copyright 2009-2019, AMT – The Association For Manufacturing Technology (“AMT”) // 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. // // Ensure that gtest is the first header otherwise Windows raises an error #include <gtest/gtest.h> // Keep this comment to keep gtest.h above. (clang-format off/on is not working here!) #include "checkpoint.hpp" #include "data_item.hpp" #include "device.hpp" #include "globals.hpp" #include "json_helper.hpp" #include "json_printer.hpp" #include "observation.hpp" #include "test_globals.hpp" #include "xml_parser.hpp" #include "xml_printer.hpp" #include <nlohmann/json.hpp> #include <fstream> #include <iostream> #include <memory> #include <sstream> #include <string> using json = nlohmann::json; using namespace std; using namespace mtconnect; class JsonPrinterStreamTest : public testing::Test { protected: void SetUp() override { m_xmlPrinter = std::make_unique<XmlPrinter>("1.5"); m_printer = std::make_unique<JsonPrinter>("1.5", true); m_config = std::make_unique<XmlParser>(); m_devices = m_config->parseFile(PROJECT_ROOT_DIR "/samples/SimpleDevlce.xml", m_xmlPrinter.get()); } void TearDown() override { m_config.reset(); m_xmlPrinter.reset(); m_printer.reset(); } DataItem *getDataItem(const char *name) { for (auto &device : m_devices) { auto di = device->getDeviceDataItem(name); if (di) return di; } return nullptr; } void addObservationToCheckpoint(Checkpoint &checkpoint, const char *name, uint64_t sequence, string value, string time = "TIME") { const auto d = getDataItem(name); ASSERT_TRUE(d) << "Could not find data item " << name; auto event = new Observation(*d, sequence, time, value); checkpoint.addObservation(event); } protected: std::unique_ptr<JsonPrinter> m_printer; std::unique_ptr<XmlParser> m_config; std::unique_ptr<XmlPrinter> m_xmlPrinter; std::vector<Device *> m_devices; }; TEST_F(JsonPrinterStreamTest, StreamHeader) { Checkpoint checkpoint; ObservationPtrArray list; checkpoint.getObservations(list); auto doc = m_printer->printSample(123, 131072, 10254805, 10123733, 10123800, list); auto jdoc = json::parse(doc); auto it = jdoc.begin(); ASSERT_EQ(string("MTConnectStreams"), it.key()); ASSERT_EQ(123, jdoc.at("/MTConnectStreams/Header/instanceId"_json_pointer).get<int32_t>()); ASSERT_EQ(131072, jdoc.at("/MTConnectStreams/Header/bufferSize"_json_pointer).get<int32_t>()); ASSERT_EQ(uint64_t(10254805), jdoc.at("/MTConnectStreams/Header/nextSequence"_json_pointer).get<uint64_t>()); ASSERT_EQ(uint64_t(10123733), jdoc.at("/MTConnectStreams/Header/firstSequence"_json_pointer).get<uint64_t>()); ASSERT_EQ(uint64_t(10123800), jdoc.at("/MTConnectStreams/Header/lastSequence"_json_pointer).get<uint64_t>()); } TEST_F(JsonPrinterStreamTest, DeviceStream) { Checkpoint checkpoint; addObservationToCheckpoint(checkpoint, "Xpos", 10254804, "100"); ObservationPtrArray list; checkpoint.getObservations(list); auto doc = m_printer->printSample(123, 131072, 10254805, 10123733, 10123800, list); // cout << "\n" << doc << endl; auto jdoc = json::parse(doc); json stream = jdoc.at("/MTConnectStreams/Streams/0/DeviceStream"_json_pointer); ASSERT_TRUE(stream.is_object()); ASSERT_EQ(string("SimpleCnc"), stream.at("/name"_json_pointer).get<string>()); ASSERT_EQ(string("872a3490-bd2d-0136-3eb0-0c85909298d9"), stream.at("/uuid"_json_pointer).get<string>()); } TEST_F(JsonPrinterStreamTest, ComponentStream) { Checkpoint checkpoint; addObservationToCheckpoint(checkpoint, "Xpos", 10254804, "100"); ObservationPtrArray list; checkpoint.getObservations(list); auto doc = m_printer->printSample(123, 131072, 10254805, 10123733, 10123800, list); auto jdoc = json::parse(doc); json stream = jdoc.at( "/MTConnectStreams/Streams/0/DeviceStream/ComponentStreams/0/ComponentStream"_json_pointer); ASSERT_TRUE(stream.is_object()); ASSERT_EQ(string("Linear"), stream.at("/component"_json_pointer).get<string>()); ASSERT_EQ(string("X1"), stream.at("/name"_json_pointer).get<string>()); ASSERT_EQ(string("e373fec0"), stream.at("/componentId"_json_pointer).get<string>()); } TEST_F(JsonPrinterStreamTest, ComponentStreamTwoComponents) { Checkpoint checkpoint; addObservationToCheckpoint(checkpoint, "Xpos", 10254804, "100"); addObservationToCheckpoint(checkpoint, "Sspeed_act", 10254805, "500"); ObservationPtrArray list; checkpoint.getObservations(list); auto doc = m_printer->printSample(123, 131072, 10254805, 10123733, 10123800, list); auto jdoc = json::parse(doc); auto streams = jdoc.at("/MTConnectStreams/Streams/0/DeviceStream/ComponentStreams"_json_pointer); ASSERT_EQ(2_S, streams.size()); json stream1 = streams.at("/0/ComponentStream"_json_pointer); ASSERT_TRUE(stream1.is_object()); ASSERT_EQ(string("Linear"), stream1.at("/component"_json_pointer).get<string>()); ASSERT_EQ(string("e373fec0"), stream1.at("/componentId"_json_pointer).get<string>()); json stream2 = streams.at("/1/ComponentStream"_json_pointer); ASSERT_TRUE(stream2.is_object()); ASSERT_EQ(string("Rotary"), stream2.at("/component"_json_pointer).get<string>()); ASSERT_EQ(string("zf476090"), stream2.at("/componentId"_json_pointer).get<string>()); } TEST_F(JsonPrinterStreamTest, TwoDevices) { Checkpoint checkpoint; addObservationToCheckpoint(checkpoint, "Xpos", 10254804, "100"); addObservationToCheckpoint(checkpoint, "z2143c50", 10254805, "AVAILABLE"); ObservationPtrArray list; checkpoint.getObservations(list); auto doc = m_printer->printSample(123, 131072, 10254805, 10123733, 10123800, list); auto jdoc = json::parse(doc); auto streams = jdoc.at("/MTConnectStreams/Streams"_json_pointer); ASSERT_EQ(2_S, streams.size()); json stream1 = streams.at("/1/DeviceStream"_json_pointer); ASSERT_TRUE(stream1.is_object()); ASSERT_EQ(string("SimpleCnc"), stream1.at("/name"_json_pointer).get<string>()); ASSERT_EQ(string("872a3490-bd2d-0136-3eb0-0c85909298d9"), stream1.at("/uuid"_json_pointer).get<string>()); json stream2 = streams.at("/0/DeviceStream"_json_pointer); ASSERT_TRUE(stream2.is_object()); ASSERT_EQ(string("SampleDevice2"), stream2.at("/name"_json_pointer).get<string>()); ASSERT_EQ(string("f2db97b0-2bd1-0137-91ba-2a0081597801"), stream2.at("/uuid"_json_pointer).get<string>()); } TEST_F(JsonPrinterStreamTest, SampleAndEventDataItem) { Checkpoint checkpoint; addObservationToCheckpoint(checkpoint, "if36ff60", 10254804, "AUTOMATIC"); // Controller Mode addObservationToCheckpoint(checkpoint, "r186cd60", 10254805, "10 20 30"); // Path Position ObservationPtrArray list; checkpoint.getObservations(list); auto doc = m_printer->printSample(123, 131072, 10254805, 10123733, 10123800, list); auto jdoc = json::parse(doc); auto streams = jdoc.at("/MTConnectStreams/Streams/0/DeviceStream/ComponentStreams"_json_pointer); ASSERT_EQ(1_S, streams.size()); auto stream = streams.at("/0/ComponentStream"_json_pointer); ASSERT_TRUE(stream.is_object()); ASSERT_EQ(string("a4a7bdf0"), stream.at("/componentId"_json_pointer).get<string>()); auto events = stream.at("/Events"_json_pointer); ASSERT_TRUE(events.is_array()); auto mode = events.at(0); ASSERT_TRUE(mode.is_object()); ASSERT_EQ(string("AUTOMATIC"), mode.at("/ControllerMode/value"_json_pointer).get<string>()); ASSERT_EQ(string("if36ff60"), mode.at("/ControllerMode/dataItemId"_json_pointer).get<string>()); ASSERT_EQ(string("mode"), mode.at("/ControllerMode/name"_json_pointer).get<string>()); ASSERT_EQ(string("TIME"), mode.at("/ControllerMode/timestamp"_json_pointer).get<string>()); ASSERT_EQ(uint64_t(10254804), mode.at("/ControllerMode/sequence"_json_pointer).get<uint64_t>()); auto samples = stream.at("/Samples"_json_pointer); ASSERT_TRUE(samples.is_array()); auto pos = samples.at(0); ASSERT_EQ(3_S, pos.at("/PathPosition/value"_json_pointer).size()); ASSERT_EQ(10.0, pos.at("/PathPosition/value/0"_json_pointer).get<double>()); ASSERT_EQ(20.0, pos.at("/PathPosition/value/1"_json_pointer).get<double>()); ASSERT_EQ(30.0, pos.at("/PathPosition/value/2"_json_pointer).get<double>()); ASSERT_EQ(string("r186cd60"), pos.at("/PathPosition/dataItemId"_json_pointer).get<string>()); ASSERT_EQ(string("TIME"), pos.at("/PathPosition/timestamp"_json_pointer).get<string>()); ASSERT_EQ(uint64_t(10254805), pos.at("/PathPosition/sequence"_json_pointer).get<uint64_t>()); } TEST_F(JsonPrinterStreamTest, ConditionDataItem) { Checkpoint checkpoint; addObservationToCheckpoint(checkpoint, "a5b23650", 10254804, "fault|syn|ack|HIGH|Syntax error"); // Motion Program Condition ObservationPtrArray list; checkpoint.getObservations(list); auto doc = m_printer->printSample(123, 131072, 10254805, 10123733, 10123800, list); auto jdoc = json::parse(doc); auto streams = jdoc.at("/MTConnectStreams/Streams/0/DeviceStream/ComponentStreams"_json_pointer); ASSERT_EQ(1_S, streams.size()); auto stream = streams.at("/0/ComponentStream"_json_pointer); ASSERT_TRUE(stream.is_object()); ASSERT_EQ(string("a4a7bdf0"), stream.at("/componentId"_json_pointer).get<string>()); auto conds = stream.at("/Condition"_json_pointer); ASSERT_TRUE(conds.is_array()); ASSERT_EQ(1_S, conds.size()); auto motion = conds.at(0); ASSERT_TRUE(motion.is_object()); ASSERT_EQ(string("a5b23650"), motion.at("/Fault/dataItemId"_json_pointer).get<string>()); ASSERT_EQ(string("motion"), motion.at("/Fault/name"_json_pointer).get<string>()); ASSERT_EQ(string("TIME"), motion.at("/Fault/timestamp"_json_pointer).get<string>()); ASSERT_EQ(uint64_t(10254804), motion.at("/Fault/sequence"_json_pointer).get<uint64_t>()); ASSERT_EQ(string("HIGH"), motion.at("/Fault/qualifier"_json_pointer).get<string>()); ASSERT_EQ(string("ack"), motion.at("/Fault/nativeSeverity"_json_pointer).get<string>()); ASSERT_EQ(string("syn"), motion.at("/Fault/nativeCode"_json_pointer).get<string>()); ASSERT_EQ(string("Syntax error"), motion.at("/Fault/value"_json_pointer).get<string>()); } TEST_F(JsonPrinterStreamTest, TimeSeries) { Checkpoint checkpoint; addObservationToCheckpoint(checkpoint, "tc9edc70", 10254804, "10|100|1.0 2.0 3 4 5.0 6 7 8.8 9.0 10.2"); // Volt Ampere Time Series ObservationPtrArray list; checkpoint.getObservations(list); auto doc = m_printer->printSample(123, 131072, 10254805, 10123733, 10123800, list); auto jdoc = json::parse(doc); auto streams = jdoc.at("/MTConnectStreams/Streams/0/DeviceStream/ComponentStreams"_json_pointer); ASSERT_EQ(1_S, streams.size()); auto stream = streams.at("/0/ComponentStream"_json_pointer); ASSERT_TRUE(stream.is_object()); ASSERT_EQ(string("afb91ba0"), stream.at("/componentId"_json_pointer).get<string>()); auto samples = stream.at("/Samples"_json_pointer); ASSERT_TRUE(samples.is_array()); ASSERT_EQ(1_S, samples.size()); auto amps = samples.at(0); ASSERT_TRUE(amps.is_object()); ASSERT_EQ(string("tc9edc70"), amps.at("/VoltAmpereTimeSeries/dataItemId"_json_pointer).get<string>()); ASSERT_EQ(string("pampts"), amps.at("/VoltAmpereTimeSeries/name"_json_pointer).get<string>()); ASSERT_EQ(string("TIME"), amps.at("/VoltAmpereTimeSeries/timestamp"_json_pointer).get<string>()); ASSERT_EQ(uint64_t(10254804), amps.at("/VoltAmpereTimeSeries/sequence"_json_pointer).get<uint64_t>()); ASSERT_EQ(10.0, amps.at("/VoltAmpereTimeSeries/sampleCount"_json_pointer).get<double>()); ASSERT_EQ(100.0, amps.at("/VoltAmpereTimeSeries/sampleRate"_json_pointer).get<double>()); auto value = amps.at("/VoltAmpereTimeSeries/value"_json_pointer); ASSERT_TRUE(value.is_array()); ASSERT_EQ(10_S, value.size()); ASSERT_EQ(1.0, value[0].get<double>()); ASSERT_EQ(2.0, value[1].get<double>()); ASSERT_EQ(3.0, value[2].get<double>()); ASSERT_EQ(4.0, value[3].get<double>()); ASSERT_EQ(5.0, value[4].get<double>()); ASSERT_EQ(6.0, value[5].get<double>()); ASSERT_EQ(7.0, value[6].get<double>()); ASSERT_NEAR(8.8, value[7].get<double>(), 0.0001); ASSERT_EQ(9.0, value[8].get<double>()); ASSERT_NEAR(10.2, value[9].get<double>(), 0.0001); } TEST_F(JsonPrinterStreamTest, AssetChanged) { Checkpoint checkpoint; addObservationToCheckpoint(checkpoint, "e4a300e0", 10254804, "CuttingTool|31d416a0-33c7"); // asset changed addObservationToCheckpoint(checkpoint, "f2df7550", 10254805, "QIF|400477d0-33c7"); // asset removed ObservationPtrArray list; checkpoint.getObservations(list); auto doc = m_printer->printSample(123, 131072, 10254805, 10123733, 10123800, list); auto jdoc = json::parse(doc); auto streams = jdoc.at("/MTConnectStreams/Streams/0/DeviceStream/ComponentStreams"_json_pointer); ASSERT_EQ(1_S, streams.size()); auto stream = streams.at("/0/ComponentStream"_json_pointer); ASSERT_TRUE(stream.is_object()); ASSERT_EQ(string("x872a3490"), stream.at("/componentId"_json_pointer).get<string>()); auto events = stream.at("/Events"_json_pointer); ASSERT_TRUE(events.is_array()); ASSERT_EQ(2_S, events.size()); auto changed = events.at(0); ASSERT_TRUE(changed.is_object()); ASSERT_EQ(string("e4a300e0"), changed.at("/AssetChanged/dataItemId"_json_pointer).get<string>()); ASSERT_EQ(string("TIME"), changed.at("/AssetChanged/timestamp"_json_pointer).get<string>()); ASSERT_EQ(uint64_t(10254804), changed.at("/AssetChanged/sequence"_json_pointer).get<uint64_t>()); ASSERT_EQ(string("CuttingTool"), changed.at("/AssetChanged/assetType"_json_pointer).get<string>()); ASSERT_EQ(string("31d416a0-33c7"), changed.at("/AssetChanged/value"_json_pointer).get<string>()); auto removed = events.at(1); ASSERT_TRUE(removed.is_object()); ASSERT_EQ(string("f2df7550"), removed.at("/AssetRemoved/dataItemId"_json_pointer).get<string>()); ASSERT_EQ(string("TIME"), removed.at("/AssetRemoved/timestamp"_json_pointer).get<string>()); ASSERT_EQ(uint64_t(10254805), removed.at("/AssetRemoved/sequence"_json_pointer).get<uint64_t>()); ASSERT_EQ(string("QIF"), removed.at("/AssetRemoved/assetType"_json_pointer).get<string>()); ASSERT_EQ(string("400477d0-33c7"), removed.at("/AssetRemoved/value"_json_pointer).get<string>()); } TEST_F(JsonPrinterStreamTest, ResetTrigger) { Checkpoint checkpoint; addObservationToCheckpoint(checkpoint, "qb9212c0", 10254804, "10.0:ACTION_COMPLETE", "TIME@100.0"); // Amperage ObservationPtrArray list; checkpoint.getObservations(list); auto doc = m_printer->printSample(123, 131072, 10254805, 10123733, 10123800, list); auto jdoc = json::parse(doc); auto streams = jdoc.at("/MTConnectStreams/Streams/0/DeviceStream/ComponentStreams"_json_pointer); ASSERT_EQ(1_S, streams.size()); auto stream = streams.at("/0/ComponentStream"_json_pointer); ASSERT_TRUE(stream.is_object()); ASSERT_EQ(string("afb91ba0"), stream.at("/componentId"_json_pointer).get<string>()); auto samples = stream.at("/Samples"_json_pointer); ASSERT_TRUE(samples.is_array()); ASSERT_EQ(1_S, samples.size()); auto amp = samples.at(0); ASSERT_TRUE(amp.is_object()); cout << amp.dump(2) << endl; ASSERT_EQ(string("qb9212c0"), amp.at("/Amperage/dataItemId"_json_pointer).get<string>()); ASSERT_EQ(string("TIME"), amp.at("/Amperage/timestamp"_json_pointer).get<string>()); ASSERT_EQ(uint64_t(10254804), amp.at("/Amperage/sequence"_json_pointer).get<uint64_t>()); ASSERT_EQ(string("ACTION_COMPLETE"), amp.at("/Amperage/resetTriggered"_json_pointer).get<string>()); ASSERT_EQ(string("AVERAGE"), amp.at("/Amperage/statistic"_json_pointer).get<string>()); ASSERT_EQ(100.0, amp.at("/Amperage/duration"_json_pointer).get<double>()); ASSERT_EQ(10.0, amp.at("/Amperage/value"_json_pointer).get<double>()); } TEST_F(JsonPrinterStreamTest, Message) { Checkpoint checkpoint; addObservationToCheckpoint(checkpoint, "m17f1750", 10254804, "XXXX|XXX is on the roof"); // asset changed ObservationPtrArray list; checkpoint.getObservations(list); auto doc = m_printer->printSample(123, 131072, 10254805, 10123733, 10123800, list); auto jdoc = json::parse(doc); auto streams = jdoc.at("/MTConnectStreams/Streams/0/DeviceStream/ComponentStreams"_json_pointer); ASSERT_EQ(1_S, streams.size()); auto stream = streams.at("/0/ComponentStream"_json_pointer); ASSERT_TRUE(stream.is_object()); ASSERT_EQ(string("p5add360"), stream.at("/componentId"_json_pointer).get<string>()); auto events = stream.at("/Events"_json_pointer); ASSERT_TRUE(events.is_array()); ASSERT_EQ(1_S, events.size()); auto message = events.at(0); ASSERT_TRUE(message.is_object()); ASSERT_EQ(string("m17f1750"), message.at("/Message/dataItemId"_json_pointer).get<string>()); ASSERT_EQ(string("TIME"), message.at("/Message/timestamp"_json_pointer).get<string>()); ASSERT_EQ(uint64_t(10254804), message.at("/Message/sequence"_json_pointer).get<uint64_t>()); ASSERT_EQ(string("XXXX"), message.at("/Message/nativeCode"_json_pointer).get<string>()); ASSERT_EQ(string("XXX is on the roof"), message.at("/Message/value"_json_pointer).get<string>()); } TEST_F(JsonPrinterStreamTest, Unavailability) { Checkpoint checkpoint; addObservationToCheckpoint(checkpoint, "m17f1750", 10254804, "|UNAVAILABLE"); // asset changed addObservationToCheckpoint(checkpoint, "a5b23650", 10254804, "unavailable||||"); // Motion Program Condition ObservationPtrArray list; checkpoint.getObservations(list); auto doc = m_printer->printSample(123, 131072, 10254805, 10123733, 10123800, list); auto jdoc = json::parse(doc); auto streams = jdoc.at("/MTConnectStreams/Streams/0/DeviceStream/ComponentStreams"_json_pointer); ASSERT_EQ(2_S, streams.size()); auto stream = streams.at("/1/ComponentStream"_json_pointer); ASSERT_TRUE(stream.is_object()); ASSERT_EQ(string("p5add360"), stream.at("/componentId"_json_pointer).get<string>()); auto events = stream.at("/Events"_json_pointer); ASSERT_TRUE(events.is_array()); ASSERT_EQ(1_S, events.size()); auto message = events.at(0); ASSERT_TRUE(message.is_object()); ASSERT_EQ(string("UNAVAILABLE"), message.at("/Message/value"_json_pointer).get<string>()); stream = streams.at("/0/ComponentStream"_json_pointer); ASSERT_TRUE(stream.is_object()); ASSERT_EQ(string("a4a7bdf0"), stream.at("/componentId"_json_pointer).get<string>()); auto conds = stream.at("/Condition"_json_pointer); ASSERT_TRUE(conds.is_array()); ASSERT_EQ(1_S, conds.size()); auto motion = conds.at(0); ASSERT_TRUE(motion.is_object()); ASSERT_EQ(string("a5b23650"), motion.at("/Unavailable/dataItemId"_json_pointer).get<string>()); }
41.344609
100
0.724637
gsbecerrag
eed13e45da5d43e75b7c41ca58c48e87d262cb48
8,963
cpp
C++
src/renamer/renamerwindow.cpp
shuhari/shuhari.toolbox
99110c253bceea9233d30d681a6b2d360e3e3a99
[ "Apache-2.0" ]
null
null
null
src/renamer/renamerwindow.cpp
shuhari/shuhari.toolbox
99110c253bceea9233d30d681a6b2d360e3e3a99
[ "Apache-2.0" ]
null
null
null
src/renamer/renamerwindow.cpp
shuhari/shuhari.toolbox
99110c253bceea9233d30d681a6b2d360e3e3a99
[ "Apache-2.0" ]
null
null
null
#include "precompiled.h" #include "renamerwindow.h" #include "resources.h" #include "resources.h" #include "app.h" #include "findthread.h" RenamerWindow::RenamerWindow() : ToolWindow() { } ToolItem* RenamerWindow::define() { return new ToolItem("renamer", strings::renamer_name(), ":/renamer", strings::renamer_tooltip(), []() { return new RenamerWindow(); }); } void RenamerWindow::createChildren() { auto dirLabel = new QLabel(strings::browse_label()); _dirEdit = new DirectoryEdit(); auto originLabel = new QLabel(strings::renamer_origin_name()); _originEdit = new QLineEdit(); auto replaceLabel = new QLabel(strings::renamer_new_name()); _replaceEdit = new QLineEdit(); auto typeLabel = new QLabel(strings::type()); _typeFixedRadio = new QRadioButton(strings::renamer_type_fixed()); _typeWildcardRadio = new QRadioButton(strings::renamer_type_wildcard()); _typeRegexRadio = new QRadioButton(strings::renamer_type_regex()); auto typeGroup = new QButtonGroup(this); typeGroup->addButton(_typeFixedRadio); typeGroup->addButton(_typeWildcardRadio); typeGroup->addButton(_typeRegexRadio); auto typeBox = new QHBoxLayout(); typeBox->addWidget(_typeFixedRadio); typeBox->addWidget(_typeWildcardRadio); typeBox->addWidget(_typeRegexRadio); typeBox->addStretch(); auto targetLabel = new QLabel(strings::target()); _targetFileCheck = new QCheckBox(strings::file()); _targetDirCheck = new QCheckBox(strings::directory()); auto targetBox = new QHBoxLayout(); targetBox->addWidget(_targetFileCheck); targetBox->addWidget(_targetDirCheck); targetBox->addStretch(); auto optionLabel = new QLabel(strings::options()); _recursiveCheck = new QCheckBox(strings::renamer_option_recursive()); _decodeUrlCheck = new QCheckBox(strings::renamer_option_decodeUrl()); auto optionBox = new QHBoxLayout(); optionBox->addWidget(_recursiveCheck); optionBox->addWidget(_decodeUrlCheck); optionBox->addStretch(); _selectBtn = new QPushButton(strings::select()); auto selectMenu = new QMenu(_selectBtn); auto selectAllAction = new QAction(strings::all(), _selectBtn); auto selectNoneAction = new QAction(strings::none(), _selectBtn); auto selectRevertAction = new QAction(strings::revert(), _selectBtn); selectMenu->addAction(selectAllAction); selectMenu->addAction(selectNoneAction); selectMenu->addAction(selectRevertAction); _selectBtn->setMenu(selectMenu); _findBtn = new QPushButton(strings::find()); _applyBtn = new QPushButton(strings::apply()); auto btnBox = new QHBoxLayout(); btnBox->addStretch(); btnBox->addWidget(_findBtn); btnBox->addWidget(_selectBtn); btnBox->addWidget(_applyBtn); auto grid = new QGridLayout(); grid->addWidget(dirLabel, 0, 0); grid->addWidget(_dirEdit, 0, 1); grid->addWidget(originLabel, 1, 0); grid->addWidget(_originEdit, 1, 1); grid->addWidget(replaceLabel, 2, 0); grid->addWidget(_replaceEdit, 2, 1); grid->addWidget(typeLabel, 3, 0); grid->addLayout(typeBox, 3, 1); grid->addWidget(targetLabel, 4, 0); grid->addLayout(targetBox, 4, 1); grid->addWidget(optionLabel, 5, 0); grid->addLayout(optionBox, 5, 1); _table = new QTableView(); _model = new RenamerModel(this); _table->setModel(_model); _table->verticalHeader()->hide(); _table->setColumnWidth(0, 200); _table->setColumnWidth(1, 200); _table->setColumnWidth(2, 200); _table->setEditTriggers(QTableView::NoEditTriggers); _table->setSelectionBehavior(QTableView::SelectRows); auto vbox = new QVBoxLayout(); vbox->addLayout(grid); vbox->addLayout(btnBox); vbox->addWidget(_table, 1); setCentralLayout(vbox); connect(_findBtn, &QPushButton::clicked, this, &RenamerWindow::on_find); connect(_applyBtn, &QPushButton::clicked, this, &RenamerWindow::on_apply); connect(selectAllAction, &QAction::triggered, this, &RenamerWindow::on_selectAll); connect(selectNoneAction, &QAction::triggered, this, &RenamerWindow::on_selectNone); connect(selectRevertAction, &QAction::triggered, this, &RenamerWindow::on_selectRevert); } void RenamerWindow::loadConfig() { _config = new RenamerConfig(tool()->id(), this); _config->load(appSettings()); _dirEdit->setDir(_config->directory()); _originEdit->setText(_config->originText()); _replaceEdit->setText(_config->replaceText()); auto type = _config->type(); switch (type) { case RenamerConfig::FixedString: _typeFixedRadio->setChecked(true); break; case RenamerConfig::Wildcard: _typeWildcardRadio->setChecked(true); break; case RenamerConfig::Regex: _typeRegexRadio->setChecked(true); break; } auto target = _config->target(); _targetFileCheck->setChecked((target & RenamerConfig::File) == RenamerConfig::File); _targetDirCheck->setChecked((target & RenamerConfig::Dir) == RenamerConfig::Dir); auto options = _config->options(); _recursiveCheck->setChecked((options & RenamerConfig::Recursive) == RenamerConfig::Recursive); _decodeUrlCheck->setChecked((options & RenamerConfig::DecodeUrl) == RenamerConfig::DecodeUrl); } void RenamerWindow::saveConfig() { _config->setDirectory(_dirEdit->currentDir()); _config->setOriginText(_originEdit->text().trimmed()); _config->setReplaceText(_replaceEdit->text().trimmed()); RenamerConfig::Type type = RenamerConfig::FixedString; if (_typeWildcardRadio->isChecked()) type = RenamerConfig::Wildcard; else if (_typeRegexRadio->isChecked()) type = RenamerConfig::Regex; _config->setType(type); int target = 0; if (_targetFileCheck->isChecked()) target |= RenamerConfig::File; if (_targetDirCheck->isChecked()) target |= RenamerConfig::Dir; _config->setTarget(target); int options = 0; if (_decodeUrlCheck->isChecked()) options |= RenamerConfig::DecodeUrl; if (_recursiveCheck->isChecked()) options |= RenamerConfig::Recursive; _config->setOptions(options); _config->save(appSettings()); } void RenamerWindow::showRunning(bool running) { _selectBtn->setEnabled(!running); _findBtn->setEnabled(!running); _applyBtn->setEnabled(!running); } void RenamerWindow::on_selectAll() { int rowCount = _model->rowCount(), colCount = _model->columnCount(); auto selModel = _table->selectionModel(); for (int row=0; row<rowCount; row++) for (int col=0; col<colCount; col++) selModel->select(_model->index(row, col), QItemSelectionModel::Select); } void RenamerWindow::on_selectNone() { int rowCount = _model->rowCount(), colCount = _model->columnCount(); auto selModel = _table->selectionModel(); for (int row=0; row<rowCount; row++) for (int col=0; col<colCount; col++) selModel->select(_model->index(row, col), QItemSelectionModel::Deselect); } void RenamerWindow::on_selectRevert() { int rowCount = _model->rowCount(), colCount = _model->columnCount(); auto selModel = _table->selectionModel(); for (int row=0; row<rowCount; row++) { QItemSelectionModel::SelectionFlag select = selModel->isRowSelected(row, QModelIndex()) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; for (int col=0; col<colCount; col++) selModel->select(_model->index(row, col), select); } } void RenamerWindow::on_find() { saveConfig(); if (_config->directory().isEmpty() || !QDir(_config->directory()).exists()) { warn(strings::prompt_invalid_directory()); return; } if (_config->originText().isEmpty()) { warn(strings::prompt_invalid_originText()); return; } if (_config->target() == 0) { warn(strings::prompt_invalid_target()); return; } showRunning(false); _model->clear(); auto thread = new FindThread(_config, this); connect(thread, &FindThread::found, this, &RenamerWindow::on_find_found); connect(thread, &FindThread::finished, this, &RenamerWindow::on_find_finished); thread->start(); } void RenamerWindow::on_apply() { auto selModel = _table->selectionModel(); for (int i=0; i<_model->rowCount(); i++) { auto item = _model->at(i); if (selModel->isRowSelected(i, QModelIndex())) { QDir dir(item->directory()); bool success = dir.rename(item->originName(), item->newName()); qDebug() << "renamer success" << success; _model->setState(i, success ? RenamerItem::SuccessState : RenamerItem::ErrorState); } } on_selectNone(); } void RenamerWindow::on_find_finished() { showRunning(false); } void RenamerWindow::on_find_found(RenamerItem *item) { _model->add(item); }
35.709163
98
0.677229
shuhari
eed2c2ad7ccba18ad7c415414aa2bb80fcaedb7e
4,607
hpp
C++
src/boost/spirit/home/qi/auxiliary/confix.hpp
cpmech/vismatrix
a4994864d3592cfa2db24119427fad096303fb4f
[ "BSD-3-Clause" ]
4
2018-12-06T00:55:34.000Z
2022-02-06T03:05:51.000Z
src/boost/spirit/home/qi/auxiliary/confix.hpp
cpmech/vismatrix
a4994864d3592cfa2db24119427fad096303fb4f
[ "BSD-3-Clause" ]
1
2016-03-31T20:56:08.000Z
2016-04-18T08:56:40.000Z
src/boost/spirit/home/qi/auxiliary/confix.hpp
cpmech/vismatrix
a4994864d3592cfa2db24119427fad096303fb4f
[ "BSD-3-Clause" ]
null
null
null
// Copyright (c) 2001-2008 Hartmut Kaiser // // 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) #if !defined(BOOST_SPIRIT_QI_CONFIX_AUG_26_2008_1012AM) #define BOOST_SPIRIT_QI_CONFIX_AUG_26_2008_1012AM #include <boost/spirit/home/qi/domain.hpp> #include <boost/spirit/home/qi/skip.hpp> #include <boost/spirit/home/support/component.hpp> #include <boost/spirit/home/support/attribute_of.hpp> #include <boost/spirit/home/support/unused.hpp> #include <boost/spirit/home/support/auxiliary/confix.hpp> /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace qi { /////////////////////////////////////////////////////////////////////////// // the director for a confix() generated parser struct confix_director { template <typename Component, typename Context, typename Iterator> struct attribute { typedef typename result_of::subject<Component>::type subject_type; typedef typename traits::attribute_of< qi::domain, subject_type, Context, Iterator>::type type; }; private: /////////////////////////////////////////////////////////////////////// template < typename Iterator, typename Context , typename Skipper, typename Expr> static void parse_helper( Iterator& first, Iterator const& last , Context& context, Skipper const& skipper, Expr const& e) { BOOST_MPL_ASSERT_MSG( (spirit::traits::is_component<qi::domain, Expr>::value), expression_is_not_convertible_to_a_parser, (Context, Expr)); typedef typename result_of::as_component<qi::domain, Expr>::type expr; expr eg = spirit::as_component(qi::domain(), e); typedef typename expr::director director; director::parse(eg, first, last, context, skipper, unused); } template <typename Context, typename Expr> static std::string what_helper(Expr const& e, Context& ctx) { typedef typename result_of::as_component<qi::domain, Expr>::type expr; expr eg = spirit::as_component(qi::domain(), e); typedef typename expr::director director; return director::what(eg, ctx); } public: /////////////////////////////////////////////////////////////////////// template < typename Component , typename Iterator, typename Context , typename Skipper, typename Attribute> static bool parse( Component const& component , Iterator& first, Iterator const& last , Context& context, Skipper const& skipper , Attribute& attr) { // parse the prefix parse_helper(first, last, context, skipper, spirit::detail::confix_extractor::prefix( proto::arg_c<0>(spirit::argument1(component)))); // generate the embedded items typedef typename spirit::result_of::subject<Component>::type::director director; bool result = director::parse(spirit::subject(component), first, last, context, skipper, attr); // append the suffix parse_helper(first, last, context, skipper, spirit::detail::confix_extractor::suffix( proto::arg_c<0>(spirit::argument1(component)))); return result; } template <typename Component, typename Context> static std::string what(Component const& component, Context const& ctx) { std::string result = "confix("; result += what_helper(spirit::detail::confix_extractor::prefix( proto::arg_c<0>(spirit::argument1(component))), ctx); result += ", "; result += what_helper(spirit::detail::confix_extractor::suffix( proto::arg_c<0>(spirit::argument1(component))), ctx); result += ")["; typedef typename spirit::result_of::subject<Component>::type::director director; result += director::what(spirit::subject(component), ctx); result += "]"; return result; } }; }}} #endif
35.992188
81
0.546125
cpmech
eed47df01d02a26282fc50caeb87e17cb9d2c418
1,080
cpp
C++
app/src/timer.cpp
yohrudkov/Uamp
4ec479156767907b5ae4c35716c1bea0897461cc
[ "MIT" ]
null
null
null
app/src/timer.cpp
yohrudkov/Uamp
4ec479156767907b5ae4c35716c1bea0897461cc
[ "MIT" ]
null
null
null
app/src/timer.cpp
yohrudkov/Uamp
4ec479156767907b5ae4c35716c1bea0897461cc
[ "MIT" ]
null
null
null
#include "timer.h" #include "ui_timer.h" #include "mainwindow.h" Timer::Timer(QWidget *parent) : QDialog(parent), ui(new Ui::Timer) { ui->setupUi(this); m_count = new QTimer(this); m_count->setInterval(60000); ui->Time->setAttribute(Qt::WA_MacShowFocusRect, 0); connect(m_count, &QTimer::timeout, [this, parent]() { ui->Time->setValue(ui->Time->value() - 1); if (ui->Time->value() == 0) qobject_cast<MainWindow *>(parent)->close(); }); connect(ui->Disable, &QPushButton::clicked, [this]() { ui->Time->setValue(0); m_count->stop(); ui->Status->setText("Timer disabled"); }); connect(ui->Activate, &QPushButton::clicked, [this]() { if (ui->Time->value() == 0) { Message("Timer error"); return ; } m_count->stop(); ui->Status->setText("Timer activated"); m_count->start(); }); } Timer::~Timer() { delete ui; delete m_count; } void Timer::showWindow() { setWindowTitle("Timer"); setModal(true); exec(); }
26.341463
68
0.561111
yohrudkov
eed7914c708cfaeaf85f381439b09d47cab05242
128
cpp
C++
tensorflow-yolo-ios/dependencies/eigen/doc/snippets/MatrixBase_isZero.cpp
initialz/tensorflow-yolo-face-ios
ba74cf39168d0128e91318e65a1b88ce4d65a167
[ "MIT" ]
27
2017-06-07T19:07:32.000Z
2020-10-15T10:09:12.000Z
tensorflow-yolo-ios/dependencies/eigen/doc/snippets/MatrixBase_isZero.cpp
initialz/tensorflow-yolo-face-ios
ba74cf39168d0128e91318e65a1b88ce4d65a167
[ "MIT" ]
3
2017-08-25T17:39:46.000Z
2017-11-18T03:40:55.000Z
tensorflow-yolo-ios/dependencies/eigen/doc/snippets/MatrixBase_isZero.cpp
initialz/tensorflow-yolo-face-ios
ba74cf39168d0128e91318e65a1b88ce4d65a167
[ "MIT" ]
10
2017-06-16T18:04:45.000Z
2018-07-05T17:33:01.000Z
version https://git-lfs.github.com/spec/v1 oid sha256:f7a925aa9d7164224342edf4003f9b299e76ea9cc9f40ba9ef2440665f648ae3 size 215
32
75
0.882813
initialz
eedb073fc66e4c3fa270a97cb658a1fd92a11e99
10,054
cxx
C++
inetcore/winhttp/v5/httpcache/httpcache.cxx
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
inetcore/winhttp/v5/httpcache/httpcache.cxx
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
inetcore/winhttp/v5/httpcache/httpcache.cxx
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/*++ Copyright (c) 2001 Microsoft Corporation Module Name: httpcache.cxx Abstract: Contains API implementation of the WinHTTP-UrlCache interaction layer Environment: Win32 user-level Revision History: --*/ /*++ - TODO: All functions assume that parameter validation has been performed already in the layer above it. Make sure all parameters that gets passed in (in test programs etc...) are validated and correct. - As it currently stands, the HTTP-Cache API functions are exposed outside via DLL exports. This is NOT what's supposed to happen. This layer is supposed to be an internal layer. Eliminate the DLL exports as soon as the API hooks are completed and extensive testing has been done to make sure that the component is really working as expected. - FindUrlCacheEntry trys to find the address specified by "http://"+_szServername+_szLastVerb -- */ #include <wininetp.h> #define __CACHE_INCLUDE__ #include "..\urlcache\cache.hxx" #include "cachelogic.hxx" #include "cachehndl.hxx" //////////////////////////////////////////////////////////////////////////////////////////// // Global Variables // CACHE_HANDLE_MANAGER * CacheHndlMgr; //////////////////////////////////////////////////////////////////////////////////////////// // // API implementation // HINTERNET WINAPI WinHttpCacheOpen( IN LPCWSTR pszAgentW, IN DWORD dwAccessType, IN LPCWSTR pszProxyW OPTIONAL, IN LPCWSTR pszProxyBypassW OPTIONAL, IN DWORD dwFlags ) { DEBUG_ENTER((DBG_CACHE, Handle, "WinHttpCacheOpen", "%wq, %s (%d), %wq, %wq, %#x", pszAgentW, InternetMapOpenType(dwAccessType), dwAccessType, pszProxyW, pszProxyBypassW, dwFlags )); DWORD dwErr; HINTERNET hInternet = NULL; if ((dwFlags & WINHTTP_FLAG_ASYNC) && (dwFlags & WINHTTP_CACHE_FLAGS_MASK)) { dwErr = ERROR_INVALID_PARAMETER; goto cleanup; } hInternet = WinHttpOpen( pszAgentW, dwAccessType, pszProxyW, pszProxyBypassW, dwFlags); cleanup: if (dwErr!=ERROR_SUCCESS) { SetLastError(dwErr); DEBUG_ERROR(API, dwErr); } DEBUG_LEAVE_API(hInternet); return hInternet; } HINTERNET WINAPI WinHttpCacheOpenRequest( IN HINTERNET hConnect, IN LPCWSTR lpszVerb, IN LPCWSTR lpszObjectName, IN LPCWSTR lpszVersion, IN LPCWSTR lpszReferrer OPTIONAL, IN LPCWSTR FAR * lplpszAcceptTypes OPTIONAL, IN DWORD dwFlags ) { DEBUG_ENTER_API((DBG_CACHE, Handle, "WinHttpCacheOpenRequest", "%#x, %.80wq, %.80wq, %.80wq, %.80wq, %#x, %#08x", hConnect, lpszVerb, lpszObjectName, lpszVersion, lpszReferrer, lplpszAcceptTypes, dwFlags )); HINTERNET hRequest; hRequest = WinHttpOpenRequest( hConnect, lpszVerb, lpszObjectName, lpszVersion, lpszReferrer, lplpszAcceptTypes, dwFlags); if (hRequest != NULL) { // The caching layer only works with GET requests if(wcscmp(L"GET", lpszVerb) == 0) { if (CacheHndlMgr == NULL) { CacheHndlMgr = new CACHE_HANDLE_MANAGER; if (CacheHndlMgr == NULL) { DEBUG_PRINT(CACHE, ERROR, ("Not enough memory to initialize CACHE_HANDLE_MANAGER")); goto quit; } } CacheHndlMgr->AddCacheRequestObject(hRequest); } } quit: DEBUG_LEAVE(hRequest); return hRequest; } BOOL WINAPI WinHttpCacheSendRequest( IN HINTERNET hRequest, IN LPCWSTR lpszHeaders, IN DWORD dwHeadersLength, IN LPVOID lpOptional, IN DWORD dwOptionalLength, IN DWORD dwTotalLength, IN DWORD_PTR dwContext ) { DEBUG_ENTER((DBG_CACHE, Bool, "WinHttpCacheSendRequest", "%#x, %.80wq, %d, %#x, %d, %d, %x", hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength, dwTotalLength, dwContext )); BOOL fResult = FALSE; if (CacheHndlMgr != NULL) { HTTPCACHE_REQUEST * HTTPCacheRequest; if ((HTTPCacheRequest = CacheHndlMgr->GetCacheRequestObject(hRequest)) != NULL) { fResult = HTTPCacheRequest->SendRequest( lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength ); goto quit; } } fResult = WinHttpSendRequest(hRequest, lpszHeaders, dwHeadersLength, lpOptional, dwOptionalLength, dwTotalLength, dwContext); quit: DEBUG_LEAVE(fResult); return fResult; } BOOL WINAPI WinHttpCacheReceiveResponse( IN HINTERNET hRequest, IN LPVOID lpBuffersOut ) { DEBUG_ENTER((DBG_CACHE, Bool, "WinHttpCacheReceiveResponse", "%#x, %#x", hRequest, lpBuffersOut )); BOOL fResult; if (CacheHndlMgr != NULL) { HTTPCACHE_REQUEST * HTTPCacheRequest; if ((HTTPCacheRequest = CacheHndlMgr->GetCacheRequestObject(hRequest)) != NULL) { fResult = HTTPCacheRequest->ReceiveResponse(lpBuffersOut); goto quit; } } fResult = WinHttpReceiveResponse(hRequest, lpBuffersOut); quit: DEBUG_LEAVE(fResult); return fResult; } BOOL WINAPI WinHttpCacheQueryDataAvailable( IN HINTERNET hRequest, OUT LPDWORD lpdwNumberOfBytesAvailable ) { DEBUG_ENTER((DBG_CACHE, Bool, "WinHttpCacheQueryDataAvailable", "%#x, %#x, %#x", hRequest, lpdwNumberOfBytesAvailable )); BOOL fResult; if (CacheHndlMgr != NULL) { HTTPCACHE_REQUEST * HTTPCacheRequest; if ((HTTPCacheRequest = CacheHndlMgr->GetCacheRequestObject(hRequest)) != NULL) { fResult = HTTPCacheRequest->QueryDataAvailable(lpdwNumberOfBytesAvailable); goto quit; } } fResult = WinHttpQueryDataAvailable(hRequest, lpdwNumberOfBytesAvailable); quit: DEBUG_LEAVE(fResult); return fResult; } BOOL WINAPI WinHttpCacheReadData( IN HINTERNET hRequest, IN LPVOID lpBuffer, IN DWORD dwNumberOfBytesToRead, OUT LPDWORD lpdwNumberOfBytesRead ) { DEBUG_ENTER((DBG_CACHE, Bool, "WinHttpCacheReadData", "%#x, %#x, %d, %#x", hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead )); BOOL fResult; if (CacheHndlMgr != NULL) { HTTPCACHE_REQUEST * HTTPCacheRequest; if ((HTTPCacheRequest = CacheHndlMgr->GetCacheRequestObject(hRequest)) != NULL) { fResult = HTTPCacheRequest->ReadData(lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead); goto quit; } } fResult = WinHttpReadData(hRequest, lpBuffer, dwNumberOfBytesToRead, lpdwNumberOfBytesRead); quit: DEBUG_LEAVE(fResult); return fResult; } BOOL WINAPI WinHttpCacheCloseHandle( IN HINTERNET hInternet ) { DEBUG_ENTER((DBG_CACHE, Bool, "WinHTTPCacheCloseRequestHandle", "%#x", hInternet )); DWORD dwHandleType; DWORD dwSize = sizeof(DWORD); DWORD fResult = FALSE; if (hInternet == NULL) goto quit; WinHttpQueryOption(hInternet, WINHTTP_OPTION_HANDLE_TYPE, &dwHandleType, &dwSize); if (dwHandleType == WINHTTP_HANDLE_TYPE_REQUEST) { if (CacheHndlMgr != NULL) { HTTPCACHE_REQUEST * HTTPCacheRequest; if ((HTTPCacheRequest = CacheHndlMgr->GetCacheRequestObject(hInternet)) != NULL) { fResult = HTTPCacheRequest->CloseRequestHandle(); CacheHndlMgr->RemoveCacheRequestObject(hInternet); if (CacheHndlMgr->RefCount() == 0) { delete CacheHndlMgr; CacheHndlMgr = NULL; } goto quit; } } } fResult = WinHttpCloseHandle(hInternet); quit: DEBUG_LEAVE(fResult); return fResult; }
25.647959
121
0.49443
npocmaka
4abcd527fecef56501d75df85e2698c148bd3712
3,852
cpp
C++
tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp
pfultz2/extra-cmake-modules
42cbdc856588ac4adc79f28c3c91123aa5a7a307
[ "BSD-3-Clause" ]
null
null
null
tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp
pfultz2/extra-cmake-modules
42cbdc856588ac4adc79f28c3c91123aa5a7a307
[ "BSD-3-Clause" ]
null
null
null
tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp
pfultz2/extra-cmake-modules
42cbdc856588ac4adc79f28c3c91123aa5a7a307
[ "BSD-3-Clause" ]
null
null
null
/* * 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 copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <QCoreApplication> #include "log1.h" #include "log2.h" #include "log3.h" #include <iostream> int main(int argc, char **argv) { QCoreApplication qapp(argc, argv); bool success = true; // NB: we cannot test against QtInfoMsg, as that (a) does not exist before // Qt 5.5, and (b) has incorrect semantics in Qt 5.5, in that it is // treated as more severe than QtCriticalMsg. if (log1().categoryName() != QLatin1String("log.one")) { qWarning("log1 category was \"%s\", expected \"log.one\"", log1().categoryName()); success = false; } #if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) if (!log1().isDebugEnabled()) { qWarning("log1 debug messages were not enabled"); success = false; } #else if (log1().isDebugEnabled()) { qWarning("log1 debug messages were enabled"); success = false; } if (!log1().isWarningEnabled()) { qWarning("log1 warning messages were not enabled"); success = false; } #endif if (foo::bar::log2().categoryName() != QLatin1String("log.two")) { qWarning("log2 category was \"%s\", expected \"log.two\"", foo::bar::log2().categoryName()); success = false; } #if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) if (!foo::bar::log2().isDebugEnabled()) { qWarning("log2 debug messages were not enabled"); success = false; } #else if (foo::bar::log2().isDebugEnabled()) { qWarning("log2 debug messages were enabled"); success = false; } if (!foo::bar::log2().isWarningEnabled()) { qWarning("log2 warning messages were not enabled"); success = false; } #endif if (log3().categoryName() != QLatin1String("three")) { qWarning("log3 category was \"%s\", expected \"three\"", log3().categoryName()); success = false; } #if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) if (!log3().isDebugEnabled()) { qWarning("log3 debug messages were not enabled"); success = false; } #else if (log3().isDebugEnabled()) { qWarning("log3 debug messages were enabled"); success = false; } if (log3().isWarningEnabled()) { qWarning("log3 warning messages were enabled"); success = false; } if (!log3().isCriticalEnabled()) { qWarning("log3 critical messages were not enabled"); success = false; } #endif return success ? 0 : 1; }
35.33945
100
0.65784
pfultz2
4ac2b1ca5e1f408cb9e6083823a14ef312cad5d3
997
cc
C++
Contests/CodeForces/Codeforces Round #579 (Div. 3)/a.cc
DCTewi/My-Codes
9904f8057ec96e21cbc8cf9c62a49658a0f6d392
[ "MIT" ]
null
null
null
Contests/CodeForces/Codeforces Round #579 (Div. 3)/a.cc
DCTewi/My-Codes
9904f8057ec96e21cbc8cf9c62a49658a0f6d392
[ "MIT" ]
null
null
null
Contests/CodeForces/Codeforces Round #579 (Div. 3)/a.cc
DCTewi/My-Codes
9904f8057ec96e21cbc8cf9c62a49658a0f6d392
[ "MIT" ]
null
null
null
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0); int Q; cin >> Q; while (Q--) { int n, minn = 1 << 30, minid = -1; cin >> n; vector<int> a(n + 5); for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] < minn) { minn = a[i]; minid = i; } } int flag = 0; for (int i = 1, j = minid; i <= n; i++) { if (a[j] != i) { flag = 1; break; } (j == n)? j = 1: j++; } if (flag) { flag = 0; for (int i = 1, j = minid; i <= n; i++) { if (a[j] != i) { flag = 1; break; } (j == 1)? j = n: j--; } } if (flag) cout << "NO\n"; else cout << "YES\n"; } return 0; }
20.346939
52
0.284855
DCTewi
4ac41fce61fc7bfdcd9a080a0c89b65b0b6803c7
1,943
hpp
C++
mlog/reference_counter.hpp
Lowdham/mlog
034134ec2048fb78084f4772275b5f67efeec433
[ "MIT" ]
2
2021-06-19T04:14:14.000Z
2021-08-30T15:39:49.000Z
mlog/reference_counter.hpp
Lowdham/mlog
034134ec2048fb78084f4772275b5f67efeec433
[ "MIT" ]
1
2021-06-21T15:58:19.000Z
2021-06-22T02:04:39.000Z
mlog/reference_counter.hpp
Lowdham/mlog
034134ec2048fb78084f4772275b5f67efeec433
[ "MIT" ]
null
null
null
// This file is part of mlog. #ifndef MLOG_REFERENCE_COUNTER_HPP_ #define MLOG_REFERENCE_COUNTER_HPP_ #include <atomic> // std::atomic<> #include <exception> // std::terminate() #include "assert.hpp" #include "fwd.hpp" namespace mlog { template <typename ValueT = long> class ReferenceCounter; template <typename ValueT> class ReferenceCounter { static_assert(is_integral<ValueT>::value && !is_same<ValueT, bool>::value, "invalid reference counter value type"); public: using value_type = ValueT; private: ::std::atomic<value_type> ref_count_; public: constexpr ReferenceCounter() noexcept : ref_count_(1) {} explicit constexpr ReferenceCounter(value_type nref) noexcept : ref_count_(nref) {} constexpr ReferenceCounter(const ReferenceCounter&) noexcept : ReferenceCounter() {} ReferenceCounter& operator=(const ReferenceCounter&) noexcept { return *this; } ~ReferenceCounter() { auto old = this->ref_count_.load(::std::memory_order_relaxed); if (old > 1) ::std::terminate(); } public: bool Unique() const noexcept { return this->ref_count_.load(::std::memory_order_relaxed) == 1; } value_type Get() const noexcept { return this->ref_count_.load(::std::memory_order_relaxed); } bool TryIncrement() noexcept { auto old = this->ref_count_.load(::std::memory_order_relaxed); for (;;) if (old == 0) return false; else if (this->ref_count_.compare_exchange_weak( old, old + 1, ::std::memory_order_relaxed)) return true; } void Increment() noexcept { auto old = this->ref_count_.fetch_add(1, ::std::memory_order_relaxed); MLOG_ASSERT(old >= 1); } bool Decrement() noexcept { auto old = this->ref_count_.fetch_sub(1, ::std::memory_order_acq_rel); MLOG_ASSERT(old >= 1); return old == 1; } }; template class ReferenceCounter<long>; } // namespace mlog #endif
24.2875
76
0.678332
Lowdham
4ac44eb10d7f3af54a7688f5587a4c13cbce985c
6,484
cpp
C++
src/AFQMC/Numerics/detail/HIP/Kernels/ajw_to_waj.hip.cpp
Hyeondeok-Shin/qmcpack
2b853b6eaa15a795eee9d92085e74b97bd69abc7
[ "NCSA" ]
null
null
null
src/AFQMC/Numerics/detail/HIP/Kernels/ajw_to_waj.hip.cpp
Hyeondeok-Shin/qmcpack
2b853b6eaa15a795eee9d92085e74b97bd69abc7
[ "NCSA" ]
11
2020-05-09T20:57:21.000Z
2020-06-10T00:00:17.000Z
src/AFQMC/Numerics/detail/HIP/Kernels/ajw_to_waj.hip.cpp
Hyeondeok-Shin/qmcpack
2b853b6eaa15a795eee9d92085e74b97bd69abc7
[ "NCSA" ]
null
null
null
/////////////////////////////////////////////////////////////////////////////// // This file is distributed under the University of Illinois/NCSA Open Source // License. See LICENSE file in top directory for details. // // Copyright (c) 2020 QMCPACK developers. // // File developed by: Fionn Malone, malone14@llnl.gov, LLNL // // File created by: Fionn Malone, malone14@llnl.gov, LLNL //////////////////////////////////////////////////////////////////////////////// #include <cassert> #include <complex> #include <hip/hip_runtime.h> #include <thrust/complex.h> #include <hip/hip_runtime.h> #include "AFQMC/Numerics/detail/HIP/Kernels/hip_settings.h" #include "AFQMC/Numerics/detail/HIP/hip_kernel_utils.h" namespace kernels { // very sloppy, needs improvement!!!! template<typename T, typename T2> __global__ void kernel_ajw_to_waj(int na, int nj, int nw, int inca, T const* A, T2* B) { int a = blockIdx.x; if (a >= na) return; T const* A_(A + inca * a); int i = threadIdx.x; int njw = nj * nw; while (i < njw) { int j = i / nw; int w = i % nw; B[(w * na + a) * nj + j] = static_cast<T2>(A_[i]); i += blockDim.x; } } template<typename T, typename T2> __global__ void kernel_ajw_to_waj(int na, int nj, int nw, int inca, thrust::complex<T> const* A, thrust::complex<T2>* B) { int a = blockIdx.x; if (a >= na) return; thrust::complex<T> const* A_(A + inca * a); int i = threadIdx.x; int njw = nj * nw; while (i < njw) { int j = i / nw; int w = i % nw; B[(w * na + a) * nj + j] = static_cast<thrust::complex<T2>>(A_[i]); i += blockDim.x; } } template<typename T, typename T2> __global__ void kernel_transpose_wabn_to_wban(int nwalk, int na, int nb, int nchol, thrust::complex<T> const* Tab, thrust::complex<T2>* Tba) { int w = blockIdx.x; int a = blockIdx.y; int b = blockIdx.z; thrust::complex<T> const* A_(Tab + ((w * na + a) * nb + b) * nchol); thrust::complex<T2>* B_(Tba + ((w * nb + b) * na + a) * nchol); int i = threadIdx.x; while (i < nchol) { B_[i] = static_cast<thrust::complex<T2>>(A_[i]); i += blockDim.x; } } void ajw_to_waj(int na, int nj, int nw, int inca, double const* A, double* B) { hipLaunchKernelGGL(kernel_ajw_to_waj, dim3(na), dim3(128), 0, 0, na, nj, nw, inca, A, B); qmc_hip::hip_kernel_check(hipGetLastError()); qmc_hip::hip_kernel_check(hipDeviceSynchronize()); } void ajw_to_waj(int na, int nj, int nw, int inca, float const* A, float* B) { hipLaunchKernelGGL(kernel_ajw_to_waj, dim3(na), dim3(128), 0, 0, na, nj, nw, inca, A, B); qmc_hip::hip_kernel_check(hipGetLastError()); qmc_hip::hip_kernel_check(hipDeviceSynchronize()); } void ajw_to_waj(int na, int nj, int nw, int inca, std::complex<double> const* A, std::complex<double>* B) { hipLaunchKernelGGL(kernel_ajw_to_waj, dim3(na), dim3(128), 0, 0, na, nj, nw, inca, reinterpret_cast<thrust::complex<double> const*>(A), reinterpret_cast<thrust::complex<double>*>(B)); qmc_hip::hip_kernel_check(hipGetLastError()); qmc_hip::hip_kernel_check(hipDeviceSynchronize()); } void ajw_to_waj(int na, int nj, int nw, int inca, std::complex<float> const* A, std::complex<float>* B) { hipLaunchKernelGGL(kernel_ajw_to_waj, dim3(na), dim3(128), 0, 0, na, nj, nw, inca, reinterpret_cast<thrust::complex<float> const*>(A), reinterpret_cast<thrust::complex<float>*>(B)); qmc_hip::hip_kernel_check(hipGetLastError()); qmc_hip::hip_kernel_check(hipDeviceSynchronize()); } void transpose_wabn_to_wban(int nwalk, int na, int nb, int nchol, std::complex<double> const* Tab, std::complex<double>* Tba) { dim3 grid_dim(nwalk, na, nb); hipLaunchKernelGGL(kernel_transpose_wabn_to_wban, dim3(grid_dim), dim3(32), 0, 0, nwalk, na, nb, nchol, reinterpret_cast<thrust::complex<double> const*>(Tab), reinterpret_cast<thrust::complex<double>*>(Tba)); qmc_hip::hip_kernel_check(hipGetLastError()); qmc_hip::hip_kernel_check(hipDeviceSynchronize()); } void transpose_wabn_to_wban(int nwalk, int na, int nb, int nchol, std::complex<float> const* Tab, std::complex<float>* Tba) { dim3 grid_dim(nwalk, na, nb); hipLaunchKernelGGL(kernel_transpose_wabn_to_wban, dim3(grid_dim), dim3(32), 0, 0, nwalk, na, nb, nchol, reinterpret_cast<thrust::complex<float> const*>(Tab), reinterpret_cast<thrust::complex<float>*>(Tba)); qmc_hip::hip_kernel_check(hipGetLastError()); qmc_hip::hip_kernel_check(hipDeviceSynchronize()); } void transpose_wabn_to_wban(int nwalk, int na, int nb, int nchol, std::complex<double> const* Tab, std::complex<float>* Tba) { dim3 grid_dim(nwalk, na, nb); hipLaunchKernelGGL(kernel_transpose_wabn_to_wban, dim3(grid_dim), dim3(32), 0, 0, nwalk, na, nb, nchol, reinterpret_cast<thrust::complex<double> const*>(Tab), reinterpret_cast<thrust::complex<float>*>(Tba)); qmc_hip::hip_kernel_check(hipGetLastError()); qmc_hip::hip_kernel_check(hipDeviceSynchronize()); } void transpose_wabn_to_wban(int nwalk, int na, int nb, int nchol, std::complex<float> const* Tab, std::complex<double>* Tba) { dim3 grid_dim(nwalk, na, nb); hipLaunchKernelGGL(kernel_transpose_wabn_to_wban, dim3(grid_dim), dim3(32), 0, 0, nwalk, na, nb, nchol, reinterpret_cast<thrust::complex<float> const*>(Tab), reinterpret_cast<thrust::complex<double>*>(Tba)); qmc_hip::hip_kernel_check(hipGetLastError()); qmc_hip::hip_kernel_check(hipDeviceSynchronize()); } } // namespace kernels
37.264368
120
0.564004
Hyeondeok-Shin
4ac839b8ac1fdd48b9ae1b449f6b6d498f48d3f9
7,582
cc
C++
core/resource-manager.cc
bourdenas/troll
0c00a993ecca95fa33a2a1bc39f912be1cfff960
[ "MIT" ]
null
null
null
core/resource-manager.cc
bourdenas/troll
0c00a993ecca95fa33a2a1bc39f912be1cfff960
[ "MIT" ]
null
null
null
core/resource-manager.cc
bourdenas/troll
0c00a993ecca95fa33a2a1bc39f912be1cfff960
[ "MIT" ]
null
null
null
#include "core/resource-manager.h" #include <experimental/filesystem> #include <fstream> #include <absl/strings/str_cat.h> #include <glog/logging.h> #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/text_format.h> #include <range/v3/action/insert.hpp> #include <range/v3/view/filter.hpp> #include <range/v3/view/map.hpp> #include <range/v3/view/transform.hpp> #include <range/v3/view/unique.hpp> #include "proto/animation.pb.h" #include "proto/key-binding.pb.h" #include "proto/scene.pb.h" #include "proto/sprite.pb.h" #include "sdl/renderer.h" #include "sound/sound-loader.h" namespace troll { namespace { // Load a proto message from text file. template <class Message> Message LoadTextProto(const std::string& uri) { DLOG(INFO) << "Loading proto text file '" << uri << "'..."; std::fstream istream(uri, std::ios::in); google::protobuf::io::IstreamInputStream pbstream(&istream); Message message; google::protobuf::TextFormat::Parse(&pbstream, &message); return message; } // Load proto message from all text files under a path. template <class Message> std::vector<Message> LoadTextProtoFromPath(const std::string& path, const std::string& extension) { const auto resource_path = std::experimental::filesystem::path(path); std::vector<Message> messages; for (const auto& p : std::experimental::filesystem::directory_iterator(resource_path)) { if (p.path().extension() != extension) continue; messages.push_back(LoadTextProto<Message>(p.path().string())); } return messages; } } // namespace void ResourceManager::LoadResources(const std::string& base_path, const Renderer* renderer, const SoundLoader* sound_loader) { LoadAnimations(base_path); LoadKeyBindings(base_path); LoadSprites(base_path, renderer); LoadTextures(base_path, renderer); LoadFonts(base_path); LoadSounds(base_path, sound_loader); } Scene ResourceManager::LoadScene(const std::string& filename) { return LoadTextProto<Scene>(filename); } const KeyBindings& ResourceManager::GetKeyBindings() const { return key_bindings_; } const Sprite& ResourceManager::GetSprite(const std::string& sprite_id) const { const auto it = sprites_.find(sprite_id); LOG_IF(FATAL, it == sprites_.end()) << "Sprite with id='" << sprite_id << "' was not found."; return it->second; } const std::vector<bool>& ResourceManager::GetSpriteCollisionMask( const std::string& sprite_id, int frame_index) const { const auto it = sprite_collision_masks_.find(sprite_id); LOG_IF(FATAL, it == sprite_collision_masks_.end()) << "Sprite collision mask with id='" << sprite_id << "' was not found."; LOG_IF(FATAL, frame_index >= it->second.size()) << "Frame index " << frame_index << " out of bounds for sprite '" << sprite_id << "'."; return it->second[frame_index]; } const AnimationScript& ResourceManager::GetAnimationScript( const std::string& script_id) const { const auto it = scripts_.find(script_id); LOG_IF(FATAL, it == scripts_.end()) << "AnimationScript with id='" << script_id << "' was not found."; return it->second; } const Texture& ResourceManager::GetTexture( const std::string& texture_id) const { const auto it = textures_.find(texture_id); LOG_IF(FATAL, it == textures_.end()) << "Texture with id='" << texture_id << "' was not found."; return *it->second; } const Font& ResourceManager::GetFont(const std::string& font_id) const { const auto it = fonts_.find(font_id); LOG_IF(FATAL, it == fonts_.end()) << "Font with id='" << font_id << "' was not found."; return *it->second; } const Music& ResourceManager::GetMusic(const std::string& track_id) const { const auto it = music_tracks_.find(track_id); LOG_IF(FATAL, it == music_tracks_.end()) << "Music track with id='" << track_id << "' was not found."; return *it->second; } const Sound& ResourceManager::GetSound(const std::string& sfx_id) const { const auto it = sfx_.find(sfx_id); LOG_IF(FATAL, it == sfx_.end()) << "Sound effect with id='" << sfx_id << "' was not found."; return *it->second; } void ResourceManager::LoadAnimations(const std::string& base_path) { const auto animations = LoadTextProtoFromPath<SpriteAnimation>( absl::StrCat(base_path, "sprites/"), ".animation"); for (const auto& animation : animations) { ranges::action::insert( scripts_, animation.script() | ranges::view::transform([](const AnimationScript& script) { return std::make_pair(script.id(), script); })); } } void ResourceManager::LoadKeyBindings(const std::string& base_path) { const auto key_bindings = LoadTextProtoFromPath<KeyBindings>( absl::StrCat(base_path, "scenes/"), ".keys"); for (const auto& keys : key_bindings) { key_bindings_.MergeFrom(keys); } } void ResourceManager::LoadSprites(const std::string& base_path, const Renderer* renderer) { const auto sprites = LoadTextProtoFromPath<Sprite>( absl::StrCat(base_path, "sprites/"), ".sprite"); sprites_ = sprites | ranges::view::transform([](const Sprite& sprite) { return std::make_pair(sprite.id(), sprite); }); sprite_collision_masks_ = sprites_ | ranges::view::values | ranges::view::transform([&base_path, renderer](const Sprite& sprite) { return std::make_pair( sprite.id(), renderer->GenerateCollisionMasks( absl::StrCat(base_path, "resources/"), sprite)); }); } void ResourceManager::LoadTextures(const std::string& base_path, const Renderer* renderer) { std::vector<std::pair<std::string, std::string>> resources = sprites_ | ranges::view::values | ranges::view::transform([](const Sprite& sprite) { return std::make_pair(sprite.resource(), sprite.colour_key().SerializeAsString()); }); std::sort(resources.begin(), resources.end()); textures_ = resources | ranges::view::unique | ranges::view::transform([&base_path, renderer](const auto& resource) { RGBa colour_key; colour_key.ParseFromString(resource.second); return std::make_pair( resource.first, Texture::CreateTextureFromFile( absl::StrCat(base_path, "resources/", resource.first), colour_key, renderer)); }); } namespace { constexpr char kDefaultFont[] = "fonts/times.ttf"; } // namespace void ResourceManager::LoadFonts(const std::string& base_path) { fonts_[kDefaultFont] = Font::CreateFontFromFile( absl::StrCat(base_path, "resources/", kDefaultFont), 16); } void ResourceManager::LoadSounds(const std::string& base_path, const SoundLoader* sound_loader) { const auto sounds = LoadTextProtoFromPath<Audio>(absl::StrCat(base_path, "scenes/"), ".sfx"); for (const Audio& sound : sounds) { for (const auto& track : sound.track()) { music_tracks_.emplace( track.id(), sound_loader->LoadMusic(absl::StrCat( base_path, "resources/sounds/", track.resource()))); } for (const auto& sfx : sound.sfx()) { sfx_.emplace(sfx.id(), sound_loader->LoadSound(absl::StrCat( base_path, "resources/sounds/", sfx.resource()))); } } } } // namespace troll
34.463636
79
0.651543
bourdenas
4acb231bbc01af0ebcc6259b488d1ae469c25748
1,933
cpp
C++
imgui_markup/src/objects/panel.cpp
FluxxCode/imgui_layer
0b0b73b132160d483259d88c9b024fdb2e1d3e63
[ "MIT" ]
null
null
null
imgui_markup/src/objects/panel.cpp
FluxxCode/imgui_layer
0b0b73b132160d483259d88c9b024fdb2e1d3e63
[ "MIT" ]
null
null
null
imgui_markup/src/objects/panel.cpp
FluxxCode/imgui_layer
0b0b73b132160d483259d88c9b024fdb2e1d3e63
[ "MIT" ]
null
null
null
#include "impch.h" #include "imgui_markup/objects/panel.h" namespace imgui_markup { Panel::Panel(std::string id, Object* parent) : Object("Panel", id, parent) { this->AddAttribute("title", &this->title_); this->AddAttribute("position", &this->global_position_); this->AddAttribute("size", &this->size_); } Panel& Panel::operator=(const Panel& other) { for (auto& child : this->child_objects_) child->SetParent(other.parent_); return *this; } void Panel::Update() { if (this->init_panel_attributes_) this->InitPanelAttributes(); if (!ImGui::Begin(this->title_)) { ImGui::End(); this->is_hovered_ = false; this->size_ = Float2(); return; } this->is_hovered_ = ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows); this->size_ = ImGui::GetWindowSize(); this->global_position_ = ImGui::GetWindowPos(); for (auto& child : this->child_objects_) { if (!child) continue; child->SetPosition(ImGui::GetCursorPos(), this->global_position_); child->Update(); } ImGui::End(); } void Panel::InitPanelAttributes() { if (this->global_position_.value_changed_) ImGui::SetNextWindowPos(this->global_position_); if (this->size_.value_changed_) ImGui::SetNextWindowSize(this->size_); this->init_panel_attributes_ = false; } bool Panel::Validate(std::string& error_message) const { if (!this->parent_) return true; if (this->parent_->GetType() == "GlobalObject") return true; error_message = "Object of type \"Panel\" can only be created inside the " "global file scope"; return false; } bool Panel::OnProcessEnd(std::string& error_message) { if (this->title_.value.empty()) this->title_ = this->id_.empty() ? "unknown" : this->id_; return true; } } // namespace imgui_markup
22.476744
78
0.630109
FluxxCode
4acedb3a7c286f671ca14090aed2c0c14d44b05b
20,208
cpp
C++
source/Lib/TLibDecoder/TDecGop.cpp
AjayKumarSahu20/SHVC_2
2ce6fe131ab12eadf8d51b3408081529b5ad9366
[ "BSD-3-Clause" ]
2
2019-12-25T07:41:29.000Z
2021-11-25T11:50:12.000Z
source/Lib/TLibDecoder/TDecGop.cpp
AjayKumarSahu20/SHVC_2
2ce6fe131ab12eadf8d51b3408081529b5ad9366
[ "BSD-3-Clause" ]
null
null
null
source/Lib/TLibDecoder/TDecGop.cpp
AjayKumarSahu20/SHVC_2
2ce6fe131ab12eadf8d51b3408081529b5ad9366
[ "BSD-3-Clause" ]
null
null
null
/* The copyright in this software is being made available under the BSD * License, included below. This software may be subject to other third party * and contributor rights, including patent rights, and no such rights are * granted under this license. * * Copyright (c) 2010-2014, ITU/ISO/IEC * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the ITU/ISO/IEC 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. */ /** \file TDecGop.cpp \brief GOP decoder class */ #include "TDecGop.h" #include "TDecCAVLC.h" #include "TDecSbac.h" #include "TDecBinCoder.h" #include "TDecBinCoderCABAC.h" #include "libmd5/MD5.h" #include "TLibCommon/SEI.h" #if SVC_EXTENSION #include "TDecTop.h" #endif #include <time.h> extern Bool g_md5_mismatch; ///< top level flag to signal when there is a decode problem //! \ingroup TLibDecoder //! \{ static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI); #if Q0074_COLOUR_REMAPPING_SEI static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* colourRemappingInfoSEI, UInt layerId=0 ); static std::vector<SEIColourRemappingInfo> storeCriSEI; //Persistent Colour Remapping Information SEI #endif // ==================================================================================================================== // Constructor / destructor / initialization / destroy // ==================================================================================================================== TDecGop::TDecGop() { m_dDecTime = 0; m_pcSbacDecoders = NULL; m_pcBinCABACs = NULL; } TDecGop::~TDecGop() { } #if SVC_EXTENSION Void TDecGop::create(UInt layerId) { m_layerId = layerId; } #else Void TDecGop::create() { } #endif Void TDecGop::destroy() { } #if SVC_EXTENSION Void TDecGop::init(TDecTop** ppcDecTop, TDecEntropy* pcEntropyDecoder, #else Void TDecGop::init( TDecEntropy* pcEntropyDecoder, #endif TDecSbac* pcSbacDecoder, TDecBinCABAC* pcBinCABAC, TDecCavlc* pcCavlcDecoder, TDecSlice* pcSliceDecoder, TComLoopFilter* pcLoopFilter, TComSampleAdaptiveOffset* pcSAO ) { m_pcEntropyDecoder = pcEntropyDecoder; m_pcSbacDecoder = pcSbacDecoder; m_pcBinCABAC = pcBinCABAC; m_pcCavlcDecoder = pcCavlcDecoder; m_pcSliceDecoder = pcSliceDecoder; m_pcLoopFilter = pcLoopFilter; m_pcSAO = pcSAO; #if SVC_EXTENSION m_ppcTDecTop = ppcDecTop; #endif } // ==================================================================================================================== // Private member functions // ==================================================================================================================== // ==================================================================================================================== // Public member functions // ==================================================================================================================== Void TDecGop::decompressSlice(TComInputBitstream* pcBitstream, TComPic*& rpcPic) { TComSlice* pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx()); // Table of extracted substreams. // These must be deallocated AND their internal fifos, too. TComInputBitstream **ppcSubstreams = NULL; //-- For time output for each slice long iBeforeTime = clock(); m_pcSbacDecoder->init( (TDecBinIf*)m_pcBinCABAC ); m_pcEntropyDecoder->setEntropyDecoder (m_pcSbacDecoder); UInt uiNumSubstreams = pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() ? pcSlice->getNumEntryPointOffsets()+1 : pcSlice->getPPS()->getNumSubstreams(); // init each couple {EntropyDecoder, Substream} UInt *puiSubstreamSizes = pcSlice->getSubstreamSizes(); ppcSubstreams = new TComInputBitstream*[uiNumSubstreams]; m_pcSbacDecoders = new TDecSbac[uiNumSubstreams]; m_pcBinCABACs = new TDecBinCABAC[uiNumSubstreams]; for ( UInt ui = 0 ; ui < uiNumSubstreams ; ui++ ) { m_pcSbacDecoders[ui].init(&m_pcBinCABACs[ui]); ppcSubstreams[ui] = pcBitstream->extractSubstream(ui+1 < uiNumSubstreams ? puiSubstreamSizes[ui] : pcBitstream->getNumBitsLeft()); } for ( UInt ui = 0 ; ui+1 < uiNumSubstreams; ui++ ) { m_pcEntropyDecoder->setEntropyDecoder ( &m_pcSbacDecoders[uiNumSubstreams - 1 - ui] ); m_pcEntropyDecoder->setBitstream ( ppcSubstreams [uiNumSubstreams - 1 - ui] ); m_pcEntropyDecoder->resetEntropy (pcSlice); } m_pcEntropyDecoder->setEntropyDecoder ( m_pcSbacDecoder ); m_pcEntropyDecoder->setBitstream ( ppcSubstreams[0] ); m_pcEntropyDecoder->resetEntropy (pcSlice); m_pcSbacDecoders[0].load(m_pcSbacDecoder); m_pcSliceDecoder->decompressSlice( ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders); m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiNumSubstreams-1] ); // deallocate all created substreams, including internal buffers. for (UInt ui = 0; ui < uiNumSubstreams; ui++) { ppcSubstreams[ui]->deleteFifo(); delete ppcSubstreams[ui]; } delete[] ppcSubstreams; delete[] m_pcSbacDecoders; m_pcSbacDecoders = NULL; delete[] m_pcBinCABACs; m_pcBinCABACs = NULL; m_dDecTime += (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC; } Void TDecGop::filterPicture(TComPic*& rpcPic) { TComSlice* pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx()); //-- For time output for each slice long iBeforeTime = clock(); // deblocking filter Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag(); m_pcLoopFilter->setCfg(bLFCrossTileBoundary); m_pcLoopFilter->loopFilterPic( rpcPic ); if( pcSlice->getSPS()->getUseSAO() ) { m_pcSAO->reconstructBlkSAOParams(rpcPic, rpcPic->getPicSym()->getSAOBlkParam()); m_pcSAO->SAOProcess(rpcPic); m_pcSAO->PCMLFDisableProcess(rpcPic); } rpcPic->compressMotion(); Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B'); if (!pcSlice->isReferenced()) c += 32; //-- For time output for each slice #if SVC_EXTENSION printf("\nPOC %4d LId: %1d TId: %1d ( %c-SLICE %s, QP%3d ) ", pcSlice->getPOC(), rpcPic->getLayerId(), pcSlice->getTLayer(), c, NaluToStr( pcSlice->getNalUnitType() ).data(), pcSlice->getSliceQp() ); #else printf("\nPOC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(), pcSlice->getTLayer(), c, pcSlice->getSliceQp() ); #endif m_dDecTime += (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC; printf ("[DT %6.3f] ", m_dDecTime ); m_dDecTime = 0; for (Int iRefList = 0; iRefList < 2; iRefList++) { printf ("[L%d ", iRefList); for (Int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(RefPicList(iRefList)); iRefIndex++) { #if SVC_EXTENSION #if VPS_EXTN_DIRECT_REF_LAYERS if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR( m_layerId ) ) { UInt refLayerId = pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId(); UInt refLayerIdc = pcSlice->getReferenceLayerIdc(refLayerId); assert( g_posScalingFactor[refLayerIdc][0] ); assert( g_posScalingFactor[refLayerIdc][1] ); printf( "%d(%d, {%1.2f, %1.2f}x)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), refLayerId, 65536.0/g_posScalingFactor[refLayerIdc][0], 65536.0/g_posScalingFactor[refLayerIdc][1] ); } else { printf ("%d", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)); } #endif if( pcSlice->getEnableTMVPFlag() && iRefList == 1 - pcSlice->getColFromL0Flag() && iRefIndex == pcSlice->getColRefIdx() ) { printf( "c" ); } printf( " " ); #else printf ("%d ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)); #endif } printf ("] "); } if (m_decodedPictureHashSEIEnabled) { SEIMessages pictureHashes = getSeisByType(rpcPic->getSEIs(), SEI::DECODED_PICTURE_HASH ); const SEIDecodedPictureHash *hash = ( pictureHashes.size() > 0 ) ? (SEIDecodedPictureHash*) *(pictureHashes.begin()) : NULL; if (pictureHashes.size() > 1) { printf ("Warning: Got multiple decoded picture hash SEI messages. Using first."); } calcAndPrintHashStatus(*rpcPic->getPicYuvRec(), hash); } #if Q0074_COLOUR_REMAPPING_SEI if (m_colourRemapSEIEnabled) { SEIMessages colourRemappingInfo = getSeisByType(rpcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO ); const SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL; if (colourRemappingInfo.size() > 1) { printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first."); } applyColourRemapping(*rpcPic->getPicYuvRec(), seiColourRemappingInfo #if SVC_EXTENSION , rpcPic->getLayerId() #endif ); } #endif #if SETTING_PIC_OUTPUT_MARK rpcPic->setOutputMark(rpcPic->getSlice(0)->getPicOutputFlag() ? true : false); #else rpcPic->setOutputMark(true); #endif rpcPic->setReconMark(true); } /** * Calculate and print hash for pic, compare to picture_digest SEI if * present in seis. seis may be NULL. Hash is printed to stdout, in * a manner suitable for the status line. Theformat is: * [Hash_type:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,(yyy)] * Where, x..x is the hash * yyy has the following meanings: * OK - calculated hash matches the SEI message * ***ERROR*** - calculated hash does not match the SEI message * unk - no SEI message was available for comparison */ static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI) { /* calculate MD5sum for entire reconstructed picture */ UChar recon_digest[3][16]; Int numChar=0; const Char* hashType = "\0"; if (pictureHashSEI) { switch (pictureHashSEI->method) { case SEIDecodedPictureHash::MD5: { hashType = "MD5"; calcMD5(pic, recon_digest); numChar = 16; break; } case SEIDecodedPictureHash::CRC: { hashType = "CRC"; calcCRC(pic, recon_digest); numChar = 2; break; } case SEIDecodedPictureHash::CHECKSUM: { hashType = "Checksum"; calcChecksum(pic, recon_digest); numChar = 4; break; } default: { assert (!"unknown hash type"); } } } /* compare digest against received version */ const Char* ok = "(unk)"; Bool mismatch = false; if (pictureHashSEI) { ok = "(OK)"; for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) { for (UInt i = 0; i < numChar; i++) { if (recon_digest[yuvIdx][i] != pictureHashSEI->digest[yuvIdx][i]) { ok = "(***ERROR***)"; mismatch = true; } } } } printf("[%s:%s,%s] ", hashType, digestToString(recon_digest, numChar), ok); if (mismatch) { g_md5_mismatch = true; printf("[rx%s:%s] ", hashType, digestToString(pictureHashSEI->digest, numChar)); } } #if Q0074_COLOUR_REMAPPING_SEI Void xInitColourRemappingLut( const Int bitDepthY, const Int bitDepthC, std::vector<Int>(&preLut)[3], std::vector<Int>(&postLut)[3], const SEIColourRemappingInfo* const pCriSEI ) { for ( Int c=0 ; c<3 ; c++ ) { Int bitDepth = c ? bitDepthC : bitDepthY ; preLut[c].resize(1 << bitDepth); postLut[c].resize(1 << pCriSEI->m_colourRemapBitDepth); Int bitDepthDiff = pCriSEI->m_colourRemapBitDepth - bitDepth; Int iShift1 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from bitdepth to ColourRemapBitdepth (manage only case colourRemapBitDepth>= bitdepth) if( bitDepthDiff<0 ) printf ("Warning: CRI SEI - colourRemapBitDepth (%d) <bitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapBitDepth, bitDepth); bitDepthDiff = pCriSEI->m_colourRemapBitDepth - pCriSEI->m_colourRemapInputBitDepth; Int iShift2 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from ColourRemapInputBitdepth to ColourRemapBitdepth (manage only case colourRemapBitDepth>= colourRemapInputBitDepth) if( bitDepthDiff<0 ) printf ("Warning: CRI SEI - colourRemapBitDepth (%d) <colourRemapInputBitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapBitDepth, pCriSEI->m_colourRemapInputBitDepth); //Fill preLut for ( Int k=0 ; k<(1<<bitDepth) ; k++ ) { Int iSample = k << iShift1 ; for ( Int iPivot=0 ; iPivot<=pCriSEI->m_preLutNumValMinus1[c] ; iPivot++ ) { Int iCodedPrev = pCriSEI->m_preLutCodedValue[c][iPivot] << iShift2; //Coded in CRInputBitdepth Int iCodedNext = pCriSEI->m_preLutCodedValue[c][iPivot+1] << iShift2; //Coded in CRInputBitdepth Int iTargetPrev = pCriSEI->m_preLutTargetValue[c][iPivot]; //Coded in CRBitdepth Int iTargetNext = pCriSEI->m_preLutTargetValue[c][iPivot+1]; //Coded in CRBitdepth if ( iCodedPrev <= iSample && iSample <= iCodedNext ) { Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev); preLut[c][k] = (Int)( 0.5f + fInterpol ); iPivot = pCriSEI->m_preLutNumValMinus1[c] + 1; } } } //Fill postLut for ( Int k=0 ; k<(1<<pCriSEI->m_colourRemapBitDepth) ; k++ ) { Int iSample = k; for ( Int iPivot=0 ; iPivot<=pCriSEI->m_postLutNumValMinus1[c] ; iPivot++ ) { Int iCodedPrev = pCriSEI->m_postLutCodedValue[c][iPivot]; //Coded in CRBitdepth Int iCodedNext = pCriSEI->m_postLutCodedValue[c][iPivot+1]; //Coded in CRBitdepth Int iTargetPrev = pCriSEI->m_postLutTargetValue[c][iPivot]; //Coded in CRBitdepth Int iTargetNext = pCriSEI->m_postLutTargetValue[c][iPivot+1]; //Coded in CRBitdepth if ( iCodedPrev <= iSample && iSample <= iCodedNext ) { Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev) ; postLut[c][k] = (Int)( 0.5f + fInterpol ); iPivot = pCriSEI->m_postLutNumValMinus1[c] + 1; } } } } } static void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId ) { if( !storeCriSEI.size() ) #if SVC_EXTENSION storeCriSEI.resize(MAX_LAYERS); #else storeCriSEI.resize(1); #endif if ( pCriSEI ) //if a CRI SEI has just been retrieved, keep it in memory (persistence management) storeCriSEI[layerId] = *pCriSEI; if( !storeCriSEI[layerId].m_colourRemapCancelFlag ) { Int iHeight = pic.getHeight(); Int iWidth = pic.getWidth(); Int iStride = pic.getStride(); Int iCStride = pic.getCStride(); Pel *YUVIn[3], *YUVOut[3]; YUVIn[0] = pic.getLumaAddr(); YUVIn[1] = pic.getCbAddr(); YUVIn[2] = pic.getCrAddr(); TComPicYuv picColourRemapped; #if SVC_EXTENSION #if AUXILIARY_PICTURES picColourRemapped.create( pic.getWidth(), pic.getHeight(), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); #else picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); #endif #else picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); #endif YUVOut[0] = picColourRemapped.getLumaAddr(); YUVOut[1] = picColourRemapped.getCbAddr(); YUVOut[2] = picColourRemapped.getCrAddr(); #if SVC_EXTENSION Int bitDepthY = g_bitDepthYLayer[layerId]; Int bitDepthC = g_bitDepthCLayer[layerId]; assert( g_bitDepthY == bitDepthY ); assert( g_bitDepthC == bitDepthC ); #else Int bitDepthY = g_bitDepthY; Int bitDepthC = g_bitDepthC; #endif std::vector<Int> preLut[3]; std::vector<Int> postLut[3]; xInitColourRemappingLut( bitDepthY, bitDepthC, preLut, postLut, &storeCriSEI[layerId] ); Int roundingOffset = (storeCriSEI[layerId].m_log2MatrixDenom==0) ? 0 : (1 << (storeCriSEI[layerId].m_log2MatrixDenom - 1)); for( Int y = 0; y < iHeight ; y++ ) { for( Int x = 0; x < iWidth ; x++ ) { Int YUVPre[3], YUVMat[3]; YUVPre[0] = preLut[0][ YUVIn[0][x] ]; YUVPre[1] = preLut[1][ YUVIn[1][x>>1] ]; YUVPre[2] = preLut[2][ YUVIn[2][x>>1] ]; YUVMat[0] = ( storeCriSEI[layerId].m_colourRemapCoeffs[0][0]*YUVPre[0] + storeCriSEI[layerId].m_colourRemapCoeffs[0][1]*YUVPre[1] + storeCriSEI[layerId].m_colourRemapCoeffs[0][2]*YUVPre[2] + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom ); YUVMat[0] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapBitDepth)-1, YUVMat[0] ); YUVOut[0][x] = postLut[0][ YUVMat[0] ]; if( (y&1) && (x&1) ) { for(Int c=1 ; c<3 ; c++) { YUVMat[c] = ( storeCriSEI[layerId].m_colourRemapCoeffs[c][0]*YUVPre[0] + storeCriSEI[layerId].m_colourRemapCoeffs[c][1]*YUVPre[1] + storeCriSEI[layerId].m_colourRemapCoeffs[c][2]*YUVPre[2] + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom ); YUVMat[c] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapBitDepth)-1, YUVMat[c] ); YUVOut[c][x>>1] = postLut[c][ YUVMat[c] ]; } } } YUVIn[0] += iStride; YUVOut[0] += iStride; if( y&1 ) { YUVIn[1] += iCStride; YUVIn[2] += iCStride; YUVOut[1] += iCStride; YUVOut[2] += iCStride; } } //Write remapped picture in decoding order Char cTemp[255]; sprintf(cTemp, "seiColourRemappedPic_L%d_%dx%d_%dbits.yuv", layerId, iWidth, iHeight, storeCriSEI[layerId].m_colourRemapBitDepth ); picColourRemapped.dump( cTemp, true, storeCriSEI[layerId].m_colourRemapBitDepth ); picColourRemapped.destroy(); storeCriSEI[layerId].m_colourRemapCancelFlag = !storeCriSEI[layerId].m_colourRemapPersistenceFlag; //Handling persistence } } #endif //! \}
38.345351
197
0.627771
AjayKumarSahu20
4acf7674a4fb807fc1275ee6743ec09e4eb55cf4
3,207
cpp
C++
demo/main.cpp
jfcameron/jfc-thread_group
279a7867d038b5cbae857d4332487d2b17e632c3
[ "MIT" ]
1
2019-12-16T15:20:05.000Z
2019-12-16T15:20:05.000Z
demo/main.cpp
jfcameron/jfc-thread_group
279a7867d038b5cbae857d4332487d2b17e632c3
[ "MIT" ]
null
null
null
demo/main.cpp
jfcameron/jfc-thread_group
279a7867d038b5cbae857d4332487d2b17e632c3
[ "MIT" ]
1
2019-12-16T15:20:51.000Z
2019-12-16T15:20:51.000Z
#include <jfc/thread_group.h> #include <atomic> #include <chrono> #include <cstdlib> #include <iostream> #include <sstream> #include <unordered_map> using namespace jfc; std::unordered_map<std::thread::id, size_t> work_log; void add_to_log(const std::thread::id id) { work_log[id] = work_log[id] + 1; } static constexpr size_t TASK_COUNT = 600000; static constexpr size_t WAIT_TIME = 1000; /// \brief single thread performing the task TASK_COUNT # of times void sequential_impl() { std::cout << "sequential work begins...\n"; const auto start_time(std::chrono::steady_clock::now()); for (std::remove_const<decltype(TASK_COUNT)>::type i(0); i < TASK_COUNT; ++i) { add_to_log(std::this_thread::get_id()); std::this_thread::sleep_for(std::chrono::nanoseconds(WAIT_TIME)); } const auto end_time(std::chrono::steady_clock::now()); std::cout << "sequential work ends...\n" << "nano seconds taken: " << std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time).count() << "\n"; } /// \brief thread_group impl, performing the task TASK_COUNT # of times (plus a few extras). Thread count is specified by the user void concurrent_impl(size_t threadCount) { auto task_count = std::make_shared<std::atomic<size_t>>(TASK_COUNT); thread_group group(threadCount); // creating keys for each ID, so we can safey write to the logging map in parallel work_log[std::this_thread::get_id()] = 0; for (const auto &id : group.thread_ids()) { work_log[id] = 0; } // =-=- init -=--= std::cout << "init begins...\n"; const auto start_time(std::chrono::steady_clock::now()); group.add_tasks({TASK_COUNT, [task_count]() { add_to_log(std::this_thread::get_id()); std::this_thread::sleep_for(std::chrono::nanoseconds(WAIT_TIME)); task_count->fetch_sub(1, std::memory_order_relaxed); }}); std::cout << "init ends.\n"; // =-=- do work -=-= std::cout << "work begins...\n"; while (task_count->load(std::memory_order_relaxed) > 0) { if (auto task = group.try_get_task()) (*task)(); } const auto end_time(std::chrono::steady_clock::now()); std::cout << "work ends...\n" << "nano seconds taken: " << std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time).count() << "\n" << "# of threads in group: " << group.thread_count() << "\n"; } int main(const int argc, const char **argv) { if (argc != 2) throw std::invalid_argument("program requires 1 arg: number of threads! Special case: 0 indicates sequential implementation. all nonzero values indicate task based concurrent impl, even if only 1 thread is requested\n"); auto thread_count = std::stoi(argv[1]); if (!thread_count) sequential_impl(); else concurrent_impl(std::stoi(argv[1]) - 1); // =-=- print stats -=-= size_t totalTaskCount(0); for (const auto &i : work_log) { std::cout << i.first << ", " << i.second << "\n"; totalTaskCount += i.second; } std::cout << "total tasks: " << totalTaskCount << "\n"; return EXIT_SUCCESS; }
27.886957
239
0.633302
jfcameron
4ad005afbeab88f64885417b22a8a55be6ef4387
6,396
cpp
C++
Resources/SVP/lab1/submissions/main.cpp
rishitsaiya/CS312-AI-Lab
30489e07a71f04b47d38139937a7229fbc4c6185
[ "MIT" ]
2
2021-12-24T16:43:43.000Z
2022-02-01T03:49:55.000Z
Resources/SVP/lab1/submissions/main.cpp
rishitsaiya/CS312-AI-Lab
30489e07a71f04b47d38139937a7229fbc4c6185
[ "MIT" ]
null
null
null
Resources/SVP/lab1/submissions/main.cpp
rishitsaiya/CS312-AI-Lab
30489e07a71f04b47d38139937a7229fbc4c6185
[ "MIT" ]
6
2021-04-23T08:37:14.000Z
2022-02-27T15:21:54.000Z
#include<bits/stdc++.h> using namespace std; #define pii pair<int, int> struct Node{ static int stamp; char value; int visited; int depth; pii parent; Node(){ depth = INT32_MAX; value = ' '; visited = false; parent = make_pair(-1, -1); } // int getColor(int db){ // if(db==stamp) return color; // return 0; // } // int getDepth(int db){ // if(db==stamp) return depth; // return INT32_MAX; // } }; int Node:: stamp = -1; class Graph{ vector<vector<Node>> G; int row, col; //solution vars int num_visited; int path_length; public: Graph(string filename); pii bfs(); pii dfs(); pii dfid(); pii dfid_subroutine(pii source, int db, int stamp); //helpers void showGraph(); void markGraph(pii index); vector<pii> moveGen(pii pos, bool rev); bool goalTest(pii pos); }; Graph :: Graph(string filename){ ifstream fin(filename); string str; int algo; fin>>algo; row = 0; num_visited = 0; path_length = 0; while(getline(fin, str)) if(str.length()){ col = str.length(); G.push_back(vector<Node>(col)); for(int j = 0; j<col; j++) G[row][j].value = str[j]; row++; } fin.close(); pii goal; if (algo==0) goal = bfs(); else if (algo == 1) goal = dfs(); else goal = dfid(); markGraph(goal); //num states explored cout<<num_visited<<endl; //path_length cout<<path_length<<endl; showGraph(); } /* helpers */ void Graph:: showGraph(){ for(vector<Node> Grow : G){ for(Node iter: Grow) if(iter.visited && iter.value != '0') cout << '1'; else cout<<iter.value; cout<<endl; } } void Graph:: markGraph(pii index){ path_length = 0; while(index != make_pair(-1,-1)){ path_length ++; G[index.first][index.second].value = '0'; index = G[index.first][index.second].parent; } } vector<pii> Graph:: moveGen(pii pos, bool rev=false){ // down up right left int rot_x[] = {0, 0, 1, -1}; int rot_y[] = {1, -1, 0, 0}; vector<pii> res; for(int i=0; i<4; i++){ int y = pos.first + rot_y[i]; int x = pos.second + rot_x[i]; if(y>=0 && y<row && x>=0 && x<col) res.push_back(make_pair(y, x)); } if(rev) // reverse order std::reverse(res.begin(), res.end()); return res; } bool Graph:: goalTest(pii pos){ if(pos.first<row && pos.first >=0 && pos.second <col && pos.second >=0) return G[pos.first][pos.second].value == '*'; return false; } /* end of helpers*/ pii Graph:: bfs(){ queue<pii> Q; Q.push(make_pair(0,0)); G[0][0].visited = true; while( !Q.empty() ){ // pop and mark visited pii iter_index = Q.front(); Q.pop(); Node &iter = G[iter_index.first][iter_index.second]; // cout<<iter_index.first<<" "<<iter_index.second<<endl; num_visited ++; // check if we reached goal! if(goalTest(iter_index)) return iter_index; //otherwise iter over neighbours vector<pii> iter_neighbours = moveGen(iter_index); for(pii neighbour : iter_neighbours){ Node &neighbour_node = G[neighbour.first][neighbour.second]; if( !neighbour_node.visited && //not visited (neighbour_node.value == ' ' || neighbour_node.value=='*') //free node ){ neighbour_node.visited = true; neighbour_node.parent = iter_index; Q.push(neighbour); } } } return {-1,-1}; } pii Graph:: dfs(){ stack<pii> S; S.push(make_pair(0,0)); G[0][0].visited = true; while( !S.empty() ){ // pop and mark visited pii iter_index = S.top(); S.pop(); Node &iter = G[iter_index.first][iter_index.second]; // printf("index (%d, %d)-> %c, depth:%d\n", iter_index.first, iter_index.second, iter.value, iter.depth); num_visited ++; // check if we reached goal! if(goalTest(iter_index)) return iter_index; //otherwise iter over neighbours for(pii neb_index : moveGen(iter_index, true)){ Node &neb = G[neb_index.first][neb_index.second]; // printf("At (%d %d)\n", neb_index.first, neb_index.second ); //check if the node is boundary bool isEmpty = (neb.value == ' ' || neb.value=='*'); if(!isEmpty) continue; // printf("Isvisitable: %d for (%d %d)\n", isVisitable, neb_index.first, neb_index.second ); if(!neb.visited){ neb.visited = true; neb.parent = iter_index; S.push(neb_index); } } } return {-1,-1}; } pii Graph:: dfid(){ pii goal = {-1, -1}; int db = 0; while(! goalTest(goal)){ G[0][0].depth = 0; goal = dfid_subroutine({0,0}, db, db++); // break; } return goal; } pii Graph::dfid_subroutine(pii source, int db, int stamp){ num_visited++; // source is closed // mark stamp to know the val of depth bound at root function call Node & iter = G[source.first][source.second]; iter.visited = stamp; if(goalTest(source)) return source; if(db!=0) for(pii neb_index : moveGen(source)){ Node &neb = G[neb_index.first][neb_index.second]; //continue if you cant go there if(!(neb.value == ' ' || neb.value=='*')) continue; if(neb.visited == stamp && iter.depth + 1 >= neb.depth) continue; neb.depth = iter.depth + 1; neb.parent = source; pii goal = dfid_subroutine(neb_index, db-1, stamp); if(goalTest(goal))return goal; } return {-1,-1}; } int main(int argc, char** argv){ if(argc != 2){ cout<<"Usage ./run.sh <filename>"<<endl; return 1; } Graph solve(argv[1]); return 0; } // //show stack // pii *end = &S.top() + 1; // pii *beg = end - S.size(); // vector<pii> stack_contents(beg, end); // for(pii index : stack_contents) // printf("(%d %d), ", index.first, index.second); // cout<<endl; // fflush(stdout);
26
114
0.528768
rishitsaiya
4ad45318918416fe8d6e9b0f6e03f7fae5c120dc
151
cc
C++
UnitTests/LoopHelixBFieldTest_unit.cc
brownd1978/KinKal
e7bf9dc4d793e9f089c30ae9defb4add8bf1657b
[ "Apache-1.1" ]
null
null
null
UnitTests/LoopHelixBFieldTest_unit.cc
brownd1978/KinKal
e7bf9dc4d793e9f089c30ae9defb4add8bf1657b
[ "Apache-1.1" ]
null
null
null
UnitTests/LoopHelixBFieldTest_unit.cc
brownd1978/KinKal
e7bf9dc4d793e9f089c30ae9defb4add8bf1657b
[ "Apache-1.1" ]
null
null
null
#include "KinKal/LoopHelix.hh" #include "UnitTests/BFieldMapTest.hh" int main(int argc, char **argv) { return BFieldMapTest<LoopHelix>(argc,argv); }
25.166667
45
0.748344
brownd1978
4ad576b8bc66773e1114ebac32ae19b8e18ee3d7
1,667
hpp
C++
include/toy/math/Vector4.hpp
ToyAuthor/ToyBoxNote
accc792f5ab2fa8911dc1a70ffbfc6dfd02db9a6
[ "Unlicense" ]
4
2017-07-06T22:18:41.000Z
2021-05-24T21:28:37.000Z
include/toy/math/Vector4.hpp
ToyAuthor/ToyBoxNote
accc792f5ab2fa8911dc1a70ffbfc6dfd02db9a6
[ "Unlicense" ]
null
null
null
include/toy/math/Vector4.hpp
ToyAuthor/ToyBoxNote
accc792f5ab2fa8911dc1a70ffbfc6dfd02db9a6
[ "Unlicense" ]
1
2020-08-02T13:00:38.000Z
2020-08-02T13:00:38.000Z
#pragma once #include "toy/math/General.hpp" namespace toy{ namespace math{ template <typename Type> class Vector4 { public: union { struct { Type x,y,z,w; }; Type data[4]; }; Vector4():x(Type(0)),y(Type(0)),z(Type(0)),w(Type(0)){} Vector4(const Type xx,const Type yy,const Type zz,const Type ww):x(xx),y(yy),z(zz),w(ww){} ~Vector4(){} void set(const Type xx,const Type yy,const Type zz,const Type ww) { x = xx; y = yy; z = zz; w = ww; } Type length() const { return ::toy::math::Sqrt<Type>(x*x+y*y+z*z+w*w); } void normalize() { Type len = length(); x /= len; y /= len; z /= len; w /= len; } Vector4<Type> operator +(const Vector4<Type>& v) const { return Vector4<Type>( x+v.x, y+v.y, z+v.z, w+v.w ); } Vector4<Type> operator -(const Vector4<Type>& v) const { return Vector4<Type>( x-v.x, y-v.y, z-v.z, w-v.w ); } Vector4<Type> operator +=(const Vector4<Type>& v) { x += v.x; y += v.y; z += v.z; w += v.w; return *this; } Vector4<Type> operator -=(const Vector4<Type>& v) { x -= v.x; y -= v.y; z -= v.z; w -= v.w; return *this; } void invert() { x = -x; y = -y; z = -z; w = -w; } Vector4(const Vector4<Type>& v) { x = v.x; y = v.y; z = v.z; w = v.w; } Vector4<Type> operator =(const Vector4<Type>& v) { x = v.x; y = v.y; z = v.z; w = v.w; return *this; } }; }//namespace math }//namespace toy
14.752212
92
0.460708
ToyAuthor
4ad95451b82cd4bc441327ee4c8e9bfc376b8596
6,005
cpp
C++
manager/src/app_profile_frame.cpp
lunixoid/sys-clk
731d0de5f580a7fa853804e0c776ba2f1623c932
[ "Beerware" ]
492
2019-02-14T16:10:55.000Z
2022-03-31T00:01:27.000Z
manager/src/app_profile_frame.cpp
lunixoid/sys-clk
731d0de5f580a7fa853804e0c776ba2f1623c932
[ "Beerware" ]
51
2019-02-14T17:31:08.000Z
2022-03-24T00:10:09.000Z
manager/src/app_profile_frame.cpp
lunixoid/sys-clk
731d0de5f580a7fa853804e0c776ba2f1623c932
[ "Beerware" ]
75
2019-02-14T17:46:32.000Z
2022-03-28T07:19:25.000Z
/* sys-clk manager, a sys-clk frontend homebrew Copyright (C) 2019 natinusala Copyright (C) 2019 p-sam Copyright (C) 2019 m4xw This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include "app_profile_frame.h" #include <borealis.hpp> #include "utils.h" #include "ipc/client.h" #include <cstring> AppProfileFrame::AppProfileFrame(Title* title) : ThumbnailFrame(), title(title) { this->setTitle("Edit application profile"); this->setIcon(new brls::MaterialIcon("\uE315")); // Get the freqs Result rc = sysclkIpcGetProfiles(title->tid, &this->profiles); if (R_FAILED(rc)) errorResult("sysclkIpcGetProfiles", rc); // Setup the right sidebar this->getSidebar()->setThumbnail(title->icon, sizeof(title->icon)); this->getSidebar()->setTitle(std::string(title->name)); this->getSidebar()->setSubtitle(formatTid(title->tid)); this->getSidebar()->getButton()->setState(brls::ButtonState::DISABLED); this->getSidebar()->getButton()->getClickEvent()->subscribe([this, title](brls::View* view) { SysClkTitleProfileList profiles; memcpy(&profiles, &this->profiles, sizeof(SysClkTitleProfileList)); for (int p = 0; p < SysClkProfile_EnumMax; p++) { for (int m = 0; m < SysClkModule_EnumMax; m++) profiles.mhzMap[p][m] /= 1000000; } Result rc = sysclkIpcSetProfiles(title->tid, &profiles); if (R_SUCCEEDED(rc)) { // TODO: set the tick mark color to blue/green once borealis has rich text support brls::Application::notify("\uE14B Profile saved"); brls::Application::popView(brls::ViewAnimation::SLIDE_RIGHT); } else { errorResult("sysclkIpcSetProfiles", rc); brls::Application::notify("An error occured while saving the profile - see logs for more details"); } }); // Setup the list brls::List* list = new brls::List(); this->addFreqs(list, SysClkProfile_Docked); this->addFreqs(list, SysClkProfile_Handheld); this->addFreqs(list, SysClkProfile_HandheldCharging); this->addFreqs(list, SysClkProfile_HandheldChargingOfficial); this->addFreqs(list, SysClkProfile_HandheldChargingUSB); this->setContentView(list); } void AppProfileFrame::addFreqs(brls::List* list, SysClkProfile profile) { // Get the freqs list->addView(new brls::Header(std::string(sysclkFormatProfile(profile, true)))); // CPU brls::SelectListItem* cpuListItem = createFreqListItem(SysClkModule_CPU, this->profiles.mhzMap[profile][SysClkModule_CPU]); this->profiles.mhzMap[profile][SysClkModule_CPU] *= 1000000; cpuListItem->getValueSelectedEvent()->subscribe([this, profile](int result) { this->onProfileChanged(); this->profiles.mhzMap[profile][SysClkModule_CPU] = result == 0 ? result : sysclk_g_freq_table_cpu_hz[result - 1]; brls::Logger::debug("Caching freq for module %d and profile %d to %" PRIu32, SysClkModule_CPU, profile, this->profiles.mhzMap[profile][SysClkModule_CPU]); }); list->addView(cpuListItem); // GPU brls::SelectListItem* gpuListItem = createFreqListItem(SysClkModule_GPU, this->profiles.mhzMap[profile][SysClkModule_GPU]); this->profiles.mhzMap[profile][SysClkModule_GPU] *= 1000000; gpuListItem->getValueSelectedEvent()->subscribe([this, profile](int result) { this->onProfileChanged(); this->profiles.mhzMap[profile][SysClkModule_GPU] = result == 0 ? result : sysclk_g_freq_table_gpu_hz[result - 1]; brls::Logger::debug("Caching freq for module %d and profile %d to %" PRIu32, SysClkModule_GPU, profile, this->profiles.mhzMap[profile][SysClkModule_GPU]); }); list->addView(gpuListItem); // MEM brls::SelectListItem* memListItem = createFreqListItem(SysClkModule_MEM, this->profiles.mhzMap[profile][SysClkModule_MEM]); this->profiles.mhzMap[profile][SysClkModule_MEM] *= 1000000; memListItem->getValueSelectedEvent()->subscribe([this, profile](int result) { this->onProfileChanged(); this->profiles.mhzMap[profile][SysClkModule_MEM] = result == 0 ? result : sysclk_g_freq_table_mem_hz[result - 1]; brls::Logger::debug("Caching freq for module %d and profile %d to %" PRIu32, SysClkModule_MEM, profile, this->profiles.mhzMap[profile][SysClkModule_MEM]); }); list->addView(memListItem); } void AppProfileFrame::onProfileChanged() { this->getSidebar()->getButton()->setState(brls::ButtonState::ENABLED); this->updateActionHint(brls::Key::B, "Cancel"); } bool AppProfileFrame::onCancel() { if (this->hasProfileChanged()) { brls::Dialog* dialog = new brls::Dialog("You have unsaved changes to this profile!\nAre you sure you want to discard them?"); dialog->addButton("No", [dialog](brls::View* view){ dialog->close(); }); dialog->addButton("Yes", [dialog](brls::View* view){ dialog->close([](){ brls::Application::popView(brls::ViewAnimation::SLIDE_RIGHT); }); }); dialog->open(); } else { brls::Application::popView(brls::ViewAnimation::SLIDE_RIGHT); } return true; } bool AppProfileFrame::hasProfileChanged() { return this->getSidebar()->getButton()->getState() == brls::ButtonState::ENABLED; }
35.958084
162
0.675271
lunixoid
4ad9ce4c75b84db5a099b4379c339793d290d8b1
542
cpp
C++
tests/ClassFactoryTestInterface.cpp
duhone/core
16b1880a79ce53f8e132a9d576d5c0b64788d865
[ "MIT" ]
null
null
null
tests/ClassFactoryTestInterface.cpp
duhone/core
16b1880a79ce53f8e132a9d576d5c0b64788d865
[ "MIT" ]
null
null
null
tests/ClassFactoryTestInterface.cpp
duhone/core
16b1880a79ce53f8e132a9d576d5c0b64788d865
[ "MIT" ]
null
null
null
#include "ClassFactoryTestInterface.h" #include "core/ClassFactory.h" using namespace CR::Core; using namespace std; auto& GetInstance() { static ClassFactory<unique_ptr<TestInterface>, TestClasses, int> instance; return instance; } bool RegisterCreator(TestClasses classType, function<unique_ptr<TestInterface>(int)> creater) { GetInstance().RegisterCreator(classType, move(creater)); return true; } std::unique_ptr<TestInterface> CreateInstance(TestClasses classType, int value) { return GetInstance().Create(classType, value); }
27.1
95
0.787823
duhone
4adc3f1e3030018504a4cad9666c434b403d91d3
3,013
cpp
C++
Uva-OnlineJudge/ACMContestAndBlackout.cpp
Maqui-LP/resolucion-de-problemas
e3c81e0f1230bf609fe2ee30f978265a9a97465c
[ "MIT" ]
null
null
null
Uva-OnlineJudge/ACMContestAndBlackout.cpp
Maqui-LP/resolucion-de-problemas
e3c81e0f1230bf609fe2ee30f978265a9a97465c
[ "MIT" ]
null
null
null
Uva-OnlineJudge/ACMContestAndBlackout.cpp
Maqui-LP/resolucion-de-problemas
e3c81e0f1230bf609fe2ee30f978265a9a97465c
[ "MIT" ]
null
null
null
/* * name: ACM Contest And Blackout * link: https://vjudge.net/problem/UVA-10600 * status: Wrong Answer * date: 15/11/2020 */ #include <iostream> #include <string> #include <vector> #include <utility> #include <algorithm> using namespace std; const int INF = 1 << 30; struct UFDS { vector<int> p, rank; //también pueden usarse arreglos estáticos UFDS (int size) { p.clear(); rank.clear(); for (int i=0; i < size; i++) { p.push_back(i); rank.push_back(0); } } int find_set (int i) { return (i == p[i]) ? i : (p[i] = find_set(p[i])); } bool same_set (int i, int j) { return find_set(i) == find_set(j); } bool union_set (int i, int j) { if (!same_set(i, j)) { int x = find_set(i); int y = find_set(j); if (rank[x] > rank[y]) { p[y] = x; } else { p[x] = y; if (rank[x] == rank[y]) rank[y]++; } return true; } return false; } }; struct Conexion { int eA, eB, c; }; //Esto es para que me lo ordene con el criterio que yo quiero bool operator < (const Conexion a, const Conexion b) { return a.c < b.c; } vector<Conexion> Kruskal(int V, vector<Conexion> aristas){ vector<Conexion> MST; UFDS ds(V); int sets = V; sort(aristas.begin(), aristas.end()); for(int i = 0; i < (int)aristas.size(); i++) { if (ds.union_set(aristas[i].eA, aristas[i].eB)) { MST.push_back(aristas[i]); } } return MST; } int Kruskal2(int V, vector<Conexion> aristas, int escA, int escB){ UFDS ds(V); int total=0; int sets=V; for(int i=0; i < (int)aristas.size(); i++){ if(aristas[i].eA == escA && aristas[i].eB == escB){ continue; } if(ds.union_set(aristas[i].eA, aristas[i].eB)){ total+=aristas[i].c; sets--; } } if(sets != 1) { return INF; } return total; } int main(){ int TC, escuelaA, escuelaB, costo, escuelas, num_conexiones, suma1, suma2, tamanio; vector<Conexion> conexiones; vector<Conexion> MST; cin >> TC; while(TC--){ cin >> escuelas >> num_conexiones; conexiones.clear(); //incializo las conexiones. escuelas + conexiones = grafo while(num_conexiones--){ cin >> escuelaA >> escuelaB >> costo; conexiones.push_back(Conexion{--escuelaA, --escuelaB, costo}); } MST = Kruskal(escuelas, conexiones); tamanio = (int) MST.size(); //suma1 = sumo las aristas de MST (es el minimo peso total) suma1 = 0; for (int i=0; i < tamanio; i++){ suma1+=MST[i].c; } suma2 = INF; //Para cada una de las aristas del MST: segundo kruskal for (int i=0; i < tamanio; i++){ suma2 = min(suma2, Kruskal2(escuelas, conexiones, MST[i].eA, MST[i].eB)); } if (suma2==INF){ suma2=suma1; } cout << suma1 << " " << suma2 << endl;; } return 0; }
22.825758
87
0.538666
Maqui-LP
4adce75d5329154c2834c66a217d6df01afb2170
753
cpp
C++
solutions/29.divide-two-integers.377323112.ac.cpp
satu0king/Leetcode-Solutions
2edff60d76c2898d912197044f6284efeeb34119
[ "MIT" ]
78
2020-10-22T11:31:53.000Z
2022-02-22T13:27:49.000Z
solutions/29.divide-two-integers.377323112.ac.cpp
satu0king/Leetcode-Solutions
2edff60d76c2898d912197044f6284efeeb34119
[ "MIT" ]
null
null
null
solutions/29.divide-two-integers.377323112.ac.cpp
satu0king/Leetcode-Solutions
2edff60d76c2898d912197044f6284efeeb34119
[ "MIT" ]
26
2020-10-23T15:10:44.000Z
2021-11-07T16:13:50.000Z
class Solution { public: int divide(int dividend, int divisor) { if (dividend == -2147483648 && divisor == -1) return 2147483647; int lol = (divisor < 0); divisor = abs(divisor); lol ^= (dividend < 0); dividend = abs(dividend); int lol2 = 1; if (lol) lol2 = -1; vector<long long> vals; vals.push_back(divisor); for (int i = 1; i < 32; i++) { long long nxt = vals.back() + vals.back(); vals.push_back(nxt); } long long ans = 0; long long current = dividend; for (int i = 31; i >= 0; i--) { if (current - vals[i] >= 0) { current -= vals[i]; ans += (1LL << i); } } cout << lol2 << " " << ans << endl; return 1LL * lol2 * ans; } };
23.53125
49
0.501992
satu0king
4add36f2996fc65352c43865c3335e1cca07c0e1
12,278
cpp
C++
src/linear_systems.cpp
RandalJBarnes/Webinan
4f0f73eca4d03edcb7ca7d78ea0fa91d32c92868
[ "BSD-3-Clause" ]
null
null
null
src/linear_systems.cpp
RandalJBarnes/Webinan
4f0f73eca4d03edcb7ca7d78ea0fa91d32c92868
[ "BSD-3-Clause" ]
null
null
null
src/linear_systems.cpp
RandalJBarnes/Webinan
4f0f73eca4d03edcb7ca7d78ea0fa91d32c92868
[ "BSD-3-Clause" ]
null
null
null
//============================================================================= // linear_systems.cpp // // A minimal set of decomposition and solution routines for systems of // linear equations. // // references: // o Golub, G.H., and Van Loan, C.F., 1996, MATRIX COMPUTATIONS, 3rd Edition, // Johns Hopkins University Press, Baltimore, Maryland, 694 pp. // // author: // Dr. Randal J. Barnes // Department of Civil, Environmental, and Geo- Engineering // University of Minnesota // // version: // 29 June 2017 //============================================================================= #include "linear_systems.h" #include <cassert> #include <cmath> #include "sum_product-inl.h" namespace{ double MIN_DIVISOR = 1e-12; } //============================================================================= // CholeskyDecomposition // // Compute the Cholesky decomposition of the symmetric positive definite // Matrix "A". // // Arguments: // // A on entrance, a symmetric positive definite Matrix. // // L on exit, the lower triangular Matrix L where A = LL'. // // Return: // // true if the decomposition was completed successfully; // false if not. // // Notes: // // o This routine is based upon Golub and Van Loan, 1996, Algorithm 4.2-1, // page 144. // // o Only the lower triangular portion of A is accessed, so only the lower // triangular portion needs to be filled. // // o The routine CholeskySolve is this routine's complementary pair. // // References: // // o Golub, G.H., and Van Loan, C.F., 1996, MATRIX COMPUTATIONS, 3rd Edition, // Johns Hopkins University Press, Baltimore, Maryland, 694 pp. //============================================================================= bool CholeskyDecomposition( const Matrix& A, Matrix& L ) { // Validate the arguments. assert(isSquare(A)); // Define local constants. const int N = A.nRows(); // Carry out the Cholesky decomposition on Matrix "A". L = A; for (int j = 0; j < N; ++j) { if (j > 0) { for (int k = j; k < N; ++k) L(k,j) -= SumProduct(j, L.Base(j,0), L.Base(k,0)); } if (L(j,j) < MIN_DIVISOR) return false; L(j,j) = sqrt(L(j,j)); for (int k = j+1; k < N; ++k) { L(k,j) /= L(j,j); L(j,k) = 0.0; } } return true; } //============================================================================= // CholeskySolve // // This routine solves the system of linear equations given by "LL' x = b", // using the Cholesky factorizion of matrix "LL' = A" and forward // elimination followed by back substitution. // // Arguments: // // L the Cholesky decomposition of a symmetric positive definite // matrix A = LL'. // b on entrance, the right hand side of the system of equations; // on exit, the solution. // // Notes: // // o This routine is based upon Golub and Van Loan, 1983, Algorithm 4.1-1, // page 53. // // o The Cholesky decomposition MUST be successfully carried out before // calling this routine. // // o This routine works in the following manner // // L y = b then L'x = y // // however, in both sub-systems the soultion overwrites the right hand // side vector b. // // References: // // Golub, G.H., and Van Loan, C.F., 1983, MATRIX COMPUTATIONS, Johns // Hopkins University Press, Baltimore, Maryland, 476 pp. // //============================================================================= void CholeskySolve( const Matrix& L, const Matrix& b, Matrix& x ) { // Validate the arguments. assert( L.nRows() == L.nCols() ); assert( b.nRows() == L.nRows() ); // Define local constants. const int N = L.nRows(); // Solve L y = b using forward elimination. x = b; double Sum; for (int i = 0; i < N; i++) { Sum = x(i,0); for (int j = 0; j < i; ++j) Sum -= L(i,j) * x(j,0); x(i,0) = Sum / L(i,i); } // Solve L' x = y using back substitution. // See Golub and Van Loan, 1983, Algorithm 4.1-2, page 53. for (int i = N-1; i >= 0; --i) { Sum = x(i,0); for (int j=i+1; j<N; ++j) Sum -= L(j,i) * x(j,0); x(i,0) = Sum / L(i,i); } } //============================================================================= // CholeskyInverse // // Return the inverse of a real, symmetric, positive definite Matrix A // whose Cholesky decomposition is given by L. // // Arguments: // L on entrance, the Cholesky decomposition of a real, symmetric, // positive definite Matrix. // // Ainv on exit, the inverse of A. // // Notes: // o The computation of the inverse is based upon the standard Cholesky // decompostion. // // References: // o Stewart, G., 1998, "Matrix Algorithms - Volume I: Basic Decompositions", // SIAM, Philadelphia, 458pp., ISBN 0-89871-414-1. //============================================================================= void CholeskyInverse( const Matrix& L, Matrix& Ainv ) { assert( L.nRows() > 0 ); assert( L.nRows() == L.nCols() ); const int N = L.nRows(); Matrix LL(L); // Invert L in place; remember that L is lower triangular. for (int k = 0; k < N; ++k) { LL(k,k) = 1.0/LL(k,k); for (int i = 0; i < k; ++i) LL(k,i) = -LL(k,k) * SumProduct( k-i, LL.Base(i,i), N, LL.Base(k,i) ); } // A = L L' --> Ainv = (L')~ L~ = (L~)' L~ Multiply_MtM( LL, LL, Ainv ); } //============================================================================= // RSPDInv // // Return the inverse of a real, symmetric, positive definite Matrix A. // // Arguments: // A on entrance, a real, symmetric, positive definite Matrix. // // Ainv on exit, the inverse of A. // // Notes: // o The computation of the inverse is based upon the standard Cholesky // decompostion. // // o Only the lower triangular portion of A is accessed, so only the lower // triangular portion needs to be filled. // // o The inversion in place for an lower triangular Matrix is based upon // the pseudo-code given in Stewart (1998, p. 179). // // o The matrices A and Ainv may be the same space in memory. // // References: // o Stewart, G., 1998, "Matrix Algorithms - Volume I: Basic Decompositions", // SIAM, Philadelphia, 458pp., ISBN 0-89871-414-1. //============================================================================= bool RSPDInv( const Matrix& A, Matrix& Ainv ) { assert(isSquare(A)); const int N = A.nRows(); // Compute the Cholesky decomposition of "A", putting the result in "L". Matrix L; CholeskyDecomposition(A,L); // Invert L in place; remember that L is lower triangular. for (int k = 0; k < N; ++k) { L(k,k) = 1.0/L(k,k); for (int i = 0; i < k; ++i) L(k,i) = -L(k,k) * SumProduct( k-i, L.Base(i,i), N, L.Base(k,i) ); } // A = L L' --> Ainv = (L')~ L~ = (L~)' L~ Multiply_MtM( L, L, Ainv ); return true; } //============================================================================= // LeastSquaresSolve // // Purpose: // This routine computes the least-squares solution to the overdetermined // system of linear equations in a Matrix-based form: // // A X = B // // using a modified Gram-Schmidt orthogonalization algorithm. // // Arguments: // A (m x n) coefficient Matrix. // B (m x p) right-hand-side column Matrix. // X (n x p) solution column Matrix. // // Return: // true if the solution is computed, and false otherwise. // // Notes: // o Matrix A must have at least as many rows as columns (i.e. m >= n), and // it must have full column rank: i.e. rank(A) = n. // // o If Matrix A is rank deficient, rank(A) < n, then false is returned. // // o This routine uses a modified Gram-Schmidt algorithm. See Golub and // Van Loan (1996, Algorithm 5.2.5). The Matrix A is rewritten using a // QR factorization: // // A = Q R // // where R (n x n) is upper triangular, and Q (m x n) with orthogonal // columns // // Q'Q = I // // Thus, the solution to the least squares problem can be given by // computing a simple back-substitution solution to // // RX = Q'B // // o However, following the recommendation of Golub and Van Loan (1996), // Section 5.3.5, the error properties of the solution can be improved // significantly by computing the factorization of the augmented Matrix // // [A,B] = [Q,S] [R,Z] // [0,P] // // = [QR, QZ+SP] // // where the augmented [Q,S] has orthogonal columns: // // [Q,S]' [Q,S] = [Q'Q Q'S] = [I,0] // [S'Q S'S] [0,I] // // Thus, // // B = QZ + SP // // and // // Q'B = Q'QZ + Q'SP // = IZ + 0P // = Z // // We solve for X using back-substitute on Z: // // R X = Z // // References: // o Golub, G. H., and C. F. Van Loan, 1996, MATRIX COMPUTATIONS (3rd // Edition), Johns Hopkins University Press, Baltimore Maryland, // ISBN 0-8018-5414-8. //============================================================================= bool LeastSquaresSolve( const Matrix& A, const Matrix& B, Matrix& X ) { assert(A.nRows() == B.nRows()); // Setup the necessary dimension constants. const int M = A.nRows(); const int N = A.nCols(); const int P = B.nCols(); // Allocate the space for the solution. X.Resize(N,P); // By design, this algorithm operates on A and B in place. That is, it is // a destructive routine. To eliminate side-effects, we work work on copies // of A and B. This is a bit slower, but much safer. Matrix AA( A ); Matrix BB( B ); // Allocate the necessary local memory for the upper-triangular Matrix R. // The augmenting column "z" will be stored in "X". Matrix R(N,N); // Carry out the modified Gram-Schmidt orthogonalization: i.e. Golub and // Van Loan (1996), Algorithm 5.2.5. applied to the augmented coefficient // Matrix. for (int k = 0; k < N; ++k) { double Sum = SumProduct(M, AA.Base(0,k), AA.nCols()); if (Sum < MIN_DIVISOR) return false; R(k,k) = sqrt(Sum); for (int i = 0; i < M; ++i) AA(i,k) /= R(k,k); for (int j = k+1; j < N; ++j) { R(k,j) = SumProduct(M, AA.Base(0,k), AA.nCols(), AA.Base(0,j), AA.nCols()); for (int i = 0; i < M; ++i) AA(i,j) -= AA(i,k)*R(k,j); } for (int p = 0; p < P; ++p) { X(k,p) = SumProduct(M, AA.Base(0,k), AA.nCols(), BB.Base(0,p), BB.nCols()); for (int i = 0; i < M; ++i) BB(i,p) -= AA(i,k)*X(k,p); } } // Compute X = R~Z using back-substitution: e.g. Golub and Van Loan (1996) // Algorithm 3.1.2. Recall that the augmenting Matrix "z" is stored in "X". if( abs(R(N-1,N-1)) < MIN_DIVISOR ) return false; for (int p = 0; p < P; ++p) X(N-1,p) /= R(N-1,N-1); for (int i = N-2; i >= 0; --i) { if (abs(R(i,i)) < MIN_DIVISOR ) return false; for (int p = 0; p < P; ++p) X(i,p) = (X(i,p) - SumProduct(N-i-1, R.Base(i,i+1), X.Base(i+1,p), X.nCols())) / R(i,i); } return true; } //============================================================================= // AffineTransformation // // Purpose: // Compute the affine transformation of each row of A, that is // // D(i,:) = A(i,:)*B + C // // This is a row-by-row operation. This transformation preserves the // dimension of the row vectors. // // Arguments: // A (MxN) Matrix containing the rows to be transformed. // B (NxN) rotation and scale Matrix. // C (1xN) shift Matrix. // D (MxN) Matrix contraining the transofrmed rows (on exit). //============================================================================= void AffineTransformation( const Matrix& A, const Matrix& B, const Matrix& C, Matrix& D ) { assert( A.nCols() == B.nRows() ); assert( B.nRows() == B.nCols() ); assert( C.nRows() == 1 ); assert( C.nCols() == B.nCols() ); Matrix DD; Multiply_MM(A,B,DD); for (int i = 0; i < DD.nRows(); ++i) { for (int j = 0; j < DD.nCols(); ++j) { DD(i,j) += C(0,j); } } D = DD; }
29.443645
97
0.52419
RandalJBarnes
4adea21a79066b39ce09308f975d069782bb3957
62
cpp
C++
25mt/test/src/cppunit/TestHeader-neural_net_vector.h.cpp
johnoel/tagest
be0a6b164683c448c90f0c3952343f5963eece3d
[ "BSD-2-Clause" ]
3
2015-08-26T17:14:02.000Z
2015-11-17T04:18:56.000Z
25mt/test/src/cppunit/TestHeader-neural_net_vector.h.cpp
johnoel/tagest
be0a6b164683c448c90f0c3952343f5963eece3d
[ "BSD-2-Clause" ]
10
2015-08-20T00:51:05.000Z
2016-11-16T19:14:48.000Z
25mt/test/src/cppunit/TestHeader-neural_net_vector.h.cpp
johnoel/tagest
be0a6b164683c448c90f0c3952343f5963eece3d
[ "BSD-2-Clause" ]
3
2016-11-16T00:52:23.000Z
2021-09-10T02:17:40.000Z
#include "neural_net_vector.h" #include "neural_net_vector.h"
20.666667
30
0.806452
johnoel
4adf65195fe875e638756800ed672043045ce38c
931
hpp
C++
old_projects/SuspendedPlotterIoT/UploadHandler.hpp
renato-grottesi/microbit
728df27704211397b27a098445e68f8de52e8e4e
[ "Apache-2.0" ]
3
2018-10-26T09:32:57.000Z
2018-11-04T18:15:03.000Z
old_projects/SuspendedPlotterIoT/UploadHandler.hpp
renato-grottesi/microbit
728df27704211397b27a098445e68f8de52e8e4e
[ "Apache-2.0" ]
null
null
null
old_projects/SuspendedPlotterIoT/UploadHandler.hpp
renato-grottesi/microbit
728df27704211397b27a098445e68f8de52e8e4e
[ "Apache-2.0" ]
null
null
null
#ifndef UPLOAD_HANDLER_H #define UPLOAD_HANDLER_H #include "HTTPRequestHandler.h" #include "SuspendedPlotter.h" class UploadHandler : public HTTPRequestHandler { public: UploadHandler(const char* rootPath, const char* path, TCPSocket* pTcpSocket); virtual ~UploadHandler(); static inline HTTPRequestHandler* inst(const char* rootPath, const char* path, TCPSocket* pTcpSocket) { return new UploadHandler(rootPath, path, pTcpSocket); } protected: virtual void doGet(); virtual void doPost(); virtual void doHead(); virtual void onReadable(); //Data has been read virtual void onWriteable(); //Data has been written & buf is free virtual void onClose(); //Connection is closing private: FILE* m_fp; int m_total_read; int m_post_size; static const float orig_x = 0.5; static const float orig_y = 0.5; float m_x; float m_y; }; #endif
25.861111
105
0.692803
renato-grottesi
4ae0370dbe3021ef55b83f3070b77d7df0637ce5
4,470
cpp
C++
src/MentalPitchShift.cpp
miRackModular/Strums_Mental_VCV_Modules
1660a55bfc1c2df098bcf028713e1f7ffbe110ab
[ "BSD-3-Clause" ]
76
2017-10-13T10:39:48.000Z
2021-12-20T14:15:45.000Z
src/MentalPitchShift.cpp
miRackModular/Strums_Mental_VCV_Modules
1660a55bfc1c2df098bcf028713e1f7ffbe110ab
[ "BSD-3-Clause" ]
54
2017-10-13T14:40:07.000Z
2022-02-01T14:48:46.000Z
src/MentalPitchShift.cpp
miRackModular/Strums_Mental_VCV_Modules
1660a55bfc1c2df098bcf028713e1f7ffbe110ab
[ "BSD-3-Clause" ]
27
2017-10-21T15:45:12.000Z
2021-01-15T12:27:51.000Z
/////////////////////////////////////////////////// // // Mental Plugin // Pitch Shifter - shift pitch by octaves or semitones // // Strum 2017-19 // strum@softhome.net // /////////////////////////////////////////////////// #include "mental.hpp" ////////////////////////////////////////////////////// struct MentalPitchShift : Module { enum ParamIds { OCTAVE_SHIFT_1, OCTAVE_SHIFT_2, SEMITONE_SHIFT_1, SEMITONE_SHIFT_2, NUM_PARAMS }; enum InputIds { OCTAVE_SHIFT_1_INPUT, OCTAVE_SHIFT_2_INPUT, SEMITONE_SHIFT_1_INPUT, SEMITONE_SHIFT_2_INPUT, OCTAVE_SHIFT_1_CVINPUT, OCTAVE_SHIFT_2_CVINPUT, SEMITONE_SHIFT_1_CVINPUT, SEMITONE_SHIFT_2_CVINPUT, NUM_INPUTS }; enum OutputIds { OCTAVE_SHIFT_1_OUTPUT, OCTAVE_SHIFT_2_OUTPUT, SEMITONE_SHIFT_1_OUTPUT, SEMITONE_SHIFT_2_OUTPUT, NUM_OUTPUTS }; MentalPitchShift() { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS); configParam(MentalPitchShift::OCTAVE_SHIFT_1, -4.5, 4.5, 0.0, ""); configParam(MentalPitchShift::OCTAVE_SHIFT_2, -4.5, 4.5, 0.0, ""); configParam(MentalPitchShift::SEMITONE_SHIFT_1, -6.5, 6.5, 0.0, ""); configParam(MentalPitchShift::SEMITONE_SHIFT_2, -6.5, 6.5, 0.0, ""); } float octave_1_out = 0.0; float octave_2_out = 0.0; float semitone_1_out = 0.0; float semitone_2_out = 0.0; void process(const ProcessArgs& args) override; }; ///////////////////////////////////////////////////// void MentalPitchShift::process(const ProcessArgs& args) { octave_1_out = inputs[OCTAVE_SHIFT_1_INPUT].getVoltage() + round(params[OCTAVE_SHIFT_1].getValue()) + round(inputs[OCTAVE_SHIFT_1_CVINPUT].getVoltage()/2); octave_2_out = inputs[OCTAVE_SHIFT_2_INPUT].getVoltage() + round(params[OCTAVE_SHIFT_2].getValue()) + round(inputs[OCTAVE_SHIFT_1_CVINPUT].getVoltage()/2); semitone_1_out = inputs[SEMITONE_SHIFT_1_INPUT].getVoltage() + round(params[SEMITONE_SHIFT_1].getValue())*(1.0/12.0) + round(inputs[SEMITONE_SHIFT_1_CVINPUT].getVoltage()/2)*(1.0/12.0); semitone_2_out = inputs[SEMITONE_SHIFT_2_INPUT].getVoltage() + round(params[SEMITONE_SHIFT_2].getValue())*(1.0/12.0) + round(inputs[SEMITONE_SHIFT_2_CVINPUT].getVoltage()/2)*(1.0/12.0); outputs[OCTAVE_SHIFT_1_OUTPUT].setVoltage(octave_1_out); outputs[OCTAVE_SHIFT_2_OUTPUT].setVoltage(octave_2_out); outputs[SEMITONE_SHIFT_1_OUTPUT].setVoltage(semitone_1_out); outputs[SEMITONE_SHIFT_2_OUTPUT].setVoltage(semitone_2_out); } ////////////////////////////////////////////////////////////////// struct MentalPitchShiftWidget : ModuleWidget { MentalPitchShiftWidget(MentalPitchShift *module) { setModule(module); setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/MentalPitchShift.svg"))); addParam(createParam<MedKnob>(Vec(2, 20), module, MentalPitchShift::OCTAVE_SHIFT_1)); addParam(createParam<MedKnob>(Vec(2, 80), module, MentalPitchShift::OCTAVE_SHIFT_2)); addParam(createParam<MedKnob>(Vec(2, 140), module, MentalPitchShift::SEMITONE_SHIFT_1)); addParam(createParam<MedKnob>(Vec(2, 200), module, MentalPitchShift::SEMITONE_SHIFT_2)); addInput(createInput<CVInPort>(Vec(3, 50), module, MentalPitchShift::OCTAVE_SHIFT_1_INPUT)); addInput(createInput<CVInPort>(Vec(3, 110), module, MentalPitchShift::OCTAVE_SHIFT_2_INPUT)); addInput(createInput<CVInPort>(Vec(3, 170), module, MentalPitchShift::SEMITONE_SHIFT_1_INPUT)); addInput(createInput<CVInPort>(Vec(3, 230), module, MentalPitchShift::SEMITONE_SHIFT_2_INPUT)); addInput(createInput<CVInPort>(Vec(33, 20), module, MentalPitchShift::OCTAVE_SHIFT_1_CVINPUT)); addInput(createInput<CVInPort>(Vec(33, 80), module, MentalPitchShift::OCTAVE_SHIFT_2_CVINPUT)); addInput(createInput<CVInPort>(Vec(33, 140), module, MentalPitchShift::SEMITONE_SHIFT_1_CVINPUT)); addInput(createInput<CVInPort>(Vec(33, 200), module, MentalPitchShift::SEMITONE_SHIFT_2_CVINPUT)); addOutput(createOutput<CVOutPort>(Vec(33, 50), module, MentalPitchShift::OCTAVE_SHIFT_1_OUTPUT)); addOutput(createOutput<CVOutPort>(Vec(33, 110), module, MentalPitchShift::OCTAVE_SHIFT_2_OUTPUT)); addOutput(createOutput<CVOutPort>(Vec(33, 170), module, MentalPitchShift::SEMITONE_SHIFT_1_OUTPUT)); addOutput(createOutput<CVOutPort>(Vec(33, 230), module, MentalPitchShift::SEMITONE_SHIFT_2_OUTPUT)); } }; Model *modelMentalPitchShift = createModel<MentalPitchShift, MentalPitchShiftWidget>("MentalPitchShift");
41.775701
187
0.707606
miRackModular
4ae062c357f69cb35ddcc76a3cca5261a114e2f5
2,049
cpp
C++
Examples/CPP/WorkingWithProjects/ImportingAndExporting/ImportDataFromMPXFileFormats.cpp
aspose-tasks/Aspose.Tasks-for-C
acb3e2b75685f65cbe34dd739c7eae0dfc285aa1
[ "MIT" ]
1
2022-03-16T14:31:36.000Z
2022-03-16T14:31:36.000Z
Examples/CPP/WorkingWithProjects/ImportingAndExporting/ImportDataFromMPXFileFormats.cpp
aspose-tasks/Aspose.Tasks-for-C
acb3e2b75685f65cbe34dd739c7eae0dfc285aa1
[ "MIT" ]
null
null
null
Examples/CPP/WorkingWithProjects/ImportingAndExporting/ImportDataFromMPXFileFormats.cpp
aspose-tasks/Aspose.Tasks-for-C
acb3e2b75685f65cbe34dd739c7eae0dfc285aa1
[ "MIT" ]
1
2020-07-01T01:26:17.000Z
2020-07-01T01:26:17.000Z
/* This project uses Automatic Package Restore feature of NuGet to resolve Aspose.Tasks for .NET API reference when the project is build. Please check https:// Docs.nuget.org/consume/nuget-faq for more information. If you do not wish to use NuGet, you can manually download Aspose.Tasks for .NET API from https://www.nuget.org/packages/Aspose.Tasks/, install it and then add its reference to this project. For any issues, questions or suggestions please feel free to contact us using https://forum.aspose.com/c/tasks */ #include "WorkingWithProjects/ImportingAndExporting/ImportDataFromMPXFileFormats.h" #include <system/type_info.h> #include <system/string.h> #include <system/shared_ptr.h> #include <system/reflection/method_base.h> #include <system/object_ext.h> #include <system/object.h> #include <system/console.h> #include <ProjectFileInfo.h> #include <Project.h> #include <enums/FileFormat.h> #include "RunExamples.h" namespace Aspose { namespace Tasks { namespace Examples { namespace CPP { namespace WorkingWithProjects { namespace ImportingAndExporting { RTTI_INFO_IMPL_HASH(3498962390u, ::Aspose::Tasks::Examples::CPP::WorkingWithProjects::ImportingAndExporting::ImportDataFromMPXFileFormats, ThisTypeBaseTypesInfo); void ImportDataFromMPXFileFormats::Run() { // The path to the documents directory. System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName()); // ExStart:ImportDataFromMPXFileFormats System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Primavera1.mpx"); System::SharedPtr<ProjectFileInfo> info = Project::GetProjectFileInfo(dataDir + u"primavera1.mpx"); System::Console::WriteLine(System::ObjectExt::Box<FileFormat>(info->get_ProjectFileFormat())); // ExEnd:ImportDataFromMPXFileFormats } } // namespace ImportingAndExporting } // namespace WorkingWithProjects } // namespace CPP } // namespace Examples } // namespace Tasks } // namespace Aspose
37.254545
164
0.781357
aspose-tasks
4ae0befef910ae6f16a4f0ce916bca5d5c30bfb0
1,017
cpp
C++
Src/MapEditor/lightedit.cpp
vox-1/MapEditor
f1b8a3df64c91e9c3aef7ee21e997f4f1163fa0e
[ "MIT" ]
23
2018-12-02T01:08:39.000Z
2022-03-19T02:28:56.000Z
Src/MapEditor/lightedit.cpp
vox-1/MapEditor
f1b8a3df64c91e9c3aef7ee21e997f4f1163fa0e
[ "MIT" ]
null
null
null
Src/MapEditor/lightedit.cpp
vox-1/MapEditor
f1b8a3df64c91e9c3aef7ee21e997f4f1163fa0e
[ "MIT" ]
15
2018-12-07T06:33:55.000Z
2022-03-26T13:27:25.000Z
#include "stdafx.h" #include "lightedit.h" using namespace graphic; cLightEdit::cLightEdit() : m_showLightDir(true) , m_openLightEdit(false) { } cLightEdit::~cLightEdit() { } bool cLightEdit::Init(graphic::cRenderer &renderer) { m_lightDir = GetMainLight().m_direction; return true; } void cLightEdit::Render(graphic::cRenderer &renderer) { m_openLightEdit = false; //ImGui::SetNextTreeNodeOpen(true, ImGuiSetCond_FirstUseEver); if (ImGui::CollapsingHeader("Light Edit")) { m_openLightEdit = true; ImGui::Checkbox("Show Light Direction", &m_showLightDir); float v[2] = { m_lightDir.x, m_lightDir.z }; if (ImGui::DragFloat2("Direction X - Z", v, 0.01f)) { m_lightDir.x = v[0]; m_lightDir.z = v[1]; m_lightDir.Normalize(); GetMainLight().m_direction = m_lightDir; } ImGui::ColorEdit3("Ambient", (float*)&GetMainLight().m_ambient); ImGui::ColorEdit3("Diffuse", (float*)&GetMainLight().m_diffuse); ImGui::ColorEdit3("Specular", (float*)&GetMainLight().m_specular); } }
19.941176
68
0.702065
vox-1
4ae281caf0afe4adb10a5aba5ad5b9af692c6b8e
1,633
cpp
C++
src/interprocess/basic_publisher/publisher.cpp
ashish-boss/goby3-examples
686b290bf84a10f02ba169a8f1363dba43c9ed95
[ "MIT" ]
3
2017-08-03T19:00:29.000Z
2019-12-15T04:47:26.000Z
src/interprocess/basic_publisher/publisher.cpp
ashish-boss/goby3-examples
686b290bf84a10f02ba169a8f1363dba43c9ed95
[ "MIT" ]
3
2020-05-14T15:49:57.000Z
2021-04-15T19:02:07.000Z
src/interprocess/basic_publisher/publisher.cpp
ashish-boss/goby3-examples
686b290bf84a10f02ba169a8f1363dba43c9ed95
[ "MIT" ]
2
2020-04-27T20:12:17.000Z
2021-08-17T01:58:56.000Z
#include <goby/middleware/marshalling/protobuf.h> // provides serializer / parser for Google Protocol Buffers #include <goby/zeromq/application/single_thread.h> // provides SingleThreadApplication #include "messages/groups.h" // defines publish/subscribe groups #include "messages/nav.pb.h" // Protobuf, defines NavigationReport #include "config.pb.h" // Protobuf, defines BasicPublisherConfig // optional "using" declaration (reduces verbiage) using Base = goby::zeromq::SingleThreadApplication<BasicPublisherConfig>; using protobuf::NavigationReport; class BasicPublisher : public Base { public: BasicPublisher() : Base(10 /*hertz*/) { // all configuration defined in BasicPublisherConfig is available using cfg(); std::cout << "My configuration int is: " << cfg().my_value() << std::endl; } // virtual method in goby::zeromq::SingleThreadApplication called at the frequency given to Base(freq) void loop() override { NavigationReport nav; nav.set_x(95 + std::rand() % 20); nav.set_y(195 + std::rand() % 20); nav.set_z(-305 + std::rand() % 10); std::cout << "Tx: " << nav.DebugString() << std::flush; interprocess().publish<groups::nav>(nav); } }; // reads command line parameters based on BasicPublisherConfig definition // these can be set on the command line (try "basic_publisher --help" to see parameters) // or in a configuration file (use "basic_publisher --example_config" for the correct syntax) // edit "config.proto" to add parameters int main(int argc, char* argv[]) { return goby::run<BasicPublisher>(argc, argv); }
39.829268
109
0.699939
ashish-boss
4ae3a86d26c2cde441c1badddcdadaddd01c7205
10,639
cc
C++
v0_1_5/lib/marisa_alpha/trie-build.cc
AdvantechRISC/apq8016_external_marisa-trie
629ed059b1e85cd8e4de363d8b3dc53c15c3e08a
[ "BSD-3-Clause" ]
null
null
null
v0_1_5/lib/marisa_alpha/trie-build.cc
AdvantechRISC/apq8016_external_marisa-trie
629ed059b1e85cd8e4de363d8b3dc53c15c3e08a
[ "BSD-3-Clause" ]
null
null
null
v0_1_5/lib/marisa_alpha/trie-build.cc
AdvantechRISC/apq8016_external_marisa-trie
629ed059b1e85cd8e4de363d8b3dc53c15c3e08a
[ "BSD-3-Clause" ]
null
null
null
#include <algorithm> #include <functional> #include <queue> #include <stdexcept> #include "range.h" #include "trie.h" namespace marisa_alpha { void Trie::build(const char * const *keys, std::size_t num_keys, const std::size_t *key_lengths, const double *key_weights, UInt32 *key_ids, int flags) { MARISA_ALPHA_THROW_IF((keys == NULL) && (num_keys != 0), MARISA_ALPHA_PARAM_ERROR); Vector<Key<String> > temp_keys; temp_keys.resize(num_keys); for (std::size_t i = 0; i < temp_keys.size(); ++i) { MARISA_ALPHA_THROW_IF(keys[i] == NULL, MARISA_ALPHA_PARAM_ERROR); std::size_t length = 0; if (key_lengths == NULL) { while (keys[i][length] != '\0') { ++length; } } else { length = key_lengths[i]; } MARISA_ALPHA_THROW_IF(length > MARISA_ALPHA_MAX_LENGTH, MARISA_ALPHA_SIZE_ERROR); temp_keys[i].set_str(String(keys[i], length)); temp_keys[i].set_weight((key_weights != NULL) ? key_weights[i] : 1.0); } build_trie(temp_keys, key_ids, flags); } void Trie::build(const std::vector<std::string> &keys, std::vector<UInt32> *key_ids, int flags) { Vector<Key<String> > temp_keys; temp_keys.resize(keys.size()); for (std::size_t i = 0; i < temp_keys.size(); ++i) { MARISA_ALPHA_THROW_IF(keys[i].length() > MARISA_ALPHA_MAX_LENGTH, MARISA_ALPHA_SIZE_ERROR); temp_keys[i].set_str(String(keys[i].c_str(), keys[i].length())); temp_keys[i].set_weight(1.0); } build_trie(temp_keys, key_ids, flags); } void Trie::build(const std::vector<std::pair<std::string, double> > &keys, std::vector<UInt32> *key_ids, int flags) { Vector<Key<String> > temp_keys; temp_keys.resize(keys.size()); for (std::size_t i = 0; i < temp_keys.size(); ++i) { MARISA_ALPHA_THROW_IF(keys[i].first.length() > MARISA_ALPHA_MAX_LENGTH, MARISA_ALPHA_SIZE_ERROR); temp_keys[i].set_str(String( keys[i].first.c_str(), keys[i].first.length())); temp_keys[i].set_weight(keys[i].second); } build_trie(temp_keys, key_ids, flags); } void Trie::build_trie(Vector<Key<String> > &keys, std::vector<UInt32> *key_ids, int flags) { if (key_ids == NULL) { build_trie(keys, static_cast<UInt32 *>(NULL), flags); return; } try { std::vector<UInt32> temp_key_ids(keys.size()); build_trie(keys, temp_key_ids.empty() ? NULL : &temp_key_ids[0], flags); key_ids->swap(temp_key_ids); } catch (const std::bad_alloc &) { MARISA_ALPHA_THROW(MARISA_ALPHA_MEMORY_ERROR); } catch (const std::length_error &) { MARISA_ALPHA_THROW(MARISA_ALPHA_SIZE_ERROR); } } void Trie::build_trie(Vector<Key<String> > &keys, UInt32 *key_ids, int flags) { Trie temp; Vector<UInt32> terminals; Progress progress(flags); MARISA_ALPHA_THROW_IF(!progress.is_valid(), MARISA_ALPHA_PARAM_ERROR); temp.build_trie(keys, &terminals, progress); typedef std::pair<UInt32, UInt32> TerminalIdPair; Vector<TerminalIdPair> pairs; pairs.resize(terminals.size()); for (UInt32 i = 0; i < pairs.size(); ++i) { pairs[i].first = terminals[i]; pairs[i].second = i; } terminals.clear(); std::sort(pairs.begin(), pairs.end()); UInt32 node = 0; for (UInt32 i = 0; i < pairs.size(); ++i) { while (node < pairs[i].first) { temp.terminal_flags_.push_back(false); ++node; } if (node == pairs[i].first) { temp.terminal_flags_.push_back(true); ++node; } } while (node < temp.labels_.size()) { temp.terminal_flags_.push_back(false); ++node; } terminal_flags_.push_back(false); temp.terminal_flags_.build(); temp.terminal_flags_.clear_select0s(); progress.test_total_size(temp.terminal_flags_.total_size()); if (key_ids != NULL) { for (UInt32 i = 0; i < pairs.size(); ++i) { key_ids[pairs[i].second] = temp.node_to_key_id(pairs[i].first); } } MARISA_ALPHA_THROW_IF(progress.total_size() != temp.total_size(), MARISA_ALPHA_UNEXPECTED_ERROR); temp.swap(this); } template <typename T> void Trie::build_trie(Vector<Key<T> > &keys, Vector<UInt32> *terminals, Progress &progress) { build_cur(keys, terminals, progress); progress.test_total_size(louds_.total_size()); progress.test_total_size(sizeof(num_first_branches_)); progress.test_total_size(sizeof(num_keys_)); if (link_flags_.empty()) { labels_.shrink(); progress.test_total_size(labels_.total_size()); progress.test_total_size(link_flags_.total_size()); progress.test_total_size(links_.total_size()); progress.test_total_size(tail_.total_size()); return; } Vector<UInt32> next_terminals; build_next(keys, &next_terminals, progress); if (has_trie()) { progress.test_total_size(trie_->terminal_flags_.total_size()); } else if (tail_.mode() == MARISA_ALPHA_BINARY_TAIL) { labels_.push_back('\0'); link_flags_.push_back(true); } link_flags_.build(); for (UInt32 i = 0; i < next_terminals.size(); ++i) { labels_[link_flags_.select1(i)] = (UInt8)(next_terminals[i] % 256); next_terminals[i] /= 256; } link_flags_.clear_select0s(); if (has_trie() || (tail_.mode() == MARISA_ALPHA_TEXT_TAIL)) { link_flags_.clear_select1s(); } links_.build(next_terminals); labels_.shrink(); progress.test_total_size(labels_.total_size()); progress.test_total_size(link_flags_.total_size()); progress.test_total_size(links_.total_size()); progress.test_total_size(tail_.total_size()); } template <typename T> void Trie::build_cur(Vector<Key<T> > &keys, Vector<UInt32> *terminals, Progress &progress) try { num_keys_ = sort_keys(keys); louds_.push_back(true); louds_.push_back(false); labels_.push_back('\0'); link_flags_.push_back(false); Vector<Key<T> > rest_keys; std::queue<Range> queue; Vector<WRange> wranges; queue.push(Range(0, (UInt32)keys.size(), 0)); while (!queue.empty()) { const UInt32 node = (UInt32)(link_flags_.size() - queue.size()); Range range = queue.front(); queue.pop(); while ((range.begin() < range.end()) && (keys[range.begin()].str().length() == range.pos())) { keys[range.begin()].set_terminal(node); range.set_begin(range.begin() + 1); } if (range.begin() == range.end()) { louds_.push_back(false); continue; } wranges.clear(); double weight = keys[range.begin()].weight(); for (UInt32 i = range.begin() + 1; i < range.end(); ++i) { if (keys[i - 1].str()[range.pos()] != keys[i].str()[range.pos()]) { wranges.push_back(WRange(range.begin(), i, range.pos(), weight)); range.set_begin(i); weight = 0.0; } weight += keys[i].weight(); } wranges.push_back(WRange(range, weight)); if (progress.order() == MARISA_ALPHA_WEIGHT_ORDER) { std::stable_sort(wranges.begin(), wranges.end(), std::greater<WRange>()); } if (node == 0) { num_first_branches_ = wranges.size(); } for (UInt32 i = 0; i < wranges.size(); ++i) { const WRange &wrange = wranges[i]; UInt32 pos = wrange.pos() + 1; if ((progress.tail() != MARISA_ALPHA_WITHOUT_TAIL) || !progress.is_last()) { while (pos < keys[wrange.begin()].str().length()) { UInt32 j; for (j = wrange.begin() + 1; j < wrange.end(); ++j) { if (keys[j - 1].str()[pos] != keys[j].str()[pos]) { break; } } if (j < wrange.end()) { break; } ++pos; } } if ((progress.trie() != MARISA_ALPHA_PATRICIA_TRIE) && (pos != keys[wrange.end() - 1].str().length())) { pos = wrange.pos() + 1; } louds_.push_back(true); if (pos == wrange.pos() + 1) { labels_.push_back(keys[wrange.begin()].str()[wrange.pos()]); link_flags_.push_back(false); } else { labels_.push_back('\0'); link_flags_.push_back(true); Key<T> rest_key; rest_key.set_str(keys[wrange.begin()].str().substr( wrange.pos(), pos - wrange.pos())); rest_key.set_weight(wrange.weight()); rest_keys.push_back(rest_key); } wranges[i].set_pos(pos); queue.push(wranges[i].range()); } louds_.push_back(false); } louds_.push_back(false); louds_.build(); if (progress.trie_id() != 0) { louds_.clear_select0s(); } if (rest_keys.empty()) { link_flags_.clear(); } build_terminals(keys, terminals); keys.swap(&rest_keys); } catch (const std::bad_alloc &) { MARISA_ALPHA_THROW(MARISA_ALPHA_MEMORY_ERROR); } catch (const std::length_error &) { MARISA_ALPHA_THROW(MARISA_ALPHA_SIZE_ERROR); } void Trie::build_next(Vector<Key<String> > &keys, Vector<UInt32> *terminals, Progress &progress) { if (progress.is_last()) { Vector<String> strs; strs.resize(keys.size()); for (UInt32 i = 0; i < strs.size(); ++i) { strs[i] = keys[i].str(); } tail_.build(strs, terminals, progress.tail()); return; } Vector<Key<RString> > rkeys; rkeys.resize(keys.size()); for (UInt32 i = 0; i < rkeys.size(); ++i) { rkeys[i].set_str(RString(keys[i].str())); rkeys[i].set_weight(keys[i].weight()); } keys.clear(); trie_.reset(new (std::nothrow) Trie); MARISA_ALPHA_THROW_IF(!has_trie(), MARISA_ALPHA_MEMORY_ERROR); trie_->build_trie(rkeys, terminals, ++progress); } void Trie::build_next(Vector<Key<RString> > &rkeys, Vector<UInt32> *terminals, Progress &progress) { if (progress.is_last()) { Vector<String> strs; strs.resize(rkeys.size()); for (UInt32 i = 0; i < strs.size(); ++i) { strs[i] = String(rkeys[i].str().ptr(), rkeys[i].str().length()); } tail_.build(strs, terminals, progress.tail()); return; } trie_.reset(new (std::nothrow) Trie); MARISA_ALPHA_THROW_IF(!has_trie(), MARISA_ALPHA_MEMORY_ERROR); trie_->build_trie(rkeys, terminals, ++progress); } template <typename T> UInt32 Trie::sort_keys(Vector<Key<T> > &keys) const { if (keys.empty()) { return 0; } for (UInt32 i = 0; i < keys.size(); ++i) { keys[i].set_id(i); } std::sort(keys.begin(), keys.end()); UInt32 count = 1; for (UInt32 i = 1; i < keys.size(); ++i) { if (keys[i - 1].str() != keys[i].str()) { ++count; } } return count; } template <typename T> void Trie::build_terminals(const Vector<Key<T> > &keys, Vector<UInt32> *terminals) const { Vector<UInt32> temp_terminals; temp_terminals.resize(keys.size()); for (UInt32 i = 0; i < keys.size(); ++i) { temp_terminals[keys[i].id()] = keys[i].terminal(); } temp_terminals.swap(terminals); } } // namespace marisa_alpha
31.017493
79
0.632014
AdvantechRISC
4ae4332272da3f90a2734c73e6e5212de96ef9ce
420
cpp
C++
sources/GameEngine/getColor.cpp
gillioa/Bomberman
5e21c317a4b3d00533acdddb99b98c08b102fe45
[ "MIT" ]
null
null
null
sources/GameEngine/getColor.cpp
gillioa/Bomberman
5e21c317a4b3d00533acdddb99b98c08b102fe45
[ "MIT" ]
null
null
null
sources/GameEngine/getColor.cpp
gillioa/Bomberman
5e21c317a4b3d00533acdddb99b98c08b102fe45
[ "MIT" ]
null
null
null
#include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> glm::vec4 getColor(unsigned int num, unsigned int total) { unsigned int ec1 = 2 * (total / (num + 1) + 1 + (total % (num + 1)) * 55) % 0xFF; unsigned int ec2 = 3 * (ec1 + total % (num + ((num + 1) % 8))) % 0xFF; unsigned int ec3 = 4 * (ec2 + total / (num + (total / 2) + 1)) % 0xFF; return (glm::vec4(ec1 / 255.0, ec2 / 255.0, ec3 / 255.0, 1)); }
38.181818
83
0.571429
gillioa
4ae64fcf8e513067035e685aeeab745c10aac43f
8,142
cc
C++
dms-enterprise/src/model/ListDDLPublishRecordsResult.cc
aliyun/aliyun-openapi-cpp-sdk
0cf5861ece17dfb0bb251f13bf3fbdb39c0c6e36
[ "Apache-2.0" ]
89
2018-02-02T03:54:39.000Z
2021-12-13T01:32:55.000Z
dms-enterprise/src/model/ListDDLPublishRecordsResult.cc
aliyun/aliyun-openapi-cpp-sdk
0cf5861ece17dfb0bb251f13bf3fbdb39c0c6e36
[ "Apache-2.0" ]
89
2018-03-14T07:44:54.000Z
2021-11-26T07:43:25.000Z
dms-enterprise/src/model/ListDDLPublishRecordsResult.cc
aliyun/aliyun-openapi-cpp-sdk
0cf5861ece17dfb0bb251f13bf3fbdb39c0c6e36
[ "Apache-2.0" ]
69
2018-01-22T09:45:52.000Z
2022-03-28T07:58:38.000Z
/* * Copyright 2009-2017 Alibaba Cloud All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <alibabacloud/dms-enterprise/model/ListDDLPublishRecordsResult.h> #include <json/json.h> using namespace AlibabaCloud::Dms_enterprise; using namespace AlibabaCloud::Dms_enterprise::Model; ListDDLPublishRecordsResult::ListDDLPublishRecordsResult() : ServiceResult() {} ListDDLPublishRecordsResult::ListDDLPublishRecordsResult(const std::string &payload) : ServiceResult() { parse(payload); } ListDDLPublishRecordsResult::~ListDDLPublishRecordsResult() {} void ListDDLPublishRecordsResult::parse(const std::string &payload) { Json::Reader reader; Json::Value value; reader.parse(payload, value); setRequestId(value["RequestId"].asString()); auto allDDLPublishRecordListNode = value["DDLPublishRecordList"]["DDLPublishRecord"]; for (auto valueDDLPublishRecordListDDLPublishRecord : allDDLPublishRecordListNode) { DDLPublishRecord dDLPublishRecordListObject; if(!valueDDLPublishRecordListDDLPublishRecord["AuditStatus"].isNull()) dDLPublishRecordListObject.auditStatus = valueDDLPublishRecordListDDLPublishRecord["AuditStatus"].asString(); if(!valueDDLPublishRecordListDDLPublishRecord["AuditExpireTime"].isNull()) dDLPublishRecordListObject.auditExpireTime = valueDDLPublishRecordListDDLPublishRecord["AuditExpireTime"].asString(); if(!valueDDLPublishRecordListDDLPublishRecord["CreatorId"].isNull()) dDLPublishRecordListObject.creatorId = std::stol(valueDDLPublishRecordListDDLPublishRecord["CreatorId"].asString()); if(!valueDDLPublishRecordListDDLPublishRecord["Finality"].isNull()) dDLPublishRecordListObject.finality = valueDDLPublishRecordListDDLPublishRecord["Finality"].asString() == "true"; if(!valueDDLPublishRecordListDDLPublishRecord["FinalityReason"].isNull()) dDLPublishRecordListObject.finalityReason = valueDDLPublishRecordListDDLPublishRecord["FinalityReason"].asString(); if(!valueDDLPublishRecordListDDLPublishRecord["PublishStatus"].isNull()) dDLPublishRecordListObject.publishStatus = valueDDLPublishRecordListDDLPublishRecord["PublishStatus"].asString(); if(!valueDDLPublishRecordListDDLPublishRecord["RiskLevel"].isNull()) dDLPublishRecordListObject.riskLevel = valueDDLPublishRecordListDDLPublishRecord["RiskLevel"].asString(); if(!valueDDLPublishRecordListDDLPublishRecord["StatusDesc"].isNull()) dDLPublishRecordListObject.statusDesc = valueDDLPublishRecordListDDLPublishRecord["StatusDesc"].asString(); if(!valueDDLPublishRecordListDDLPublishRecord["WorkflowInstanceId"].isNull()) dDLPublishRecordListObject.workflowInstanceId = std::stol(valueDDLPublishRecordListDDLPublishRecord["WorkflowInstanceId"].asString()); auto allPublishTaskInfoListNode = valueDDLPublishRecordListDDLPublishRecord["PublishTaskInfoList"]["PublishTaskInfo"]; for (auto valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo : allPublishTaskInfoListNode) { DDLPublishRecord::PublishTaskInfo publishTaskInfoListObject; if(!valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo["DbId"].isNull()) publishTaskInfoListObject.dbId = std::stol(valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo["DbId"].asString()); if(!valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo["Logic"].isNull()) publishTaskInfoListObject.logic = valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo["Logic"].asString() == "true"; if(!valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo["PlanTime"].isNull()) publishTaskInfoListObject.planTime = valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo["PlanTime"].asString(); if(!valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo["PublishStrategy"].isNull()) publishTaskInfoListObject.publishStrategy = valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo["PublishStrategy"].asString(); if(!valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo["StatusDesc"].isNull()) publishTaskInfoListObject.statusDesc = valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo["StatusDesc"].asString(); if(!valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo["TaskJobStatus"].isNull()) publishTaskInfoListObject.taskJobStatus = valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo["TaskJobStatus"].asString(); auto allPublishJobListNode = valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfo["PublishJobList"]["PublishJob"]; for (auto valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfoPublishJobListPublishJob : allPublishJobListNode) { DDLPublishRecord::PublishTaskInfo::PublishJob publishJobListObject; if(!valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfoPublishJobListPublishJob["ExecuteCount"].isNull()) publishJobListObject.executeCount = std::stol(valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfoPublishJobListPublishJob["ExecuteCount"].asString()); if(!valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfoPublishJobListPublishJob["Scripts"].isNull()) publishJobListObject.scripts = valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfoPublishJobListPublishJob["Scripts"].asString(); if(!valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfoPublishJobListPublishJob["TableName"].isNull()) publishJobListObject.tableName = valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfoPublishJobListPublishJob["TableName"].asString(); if(!valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfoPublishJobListPublishJob["StatusDesc"].isNull()) publishJobListObject.statusDesc = valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfoPublishJobListPublishJob["StatusDesc"].asString(); if(!valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfoPublishJobListPublishJob["TaskJobStatus"].isNull()) publishJobListObject.taskJobStatus = valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfoPublishJobListPublishJob["TaskJobStatus"].asString(); if(!valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfoPublishJobListPublishJob["DBTaskGroupId"].isNull()) publishJobListObject.dBTaskGroupId = std::stol(valueDDLPublishRecordListDDLPublishRecordPublishTaskInfoListPublishTaskInfoPublishJobListPublishJob["DBTaskGroupId"].asString()); publishTaskInfoListObject.publishJobList.push_back(publishJobListObject); } dDLPublishRecordListObject.publishTaskInfoList.push_back(publishTaskInfoListObject); } dDLPublishRecordList_.push_back(dDLPublishRecordListObject); } if(!value["Success"].isNull()) success_ = value["Success"].asString() == "true"; if(!value["ErrorMessage"].isNull()) errorMessage_ = value["ErrorMessage"].asString(); if(!value["ErrorCode"].isNull()) errorCode_ = value["ErrorCode"].asString(); } std::string ListDDLPublishRecordsResult::getErrorCode()const { return errorCode_; } std::string ListDDLPublishRecordsResult::getErrorMessage()const { return errorMessage_; } std::vector<ListDDLPublishRecordsResult::DDLPublishRecord> ListDDLPublishRecordsResult::getDDLPublishRecordList()const { return dDLPublishRecordList_; } bool ListDDLPublishRecordsResult::getSuccess()const { return success_; }
62.152672
181
0.842545
aliyun
4aeb1785c46d095ced534989f8487601767d32dd
838
inl
C++
gle/vao.inl
zacklukem/gle
b643eb9f418df7c80c96abf5521a92589fa17ab3
[ "MIT" ]
null
null
null
gle/vao.inl
zacklukem/gle
b643eb9f418df7c80c96abf5521a92589fa17ab3
[ "MIT" ]
null
null
null
gle/vao.inl
zacklukem/gle
b643eb9f418df7c80c96abf5521a92589fa17ab3
[ "MIT" ]
null
null
null
GLE_NAMESPACE_BEGIN inline VAO::VAO() : handle(0) {} inline VAO::~VAO() { if (handle) glDeleteVertexArrays(1, &handle); } inline void VAO::init() { glGenVertexArrays(1, &handle); } inline void VAO::bind() const { glBindVertexArray(handle); } template <class T> inline void VAO::attr(GLuint index, const VBO<T> &vbo) const { bind(); vbo.bind(); switch (VBO<T>::gl_value_type) { case GL_BYTE: case GL_UNSIGNED_BYTE: case GL_SHORT: case GL_UNSIGNED_SHORT: case GL_INT: case GL_UNSIGNED_INT: glVertexAttribIPointer(index, VBO<T>::gl_value_size, VBO<T>::gl_value_type, sizeof(T), (void *)0); break; default: glVertexAttribPointer(index, VBO<T>::gl_value_size, VBO<T>::gl_value_type, GL_FALSE, sizeof(T), (void *)0); break; } } GLE_NAMESPACE_END
24.647059
79
0.649165
zacklukem
4aefbdbfec1a0f6e01531a949db249d0bc6430f4
3,424
hpp
C++
dev/Basic/long/config/LT_Config.hpp
gusugusu1018/simmobility-prod
d30a5ba353673f8fd35f4868c26994a0206a40b6
[ "MIT" ]
50
2018-12-21T08:21:38.000Z
2022-01-24T09:47:59.000Z
dev/Basic/long/config/LT_Config.hpp
gusugusu1018/simmobility-prod
d30a5ba353673f8fd35f4868c26994a0206a40b6
[ "MIT" ]
2
2018-12-19T13:42:47.000Z
2019-05-13T04:11:45.000Z
dev/Basic/long/config/LT_Config.hpp
gusugusu1018/simmobility-prod
d30a5ba353673f8fd35f4868c26994a0206a40b6
[ "MIT" ]
27
2018-11-28T07:30:34.000Z
2022-02-05T02:22:26.000Z
/* * Copyright Singapore-MIT Alliance for Research and Technology * * File: LT_Config.hpp * Author: Pedro Gandola <pedrogandola@smart.mit.edu> * * Created on November 6, 2013, 11:26 AM */ #pragma once #include <string> #include "Common.hpp" #include "conf/PropertyLoader.hpp" #include "util/SingletonHolder.hpp" namespace sim_mob { namespace long_term { /** * Reads long-term properties from ini file. * * Supported fields: * [events injector] * events_file=<file absolute path> * */ class InjectorConfig : public PropertyLoader { public: /** * Constructor to load from given file. * @param file to load properties. */ InjectorConfig(const std::string& file); InjectorConfig(const InjectorConfig& orig); virtual ~InjectorConfig(); const std::string& getEventsFile() const; void setEventsFile(const std::string& filePath); protected: friend class LT_Config; /** * Inherited from PropertyLoader */ void loadImpl(const boost::property_tree::ptree& tree); private: std::string eventsFile; }; /** * Reads long-term properties from ini file. * * [housing market] * time_on_market=<int 0-365> */ class HM_Config : public PropertyLoader { public: /** * Constructor to load from given file. * @param file to load properties. */ HM_Config(const std::string& file); HM_Config(const HM_Config& orig); virtual ~HM_Config(); unsigned int getTimeOnMarket() const; void setTimeOnMarket(unsigned int filePath); protected: friend class LT_Config; /** * Inherited from PropertyLoader */ void loadImpl(const boost::property_tree::ptree& tree); private: unsigned int timeOnMarket; }; /** * Reads long-term properties from ini file. * * Containing all configurations. * * It is possible to avoid the configuration. */ class LT_Config : public PropertyLoader { public: LT_Config(const std::string& file); LT_Config(const LT_Config& orig); virtual ~LT_Config(); const HM_Config& getHM_Config() const; const InjectorConfig& getInjectorConfig() const; protected: /** * Inherited from PropertyLoader */ void loadImpl(const boost::property_tree::ptree& tree); private: HM_Config hmConfig; InjectorConfig injectorConfig; }; /** * Configuration Singleton. */ template<typename T = LT_Config> struct ConfigLifeCycle { static T * create() { T* config = new T(LT_CONFIG_FILE); config->load(); return config; } static void destroy(T* config) { delete config; } }; typedef SingletonHolder<LT_Config, ConfigLifeCycle> LT_ConfigSingleton; } }
27.612903
79
0.530374
gusugusu1018
4af346b95b3a14a669b8279e25f9dd35987fe323
69,496
cxx
C++
com/rpc/ndr20/asyncu.cxx
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
com/rpc/ndr20/asyncu.cxx
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
com/rpc/ndr20/asyncu.cxx
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Copyright (c) 1996 - 2000 Microsoft Corporation Module Name : asyncu.c Abstract : This file contains the ndr async uuid implementation. Author : Ryszard K. Kott (ryszardk) Oct 1997 Revision History : ---------------------------------------------------------------------*/ #define USE_STUBLESS_PROXY #define CINTERFACE #include "ndrp.h" #include "ndrole.h" #include "rpcproxy.h" #include "mulsyntx.h" #include "hndl.h" #include "interp2.h" #include "asyncu.h" #include "attack.h" #include <stddef.h> #include <stdarg.h> #pragma code_seg(".orpc") RPC_STATUS NdrpBeginDcomAsyncClientCall( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, unsigned char * StartofStack ); RPC_STATUS NdrpFinishDcomAsyncClientCall( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, unsigned char * StartofStack ); const IID * RPC_ENTRY NdrGetProxyIID( const void *pThis); VOID NdrpAsyncDCOMFreeParams( PNDR_DCOM_ASYNC_MESSAGE pAsyncMsg ) { /*++ Routine Description: Frees the parameters for both the begin and finish calls. Arguments: pAsyncMsg - Supplies a pointer to the async message. Return Value: None. --*/ if ( pAsyncMsg->BeginStack ) { if ( pAsyncMsg->FinishStack ) { // Clear out the IN OUT parameters on the begin stack // so that they are not freed twice. int n; REGISTER_TYPE *pBeginStack = (REGISTER_TYPE *)pAsyncMsg->BeginStack; PPARAM_DESCRIPTION BeginParams = (PPARAM_DESCRIPTION)pAsyncMsg->BeginParams; int BeginNumberParams = (int)pAsyncMsg->nBeginParams; for( n = 0; n < BeginNumberParams; n++ ) { if ( BeginParams[n].ParamAttr.IsIn && BeginParams[n].ParamAttr.IsOut ) { pBeginStack[ BeginParams[ n ].StackOffset / sizeof(REGISTER_TYPE) ] = 0; } } } pAsyncMsg->StubMsg.StackTop = pAsyncMsg->BeginStack; NdrpFreeParams( & (pAsyncMsg->StubMsg), pAsyncMsg->nBeginParams, (PPARAM_DESCRIPTION)pAsyncMsg->BeginParams, pAsyncMsg->BeginStack ); } if ( pAsyncMsg->FinishStack ) { pAsyncMsg->StubMsg.StackTop = pAsyncMsg->FinishStack; NdrpFreeParams( & (pAsyncMsg->StubMsg), pAsyncMsg->nFinishParams, (PPARAM_DESCRIPTION)pAsyncMsg->FinishParams, pAsyncMsg->FinishStack ); } } CLIENT_CALL_RETURN RPC_VAR_ENTRY NdrDcomAsyncClientCall( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ... ) /* This entry is used by the stubless proxy invoker and also by OLE thunks. Sync stubless proxies would invoke to NdrClientCall2. On ia64, this entry would be used by -Oic generated code. Note that signaling on the client happens behind the async proxy's back as channel effectively signals to the app and the app issues the Finish. */ { va_list ArgList; unsigned char * StartofStack; CLIENT_CALL_RETURN Ret; ulong ProcNum; // // Get address of argument to this function following pFormat. This // is the address of the address of the first argument of the function // calling this function. // Then get the address of the stack where the parameters are. // INIT_ARG( ArgList, pFormat); GET_FIRST_IN_ARG(ArgList); StartofStack = (uchar *) GET_STACK_START(ArgList); // Object proc layout is fixed for anything that can show up here. ProcNum = *(ushort *)(pFormat+6); if ( ProcNum & 0x1 ) { // An odd proc number means a Begin call (0,1,2,Begin,Finish, ...). Ret.Simple = NdrpBeginDcomAsyncClientCall( pStubDescriptor, pFormat, StartofStack ); } else { Ret.Simple = NdrpFinishDcomAsyncClientCall( pStubDescriptor, pFormat, StartofStack ); } return Ret; } #if defined(_WIN64) CLIENT_CALL_RETURN RPC_ENTRY NdrpDcomAsyncClientCall( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, unsigned char * StartofStack ) /* Used only on WIN64, this entry is used by the stubless proxy invoker and also by OLE thunks. Sync stubless proxies would invoke to NdrpClientCall2. Note that signaling on the client happens behind the async proxy's back as channel effectively signals to the app and the app issues the Finish. */ { CLIENT_CALL_RETURN Ret; ulong ProcNum; // Object proc layout is fixed for anything that can show up here. ProcNum = *(ushort *)(pFormat+6); if ( ProcNum & 0x1 ) { // An odd proc number means a Begin call (0,1,2,Begin,Finish, ...). Ret.Simple = NdrpBeginDcomAsyncClientCall( pStubDescriptor, pFormat, StartofStack ); } else { Ret.Simple = NdrpFinishDcomAsyncClientCall( pStubDescriptor, pFormat, StartofStack ); } return Ret; } #endif HRESULT NdrpBeginDcomAsyncClientCall( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, unsigned char * StartofStack ) /* Notes: OLE Refcounting. The model for async_uuid() is that async proxies or stubs are created with RefCount==1 and should never ever be addrefed by the engine. What the engine does is only the AsyncMsg clean up when done. The decision to destroy the AsyncPB or AsyncSB object is up to the client side PM or channel's SM for the server side. */ { PNDR_DCOM_ASYNC_MESSAGE pAsyncMsg; RPC_MESSAGE * pRpcMsg; MIDL_STUB_MESSAGE * pStubMsg; PFORMAT_STRING pFormatParam; uchar * pArg; void * pThis = *(void **)StartofStack; INTERPRETER_FLAGS OldOiFlags; INTERPRETER_OPT_FLAGS NewOiFlags; PPARAM_DESCRIPTION Params; long NumberParams; long n; RPC_STATUS Status; PNDR_DCOM_OI2_PROC_HEADER pProcHeader = (PNDR_DCOM_OI2_PROC_HEADER)pFormat; PNDR_PROC_HEADER_EXTS pHeaderExts = 0; CStdAsyncProxyBuffer * pAsyncPB; const IID * piid; HRESULT hr = S_OK; BOOL fSendCalled = FALSE; NDR_PROC_CONTEXT * pContext = NULL; pAsyncPB = (CStdAsyncProxyBuffer*) ((uchar*)pThis - offsetof(CStdProxyBuffer, pProxyVtbl)); piid = NdrGetProxyIID( pThis ); Status = NdrpSetupBeginClientCall( pAsyncPB, StartofStack, pProcHeader->StackSize, *piid ); if ( !SUCCEEDED(Status) ) return Status; pAsyncMsg = (PNDR_DCOM_ASYNC_MESSAGE)pAsyncPB->CallState.pAsyncMsg; // We need to switch to our copy of the stack everywhere, including pStubMsg. StartofStack = pAsyncMsg->ProcContext.StartofStack; pRpcMsg = & pAsyncMsg->RpcMsg; pStubMsg = & pAsyncMsg->StubMsg; pContext = ( NDR_PROC_CONTEXT * ) &pAsyncMsg->ProcContext; pStubMsg->pContext = pContext; pContext->StartofStack = StartofStack; pStubMsg->FullPtrXlatTables = 0; OldOiFlags = pProcHeader->OldOiFlags; NewOiFlags = pProcHeader->Oi2Flags; NumberParams = pProcHeader->NumberParams; // // Parameter descriptions are nicely spit out by MIDL. // Params = (PPARAM_DESCRIPTION)(pFormat + sizeof(NDR_DCOM_OI2_PROC_HEADER)); // Proc header extentions, from NDR ver. 5.2, MIDL 5.0.+ // Params must be set correctly here because of exceptions. if ( NewOiFlags.HasExtensions ) { pHeaderExts = (NDR_PROC_HEADER_EXTS *)Params; Params = (PPARAM_DESCRIPTION)((uchar*)Params + pHeaderExts->Size); } pAsyncMsg->nBeginParams = pContext->NumberParams = NumberParams; pAsyncMsg->BeginParams = pContext->Params = Params; pAsyncMsg->pThis = pThis; pContext->DceTypeFormatString = pStubDescriptor->pFormatTypes; // This is OLE only code path - use a single TryExcept. // After catching it just map it to OLE exception. RpcTryExcept { ulong RpcFlags; // Note, pProcHeader->ProcNum is the async proc number. NdrProxyInitialize( pThis, pRpcMsg, pStubMsg, pStubDescriptor, (pProcHeader->ProcNum + 3)/2 // sync proc number ); pStubMsg->pAsyncMsg = (struct _NDR_ASYNC_MESSAGE *) pAsyncMsg; if ( OldOiFlags.FullPtrUsed ) pStubMsg->FullPtrXlatTables = NdrFullPointerXlatInit( 0, XLAT_CLIENT ); // Set Rpc flags after the call to client initialize. RpcFlags= *(ulong UNALIGNED *)(pFormat + 2); pStubMsg->RpcMsg->RpcFlags = RpcFlags; // Must do this before the sizing pass! pStubMsg->StackTop = pContext->StartofStack = StartofStack; if ( NewOiFlags.HasExtensions ) { pStubMsg->fHasExtensions = 1; pStubMsg->fHasNewCorrDesc = pHeaderExts->Flags2.HasNewCorrDesc; if ( pHeaderExts->Flags2.ClientCorrCheck ) { void * pCache = NdrpAlloca( &pAsyncMsg->ProcContext.AllocateContext, NDR_DEFAULT_CORR_CACHE_SIZE ); NdrCorrelationInitialize( pStubMsg, pCache, NDR_DEFAULT_CORR_CACHE_SIZE, 0 /* flags */ ); } } // // ---------------------------------------------------------------- // Sizing Pass. // ---------------------------------------------------------------- // // // Get the compile time computed buffer size. // pStubMsg->BufferLength = pProcHeader->ClientBufferSize; // // Check ref pointers and do object proc [out] zeroing. // for ( n = 0; n < NumberParams; n++ ) { pArg = StartofStack + Params[n].StackOffset; if ( Params[n].ParamAttr.IsSimpleRef ) { // We can raise the exception here as there is no out only args. if ( ! *((uchar **)pArg) ) RpcRaiseException( RPC_X_NULL_REF_POINTER ); } // [out] only argument on the Begin call. if ( ! Params[n].ParamAttr.IsIn && Params[n].ParamAttr.IsOut && ! Params[n].ParamAttr.IsReturn) RpcRaiseException( RPC_S_INTERNAL_ERROR ); } // // Skip buffer size pass if possible. // if ( NewOiFlags.ClientMustSize ) { NdrpSizing( pStubMsg, TRUE ); // IsObject } // // Do the GetBuffer. // pRpcMsg->RpcFlags |= RPC_BUFFER_ASYNC; NdrProxyGetBuffer( pThis, pStubMsg ); NDR_ASSERT( pStubMsg->fBufferValid, "Invalid buffer" ); pAsyncMsg->StubPhase = STUB_MARSHAL; // // ---------------------------------------------------------- // Marshall Pass. // ---------------------------------------------------------- // NdrpClientMarshal ( pStubMsg, TRUE ); // IsObject // // Make the RPC call. // pAsyncMsg->StubPhase = NDR_ASYNC_CALL_PHASE; fSendCalled = NdrpDcomAsyncClientSend( pStubMsg, pAsyncPB->punkOuter ); // PM's entry if ( fSendCalled ) hr = S_OK; } RpcExcept( 1 ) { RPC_STATUS ExceptionCode = RpcExceptionCode(); pAsyncPB->CallState.Flags.BeginError = 1; // Actually dismantle the call. // This is a request call and there is nothing left at the runtime. pAsyncMsg->StubPhase = NDR_ASYNC_ERROR_PHASE; pAsyncMsg->ErrorCode = ExceptionCode; hr = NdrHrFromWin32Error(ExceptionCode); pAsyncPB->CallState.Hr = hr; // Async call in request phase: don't touch [out] params. } RpcEndExcept // "Finally" // Dont touch anything, the client has to call the Finish method anyway. pAsyncPB->CallState.Flags.BeginDone = 1; if ( SUCCEEDED(hr) ) { NdrpCloneInOnlyCorrArgs( pAsyncMsg, pAsyncMsg->StubMsg.StubDesc->pFormatTypes ); // Channel will prompt signal } else if (!fSendCalled ) NdrpAsyncProxySignal( pAsyncPB ); // No need to release, our refcount should be 1 at this point. return hr; } void NdrpCloneInOnlyCorrArgs( NDR_DCOM_ASYNC_MESSAGE * pAsyncMsg, PFORMAT_STRING pTypeFormat ) /* Walk the client stack looking for an in only argument flagged to clone. For each one, replace the arg with a clone that we control. Assumption is, we do it before returning to the user from the Begin call and also we clone walking the copy of the app's stack not the app stack. The stack modified in this way will be the one to access for the weird crossreferenced correlated args. This issue doesn't happen on the server, as we keep the Begin stack around when the Finish call is processed. */ { unsigned char * pBeginStack = pAsyncMsg->BeginStack; PPARAM_DESCRIPTION Params = (PPARAM_DESCRIPTION)pAsyncMsg->BeginParams; int NumberParams = (int)pAsyncMsg->nBeginParams; unsigned char * pArg; int n; for ( n = 0; n < NumberParams; n++ ) { if ( Params[n].ParamAttr.SaveForAsyncFinish ) { // Note that the arguments that need cloning come from top level size_is, // length_is etc, switch_is and iid_is attributes. // Hence, the only types of interest are uuid clones and integral types // different from hyper. // On top of it, we deal with stack-slot chunks of memory, so we don't // have to care about mac issues. pArg = pBeginStack + Params[n].StackOffset; if ( Params[n].ParamAttr.IsBasetype ) { if ( Params[n].ParamAttr.IsSimpleRef ) { void * pPointee = AsyncAlloca( pAsyncMsg, 8 ); // The assignment needs to follow the type. RpcpMemoryCopy( pPointee, *(void **)pArg, SIMPLE_TYPE_MEMSIZE( Params[n].SimpleType.Type ) ); *(void**)pArg = pPointee; } // else the stack slot has the simple value already. } else { // If it's not a base type, then it cannot be by value. // It has to be a pointer to a simple type or to an iid. PFORMAT_STRING pParamFormat; pParamFormat = pTypeFormat + Params[n].TypeOffset; if ( IS_BASIC_POINTER(*pParamFormat) ) // not FC_IP { if ( SIMPLE_POINTER(pParamFormat[1]) ) { // Covers things like a unique pointer to a size // Essentially the same as for the simple ref above. void * pPointee = AsyncAlloca( pAsyncMsg, 8 ); // The assignment needs to follow the type. RpcpMemoryCopy( pPointee, *(void **)pArg, SIMPLE_TYPE_MEMSIZE( pParamFormat[2] ) ); *(void**)pArg = pPointee; } else { // has to be the riid case. // REFIID* comes out as FC_?P -> FC_?P -> FC_STRUCT PFORMAT_STRING pFormat; pFormat = pParamFormat + *(short *)(pParamFormat + 2); if ( IS_BASIC_POINTER(*pFormat) && ! SIMPLE_POINTER(pParamFormat[1]) ) { pParamFormat = pFormat + *(short *)(pFormat + 2); if ( *pParamFormat == FC_STRUCT ) { // one alloc for REFIID and IID itself. IID** ppIID = (IID**)AsyncAlloca( pAsyncMsg, sizeof(IID *) + sizeof(IID)); IID* pIID = (IID *)(ppIID + 1); *ppIID = pIID; //set pointer RpcpMemoryCopy( pIID, **(IID ***)pArg, sizeof(IID)); *(IID ***)pArg = ppIID; } else RpcRaiseException( RPC_S_INTERNAL_ERROR ); } else RpcRaiseException( RPC_S_INTERNAL_ERROR ); } } else { // has to be the riid case. // REFIID comes out as FC_STRUCT if ( *pParamFormat == FC_STRUCT ) { IID *pIID = (IID*)AsyncAlloca( pAsyncMsg, sizeof(IID) ); RpcpMemoryCopy( pIID, *(IID **)pArg, sizeof(IID)); *(IID **)pArg = pIID; } else RpcRaiseException( RPC_S_INTERNAL_ERROR ); } } } } } HRESULT NdrpFinishDcomAsyncClientCall( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, unsigned char * StartofStack ) { RPC_MESSAGE * pRpcMsg; MIDL_STUB_MESSAGE * pStubMsg; PFORMAT_STRING pFormatParam; uchar * pArg; void * pThis = *(void **)StartofStack; CLIENT_CALL_RETURN ReturnValue; INTERPRETER_FLAGS OldOiFlags; // Finish proc flags INTERPRETER_OPT_FLAGS NewOiFlags; // PPARAM_DESCRIPTION Params; // long NumberParams; long n; NDR_ASYNC_CALL_FLAGS CallFlags; PNDR_DCOM_OI2_PROC_HEADER pProcHeader = (PNDR_DCOM_OI2_PROC_HEADER)pFormat; PNDR_PROC_HEADER_EXTS pHeaderExts = 0; CStdAsyncProxyBuffer * pAsyncPB; const IID * piid; HRESULT hr = S_OK; NDR_PROC_CONTEXT * pContext = NULL; ReturnValue.Simple = 0; pAsyncPB = (CStdAsyncProxyBuffer*) ((uchar*)pThis - offsetof(CStdProxyBuffer, pProxyVtbl)); piid = NdrGetProxyIID( pThis ); hr = NdrpSetupFinishClientCall( pAsyncPB, StartofStack, pProcHeader->StackSize, *piid, pProcHeader->ProcNum ); if ( !SUCCEEDED(hr) ) return hr; // Note that we cant call to NdrProxyInitialize again. PNDR_DCOM_ASYNC_MESSAGE pAsyncMsg = (PNDR_DCOM_ASYNC_MESSAGE)pAsyncPB->CallState.pAsyncMsg; pRpcMsg = & pAsyncMsg->RpcMsg; pStubMsg = & pAsyncMsg->StubMsg; pContext = ( NDR_PROC_CONTEXT * )pStubMsg->pContext; OldOiFlags = pProcHeader->OldOiFlags; NewOiFlags = pProcHeader->Oi2Flags; NumberParams = pProcHeader->NumberParams; // // Parameter descriptions are nicely spit out by MIDL. // Params = (PPARAM_DESCRIPTION)(pFormat + sizeof(NDR_DCOM_OI2_PROC_HEADER)); if ( NewOiFlags.HasExtensions ) { pHeaderExts = (NDR_PROC_HEADER_EXTS *)Params; Params = (PPARAM_DESCRIPTION)((uchar*)Params + pHeaderExts->Size); } CallFlags = pAsyncMsg->Flags; // Initialize the stack top in the stub msg to be // this stack, the stack for the finish call parameters. pAsyncMsg->nFinishParams = pContext->NumberParams = NumberParams; pAsyncMsg->FinishParams = pContext->Params = Params; pStubMsg->StackTop = pContext->StartofStack = StartofStack; // OLE only code path - single RpcTryExcept. // RpcTryExcept { BOOL fRaiseExcFlag = FALSE; if ( CallFlags.ErrorPending ) RpcRaiseException( pAsyncMsg->ErrorCode ); // We need to zero out the [out] parameters and to check // the ref pointers. for ( n = 0; n < NumberParams; n++ ) { pArg = StartofStack + Params[n].StackOffset; if ( Params[n].ParamAttr.IsSimpleRef ) { // We cannot raise the exception here, // as some out args may not be zeroed out yet. if ( ! *((uchar **)pArg) ) { fRaiseExcFlag = TRUE; continue; } } // We do the basetype check to cover the // [out] simple ref to basetype case. // if ( Params[n].ParamAttr.IsPartialIgnore || ( ! Params[n].ParamAttr.IsIn && ! Params[n].ParamAttr.IsReturn ) ) { if ( Params[n].ParamAttr.IsBasetype ) { // [out] only arg can only be ref, we checked that above. MIDL_memset( *(uchar **)pArg, 0, (size_t)SIMPLE_TYPE_MEMSIZE( Params[n].SimpleType.Type )); } else { pFormatParam = pStubDescriptor->pFormatTypes + Params[n].TypeOffset; NdrClientZeroOut( pStubMsg, pFormatParam, *(uchar **)pArg ); } } } if ( fRaiseExcFlag ) RpcRaiseException( RPC_X_NULL_REF_POINTER ); NdrDcomAsyncReceive( pStubMsg ); // // ---------------------------------------------------------- // Unmarshall Pass. // ---------------------------------------------------------- // NdrpClientUnMarshal( pStubMsg, &ReturnValue ); // DCOM interface must have HRESULT as return value. hr = (HRESULT) ReturnValue.Simple; } RpcExcept( 1 ) { RPC_STATUS ExceptionCode = RpcExceptionCode(); // // In OLE, since they don't know about error_status_t and wanted to // reinvent the wheel, check to see if we need to map the exception. // In either case, set the return value and then try to free the // [out] params, if required. // hr = NdrHrFromWin32Error(ExceptionCode); // // Set the Buffer endpoints so the NdrFree routines work. // pStubMsg->BufferStart = 0; pStubMsg->BufferEnd = 0; for ( n = 0; n < NumberParams; n++ ) { // // Skip everything but [out] only parameters. We make // the basetype check to cover [out] simple ref pointers // to basetypes. // if ( !Params[n].ParamAttr.IsPartialIgnore ) { if ( Params[n].ParamAttr.IsIn || Params[n].ParamAttr.IsReturn || Params[n].ParamAttr.IsBasetype ) continue; } pArg = StartofStack + Params[n].StackOffset; pFormatParam = pStubDescriptor->pFormatTypes + Params[n].TypeOffset; NdrClearOutParameters( pStubMsg, pFormatParam, *((uchar **)pArg) ); } } RpcEndExcept // Finish // Cleanup everything. However, don't free pAsyncPB itself. NdrpAsyncProxyMsgDestructor( pAsyncPB ); // Never addref or release async proxy object, this is app's/PM's job. return hr; } HRESULT RPC_ENTRY NdrDcomAsyncStubCall( struct IRpcStubBuffer * pThis, struct IRpcChannelBuffer * pChannel, PRPC_MESSAGE pRpcMsg, ulong * pdwStubPhase ) /*++ Routine Description : Server Interpreter entry point for DCOM async procs. This is the Begin entry for channel (regular dispatch entry from stub.c). The Finish happen when the channel calls stub's Synchronize::Signal method on the stub object. The call then comes to NdrpAsyncStubSignal later below. Arguments : pThis - Object proc's 'this' pointer. pChannel - Object proc's Channel Buffer. pRpcMsg - The RPC message. pdwStubPhase - Used to track the current interpreter's activity. Return : Status of S_OK. Notes : The engine never calls a signal on behalf of the user, regardless what kind of errors happen during begin (cannot setup begin, cannot unmarshal, app dies in invoke). In each of these cases, the engine simply returns an error code to the channel. The only time the engine would call FreeBuffer on the server is if the engine died between a successful GetBuffer and the final Send. Notes on OLE Refcounting. The model for async_uuid() is that async proxies or stubs are created with RefCount==1 and should never ever be addrefed by the engine. What the engine does is only the AsyncMsg clean up when done. The decision to destroy the AsyncPB or AsyncSB object is up to the client side PM or channel's SM for the server side. */ { PNDR_DCOM_ASYNC_MESSAGE pAsyncMsg; PMIDL_SERVER_INFO pServerInfo; PMIDL_STUB_DESC pStubDesc; const SERVER_ROUTINE * DispatchTable; unsigned long ProcNum; ushort FormatOffset; PFORMAT_STRING pFormat; PFORMAT_STRING pFormatParam; PMIDL_STUB_MESSAGE pStubMsg; uchar * pArgBuffer; uchar * pArg; uchar ** ppArg; PPARAM_DESCRIPTION Params; INTERPRETER_FLAGS OldOiFlags; INTERPRETER_OPT_FLAGS NewOiFlags; long NumberParams; BOOL fBadStubDataException = FALSE; BOOL fManagerCodeInvoked = FALSE; long n; PNDR_DCOM_OI2_PROC_HEADER pProcHeader; PNDR_PROC_HEADER_EXTS pHeaderExts = 0; CStdAsyncStubBuffer * pAsyncSB; HRESULT hr; const IID * piid = 0; BOOL fErrorInInvoke = FALSE; BOOL fRecoverableErrorInInvoke = FALSE; IUnknown * pSrvObj; CInterfaceStubVtbl * pStubVTable; NDR_PROC_CONTEXT * pContext = NULL ; RPC_STATUS ExceptionCode = 0; NDR_ASSERT( ! ((ULONG_PTR)pRpcMsg->Buffer & 0x7), "marshaling buffer misaligned at server" ); // The channel dispatches to the engine with the sync proc num. // We need only async proc num at the engine level. ProcNum = pRpcMsg->ProcNum; ProcNum = 2 * ProcNum - 3; // Begin method # pSrvObj = (IUnknown *)((CStdStubBuffer *)pThis)->pvServerObject; DispatchTable = (SERVER_ROUTINE *)pSrvObj->lpVtbl; pStubVTable = (CInterfaceStubVtbl *) (*((uchar **)pThis) - sizeof(CInterfaceStubHeader)); piid = pStubVTable->header.piid; pServerInfo = (PMIDL_SERVER_INFO) pStubVTable->header.pServerInfo; pStubDesc = pServerInfo->pStubDesc; FormatOffset = pServerInfo->FmtStringOffset[ ProcNum ]; pFormat = &((pServerInfo->ProcString)[FormatOffset]); // The proc header has a fixed layout now. pProcHeader = (PNDR_DCOM_OI2_PROC_HEADER) pFormat; pAsyncSB = (CStdAsyncStubBuffer *) ((uchar *)pThis - offsetof(CStdAsyncStubBuffer,lpVtbl)); hr = NdrpSetupBeginStubCall( pAsyncSB, pProcHeader->StackSize, *piid ); if ( FAILED(hr) ) return hr; pAsyncMsg = (PNDR_DCOM_ASYNC_MESSAGE)pAsyncSB->CallState.pAsyncMsg; pStubMsg = & pAsyncMsg->StubMsg; pContext = &pAsyncMsg->ProcContext; // Both rpc runtime and channel require that we use a copy of the rpc message. RpcpMemoryCopy( & pAsyncMsg->RpcMsg, pRpcMsg, sizeof(RPC_MESSAGE) ); pRpcMsg = & pAsyncMsg->RpcMsg; pRpcMsg->RpcFlags |= RPC_BUFFER_ASYNC; // The arg buffer is zeroed out already. pArgBuffer = pAsyncMsg->ProcContext.StartofStack; // // Get new interpreter info. // OldOiFlags = pProcHeader->OldOiFlags; NewOiFlags = pProcHeader->Oi2Flags; NumberParams = pProcHeader->NumberParams; Params = (PPARAM_DESCRIPTION)(pFormat + sizeof(NDR_DCOM_OI2_PROC_HEADER)); if ( NewOiFlags.HasExtensions ) { pHeaderExts = (NDR_PROC_HEADER_EXTS *)Params; Params = (PPARAM_DESCRIPTION)((uchar*)Params + pHeaderExts->Size); } pAsyncMsg->nBeginParams = pContext->NumberParams = NumberParams; pAsyncMsg->BeginParams = pContext->Params = Params; pAsyncMsg->pThis = pThis; pContext->DceTypeFormatString = pStubDesc->pFormatTypes; // // Wrap the unmarshalling and the invoke call in the try block of // a try-finally. Put the free phase in the associated finally block. // // We abstract the level of indirection here. RpcTryFinally { // OLE: put pThis in first dword of stack. // ((void **)pArgBuffer)[0] = ((CStdStubBuffer *)pThis)->pvServerObject; // Initialize the Stub message. // NdrStubInitialize( pRpcMsg, pStubMsg, pStubDesc, pChannel ); pStubMsg->pAsyncMsg = (struct _NDR_ASYNC_MESSAGE *) pAsyncMsg; pAsyncMsg->pdwStubPhase = pdwStubPhase; // the phase is STUB_UNMARSHAL // Raise exceptions after initializing the stub. if ( OldOiFlags.FullPtrUsed ) pStubMsg->FullPtrXlatTables = NdrFullPointerXlatInit( 0, XLAT_SERVER ); else pStubMsg->FullPtrXlatTables = 0; // // Set StackTop AFTER the initialize call, since it zeros the field // out. // pStubMsg->StackTop = pArgBuffer; if ( NewOiFlags.HasExtensions ) { pStubMsg->fHasExtensions = 1; pStubMsg->fHasNewCorrDesc = pHeaderExts->Flags2.HasNewCorrDesc; if ( pHeaderExts->Flags2.ServerCorrCheck ) { void * pCache = NdrpAlloca( &pAsyncMsg->ProcContext.AllocateContext, NDR_DEFAULT_CORR_CACHE_SIZE ); NdrCorrelationInitialize( pStubMsg, pCache, NDR_DEFAULT_CORR_CACHE_SIZE, 0 /* flags */ ); } } // StubPhase set up by invoke is STUB_UNMARSHAL RpcTryExcept { // -------------------------------- // Unmarshall all of our parameters. // -------------------------------- NdrpServerUnMarshal( pStubMsg ); } // Last ditch checks. if ( pRpcMsg->BufferLength < (uint)(pStubMsg->Buffer - (uchar *)pRpcMsg->Buffer) ) { RpcRaiseException( RPC_X_BAD_STUB_DATA ); } RpcExcept( NdrServerUnmarshallExceptionFlag(GetExceptionInformation()) ) { ExceptionCode = RpcExceptionCode(); // Filter set in rpcndr.h to catch one of the following // STATUS_ACCESS_VIOLATION // STATUS_DATATYPE_MISALIGNMENT // RPC_X_BAD_STUB_DATA fBadStubDataException = TRUE; pAsyncMsg->Flags.BadStubData = 1; pAsyncMsg->Flags.ErrorPending = 1; if ( RPC_BAD_STUB_DATA_EXCEPTION_FILTER ) { ExceptionCode = RPC_X_BAD_STUB_DATA; } pAsyncMsg->ErrorCode = ExceptionCode; pAsyncSB->CallState.Flags.BeginError = 1; pAsyncSB->CallState.Hr = NdrHrFromWin32Error( ExceptionCode); NdrpFreeMemoryList( pStubMsg ); RpcRaiseException( ExceptionCode ); } RpcEndExcept // // Do [out] initialization before the invoke. // for ( n = 0; n < NumberParams; n++ ) { if ( Params[n].ParamAttr.IsIn || Params[n].ParamAttr.IsReturn ) continue; // This is a Begin call, there cannot be any [out] only args. RpcRaiseException( RPC_S_INTERNAL_ERROR ); } // // OLE interfaces use pdwStubPhase in the exception filter. // See CStdStubBuffer_Invoke in stub.c. // *pdwStubPhase = STUB_CALL_SERVER; // We need to catch exception in the manager code separately // as the model implies that there will be no other call from // the server app to clean up. pAsyncSB->CallState.Flags.BeginDone = 1; RpcTryExcept { // // Check for a thunk. Compiler does all the setup for us. // if ( pServerInfo->ThunkTable && pServerInfo->ThunkTable[ ProcNum ] ) { fManagerCodeInvoked = TRUE; pServerInfo->ThunkTable[ ProcNum ]( pStubMsg ); } else { // // Note that this ArgNum is not the number of arguments declared // in the function we called, but really the number of // REGISTER_TYPEs occupied by the arguments to a function. // long ArgNum; MANAGER_FUNCTION pFunc; REGISTER_TYPE ReturnValue; pFunc = (MANAGER_FUNCTION) DispatchTable[ ProcNum ]; ArgNum = (long)pProcHeader->StackSize / sizeof(REGISTER_TYPE); // // The StackSize includes the size of the return. If we want // just the number of REGISTER_TYPES, then ArgNum must be reduced // by 1 when there is a return value AND the current ArgNum count // is greater than 0. // if ( ArgNum && NewOiFlags.HasReturn ) ArgNum--; // Being here means that we can expect results. Note that the user // can call RpcCompleteCall from inside of the manager code. fManagerCodeInvoked = TRUE; ReturnValue = Invoke( pFunc, (REGISTER_TYPE *)pArgBuffer, #if defined(_WIN64) NewOiFlags.HasExtensions ? ((PNDR_PROC_HEADER_EXTS64)pHeaderExts)->FloatArgMask : 0, #endif ArgNum); if ( NewOiFlags.HasReturn ) { // Pass the app's HR from Begin call to the channel. (*pfnDcomChannelSetHResult)( pRpcMsg, NULL, // reserved (HRESULT) ReturnValue); } // We are discarding the return value as it is not the real one. } } RpcExcept( 1 ) { fErrorInInvoke = TRUE; pAsyncMsg->Flags.ErrorPending = 1; pAsyncMsg->ErrorCode = RpcExceptionCode(); pAsyncSB->CallState.Flags.BeginError = 1; pAsyncSB->CallState.Hr = NdrHrFromWin32Error( RpcExceptionCode()); } RpcEndExcept // Done with invoking Begin } RpcFinally { if ( !fManagerCodeInvoked ) { // Failed without invoking Begin - return an error. Remember the error. if ( fBadStubDataException ) pAsyncMsg->ErrorCode = RPC_X_BAD_STUB_DATA; pAsyncSB->CallState.Flags.BeginDone = 1; hr = pAsyncSB->CallState.Hr; } else // fManagerCodeInvoked { hr = S_OK; if ( fErrorInInvoke ) hr = pAsyncSB->CallState.Hr; } } RpcEndFinally return hr; } void NdrpCloneInOutStubArgs( NDR_DCOM_ASYNC_MESSAGE * pAsyncMsg ) /* Walk the second stack looking for an in-out argument. For each one, find the corresponding in-out atgument from the first stack and clone it to the second stack. Note, we need to do it only on the server side where we preserver the first stack, the dispatch buffer and all the arguments from the first stack. On the client, this is the app's task to supply meaningful in-out arguments for the second stack. */ { REGISTER_TYPE * pBeginStack = (REGISTER_TYPE *)pAsyncMsg->BeginStack; REGISTER_TYPE * pFinishStack = (REGISTER_TYPE *)pAsyncMsg->FinishStack; PPARAM_DESCRIPTION BeginParams = (PPARAM_DESCRIPTION)pAsyncMsg->BeginParams; int BeginNumberParams = (int)pAsyncMsg->nBeginParams; PPARAM_DESCRIPTION FinishParams = (PPARAM_DESCRIPTION)pAsyncMsg->FinishParams; int FinishNumberParams = pAsyncMsg->nFinishParams; int FirstIO = 0; int n; for ( n = 0; n < FinishNumberParams; n++ ) { // Find in-out arg that needs cloning. if ( FinishParams[n].ParamAttr.IsIn && FinishParams[n].ParamAttr.IsOut ) { // Find the first IO on the first stack while ( FirstIO < BeginNumberParams ) { if ( BeginParams[ FirstIO ].ParamAttr.IsIn && BeginParams[ FirstIO ].ParamAttr.IsOut ) { break; } FirstIO++; } if ( BeginNumberParams <= FirstIO ) RpcRaiseException( RPC_S_INTERNAL_ERROR ); // Clone it to the second stack pFinishStack[ FinishParams[n].StackOffset / sizeof(REGISTER_TYPE) ] = pBeginStack[ BeginParams[ FirstIO ].StackOffset / sizeof(REGISTER_TYPE) ]; FirstIO++; } } } HRESULT NdrpCompleteDcomAsyncStubCall( CStdAsyncStubBuffer * pAsyncSB ) /*++ Routine Description : Complete an async call on the server side. Arguments : AsyncHandle - raw or object handle (if pointer) as appropriate, pAsyncMsg - pointer to async msg structure, pReturnValue - from the user to pass back to caller. Return : Status of S_OK. --*/ { PNDR_DCOM_ASYNC_MESSAGE pAsyncMsg; PMIDL_SERVER_INFO pServerInfo; PMIDL_STUB_DESC pStubDesc; // should be the same const SERVER_ROUTINE * DispatchTable; // should be the same unsigned long ProcNum; // should be 1+ ushort FormatOffset; PFORMAT_STRING pFormat; PFORMAT_STRING pFormatParam; RPC_MESSAGE * pRpcMsg; MIDL_STUB_MESSAGE * pStubMsg; INTERPRETER_FLAGS OldOiFlags; // Finish flags INTERPRETER_OPT_FLAGS NewOiFlags; // Finish flags PPARAM_DESCRIPTION Params; // Finish params uchar * pArgBuffer; // new stack // MZ, BUG BUG, Fix after ship // ulong * pdwStubPhase; uchar * pArg; long NumberParams; long n; PNDR_DCOM_OI2_PROC_HEADER pProcHeader; PNDR_PROC_HEADER_EXTS pHeaderExts = 0; IUnknown * pSrvObj; CInterfaceStubVtbl * pStubVTable; void * pThis; HRESULT hr; const IID * piid; // should be the same BOOL fManagerCodeInvoked = FALSE; BOOL fErrorInInvoke = FALSE; RPC_STATUS ExceptionCode = 0; boolean fParamsFreed = FALSE; NDR_PROC_CONTEXT * pContext = NULL; // We validated both the stub and the async context in the signal call. // We validated the pAsyncSB in the Signal call. // Do additional checks. pAsyncMsg = (PNDR_DCOM_ASYNC_MESSAGE)pAsyncSB->CallState.pAsyncMsg; pThis = pAsyncMsg->pThis; // See if channel calls on the right stub if ( & pAsyncSB->lpVtbl != pThis) return E_INVALIDARG; pRpcMsg = & pAsyncMsg->RpcMsg; pStubMsg = & pAsyncMsg->StubMsg; // We have preserved the sync proc num that the channel used. // We need only async proc num at the engine level. // ProcNum = pRpcMsg->ProcNum; ProcNum = 2 * ProcNum - 3 + 1; // Finish method # pSrvObj = (IUnknown *)((CStdStubBuffer *)pThis)->pvServerObject; DispatchTable = (SERVER_ROUTINE *)pSrvObj->lpVtbl; pStubVTable = (CInterfaceStubVtbl *) (*((uchar **)pThis) - sizeof(CInterfaceStubHeader)); piid = pStubVTable->header.piid; pServerInfo = (PMIDL_SERVER_INFO) pStubVTable->header.pServerInfo; pStubDesc = pServerInfo->pStubDesc; FormatOffset = pServerInfo->FmtStringOffset[ ProcNum ]; pFormat = &((pServerInfo->ProcString)[ FormatOffset ]); // The proc header has a fixed layout now. pProcHeader = (PNDR_DCOM_OI2_PROC_HEADER) pFormat; // Validate and setup for finish. hr = NdrpSetupFinishStubCall( pAsyncSB, pProcHeader->StackSize, *piid ); if ( hr ) return hr; // The arg buffer is zeroed out already. Note, this is the second stack. pContext = &pAsyncMsg->ProcContext; pArgBuffer = pContext->StartofStack; pStubMsg->StackTop = pArgBuffer; // // Get new interpreter info. // OldOiFlags = pProcHeader->OldOiFlags; NewOiFlags = pProcHeader->Oi2Flags; NumberParams = pProcHeader->NumberParams; Params = (PPARAM_DESCRIPTION)(pFormat + sizeof(NDR_DCOM_OI2_PROC_HEADER)); if ( NewOiFlags.HasExtensions ) { pHeaderExts = (NDR_PROC_HEADER_EXTS *)Params; Params = (PPARAM_DESCRIPTION)((uchar*)Params + pHeaderExts->Size); } pAsyncMsg->nFinishParams = pContext->NumberParams = NumberParams; pAsyncMsg->FinishParams = pContext->Params = Params; pContext->DceTypeFormatString = pStubDesc->pFormatTypes; pStubMsg->pContext = pContext; // Wrap the unmarshalling, mgr call and marshalling in the try block of // a try-finally. Put the free phase in the associated finally block. // RpcTryFinally { if ( pAsyncMsg->Flags.ErrorPending ) RpcRaiseException( pAsyncMsg->ErrorCode ); // Initialize the args of the new stack. // OLE: put pThis in first dword of stack. // ((void **)pArgBuffer)[0] = ((CStdStubBuffer *)pThis)->pvServerObject; // // Do [out] initialization before invoking Finish // NdrpCloneInOutStubArgs( pAsyncMsg ); NdrpServerOutInit( pStubMsg ); // // OLE interfaces use pdwStubPhase in the exception filter. // See CStdStubBuffer_Invoke in stub.c. // // MZ, BUG BUG, fix after ship // *pdwStubPhase = STUB_CALL_SERVER; // We need to catch exception in the manager code separately // as the model implies that there will be no other call from // the server app to clean up. RpcTryExcept { // // Check for a thunk. Compiler does all the setup for us. // if ( pServerInfo->ThunkTable && pServerInfo->ThunkTable[ProcNum] ) { fManagerCodeInvoked = TRUE; pServerInfo->ThunkTable[ProcNum]( pStubMsg ); } else { // // Note that this ArgNum is not the number of arguments declared // in the function we called, but really the number of // REGISTER_TYPEs occupied by the arguments to a function. // long ArgNum; MANAGER_FUNCTION pFunc; REGISTER_TYPE ReturnValue; pFunc = (MANAGER_FUNCTION) DispatchTable[ProcNum]; ArgNum = (long)pProcHeader->StackSize / sizeof(REGISTER_TYPE); // // The StackSize includes the size of the return. If we want // just the number of REGISTER_TYPES, then ArgNum must be reduced // by 1 when there is a return value AND the current ArgNum count // is greater than 0. // if ( ArgNum && NewOiFlags.HasReturn ) ArgNum--; fManagerCodeInvoked = TRUE; ReturnValue = Invoke( pFunc, (REGISTER_TYPE *)pArgBuffer, #if defined(_WIN64) NewOiFlags.HasExtensions ? ((PNDR_PROC_HEADER_EXTS64)pHeaderExts)->FloatArgMask : 0, #endif ArgNum); // This is the return value that should be marshaled back. if ( NewOiFlags.HasReturn ) { ((REGISTER_TYPE *)pArgBuffer)[ArgNum] = ReturnValue; // Pass the app's HR to the channel. (*pfnDcomChannelSetHResult)( pRpcMsg, NULL, // reserved (HRESULT) ReturnValue); } } } RpcExcept( 1 ) { pAsyncMsg->Flags.ErrorPending = 1; pAsyncMsg->ErrorCode = RpcExceptionCode(); fErrorInInvoke = TRUE; } RpcEndExcept // Done with invoking Finish if ( pAsyncMsg->Flags.ErrorPending ) RpcRaiseException( pAsyncMsg->ErrorCode ); // // Buffer size pass. // pStubMsg->BufferLength = pProcHeader->ServerBufferSize; if ( NewOiFlags.ServerMustSize ) { NdrpSizing( pStubMsg, FALSE ); // IsClient } // Get buffer. NdrStubGetBuffer( (IRpcStubBuffer*)pAsyncMsg->pThis, pStubMsg->pRpcChannelBuffer, pStubMsg ); // // Marshall pass. // NdrpServerMarshal( pStubMsg, TRUE ); // IsObject if ( pRpcMsg->BufferLength < (uint)(pStubMsg->Buffer - (uchar *)pRpcMsg->Buffer) ) { NDR_ASSERT( 0, "NdrStubCall2 marshal: buffer overflow!" ); RpcRaiseException( RPC_X_BAD_STUB_DATA ); } pRpcMsg->BufferLength = (ulong)(pStubMsg->Buffer - (uchar *)pRpcMsg->Buffer); // We don't drop to the runtime like for synchronous calls, // we send the last buffer explicitly. fParamsFreed = TRUE; // see comment on async.cxx on why we call this twice. NdrpAsyncDCOMFreeParams( pAsyncMsg ); NdrpDcomAsyncSend( pStubMsg, 0 ); // server doesn't pass pSynchronize back to channel. } RpcFinally { // Don't free parameters if we died because of bad stub data in unmarshaling. if ( ! pAsyncMsg->Flags.BadStubData && !fParamsFreed) { NdrpAsyncDCOMFreeParams( pAsyncMsg ); } if ( pAsyncMsg->Flags.ErrorPending ) hr = NdrHrFromWin32Error( pAsyncMsg->ErrorCode ); else hr = S_OK; // If we are here, error or not, it means that we can (and need to) dispose of // the async context information NdrpAsyncStubMsgDestructor( pAsyncSB ); // The engine never addrefs or releases the call object. } RpcEndFinally return hr; } HRESULT NdrpAsyncProxyMsgConstructor( CStdAsyncProxyBuffer * pAsyncPB ) { NdrDcomAsyncCallState * pCallState = & pAsyncPB->CallState; pCallState->Lock = 0; pCallState->Signature = NDR_ASYNC_PROXY_SIGNATURE; pCallState->pAsyncMsg = 0; *((long*)&pCallState->Flags) = 0; pCallState->Hr = 0; return S_OK; } HRESULT NdrpAsyncStubMsgConstructor( CStdAsyncStubBuffer * pAsyncSB ) { NdrDcomAsyncCallState * pCallState = & pAsyncSB->CallState; pCallState->Lock = 0; pCallState->Signature = NDR_ASYNC_STUB_SIGNATURE; pCallState->pAsyncMsg = 0; *((long*)&pCallState->Flags) = 0; pCallState->Hr = 0; return S_OK; } HRESULT NdrpAsyncProxyMsgDestructor( CStdAsyncProxyBuffer * pAsyncPB ) { NdrDcomAsyncCallState * pCallState = & pAsyncPB->CallState; if ( pCallState->pAsyncMsg ) { NdrpFreeDcomAsyncMsg( (PNDR_DCOM_ASYNC_MESSAGE)pCallState->pAsyncMsg ); pCallState->pAsyncMsg = 0; } *((long*)&pCallState->Flags) = 0; pCallState->Hr = 0; return S_OK; } HRESULT NdrpAsyncStubMsgDestructor( CStdAsyncStubBuffer * pAsyncSB ) { NdrDcomAsyncCallState * pCallState = & pAsyncSB->CallState; if ( pCallState->pAsyncMsg ) { NdrpFreeDcomAsyncMsg( (PNDR_DCOM_ASYNC_MESSAGE)pCallState->pAsyncMsg ); pCallState->pAsyncMsg = 0; } *((long*)&pCallState->Flags) = 0; pCallState->Hr = 0; return S_OK; } HRESULT NdrpValidateAsyncProxyCall( CStdAsyncProxyBuffer * pAsyncPB ) { HRESULT hr = S_OK; RpcTryExcept { NdrDcomAsyncCallState * pCallState = & pAsyncPB->CallState; if ( pCallState->Signature != NDR_ASYNC_PROXY_SIGNATURE ) hr = E_INVALIDARG; } RpcExcept(1) { hr = E_INVALIDARG; } RpcEndExcept; return hr; } HRESULT NdrpValidateAsyncStubCall( CStdAsyncStubBuffer * pAsyncSB ) { HRESULT hr = S_OK; RpcTryExcept { NdrDcomAsyncCallState * pCallState = & pAsyncSB->CallState; if ( pCallState->Signature != NDR_ASYNC_STUB_SIGNATURE ) hr = E_INVALIDARG; } RpcExcept(1) { hr = E_INVALIDARG; } RpcEndExcept; return hr; } HRESULT NdrpValidateDcomAsyncMsg( PNDR_DCOM_ASYNC_MESSAGE pAsyncMsg ) { HRESULT hr = RPC_S_OK; RpcTryExcept { if ( pAsyncMsg->Signature != NDR_DCOM_ASYNC_SIGNATURE || pAsyncMsg->Version != NDR_DCOM_ASYNC_VERSION ) { hr = E_INVALIDARG; } } RpcExcept(1) { hr = E_INVALIDARG; } RpcEndExcept; return hr; } HRESULT NdrpSetupBeginClientCall( CStdAsyncProxyBuffer * pAsyncPB, void * StartofStack, unsigned short StackSize, REFIID riid ) /* This method creates and initializes async msg. */ { PNDR_DCOM_ASYNC_MESSAGE pAsyncMsg; HRESULT hr = S_OK; hr = NdrpValidateAsyncProxyCall( pAsyncPB ); if ( ! SUCCEEDED(hr) ) return hr; if ( pAsyncPB->CallState.pAsyncMsg != 0 || pAsyncPB->CallState.Flags.BeginStarted ) return E_FAIL; // Do this first to simplify error conditions. pAsyncMsg = (NDR_DCOM_ASYNC_MESSAGE*) I_RpcBCacheAllocate( sizeof(NDR_DCOM_ASYNC_MESSAGE) + StackSize + NDR_ASYNC_GUARD_SIZE ); if ( ! pAsyncMsg ) { NdrpAsyncProxySignal( pAsyncPB ); return E_OUTOFMEMORY; } // Initialize the async message properly MIDL_memset( pAsyncMsg, 0x0, sizeof( NDR_DCOM_ASYNC_MESSAGE) ); pAsyncMsg->Signature = NDR_DCOM_ASYNC_SIGNATURE; pAsyncMsg->Version = NDR_DCOM_ASYNC_VERSION; pAsyncMsg->SyntaxType = XFER_SYNTAX_DCE; pAsyncMsg->ProcContext.StartofStack = (uchar *) & pAsyncMsg->AppStack; pAsyncMsg->BeginStack = (uchar *) & pAsyncMsg->AppStack; pAsyncMsg->BeginStackSize = StackSize; pAsyncMsg->StubPhase = NDR_ASYNC_PREP_PHASE; NdrpAllocaInit( &pAsyncMsg->ProcContext.AllocateContext ); // Client: copy stack from the app's request call. RpcpMemoryCopy( & pAsyncMsg->AppStack, StartofStack, StackSize ); MIDL_memset( ((char *)& pAsyncMsg->AppStack) + StackSize, 0x71, NDR_ASYNC_GUARD_SIZE ); pAsyncMsg->pAsyncPB = pAsyncPB; pAsyncPB->CallState.Flags.BeginStarted = 1; pAsyncPB->CallState.pAsyncMsg = pAsyncMsg; return S_OK; } HRESULT NdrpSetupFinishClientCall( CStdAsyncProxyBuffer * pAsyncPB, void * StartofStack, unsigned short StackSize, REFIID riid, unsigned long FinishProcNum ) /* This method creates and initializes async msg. */ { PNDR_DCOM_ASYNC_MESSAGE pAsyncMsg; HRESULT hr = S_OK; hr = NdrpValidateAsyncProxyCall( pAsyncPB ); if ( ! SUCCEEDED(hr) ) return hr; if ( !pAsyncPB->CallState.Flags.BeginStarted || !pAsyncPB->CallState.Flags.BeginDone || pAsyncPB->CallState.Flags.FinishStarted ) return E_FAIL; pAsyncMsg = (PNDR_DCOM_ASYNC_MESSAGE)pAsyncPB->CallState.pAsyncMsg; hr = NdrpValidateDcomAsyncMsg( pAsyncMsg ); if ( ! SUCCEEDED(hr) ) return hr; if ( (FinishProcNum + 3)/2 != (pAsyncMsg->RpcMsg.ProcNum & 0x7fff) ) return E_FAIL; // Initialize the async message properly pAsyncMsg->ProcContext.StartofStack = (uchar *) StartofStack; pAsyncMsg->FinishStack = (uchar *) StartofStack; pAsyncMsg->FinishStackSize = StackSize; pAsyncMsg->StubPhase = NDR_ASYNC_PREP_PHASE; NdrSetupLowStackMark( &pAsyncMsg->StubMsg ); // Dont allocate or copy the new stack anywhere. pAsyncPB->CallState.Flags.FinishStarted = 1; return S_OK; } HRESULT NdrpSetupBeginStubCall( CStdAsyncStubBuffer * pAsyncSB, unsigned short StackSize, REFIID riid ) /* This method creates and initializes async msg. */ { PNDR_DCOM_ASYNC_MESSAGE pAsyncMsg; HRESULT hr = S_OK; hr = NdrpValidateAsyncStubCall( pAsyncSB ); if ( ! SUCCEEDED(hr) ) return hr; if ( pAsyncSB->CallState.pAsyncMsg != 0 || pAsyncSB->CallState.Flags.BeginStarted ) hr = E_FAIL; else { pAsyncMsg = (NDR_DCOM_ASYNC_MESSAGE*) I_RpcBCacheAllocate( sizeof( NDR_DCOM_ASYNC_MESSAGE) + StackSize + NDR_ASYNC_GUARD_SIZE ); if ( ! pAsyncMsg ) hr = E_OUTOFMEMORY; } if ( ! SUCCEEDED(hr) ) { // The stub never signals. pAsyncSB->CallState.Flags.BeginError = 1; pAsyncSB->CallState.Hr = hr; return hr; } // Initialize the async message properly MIDL_memset( pAsyncMsg, 0x0, sizeof( NDR_DCOM_ASYNC_MESSAGE) ); pAsyncMsg->Signature = NDR_DCOM_ASYNC_SIGNATURE; pAsyncMsg->Version = NDR_DCOM_ASYNC_VERSION; pAsyncMsg->SyntaxType = XFER_SYNTAX_DCE; pAsyncMsg->ProcContext.StartofStack = (uchar *) & pAsyncMsg->AppStack; pAsyncMsg->BeginStack = (uchar *) & pAsyncMsg->AppStack; pAsyncMsg->BeginStackSize = StackSize; pAsyncMsg->StubPhase = STUB_UNMARSHAL; pAsyncMsg->StubMsg.pContext = &pAsyncMsg->ProcContext; NdrpAllocaInit( &pAsyncMsg->ProcContext.AllocateContext ); // Server: zero out stack for allocs. MIDL_memset( & pAsyncMsg->AppStack, 0x0, StackSize ); MIDL_memset( ((char *)& pAsyncMsg->AppStack) + StackSize, 0x71, NDR_ASYNC_GUARD_SIZE ); pAsyncSB->CallState.pAsyncMsg = pAsyncMsg; pAsyncSB->CallState.Flags.BeginStarted = 1; pAsyncMsg->pAsyncSB = pAsyncSB; return S_OK; } HRESULT NdrpSetupFinishStubCall( CStdAsyncStubBuffer * pAsyncSB, unsigned short StackSize, REFIID riid ) /* This method creates and initializes async msg. */ { PNDR_DCOM_ASYNC_MESSAGE pAsyncMsg; uchar * pFinishStack; HRESULT hr = S_OK; hr = NdrpValidateAsyncStubCall( pAsyncSB ); if ( ! SUCCEEDED(hr) ) return hr; if ( !pAsyncSB->CallState.Flags.BeginStarted || !pAsyncSB->CallState.Flags.BeginDone || pAsyncSB->CallState.Flags.FinishStarted ) return E_FAIL; if ( pAsyncSB->CallState.Hr != 0 ) return pAsyncSB->CallState.Hr; pAsyncMsg = (PNDR_DCOM_ASYNC_MESSAGE)pAsyncSB->CallState.pAsyncMsg; hr = NdrpValidateDcomAsyncMsg( pAsyncMsg ); if ( ! SUCCEEDED(hr) ) return hr; // We need to create the second stack for the app invoke. // Do this first to simplify error conditions. RpcTryExcept { pFinishStack = (uchar*) AsyncAlloca( pAsyncMsg, StackSize + NDR_ASYNC_GUARD_SIZE ); } RpcExcept( 1 ) { NdrpAsyncStubMsgDestructor( pAsyncSB ); return E_OUTOFMEMORY; } RpcEndExcept // Initialize the async message properly // the finish stack is quite possibly different from beginning stack. we need to // readjust the low stack mark for finish call NdrSetupLowStackMark( &pAsyncMsg->StubMsg ); pAsyncMsg->ProcContext.StartofStack = (uchar *) pFinishStack; pAsyncMsg->FinishStack = (uchar *) pFinishStack; pAsyncMsg->FinishStackSize = StackSize; pAsyncMsg->StubMsg.pContext = &pAsyncMsg->ProcContext; // Server: zero out stack for allocs. MIDL_memset( pFinishStack, 0x0, StackSize ); MIDL_memset( (char *)pFinishStack + StackSize, 0x72, NDR_ASYNC_GUARD_SIZE ); pAsyncSB->CallState.Flags.FinishStarted = 1; return S_OK; } HRESULT NdrpAsyncProxySignal( CStdAsyncProxyBuffer * pAsyncPB ) { ISynchronize * pSynchronize; HRESULT hr; IUnknown * punkOuter = pAsyncPB->punkOuter; hr = punkOuter->lpVtbl->QueryInterface( punkOuter, IID_ISynchronize, (void**)&pSynchronize ); if ( SUCCEEDED(hr) ) { pSynchronize->lpVtbl->Signal( pSynchronize ); pSynchronize->lpVtbl->Release( pSynchronize ); } return hr; } _inline HRESULT NdrpCallStateLock( NdrDcomAsyncCallState * pCallState ) { if ( 0 != InterlockedCompareExchange( (long*)& pCallState->Lock, 1, 0 ) ) { return E_FAIL; } return RPC_S_OK; } _inline void NdrpCallStateUnlock( NdrDcomAsyncCallState * pCallState ) { InterlockedDecrement( (long*)& pCallState->Lock ); return; } HRESULT NdrpAsyncProxyLock( CStdAsyncProxyBuffer * pAsyncPB ) { return NdrpCallStateLock( & pAsyncPB->CallState ); } void NdrpAsyncProxyUnlock( CStdAsyncProxyBuffer * pAsyncPB ) { NdrpCallStateUnlock( & pAsyncPB->CallState ); } HRESULT NdrpAsyncStubLock( CStdAsyncStubBuffer * pAsyncSB ) { return NdrpCallStateLock( & pAsyncSB->CallState ); } void NdrpAsyncStubUnlock( CStdAsyncStubBuffer * pAsyncSB ) { NdrpCallStateUnlock( & pAsyncSB->CallState ); } void NdrpFreeDcomAsyncMsg( PNDR_DCOM_ASYNC_MESSAGE pAsyncMsg ) /* This routine would free the AsyncMsg but not the AsyncHandle, as on the server the user may need it and on the client it is user's to begin with. */ { if ( pAsyncMsg ) { PMIDL_STUB_MESSAGE pStubMsg = & pAsyncMsg->StubMsg; NdrFullPointerXlatFree(pStubMsg->FullPtrXlatTables); // in NDR64, we are using allocacontext to hold corr info, so we don't // want to free it there. if ( pAsyncMsg->SyntaxType == XFER_SYNTAX_DCE ) NdrCorrelationFree( pStubMsg ); // Free the RPC buffer. if ( pStubMsg->IsClient ) { if ( ! pAsyncMsg->Flags.RuntimeCleanedUp ) { void * pThis = *(void **)pAsyncMsg->ProcContext.StartofStack; NdrProxyFreeBuffer( pThis, pStubMsg ); } } NdrpAllocaDestroy( &pAsyncMsg->ProcContext.AllocateContext ); // Prevent reusing of a handle that has been freed; pAsyncMsg->Signature = NDR_FREED_ASYNC_SIGNATURE; I_RpcBCacheFree( pAsyncMsg ); } } BOOL NdrpDcomAsyncSend( PMIDL_STUB_MESSAGE pStubMsg, ISynchronize * pSynchronize ) /* Call the channel to send. On the client, pass the app's pSynchronize to it, such that channel can signal the app. On the server, pass NULL instead of a pSynchronize. */ { PRPC_MESSAGE pRpcMsg = pStubMsg->RpcMsg; HRESULT hr = S_OK; RPC_STATUS Status = RPC_S_OK; BOOL fSendCalled = FALSE; pRpcMsg->RpcFlags |= RPC_BUFFER_ASYNC; if ( pStubMsg->pRpcChannelBuffer ) { IAsyncRpcChannelBuffer * pAsChannel; IRpcChannelBuffer * pChannel = (IRpcChannelBuffer *) pStubMsg->pRpcChannelBuffer; hr = pChannel->lpVtbl->QueryInterface( pChannel, IID_IAsyncRpcChannelBuffer, (void**)& pAsChannel ); if ( SUCCEEDED(hr) ) { fSendCalled = TRUE; hr = pAsChannel->lpVtbl->Send( pAsChannel, (RPCOLEMESSAGE *)pRpcMsg, pSynchronize, (ulong*)& Status ); pAsChannel->lpVtbl->Release( pAsChannel ); // The channel never returns this code now for new async. NDR_ASSERT( Status != RPC_S_SEND_INCOMPLETE, "Unexpected channel error" ); } } else hr = E_NOINTERFACE; if ( pSynchronize ) pSynchronize->lpVtbl->Release(pSynchronize); // Alex: if ( SUCCEEDED(hr) && Status == RPC_S_OK ) pStubMsg->fBufferValid = TRUE; else RpcRaiseException( Status ); return fSendCalled; } BOOL NdrpDcomAsyncClientSend( PMIDL_STUB_MESSAGE pStubMsg, IUnknown * punkOuter ) /* Call the channel to send. On the client pass app's pSynchronize to it, such that channel can signal the app. On the server pass NULL instead of a pSynchronize. */ { PRPC_MESSAGE pRpcMsg = pStubMsg->RpcMsg; HRESULT hr = S_OK; BOOL fSendCalled = FALSE; ISynchronize * pSynchronize = 0; // Channel needs somebody to signal to, this will be the app. hr = punkOuter->lpVtbl->QueryInterface( punkOuter, IID_ISynchronize, (void**) &pSynchronize ); if ( SUCCEEDED(hr) ) fSendCalled = NdrpDcomAsyncSend( pStubMsg, pSynchronize ); return fSendCalled; } void NdrDcomAsyncReceive( PMIDL_STUB_MESSAGE pStubMsg ) { PRPC_MESSAGE pRpcMsg = pStubMsg->RpcMsg; RPC_STATUS Status = RPC_S_OK; HRESULT hr; pRpcMsg->RpcFlags |= RPC_BUFFER_ASYNC; pRpcMsg->RpcFlags &= ~RPC_BUFFER_PARTIAL; // A complete call. if ( pStubMsg->pRpcChannelBuffer ) { IAsyncRpcChannelBuffer * pAsyncChannel = (IAsyncRpcChannelBuffer *) pStubMsg->pRpcChannelBuffer; hr = pAsyncChannel->lpVtbl->Receive( pAsyncChannel, (PRPCOLEMESSAGE) pRpcMsg, (unsigned long *)&Status ); } if ( Status ) { // No pending, the call would have blocked, real bug happened. if ( pStubMsg->pAsyncMsg ) ((PNDR_DCOM_ASYNC_MESSAGE)pStubMsg->pAsyncMsg)->Flags.RuntimeCleanedUp = 1; RpcRaiseException(Status); } else { pStubMsg->Buffer = (uchar*) pRpcMsg->Buffer; pStubMsg->BufferStart = (uchar*)pRpcMsg->Buffer; pStubMsg->BufferEnd = (uchar*)pRpcMsg->Buffer + pRpcMsg->BufferLength; pStubMsg->fBufferValid = TRUE; } } HRESULT Ndr64pCompleteDcomAsyncStubCall( CStdAsyncStubBuffer * pAsyncSB ); HRESULT NdrpAsyncStubSignal( CStdAsyncStubBuffer * pAsyncSB ) /* Signal on the async stub object: The channel signals that the Finish call should be executed. See if the stub object is active (or find one that is). If the stub object is not active then the call fails. */ { HRESULT hr = S_OK; BOOL fFoundActiveCall = FALSE; while ( SUCCEEDED(hr) && ! fFoundActiveCall ) { hr = NdrpValidateAsyncStubCall( pAsyncSB ); if ( SUCCEEDED(hr) ) { if ( pAsyncSB->CallState.Flags.BeginStarted ) { fFoundActiveCall = TRUE; } else { // Switch to the base interface call object. In case of // delegation one of the base interface objects would be active. IRpcStubBuffer * pBaseStubBuffer = pAsyncSB->pBaseStubBuffer; if ( pBaseStubBuffer ) { pAsyncSB = (CStdAsyncStubBuffer *) ((uchar *)pBaseStubBuffer - offsetof(CStdAsyncStubBuffer,lpVtbl)); } else { // None of the stubs active and a signal came. hr = E_FAIL; } } } } if ( SUCCEEDED(hr) ) { PNDR_DCOM_ASYNC_MESSAGE pAsyncMsg = (PNDR_DCOM_ASYNC_MESSAGE)pAsyncSB->CallState.pAsyncMsg; hr = NdrpValidateDcomAsyncMsg( pAsyncMsg ); if ( SUCCEEDED(hr) ) { #if defined(BUILD_NDR64) if ( pAsyncMsg->SyntaxType == XFER_SYNTAX_DCE ) hr = NdrpCompleteDcomAsyncStubCall( pAsyncSB ); else hr = Ndr64pCompleteDcomAsyncStubCall( pAsyncSB ); #else hr = NdrpCompleteDcomAsyncStubCall( pAsyncSB ); #endif } } return hr; }
30.804965
114
0.545082
npocmaka
4af6680708c7bd5e558fad69c48cb12838f14704
936
cpp
C++
lang/C++/sort-disjoint-sublist-1.cpp
ethansaxenian/RosettaDecode
8ea1a42a5f792280b50193ad47545d14ee371fb7
[ "MIT" ]
1
2018-11-09T22:08:38.000Z
2018-11-09T22:08:38.000Z
lang/C++/sort-disjoint-sublist-1.cpp
ethansaxenian/RosettaDecode
8ea1a42a5f792280b50193ad47545d14ee371fb7
[ "MIT" ]
null
null
null
lang/C++/sort-disjoint-sublist-1.cpp
ethansaxenian/RosettaDecode
8ea1a42a5f792280b50193ad47545d14ee371fb7
[ "MIT" ]
1
2018-11-09T22:08:40.000Z
2018-11-09T22:08:40.000Z
#include <algorithm> #include <iostream> #include <iterator> #include <vector> template <typename ValueIterator, typename IndicesIterator> void sortDisjoint(ValueIterator valsBegin, IndicesIterator indicesBegin, IndicesIterator indicesEnd) { std::vector<int> temp; for (IndicesIterator i = indicesBegin; i != indicesEnd; ++i) temp.push_back(valsBegin[*i]); // extract std::sort(indicesBegin, indicesEnd); // sort std::sort(temp.begin(), temp.end()); // sort a C++ container std::vector<int>::const_iterator j = temp.begin(); for (IndicesIterator i = indicesBegin; i != indicesEnd; ++i, ++j) valsBegin[*i] = *j; // replace } int main() { int values[] = { 7, 6, 5, 4, 3, 2, 1, 0 }; int indices[] = { 6, 1, 7 }; sortDisjoint(values, indices, indices+3); std::copy(values, values + 8, std::ostream_iterator<int>(std::cout, " ")); std::cout << "\n"; return 0; }
26.742857
78
0.633547
ethansaxenian
4af6e6a094f9a6f96cedd586bcbd8da1a1d29c71
1,329
cc
C++
src/idt/targets/typescript_cpp_v8/templates/CppV8.stache.cc
aabtop/reify
ddc7ce0250ecba78755eaa4793ad8135e4009131
[ "MIT" ]
6
2020-05-19T21:35:10.000Z
2021-06-22T15:49:04.000Z
src/idt/targets/typescript_cpp_v8/templates/CppV8.stache.cc
aabtop/reify
ddc7ce0250ecba78755eaa4793ad8135e4009131
[ "MIT" ]
26
2020-05-24T20:56:39.000Z
2021-09-04T04:46:30.000Z
src/idt/targets/typescript_cpp_v8/templates/CppV8.stache.cc
aabtop/reify
ddc7ce0250ecba78755eaa4793ad8135e4009131
[ "MIT" ]
null
null
null
// {{! // clang-format off // }} #include "{{v8HeaderFile}}" #include <cassert> #include <v8.h> #include "{{immutableRefCountedHeaderFile}}" #include "context_environment.h" namespace reify_v8 { using namespace {{namespace}}; {{#convertToImmRefCntFunctions}} {{{.}}} {{/convertToImmRefCntFunctions}} } // namespace reify_v8 namespace { #include "src_gen/lib_ts.h" #include "src_gen/reify_generated_interface_ts.h" } // namespace namespace reify { namespace typescript_cpp_v8 { namespace {{immRefCntNamespace}} { std::vector<CompilerEnvironment::InputModule> typescript_declarations() { const CompilerEnvironment::InputModule lib_interface_module = { *VirtualFilesystem::AbsolutePath::FromComponents({"{{immRefCntNamespace}}.ts"}), std::string_view(reinterpret_cast<const char*>(lib_ts), lib_ts_len)}; const CompilerEnvironment::InputModule reify_generated_module = { *VirtualFilesystem::AbsolutePath::FromComponents({"reify_generated_interface.ts"}), std::string_view( reinterpret_cast<const char*>(reify_generated_interface_ts), reify_generated_interface_ts_len)}; return std::vector<CompilerEnvironment::InputModule>({lib_interface_module, reify_generated_module}); } } // namespace {{immRefCntNamespace}} } // namespace typescript_cpp_v8 } // namespace reify
27.6875
103
0.748683
aabtop
4af8d081198c7c4c9b7fc7d459c97d99e072afba
1,322
cpp
C++
sum-of-subarray-minimums/sum-of-subarray-minimums.cpp
JanaSabuj/Leetcode-solutions
78d10926b15252a969df598fbf1f9b69b2760b79
[ "MIT" ]
13
2019-10-12T14:36:32.000Z
2021-06-08T04:26:30.000Z
sum-of-subarray-minimums/sum-of-subarray-minimums.cpp
JanaSabuj/Leetcode-solutions
78d10926b15252a969df598fbf1f9b69b2760b79
[ "MIT" ]
1
2020-02-29T14:02:39.000Z
2020-02-29T14:02:39.000Z
sum-of-subarray-minimums/sum-of-subarray-minimums.cpp
JanaSabuj/Leetcode-solutions
78d10926b15252a969df598fbf1f9b69b2760b79
[ "MIT" ]
3
2020-02-08T12:04:28.000Z
2020-03-17T11:53:00.000Z
class Solution { const int mod = 1e9 + 7; public: int sumSubarrayMins(vector<int>& arr) { int n = arr.size(); int area[n][2]; // ple stack<int> s; for(int i = 0; i < n; i++){ while(!s.empty() and arr[s.top()] > arr[i]) s.pop(); if(s.empty()) area[i][0] = 0; else area[i][0] = s.top() + 1; s.push(i); } // nle stack<int> st; for(int i = n - 1; i >= 0; i--){ while(!st.empty() and arr[st.top()] >= arr[i]) st.pop(); if(st.empty()) area[i][1] = n - 1; else area[i][1] = st.top() - 1; st.push(i); } int sum = 0; for(int i = 0; i < n; i++){ int lo = area[i][0], hi = area[i][1]; // cout << i << " " << lo << " " << hi << endl; long prod = ((i - lo + 1) % mod * (hi - i + 1) % mod) % mod; prod = (prod % mod * arr[i] % mod) % mod; sum = (sum + prod) % mod; // sum = (sum + ((arr[i] % mod * ((i - lo + 1) * (hi - i + 1)) % mod)) % mod) % mod; } cout << mod << endl; return sum ; } };
29.377778
96
0.323752
JanaSabuj
4afa402b8081d189304bac4848788fbd9d0852c0
24,891
cpp
C++
oss_src/fileio/oss_webstor/asyncurl.cpp
venkattgg/venkey
796b9bdfb2fa1b881d82080754643c7e68629cd2
[ "BSD-3-Clause" ]
493
2016-07-11T13:35:24.000Z
2022-02-15T13:04:29.000Z
oss_src/fileio/oss_webstor/asyncurl.cpp
venkattgg/venkey
796b9bdfb2fa1b881d82080754643c7e68629cd2
[ "BSD-3-Clause" ]
27
2016-07-13T20:01:07.000Z
2022-02-01T18:55:28.000Z
oss_src/fileio/oss_webstor/asyncurl.cpp
venkattgg/venkey
796b9bdfb2fa1b881d82080754643c7e68629cd2
[ "BSD-3-Clause" ]
229
2016-07-12T10:39:54.000Z
2022-02-15T13:04:31.000Z
////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2011-2013, OblakSoft LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // 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. // // // Authors: Maxim Mazeev <mazeev@hotmail.com> // Artem Livshits <artem.livshits@gmail.com> ////////////////////////////////////////////////////////////////////////////// // Async functionality for cURL. ////////////////////////////////////////////////////////////////////////////// #include "asyncurl.h" #include "sysutils.h" #define NOMINMAX #include <algorithm> #include <stdexcept> #include <curl/curl.h> namespace webstor { namespace internal { ////////////////////////////////////////////////////////////////////////////// // AsyncState -- async state potion of cURL object. struct AsyncState { AsyncState(); void setCompleted() { completedEvent.set(); } bool isCompleted() { return completedEvent.wait( 0 ); } static void setToCurl( CURL *curl, AsyncState *as ); // nofail static AsyncState * getFromCurl( CURL *curl ); // nofail EventSync completedEvent; CURLcode opResult; SocketHandle socket; AsyncLoop * asyncLoop; #ifdef PERF UInt64 creationTimestamp; #endif }; inline AsyncState::AsyncState() : opResult( CURLE_OK ) , socket( 0 ) , asyncLoop( 0 ) { completedEvent.set(); #ifdef PERF creationTimestamp = timeElapsed(); #endif } inline void AsyncState::setToCurl( CURL *curl, AsyncState *as ) // nofail { dbgAssert( curl ); dbgVerify( curl_easy_setopt( curl, CURLOPT_PRIVATE, as ) == CURLE_OK ); } inline AsyncState * AsyncState::getFromCurl( CURL *curl ) // nofail { dbgAssert( curl ); AsyncState *as = 0; dbgVerify( curl_easy_getinfo( curl, CURLINFO_PRIVATE, &as ) == CURLE_OK ); return as; } ////////////////////////////////////////////////////////////////////////////// // AsyncLoop -- async cURL-multi object. #define curl_multi_setopt_checked( handle, option, ... ) dbgVerify( curl_multi_setopt( handle, option, __VA_ARGS__ ) == CURLM_OK ) #define curl_multi_assign_checked( handle, socket, data ) dbgVerify( curl_multi_assign( handle, socket, data ) == CURLM_OK ) class AsyncLoop { public: AsyncLoop(); static void destroy( AsyncLoop *head ); static void pendOp( AsyncLoop *head, CURL *request, size_t connectionsPerThread ); void cancelOp( CURL *request ); // nofail private: enum { c_maxSocketTimeout = 3000, c_interruptOnlyTimeout = -1 }; AsyncLoop( const AsyncLoop & ); // forbidden AsyncLoop & operator=( const AsyncLoop & ); // forbidden ~AsyncLoop(); bool pendOp( CURL *request, size_t connectionsPerThread, size_t *totalRequest ); void asyncLoop(); static TaskResult TASKAPI asyncLoopTask( void *arg ); void handlePendingRequests(); void addNewRequests(); void removeCanceledRequests(); void removeCompletedRequests(); void addSocket( AsyncState *asyncState, curl_socket_t socket, int what ); // nofail void removeSocket( AsyncState *asyncState ); // nofail void executeSocketAction( SocketHandle socket, SocketActionMask actionMask = 0 ); // nofail // Curl callbacks. static int handleAddRemoveSocket( CURL *curl, curl_socket_t socket, int what, void *ctx, void *socketData ); // nofail static int handleTimeout( CURLM *multi, long msTimeout, void *ctx ); // nofail // Curl multi-handle. CURLM *m_multiCurl; // Background thread control. bool m_shutdown; TaskCtrl m_asyncLoopTaskCtrl; // Timeout recommended by curl. UInt32 m_socketActionTimeout; // A pool of active sockets provided by curl through the handleAddRemoveSocket callback. // The field is used by asyncLoop thread only. // We don't have any synchronization for this field. SocketPool m_socketPool; ExLockSync m_lock; // The next asyncLoop item. Needed to handle more requests than one asyncLoop // can process. // The head asyncLoop is always created by ConnectionAsyncManager. // Subsequent asyncLoops get created on-demand and they never destroy. In other words, // if 'next' is not NULL, it will stay not NULL and won't change. AsyncLoop *volatile m_next; // all write access must go through the m_lock // Pending new and canceled request. Can be added by any thread but removed by asyncLoop thread only. // (all access must be synchronized through the m_lock.) std::vector< CURL * > m_pendingRequests; std::vector< CURL * > m_canceledRequests; // Number of running requests (number of easy handles in the multi-handle). // It's equal or greater than the number of sockets in the m_socketPool. // The field is modified by the asyncLoop thread only after easy handle is // added/removed to/from the multi-handle. volatile size_t m_runningRequestCount; // A flag indicating if there are pending new or canceled requests. volatile bool m_hasPending; }; static void raiseIfError( CURLMcode multiCurlCode ) { dbgAssert( multiCurlCode != CURLM_CALL_MULTI_PERFORM ); // this is supposed to be obsolete error if( multiCurlCode == CURLM_OUT_OF_MEMORY ) { throw std::bad_alloc(); } if( multiCurlCode != CURLM_OK ) { std::string msg( "curl: " ); msg.append( curl_multi_strerror( multiCurlCode ) ); throw std::runtime_error( msg ); } } AsyncLoop::AsyncLoop() : m_multiCurl( NULL ) , m_shutdown( false ) , m_socketActionTimeout( c_maxSocketTimeout ) , m_next ( NULL ) , m_runningRequestCount( 0 ) , m_hasPending( false ) { // Allocate a multi-handle. m_multiCurl = curl_multi_init(); if( !m_multiCurl ) { throw std::bad_alloc(); } curl_multi_setopt_checked( m_multiCurl, CURLMOPT_SOCKETFUNCTION, handleAddRemoveSocket ); curl_multi_setopt_checked( m_multiCurl, CURLMOPT_SOCKETDATA, this ); curl_multi_setopt_checked( m_multiCurl, CURLMOPT_TIMERFUNCTION, handleTimeout ); curl_multi_setopt_checked( m_multiCurl, CURLMOPT_TIMERDATA, this ); // Start the background task. try { taskStartAsync( &asyncLoopTask, this, &m_asyncLoopTaskCtrl ); } catch( ... ) { dbgVerify( curl_multi_cleanup( m_multiCurl ) == CURLM_OK ); throw; } LOG_TRACE( "create AsyncLoop: asyncLoop=0x%llx", ( UInt64 )this ); } AsyncLoop::~AsyncLoop() { LOG_TRACE( "destroy AsyncLoop: asyncLoop=0x%llx", ( UInt64 )this ); // Shutdown the background thread. m_shutdown = true; m_socketPool.signal(); // nofail m_asyncLoopTaskCtrl.wait(); // nofail // Lifetime of AsyncMan should be greater than any async request managed through // this AsyncMan instance. // In other words, all async requests should be completed/canceled // (or connection deleted) // before AsyncMan can be destroyed. dbgAssert( m_runningRequestCount == 0 ); // Release the multi-handle. dbgVerify( curl_multi_cleanup( m_multiCurl ) == CURLM_OK ); } void AsyncLoop::destroy( AsyncLoop *head ) // nofail { while( head ) { AsyncLoop *next = head->m_next; delete head; head = next; } } TaskResult TASKAPI AsyncLoop::asyncLoopTask( void *arg ) { dbgAssert( arg ); static_cast< AsyncLoop * >( arg )->asyncLoop(); return 0; } void AsyncLoop::asyncLoop() { // This runs as an asynchronous task. dbgAssert( m_multiCurl ); SocketActions socketActions; while( !m_shutdown ) { try { if( m_hasPending ) { // Add new and remove canceled requests. handlePendingRequests(); dbgAssert( m_runningRequestCount >= m_socketPool.size() ); } size_t socketCount = m_socketPool.size(); if( m_runningRequestCount > socketCount ) { // We have added more requests to the multi-handle than the number of sockets // curl reported back to us yet. Execute 'timeout' action. executeSocketAction( INVALID_SOCKET_HANDLE ); } else { // Wait for any activity. socketActions.reserve( socketCount ); if( m_socketPool.wait( m_socketActionTimeout, c_interruptOnlyTimeout, &socketActions ) ) { // Some activity (or interrupt) has been detected, handle it. for( SocketActions::const_iterator it = socketActions.begin(); it != socketActions.end(); ++it ) { executeSocketAction( it->first, it->second ); } } else { // No activity, go through all sockets and check their status. // Note: curl_multi_socket_all(..) is deprecated but it doesn't seem // there is another way to check all sockets. Without this call some sockets // may stuck for very long. int stillRunning = 0; CURLMcode multiCurlCode = curl_multi_socket_all( m_multiCurl, &stillRunning ); raiseIfError( multiCurlCode ); } } // Remove completed requests. removeCompletedRequests(); dbgAssert( m_runningRequestCount >= m_socketPool.size() ); } catch( ... ) { // Continue to work no matter what. handleBackgroundError(); taskSleep( 3000 ); } } } void AsyncLoop::executeSocketAction( SocketHandle socket, SocketActionMask actionMask ) // nofail { CASSERT( SA_POLL_IN == CURL_CSELECT_IN ); CASSERT( SA_POLL_OUT == CURL_CSELECT_OUT ); CASSERT( SA_POLL_ERR == CURL_CSELECT_ERR ); CASSERT( sizeof( curl_socket_t ) == sizeof( SocketHandle ) ); try { int stillRunning = 0; CURLMcode multiCurlCode = curl_multi_socket_action( m_multiCurl, ( curl_socket_t ) socket, actionMask, &stillRunning ); raiseIfError( multiCurlCode ); } catch( ... ) { // We cannot fail this method, handle the error and continue. handleBackgroundError(); } } int AsyncLoop::handleAddRemoveSocket( CURL *curl, curl_socket_t socket, int what, void *ctx, void *socketData ) // nofail { AsyncLoop *const asyncLoop = static_cast< AsyncLoop * >( ctx ); dbgAssert( asyncLoop ); AsyncState *const asyncState = AsyncState::getFromCurl( curl ); // nofail dbgAssert( asyncState ); if( what == CURL_POLL_REMOVE ) { asyncLoop->removeSocket( asyncState ); // nofail // Do not try to do anything with the socket here because it may be invalid. } else { asyncLoop->addSocket( asyncState, socket, what ); // nofail } return 0; } int AsyncLoop::handleTimeout( CURLM *multi, long msTimeout, void *ctx ) // nofail { AsyncLoop *const asyncLoop = static_cast< AsyncLoop * >( ctx ); dbgAssert( asyncLoop ); if( msTimeout == 0 ) { // Execute 'timeout' action. asyncLoop->executeSocketAction( INVALID_SOCKET_HANDLE ); // nofail asyncLoop->m_socketActionTimeout = c_maxSocketTimeout; } else { asyncLoop->m_socketActionTimeout = std::min( static_cast< UInt32 >( msTimeout ), // this handles -1 as well static_cast< UInt32 >( c_maxSocketTimeout ) ); } return 0; } void AsyncLoop::handlePendingRequests() { m_lock.claimLock(); ScopedExLock lock( &m_lock ); // Check if there are any new requests, add them to the multi-handle. addNewRequests(); // Check if there are any canceled requests, remove them from the multi-handle. removeCanceledRequests(); m_hasPending = false; } void AsyncLoop::addNewRequests() { dbgAssert( m_lock.dbgHoldLock() ); CURLMcode multiCurlCode = CURLM_OK; // Reserve space in the socketList to ensure nofail in addSocket(..). m_socketPool.reserve( m_runningRequestCount + m_pendingRequests.size() ); // can throw std::bad_alloc. // Add pending requests. if( !m_pendingRequests.empty() ) { for( size_t i = 0; i < m_pendingRequests.size(); ++i ) { CURL *const request = m_pendingRequests[ i ]; dbgAssert( request ); AsyncState *const asyncState = AsyncState::getFromCurl( request ); dbgAssert( asyncState ); dbgAssert( !asyncState->isCompleted() ); m_pendingRequests[ i ] = NULL; if( ( multiCurlCode = curl_multi_add_handle( m_multiCurl, request ) ) == CURLM_OK ) { m_runningRequestCount++; #ifdef PERF LOG_TRACE( "request enqueueing lag: request=0x%llx, runningCount=%llu, asyncLoop=0x%llx, elapsed=%llu", ( UInt64 )request, m_runningRequestCount, ( UInt64 )this, timeElapsed() - asyncState->creationTimestamp ); #endif } else { dbgAssert( multiCurlCode == CURLM_OUT_OF_MEMORY ); asyncState->opResult = CURLE_OUT_OF_MEMORY; asyncState->setCompleted(); } } m_pendingRequests.clear(); } } void AsyncLoop::removeCanceledRequests() { dbgAssert( m_lock.dbgHoldLock() ); if( !m_canceledRequests.empty() ) { for( size_t i = 0; i < m_canceledRequests.size(); ++i ) { CURL *const request = m_canceledRequests[ i ]; dbgAssert( request ); AsyncState *const asyncState = AsyncState::getFromCurl( request ); dbgAssert( asyncState ); m_canceledRequests[ i ] = NULL; if( !asyncState->isCompleted() ) { dbgVerify( m_socketPool.remove( asyncState->socket ) ); dbgVerify( curl_multi_remove_handle( m_multiCurl, request ) == CURLM_OK ); dbgAssert( m_runningRequestCount ); m_runningRequestCount--; asyncState->setCompleted(); } } m_canceledRequests.clear(); } } void AsyncLoop::removeSocket( AsyncState *asyncState ) // nofail { if( asyncState ) m_socketPool.remove( asyncState->socket ); // nofail } void AsyncLoop::addSocket( AsyncState *asyncState, curl_socket_t socket, int what ) // nofail { dbgAssert( asyncState ); dbgAssert( !asyncState->isCompleted() ); CASSERT( SA_POLL_IN == CURL_POLL_IN ); CASSERT( SA_POLL_OUT == CURL_POLL_OUT ); // Assign the socket to the socketReady signal. CASSERT( sizeof( curl_socket_t ) == sizeof( SocketHandle ) ); asyncState->socket = ( SocketHandle )( socket ); m_socketPool.add( asyncState->socket, what ); // nofail } void AsyncLoop::removeCompletedRequests() { int left = 0; while( CURLMsg *const msg = curl_multi_info_read( m_multiCurl, &left ) ) { if( msg->msg == CURLMSG_DONE ) { CURL *curl = msg->easy_handle; CURLcode curlCode = msg->data.result; // Note: msg points to an internal record which doesn't survive // curl_multi_remove_handle(..) call, // so don't access msg after this line! dbgVerify( curl_multi_remove_handle( m_multiCurl, curl ) == CURLM_OK ); dbgAssert( m_runningRequestCount ); m_runningRequestCount--; AsyncState *const asyncState = AsyncState::getFromCurl( curl ); // nofail dbgAssert( asyncState ); removeSocket( asyncState ); // Save if the request failed, the error will be raised by the thread that // calls completeXXX. asyncState->opResult = curlCode; #ifdef PERF LOG_TRACE( "request completion time: request=0x%llx, runningCount=%llu, asyncLoop=0x%llx, elapsed=%llu", ( UInt64 )curl, m_runningRequestCount, ( UInt64 )this, timeElapsed() - asyncState->creationTimestamp ); #endif // Now tell everyone that the request has completed. asyncState->setCompleted(); } } } void AsyncLoop::pendOp( AsyncLoop *head, CURL *request, size_t connectionsPerThread ) { dbgAssert( head ); dbgAssert( request ); // // Algorithm: // // 1. if we have only 1 thread/asyncLoop: // then if number of requests < m_connectionsPerThread => append to that thread // else create a new thread/asyncLoop. // 2. if we have multiple threads/asyncLoops: // then append to the first thread with number of requests < half of m_connectionsPerThread. // if we could not find such thread then find the min number of requests across all threads. // if min < m_connectionsPerThread => append to that thread else create a new thread/asyncLoop. while( true ) { size_t totalRequest = 0; size_t minTotalRequest = 0; AsyncLoop *candidate = head; AsyncLoop *last = head; if( head->m_next ) { // We have multiple asyncLoops. size_t half = std::max( ( size_t )1, connectionsPerThread / 2 ); minTotalRequest = -1; for( AsyncLoop *cur = head; cur; cur = cur->m_next ) { // Make sure we see memory pointed to by cur->m_next as // initalized. cpuMemLoadFence(); // Try to append with limit set to 'half'. if( cur->AsyncLoop::pendOp( request, half, &totalRequest ) ) { return; } // The current asyncLoop has more than 'half' requests. if( totalRequest < minTotalRequest ) { // Remember the min. minTotalRequest = totalRequest; candidate = cur; } // Remember in case this is the last. last = cur; } } // Try to append to the head (if this is the only asyncLoop) or // to the found 'min' candidate (if there are multiple asyncLoops). dbgAssert( candidate ); if( minTotalRequest < connectionsPerThread && candidate->AsyncLoop::pendOp( request, connectionsPerThread, &totalRequest ) ) { return; } // We don't have an asyncLoop that can accommodate a new request, create a new one. candidate = new AsyncLoop(); { head->m_lock.claimLock(); // nofail ScopedExLock lock( &head->m_lock ); // While we were waiting for the lock, another thread could create and add a new asyncLoop. // Find the real last item. for( ; last->m_next; last = last->m_next ) {} // Add the created asyncLoop. last->m_next = candidate; } // Add the request to the created asyncLoop. if( candidate->AsyncLoop::pendOp( request, connectionsPerThread, &totalRequest ) ) { return; } // ops, another thread managed to append its request(s) to the new asyncLoop we have just created. // Repeat, we should be more lucky the next time. } } bool AsyncLoop::pendOp( CURL *request, size_t connectionsPerThread, size_t *totalRequest ) { dbgAssert( request ); dbgAssert( totalRequest ); { m_lock.claimLock(); ScopedExLock lock( &m_lock ); *totalRequest = m_runningRequestCount + m_pendingRequests.size(); if( *totalRequest >= connectionsPerThread ) { return false; } // Pre-allocate some space to avoid std::bad_alloc and ensure nofail in cancel(..). m_canceledRequests.reserve( *totalRequest + 1 ); // +1 one extra for the request being appended. // Append pending request. AsyncState *const asyncState = AsyncState::getFromCurl( request ); // nofail dbgAssert( asyncState ); m_pendingRequests.push_back( request ); // can throw std::bad_alloc asyncState->completedEvent.reset(); // nofail asyncState->opResult = CURLE_BAD_FUNCTION_ARGUMENT; asyncState->asyncLoop = this; ( *totalRequest )++; m_hasPending = true; } m_socketPool.signal(); // nofail return true; } void AsyncLoop::cancelOp( CURL *request ) // nofail { dbgAssert( request ); AsyncState *const asyncState = AsyncState::getFromCurl( request ); // nofail dbgAssert( asyncState ); if( !asyncState->isCompleted() ) { // Append cancellation. { m_lock.claimLock(); ScopedExLock lock( &m_lock ); dbgAssert( m_canceledRequests.capacity() > m_pendingRequests.size() ); m_canceledRequests.push_back( request ); // nofail because it has enough capacity reserved by pendOp(..) m_hasPending = true; } m_socketPool.signal(); // nofail // Wait for the complete event. asyncState->completedEvent.wait(); // nofail } } ////////////////////////////////////////////////////////////////////////////// // AsyncCurl -- cURL extended with async functionality. AsyncCurl::AsyncCurl() { m_asyncState = new AsyncState; m_curl = curl_easy_init(); if( !m_curl ) { delete m_asyncState; throw std::bad_alloc(); } } AsyncCurl::~AsyncCurl() { cancelOp(); // nofail delete m_asyncState; curl_easy_cleanup( m_curl ); } void AsyncCurl::pendOp( AsyncMan *opMan ) { dbgAssert( opMan ); dbgAssert( !m_asyncState->asyncLoop ); dbgAssert( !AsyncState::getFromCurl( m_curl ) || AsyncState::getFromCurl( m_curl ) == m_asyncState ); AsyncState::setToCurl( m_curl, m_asyncState ); AsyncLoop::pendOp( opMan->head(), m_curl, opMan->connectionsPerThread() ); dbgAssert( m_asyncState->asyncLoop ); } void AsyncCurl::completeOp() // nofail { m_asyncState->completedEvent.wait(); // nofail m_asyncState->asyncLoop = 0; AsyncState::setToCurl( m_curl, 0 ); // nofail } void AsyncCurl::cancelOp() // nofail { if( m_asyncState->asyncLoop ) m_asyncState->asyncLoop->cancelOp( m_curl ); m_asyncState->asyncLoop = 0; AsyncState::setToCurl( m_curl, 0 ); // nofail } bool AsyncCurl::isOpCompleted() const // nofail { return m_asyncState->isCompleted(); // nofail } int AsyncCurl::opResult() const // nofail, returns CURLcode { return m_asyncState->opResult; } EventSync * AsyncCurl::completedEvent() const { return &m_asyncState->completedEvent; } } // namespace internal using namespace internal; ////////////////////////////////////////////////////////////////////////////// // AsyncCurlOpMan -- manager for async cURL operations. AsyncMan::AsyncMan( size_t connectionsPerThread ) : m_head( new AsyncLoop ) , m_connectionsPerThread( connectionsPerThread + !connectionsPerThread ) { if( m_connectionsPerThread > c_cMaxConnectionsPerThread ) m_connectionsPerThread = c_cMaxConnectionsPerThread; } AsyncMan::~AsyncMan() { AsyncLoop::destroy( m_head ); } ////////////////////////////////////////////////////////////////////////////// // Background error handling. static BackgroundErrHandler *s_backgroundErrHandler = 0; void internal::handleBackgroundError() // nofail { // This function must be called from inside of a catch( ... ). if( s_backgroundErrHandler ) { ( *s_backgroundErrHandler )(); // must be nofail } else { dbgPanicSz( "BUG: background error handler is unset!!!" ); } } void setBackgroundErrHandler( BackgroundErrHandler *eh ) { s_backgroundErrHandler = eh; } } // namespace webstor
28.544725
130
0.599092
venkattgg
4afc58bd3678ce6f61cfd0fbc7cedaa91bbc8af6
2,481
cxx
C++
event/cyan/event.cxx
sayan-chaliha/cyan
4e653d08ecfec0f2b4c6c077359f5a66787197a4
[ "MIT" ]
3
2021-10-30T14:59:38.000Z
2022-02-21T03:17:48.000Z
event/cyan/event.cxx
sayan-chaliha/cyan
4e653d08ecfec0f2b4c6c077359f5a66787197a4
[ "MIT" ]
null
null
null
event/cyan/event.cxx
sayan-chaliha/cyan
4e653d08ecfec0f2b4c6c077359f5a66787197a4
[ "MIT" ]
null
null
null
/** * The MIT License (MIT) * * Copyright (c) 2020, Sayan Chaliha * * 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 <mutex> #include <thread> #include <memory> #include <cyan/event.h> #include <cyan/event/basic_loop.txx> #include <cyan/event/basic_async.txx> #include <cyan/event/basic_io.txx> namespace { static std::thread::id main_thread_id = std::this_thread::get_id(); } namespace cyan::event { inline namespace v1 { std::shared_ptr<event::loop> get_main_loop() { static std::shared_ptr<event::loop> loop; static std::once_flag once_flag; std::call_once(once_flag, [&] { loop = std::make_shared<event::loop>(); }); return loop; } template class basic_loop<default_backend_traits>; template class basic_async<default_backend_traits>; template class basic_idle<default_backend_traits>; template class basic_timer<default_backend_traits>; template class basic_timer_wheel<default_backend_traits>; template class basic_io<default_backend_traits>; } // v1 } // cyan::event namespace cyan::this_thread { inline namespace v1 { std::shared_ptr<event::loop> get_event_loop() { if (std::this_thread::get_id() == main_thread_id) { return cyan::event::get_main_loop(); } static thread_local std::shared_ptr<event::loop> loop; static thread_local std::once_flag once_flag; std::call_once(once_flag, [&] { loop = std::make_shared<event::loop>(); }); return loop; } } // v1 } // cyan::this_thread
29.891566
81
0.742846
sayan-chaliha