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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f5079dc0b5a15d470dcfa4ffe09aa296a1c460b2
| 1,563
|
cpp
|
C++
|
code/Brain/MarkovBrain/Gate/TritDeterministicGate.cpp
|
cliff-bohm/Comparitive_Hybrid_Approach_Replication
|
44afa3ea663bc06eeca0bc272909329d8ffe81ec
|
[
"MIT"
] | null | null | null |
code/Brain/MarkovBrain/Gate/TritDeterministicGate.cpp
|
cliff-bohm/Comparitive_Hybrid_Approach_Replication
|
44afa3ea663bc06eeca0bc272909329d8ffe81ec
|
[
"MIT"
] | null | null | null |
code/Brain/MarkovBrain/Gate/TritDeterministicGate.cpp
|
cliff-bohm/Comparitive_Hybrid_Approach_Replication
|
44afa3ea663bc06eeca0bc272909329d8ffe81ec
|
[
"MIT"
] | null | null | null |
// MABE is a product of The Hintze Lab @ MSU
// for general research information:
// hintzelab.msu.edu
// for MABE documentation:
// github.com/Hintzelab/MABE/wiki
//
// Copyright (c) 2015 Michigan State University. All rights reserved.
// to view the full license, visit:
// github.com/Hintzelab/MABE/wiki/License
#include "TritDeterministicGate.h"
std::shared_ptr<ParameterLink<std::string>> TritDeterministicGate::IO_RangesPL = Parameters::register_parameter("BRAIN_MARKOV_GATES_TRIT-IO_Ranges", (std::string)"1-4,1-4", "range of number of inputs and outputs (min inputs-max inputs,min outputs-max outputs)");
TritDeterministicGate::TritDeterministicGate(std::pair<std::vector<int>, std::vector<int>> addresses, std::vector<std::vector<int>> _table, int _ID, std::shared_ptr<ParametersTable> _PT) :
AbstractGate(_PT) {
ID = _ID;
inputs = addresses.first;
outputs = addresses.second;
table = _table;
}
void TritDeterministicGate::update(std::vector<double> & nodes, std::vector<double> & nextNodes) {
int input = vectorToTritToInt(nodes,inputs,true); // converts the input values into an index
for (size_t i = 0; i < outputs.size(); i++) {
nextNodes[outputs[i]] += table[input][i];
}
}
std::shared_ptr<AbstractGate> TritDeterministicGate::makeCopy(std::shared_ptr<ParametersTable> _PT)
{
if (_PT == nullptr) {
_PT = PT;
}
auto newGate = std::make_shared<TritDeterministicGate>(_PT);
newGate->table = table;
newGate->ID = ID;
newGate->inputs = inputs;
newGate->outputs = outputs;
return newGate;
}
| 37.214286
| 262
| 0.71785
|
cliff-bohm
|
f509caebb3efb4ecd3e9e776cdbce2ad0248a6f8
| 1,921
|
hpp
|
C++
|
gamess/libqc/rysq/src/cuda/matrix.hpp
|
andremirt/v_cond
|
6b5c364d7cd4243686488b2bd4318be3927e07ea
|
[
"Unlicense"
] | null | null | null |
gamess/libqc/rysq/src/cuda/matrix.hpp
|
andremirt/v_cond
|
6b5c364d7cd4243686488b2bd4318be3927e07ea
|
[
"Unlicense"
] | null | null | null |
gamess/libqc/rysq/src/cuda/matrix.hpp
|
andremirt/v_cond
|
6b5c364d7cd4243686488b2bd4318be3927e07ea
|
[
"Unlicense"
] | null | null | null |
#ifndef _RYSQ_MATRIX_HPP_
#define _RYSQ_MATRIX_HPP_
#include <stdlib.h>
#if !defined(__host__) && !defined(__device__)
#define __host__
#define __device__
#endif
namespace rysq {
struct matrix_layout {
matrix_layout() {}
matrix_layout(size_t size1, size_t size2, size_t ld = 0)
: size1(size1),size2(size2), ld_((ld) ? ld : size1), size(ld_*size2) {}
__host__ __device__
int element_at(int i,int j) const { return i + j* ld_;}
size_t size1, size2, ld_, size;
};
template<typename T>
class matrix_data_array {
matrix_layout layout_;
T *data_;
size_t size_;
public:
matrix_data_array() {}
matrix_data_array(const matrix_layout &layout, T *data, size_t size)
: layout_(layout), data_(data), size_(size){}
const matrix_layout& layout() const { return layout_; }
T* operator[](int i) { return data_ + i*layout_.size; }
const T* operator[](int i) const { return data_ + i* layout_.size; }
size_t size()const { return size_; }
};
template<typename T>
class matrix {
matrix_layout layout_;
T *data_;
public:
matrix() {}
matrix(size_t size1, size_t size2, T *data,size_t ld = 0)
: layout_(size1, size2, ld), data_(data) {}
size_t size1 () const { return layout_.size1; }
size_t size2 () const { return layout_.size2; }
T& operator()(int i,int j) { return data_[layout_.element_at(i,j)]; }
const T& operator()(int i,int j) const { return data_[layout_.element_at(i,j)]; }
};
namespace cuda {
void reduce(const rysq::matrix_data_array<double> A,
double scale, rysq::matrix<double> B);
// static void reduce(const rysq::matrix_data_array<double> A,
// double scale, rysq::matrix<double> B) {
// reduce <double>(A, scale, B);
// }
// static void reduce(const rysq::matrix_data_array<double> A,
// double scale, rysq::matrix<double> B) {
// reduce(A, scale, B);
// }
}
}
#endif /* _RYSQ_MATRIX_HPP_ */
| 26.680556
| 82
| 0.664237
|
andremirt
|
f50a6043320384e34588a0d5f2f10c924d01f67f
| 648
|
cpp
|
C++
|
BlackVision/LibBlackVision/Source/Engine/Graphics/Shaders/Parameters/ShaderParamMat3.cpp
|
black-vision-engine/bv-engine
|
85089d41bb22afeaa9de070646e12aa1777ecedf
|
[
"MIT"
] | 1
|
2022-01-28T11:43:47.000Z
|
2022-01-28T11:43:47.000Z
|
BlackVision/LibBlackVision/Source/Engine/Graphics/Shaders/Parameters/ShaderParamMat3.cpp
|
black-vision-engine/bv-engine
|
85089d41bb22afeaa9de070646e12aa1777ecedf
|
[
"MIT"
] | null | null | null |
BlackVision/LibBlackVision/Source/Engine/Graphics/Shaders/Parameters/ShaderParamMat3.cpp
|
black-vision-engine/bv-engine
|
85089d41bb22afeaa9de070646e12aa1777ecedf
|
[
"MIT"
] | null | null | null |
#include "stdafx.h"
#include "ShaderParamMat3.h"
#include "Memory/MemoryLeaks.h"
namespace bv {
// ****************************
//
ShaderParamMat3::ShaderParamMat3 ( const std::string & name, const glm::mat3 & value )
: GenericShaderParam( ShaderParamTypeTraits< ValueMat3::ValueType >::paramType, name )
, m_val( value )
{
}
// ****************************
//
void ShaderParamMat3::SetValue ( const glm::mat3 & value )
{
m_val = value;
}
// ****************************
//
const void * ShaderParamMat3::GetValuePtr () const
{
return &m_val;
}
} //bv
| 17.513514
| 102
| 0.501543
|
black-vision-engine
|
f50a93c785c58ac6098a6651290a4b9002dd9b49
| 1,126
|
hpp
|
C++
|
src/oni.hpp
|
typingtanuki/chato
|
61c76bda12d4ef855e3fad06338d94a3f1735971
|
[
"Apache-2.0"
] | null | null | null |
src/oni.hpp
|
typingtanuki/chato
|
61c76bda12d4ef855e3fad06338d94a3f1735971
|
[
"Apache-2.0"
] | null | null | null |
src/oni.hpp
|
typingtanuki/chato
|
61c76bda12d4ef855e3fad06338d94a3f1735971
|
[
"Apache-2.0"
] | null | null | null |
#include "constants.hpp"
#include "light.hpp"
#include "motor.hpp"
#include "timer.hpp"
#include "keypad.hpp"
enum OniState {
INIT,
IDLE,
MOVE
};
class Oni {
private:
Light *eye = new Light(DIGITAL_PIN3, 12, 24);
Motor *eyeMotor = new Motor(DIGITAL_PIN9);
Motor *axeMotor = new Motor(DIGITAL_PIN13);
Light *axe = new Light(DIGITAL_PIN5, 60, 60);
Keypad *keypad;
bool autoEyeState = false;
bool autoAxeState = false;
unsigned long nextEyeTime = 0;
unsigned long nextAxeTime = 0;
unsigned long nextEyeMoveTime = 0;
unsigned long nextOniTime = 0;
LightState eyeState = OFF;
LightState axeState = OFF;
OniState oniState = INIT;
void autoEyeControl();
void autoAxeControl();
void autoEyeLightControl();
void autoAxeLightControl();
void newEyeState();
static LightState nextLightPattern(LightState current);
static LightState pickEyeState();
void newAxeState();
static LightState pickAxeState();
static OniState newOniState();
public:
explicit Oni(Keypad *keypad);
void init();
void loop();
};
| 18.766667
| 59
| 0.668739
|
typingtanuki
|
f50c0a94e46967a99ecb3936474a09e047e75c0d
| 826
|
cpp
|
C++
|
summary-ranges/solution-0.cpp
|
tsenmu/leetcode
|
6f6d11dec4e5ee0fbc0c59fd6fa97b2c556e05ee
|
[
"Apache-2.0"
] | null | null | null |
summary-ranges/solution-0.cpp
|
tsenmu/leetcode
|
6f6d11dec4e5ee0fbc0c59fd6fa97b2c556e05ee
|
[
"Apache-2.0"
] | null | null | null |
summary-ranges/solution-0.cpp
|
tsenmu/leetcode
|
6f6d11dec4e5ee0fbc0c59fd6fa97b2c556e05ee
|
[
"Apache-2.0"
] | null | null | null |
class Solution {
protected:
string yieldRange(int begin, int end) {
if (begin == end) {
return to_string(begin);
}
return to_string(begin) + "->" + to_string(end);
}
public:
vector<string> summaryRanges(vector<int>& nums) {
const int n = nums.size();
vector<string> result;
if (n == 0) {
return result;
}
if (n == 1) {
result.push_back(yieldRange(nums[0], nums[0]));
return result;
}
int last = nums[0];
int begin = last;
for (int i = 1; i < n; ++i) {
if (nums[i] - last != 1) {
result.push_back(yieldRange(begin, last));
begin = nums[i];
}
last = nums[i];
}
result.push_back(yieldRange(begin, nums[n - 1]));
return result;
}
};
| 21.179487
| 55
| 0.493947
|
tsenmu
|
f50c6328dd3f28621e77d38577eff115188dea88
| 1,119
|
cpp
|
C++
|
Gems/EMotionFX/Code/EMotionFX/Source/MeshDeformer.cpp
|
aaarsene/o3de
|
37e3b0226958974defd14dd6d808e8557dcd7345
|
[
"Apache-2.0",
"MIT"
] | 1
|
2021-09-13T00:01:12.000Z
|
2021-09-13T00:01:12.000Z
|
Gems/EMotionFX/Code/EMotionFX/Source/MeshDeformer.cpp
|
aaarsene/o3de
|
37e3b0226958974defd14dd6d808e8557dcd7345
|
[
"Apache-2.0",
"MIT"
] | null | null | null |
Gems/EMotionFX/Code/EMotionFX/Source/MeshDeformer.cpp
|
aaarsene/o3de
|
37e3b0226958974defd14dd6d808e8557dcd7345
|
[
"Apache-2.0",
"MIT"
] | 1
|
2021-07-20T11:07:25.000Z
|
2021-07-20T11:07:25.000Z
|
/*
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// include the required headers
#include "MeshDeformer.h"
#include <EMotionFX/Source/Allocators.h>
namespace EMotionFX
{
AZ_CLASS_ALLOCATOR_IMPL(MeshDeformer, DeformerAllocator, 0)
// constructor
MeshDeformer::MeshDeformer(Mesh* mesh)
: BaseObject()
{
mMesh = mesh;
mIsEnabled = true;
}
// destructor
MeshDeformer::~MeshDeformer()
{
}
// check if the deformer is enabled
bool MeshDeformer::GetIsEnabled() const
{
return mIsEnabled;
}
// enable or disable it
void MeshDeformer::SetIsEnabled(bool enabled)
{
mIsEnabled = enabled;
}
// reinitialize the mesh deformer
void MeshDeformer::Reinitialize(Actor* actor, Node* node, uint32 lodLevel)
{
MCORE_UNUSED(actor);
MCORE_UNUSED(node);
MCORE_UNUSED(lodLevel);
}
} // namespace EMotionFX
| 20.722222
| 158
| 0.649687
|
aaarsene
|
f50f03ccfa9b71427ab0430e3de9159602a849f4
| 423
|
cpp
|
C++
|
tests/testsmain.cpp
|
k9lego/huestacean
|
e72b43b66cc3b6b58554fa49ac207ad9f945c3fb
|
[
"Apache-2.0"
] | 540
|
2018-02-16T15:15:43.000Z
|
2022-03-01T22:35:18.000Z
|
tests/testsmain.cpp
|
k9lego/huestacean
|
e72b43b66cc3b6b58554fa49ac207ad9f945c3fb
|
[
"Apache-2.0"
] | 153
|
2018-02-19T13:33:14.000Z
|
2022-02-26T04:57:10.000Z
|
tests/testsmain.cpp
|
k9lego/huestacean
|
e72b43b66cc3b6b58554fa49ac207ad9f945c3fb
|
[
"Apache-2.0"
] | 66
|
2018-03-17T10:54:54.000Z
|
2022-02-16T16:20:46.000Z
|
#define CATCH_CONFIG_RUNNER
#include "catch/catch.hpp"
#include <QCoreApplication>
int main(int argc, char* argv[])
{
QCoreApplication a(argc, argv);
QCoreApplication::setOrganizationName("Brady Brenot");
QCoreApplication::setOrganizationDomain("bradybrenot.com");
QCoreApplication::setApplicationName("Huestacean Test");
int result = Catch::Session().run(argc, argv);
return (result < 0xff ? result : 0xff);
}
| 22.263158
| 60
| 0.751773
|
k9lego
|
f50f1174e3844b028bb752ce92df7036d918a0df
| 4,461
|
cpp
|
C++
|
source/shared/cpp/ObjectModel/ActionParserRegistration.cpp
|
sivasakthiv/AdaptiveCards
|
dfa4bfef70c1111e1a5cc8eed90b2f1e8d76f75c
|
[
"MIT"
] | 1
|
2020-12-07T10:57:38.000Z
|
2020-12-07T10:57:38.000Z
|
source/shared/cpp/ObjectModel/ActionParserRegistration.cpp
|
sivasakthiv/AdaptiveCards
|
dfa4bfef70c1111e1a5cc8eed90b2f1e8d76f75c
|
[
"MIT"
] | 43
|
2020-09-04T23:34:16.000Z
|
2022-02-26T11:36:24.000Z
|
source/shared/cpp/ObjectModel/ActionParserRegistration.cpp
|
sivasakthiv/AdaptiveCards
|
dfa4bfef70c1111e1a5cc8eed90b2f1e8d76f75c
|
[
"MIT"
] | 16
|
2021-02-10T07:46:07.000Z
|
2021-11-23T10:22:44.000Z
|
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "ActionParserRegistration.h"
#include "AdaptiveCardParseException.h"
#include "BaseElement.h"
#include "OpenUrlAction.h"
#include "ShowCardAction.h"
#include "SubmitAction.h"
#include "ToggleVisibilityAction.h"
#include "UnknownAction.h"
namespace AdaptiveSharedNamespace
{
ActionElementParserWrapper::ActionElementParserWrapper(std::shared_ptr<ActionElementParser> parserToWrap) :
m_parser{parserToWrap}
{
}
std::shared_ptr<BaseActionElement> ActionElementParserWrapper::Deserialize(ParseContext& context, const Json::Value& value)
{
const auto& idProperty = ParseUtil::GetString(value, AdaptiveCardSchemaKey::Id);
const AdaptiveSharedNamespace::InternalId internalId = AdaptiveSharedNamespace::InternalId::Next();
context.PushElement(idProperty, internalId);
std::shared_ptr<BaseActionElement> element = m_parser->Deserialize(context, value);
context.PopElement();
return element;
}
std::shared_ptr<BaseActionElement> ActionElementParserWrapper::DeserializeFromString(ParseContext& context, const std::string& value)
{
return Deserialize(context, ParseUtil::GetJsonValueFromString(value));
}
ActionParserRegistration::ActionParserRegistration()
{
m_knownElements.insert({
ActionTypeToString(ActionType::OpenUrl),
ActionTypeToString(ActionType::ShowCard),
ActionTypeToString(ActionType::Submit),
ActionTypeToString(ActionType::ToggleVisibility),
ActionTypeToString(ActionType::UnknownAction),
});
m_cardElementParsers.insert(
{{ActionTypeToString(ActionType::OpenUrl), std::make_shared<OpenUrlActionParser>()},
{ActionTypeToString(ActionType::ShowCard), std::make_shared<ShowCardActionParser>()},
{ActionTypeToString(ActionType::Submit), std::make_shared<SubmitActionParser>()},
{ActionTypeToString(ActionType::ToggleVisibility), std::make_shared<ToggleVisibilityActionParser>()},
{ActionTypeToString(ActionType::UnknownAction), std::make_shared<UnknownActionParser>()}});
}
void ActionParserRegistration::AddParser(std::string const& elementType, std::shared_ptr<ActionElementParser> parser)
{
// make sure caller isn't attempting to overwrite a known element's parser
if (m_knownElements.find(elementType) == m_knownElements.end())
{
ActionParserRegistration::m_cardElementParsers[elementType] = parser;
}
else
{
throw AdaptiveCardParseException(ErrorStatusCode::UnsupportedParserOverride, "Overriding known action parsers is unsupported");
}
}
void ActionParserRegistration::RemoveParser(std::string const& elementType)
{
// make sure caller isn't attempting to remove a known element's parser
if (m_knownElements.find(elementType) == m_knownElements.end())
{
ActionParserRegistration::m_cardElementParsers.erase(elementType);
}
else
{
throw AdaptiveCardParseException(ErrorStatusCode::UnsupportedParserOverride, "Removing known action parsers is unsupported");
}
}
std::shared_ptr<ActionElementParser> ActionParserRegistration::GetParser(std::string const& elementType) const
{
auto parser = m_cardElementParsers.find(elementType);
if (parser != ActionParserRegistration::m_cardElementParsers.end())
{
// Why do we wrap the parser? As we parse elements, we need to push and pop state from the stack for ID
// collision detection. We *could* do this within the implementation of parsers themselves, but that would
// mean having to explain all of this to custom element parser implementors. Instead, we wrap every parser
// we hand out with a helper class that performs the push/pop on behalf of the element parser. For more
// details, refer to the giant comment on ID collision detection in ParseContext.cpp.
std::shared_ptr<ActionElementParser> wrappedParser = std::make_shared<ActionElementParserWrapper>(parser->second);
return wrappedParser;
}
else
{
return std::shared_ptr<ActionElementParser>(nullptr);
}
}
}
| 44.61
| 139
| 0.702085
|
sivasakthiv
|
f5112da53a614a87c972b3056dee8ff3b0850e52
| 2,957
|
hpp
|
C++
|
include/codegen/include/UnityEngine/EventSystems/OVRPhysicsRaycaster_--c.hpp
|
Futuremappermydud/Naluluna-Modifier-Quest
|
bfda34370764b275d90324b3879f1a429a10a873
|
[
"MIT"
] | 1
|
2021-11-12T09:29:31.000Z
|
2021-11-12T09:29:31.000Z
|
include/codegen/include/UnityEngine/EventSystems/OVRPhysicsRaycaster_--c.hpp
|
Futuremappermydud/Naluluna-Modifier-Quest
|
bfda34370764b275d90324b3879f1a429a10a873
|
[
"MIT"
] | null | null | null |
include/codegen/include/UnityEngine/EventSystems/OVRPhysicsRaycaster_--c.hpp
|
Futuremappermydud/Naluluna-Modifier-Quest
|
bfda34370764b275d90324b3879f1a429a10a873
|
[
"MIT"
] | 2
|
2021-10-03T02:14:20.000Z
|
2021-11-12T09:29:36.000Z
|
// Autogenerated from CppHeaderCreator on 7/27/2020 3:10:06 PM
// Created by Sc2ad
// =========================================================================
#pragma once
#pragma pack(push, 8)
// Begin includes
#include "utils/typedefs.h"
// Including type: System.Object
#include "System/Object.hpp"
// Including type: UnityEngine.EventSystems.OVRPhysicsRaycaster
#include "UnityEngine/EventSystems/OVRPhysicsRaycaster.hpp"
// Including type: UnityEngine.RaycastHit
#include "UnityEngine/RaycastHit.hpp"
#include "utils/il2cpp-utils.hpp"
// Completed includes
// Begin forward declares
// Forward declaring namespace: System
namespace System {
// Forward declaring type: Comparison`1<T>
template<typename T>
class Comparison_1;
}
// Completed forward declares
// Type namespace: UnityEngine.EventSystems
namespace UnityEngine::EventSystems {
// Autogenerated type: UnityEngine.EventSystems.OVRPhysicsRaycaster/<>c
class OVRPhysicsRaycaster::$$c : public ::Il2CppObject {
public:
// Get static field: static public readonly UnityEngine.EventSystems.OVRPhysicsRaycaster/<>c <>9
static UnityEngine::EventSystems::OVRPhysicsRaycaster::$$c* _get_$$9();
// Set static field: static public readonly UnityEngine.EventSystems.OVRPhysicsRaycaster/<>c <>9
static void _set_$$9(UnityEngine::EventSystems::OVRPhysicsRaycaster::$$c* value);
// Get static field: static public System.Comparison`1<UnityEngine.RaycastHit> <>9__15_0
static System::Comparison_1<UnityEngine::RaycastHit>* _get_$$9__15_0();
// Set static field: static public System.Comparison`1<UnityEngine.RaycastHit> <>9__15_0
static void _set_$$9__15_0(System::Comparison_1<UnityEngine::RaycastHit>* value);
// Get static field: static public System.Comparison`1<UnityEngine.RaycastHit> <>9__16_0
static System::Comparison_1<UnityEngine::RaycastHit>* _get_$$9__16_0();
// Set static field: static public System.Comparison`1<UnityEngine.RaycastHit> <>9__16_0
static void _set_$$9__16_0(System::Comparison_1<UnityEngine::RaycastHit>* value);
// static private System.Void .cctor()
// Offset: 0x18EA91C
static void _cctor();
// System.Int32 <Raycast>b__15_0(UnityEngine.RaycastHit r1, UnityEngine.RaycastHit r2)
// Offset: 0x18EA98C
int $Raycast$b__15_0(UnityEngine::RaycastHit r1, UnityEngine::RaycastHit r2);
// System.Int32 <Spherecast>b__16_0(UnityEngine.RaycastHit r1, UnityEngine.RaycastHit r2)
// Offset: 0x18EA9D0
int $Spherecast$b__16_0(UnityEngine::RaycastHit r1, UnityEngine::RaycastHit r2);
// public System.Void .ctor()
// Offset: 0x18EA984
// Implemented from: System.Object
// Base method: System.Void Object::.ctor()
static OVRPhysicsRaycaster::$$c* New_ctor();
}; // UnityEngine.EventSystems.OVRPhysicsRaycaster/<>c
}
DEFINE_IL2CPP_ARG_TYPE(UnityEngine::EventSystems::OVRPhysicsRaycaster::$$c*, "UnityEngine.EventSystems", "OVRPhysicsRaycaster/<>c");
#pragma pack(pop)
| 50.118644
| 132
| 0.735543
|
Futuremappermydud
|
f511311f7559c4372d7dd7dca01bd935d8d911ca
| 1,069
|
hpp
|
C++
|
lib/inc/facter/facts/windows/dmi_resolver.hpp
|
whopper/cfacter
|
f489f62e19a161e2d909199aebd896e323dac0e8
|
[
"Apache-2.0"
] | null | null | null |
lib/inc/facter/facts/windows/dmi_resolver.hpp
|
whopper/cfacter
|
f489f62e19a161e2d909199aebd896e323dac0e8
|
[
"Apache-2.0"
] | null | null | null |
lib/inc/facter/facts/windows/dmi_resolver.hpp
|
whopper/cfacter
|
f489f62e19a161e2d909199aebd896e323dac0e8
|
[
"Apache-2.0"
] | null | null | null |
/**
* @file
* Declares the Windows Desktop Management Information (DMI) fact resolver.
*/
#pragma once
#include "../resolvers/dmi_resolver.hpp"
#include <facter/util/windows/wmi.hpp>
#include <string>
#include <memory>
namespace facter { namespace facts { namespace windows {
/**
* Responsible for resolving DMI facts.
*/
struct dmi_resolver : resolvers::dmi_resolver
{
/**
* Constructs the dmi_resolver.
* @param wmi_conn The WMI connection to use when resolving facts.
*/
dmi_resolver(std::shared_ptr<util::windows::wmi> wmi_conn = std::make_shared<util::windows::wmi>());
protected:
/**
* Collects the resolver data.
* @param facts The fact collection that is resolving facts.
* @return Returns the resolver data.
*/
virtual data collect_data(collection& facts) override;
private:
std::string read(std::string const& path);
std::shared_ptr<util::windows::wmi> _wmi;
};
}}} // namespace facter::facts::windows
| 27.410256
| 108
| 0.634238
|
whopper
|
f511d895d75af332b9ef48f66861792b00977e63
| 6,078
|
hpp
|
C++
|
communication/include/communication/CommDefs.hpp
|
irisk29/concord-bft
|
daf6a4a156fa2e9107f65de6ec6a26c39cd99796
|
[
"Apache-2.0"
] | null | null | null |
communication/include/communication/CommDefs.hpp
|
irisk29/concord-bft
|
daf6a4a156fa2e9107f65de6ec6a26c39cd99796
|
[
"Apache-2.0"
] | null | null | null |
communication/include/communication/CommDefs.hpp
|
irisk29/concord-bft
|
daf6a4a156fa2e9107f65de6ec6a26c39cd99796
|
[
"Apache-2.0"
] | null | null | null |
// Concord
//
// Copyright (c) 2018-2020 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache 2.0 license (the "License").
// You may not use this product except in compliance with the Apache 2.0 License.
//
// This product may include a number of subcomponents with separate copyright
// notices and license terms. Your use of these subcomponents is subject to the
// terms and conditions of the subcomponent's license, as noted in the
// LICENSE file.
#pragma once
#include <string>
#include <cstdint>
#include <memory>
#include <unordered_map>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/socket.h>
#include <unistd.h>
#include "communication/ICommunication.hpp"
#include "communication/StatusInfo.h"
#include "secret_data.h"
namespace bft::communication {
typedef struct sockaddr_in Addr;
struct NodeInfo {
std::string host;
std::uint16_t port;
bool isReplica;
};
typedef std::unordered_map<NodeNum, NodeInfo> NodeMap;
enum CommType { PlainUdp, SimpleAuthUdp, PlainTcp, SimpleAuthTcp, TlsTcp };
struct BaseCommConfig {
CommType commType;
std::string listenHost;
uint16_t listenPort;
uint32_t bufferLength;
NodeMap nodes;
UPDATE_CONNECTIVITY_FN statusCallback;
NodeNum selfId;
BaseCommConfig(CommType type,
const std::string &host,
uint16_t port,
uint32_t bufLength,
NodeMap _nodes,
NodeNum _selfId,
UPDATE_CONNECTIVITY_FN _statusCallback = nullptr)
: commType{type},
listenHost{host},
listenPort{port},
bufferLength{bufLength},
nodes{std::move(_nodes)},
statusCallback{std::move(_statusCallback)},
selfId{_selfId} {}
virtual ~BaseCommConfig() = default;
};
struct PlainUdpConfig : BaseCommConfig {
PlainUdpConfig(const std::string &host,
uint16_t port,
uint32_t bufLength,
NodeMap _nodes,
NodeNum _selfId,
UPDATE_CONNECTIVITY_FN _statusCallback = nullptr)
: BaseCommConfig(
CommType::PlainUdp, host, port, bufLength, std::move(_nodes), _selfId, std::move(_statusCallback)) {}
};
struct PlainTcpConfig : BaseCommConfig {
int32_t maxServerId;
PlainTcpConfig(const std::string &host,
uint16_t port,
uint32_t bufLength,
NodeMap _nodes,
int32_t _maxServerId,
NodeNum _selfId,
UPDATE_CONNECTIVITY_FN _statusCallback = nullptr)
: BaseCommConfig(
CommType::PlainTcp, host, port, bufLength, std::move(_nodes), _selfId, std::move(_statusCallback)),
maxServerId{_maxServerId} {}
};
struct TlsTcpConfig : PlainTcpConfig {
std::string certificatesRootPath;
// set specific suite or list of suites, as described in OpenSSL
// https://www.openssl.org/docs/man1.0.2/man1/ciphers.html
std::string cipherSuite;
std::optional<concord::secretsmanager::SecretData> secretData;
TlsTcpConfig(const std::string &host,
uint16_t port,
uint32_t bufLength,
NodeMap _nodes,
int32_t _maxServerId,
NodeNum _selfId,
const std::string &certRootPath,
const std::string &ciphSuite,
UPDATE_CONNECTIVITY_FN _statusCallback = nullptr,
std::optional<concord::secretsmanager::SecretData> decryptionSecretData = std::nullopt)
: PlainTcpConfig(host, port, bufLength, std::move(_nodes), _maxServerId, _selfId, std::move(_statusCallback)),
certificatesRootPath{certRootPath},
cipherSuite{ciphSuite},
secretData{std::move(decryptionSecretData)} {
commType = CommType::TlsTcp;
}
};
class PlainUDPCommunication : public ICommunication {
public:
static PlainUDPCommunication *create(const PlainUdpConfig &config);
int getMaxMessageSize() override;
int Start() override;
int Stop() override;
bool isRunning() const override;
ConnectionStatus getCurrentConnectionStatus(NodeNum node) override;
int send(NodeNum destNode, std::vector<uint8_t> &&msg) override;
std::set<NodeNum> send(std::set<NodeNum> dests, std::vector<uint8_t> &&msg) override;
void setReceiver(NodeNum receiverNum, IReceiver *receiver) override;
~PlainUDPCommunication() override;
private:
class PlainUdpImpl;
// TODO(IG): convert to smart ptr
PlainUdpImpl *_ptrImpl = nullptr;
explicit PlainUDPCommunication(const PlainUdpConfig &config);
};
class PlainTCPCommunication : public ICommunication {
public:
static PlainTCPCommunication *create(const PlainTcpConfig &config);
int getMaxMessageSize() override;
int Start() override;
int Stop() override;
bool isRunning() const override;
ConnectionStatus getCurrentConnectionStatus(NodeNum node) override;
int send(NodeNum destNode, std::vector<uint8_t> &&msg) override;
std::set<NodeNum> send(std::set<NodeNum> dests, std::vector<uint8_t> &&msg) override;
void setReceiver(NodeNum receiverNum, IReceiver *receiver) override;
~PlainTCPCommunication() override;
private:
class PlainTcpImpl;
PlainTcpImpl *_ptrImpl = nullptr;
explicit PlainTCPCommunication(const PlainTcpConfig &config);
};
class TlsTCPCommunication : public ICommunication {
public:
static TlsTCPCommunication *create(const TlsTcpConfig &config);
int getMaxMessageSize() override;
int Start() override;
int Stop() override;
bool isRunning() const override;
ConnectionStatus getCurrentConnectionStatus(NodeNum node) override;
int send(NodeNum destNode, std::vector<uint8_t> &&msg) override;
std::set<NodeNum> send(std::set<NodeNum> dests, std::vector<uint8_t> &&msg) override;
void setReceiver(NodeNum receiverNum, IReceiver *receiver) override;
~TlsTCPCommunication() override;
private:
class TlsTcpImpl;
friend class AsyncTlsConnection;
std::unique_ptr<TlsTcpImpl> impl_;
explicit TlsTCPCommunication(const TlsTcpConfig &config);
};
} // namespace bft::communication
| 30.69697
| 116
| 0.699737
|
irisk29
|
f512db47e285be6ddab66ee5372e8d187e73778a
| 1,251
|
hpp
|
C++
|
include/pstore/http/http_date.hpp
|
paulhuggett/pstore2
|
a0c663d10a2e2713fdf39ecdae1f9c1e96041f5c
|
[
"Apache-2.0"
] | 11
|
2018-02-02T21:24:49.000Z
|
2020-12-11T04:06:03.000Z
|
include/pstore/http/http_date.hpp
|
SNSystems/pstore
|
74e9dd960245d6bfc125af03ed964d8ad660a62d
|
[
"Apache-2.0"
] | 63
|
2018-02-05T17:24:59.000Z
|
2022-03-22T17:26:28.000Z
|
include/pstore/http/http_date.hpp
|
paulhuggett/pstore
|
067be94d87c87fce524c8d76c6f47c347d8f1853
|
[
"Apache-2.0"
] | 5
|
2020-01-13T22:47:11.000Z
|
2021-05-14T09:31:15.000Z
|
//===- include/pstore/http/http_date.hpp ------------------*- mode: C++ -*-===//
//* _ _ _ _ _ *
//* | |__ | |_| |_ _ __ __| | __ _| |_ ___ *
//* | '_ \| __| __| '_ \ / _` |/ _` | __/ _ \ *
//* | | | | |_| |_| |_) | | (_| | (_| | || __/ *
//* |_| |_|\__|\__| .__/ \__,_|\__,_|\__\___| *
//* |_| *
//===----------------------------------------------------------------------===//
//
// Part of the pstore project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/SNSystems/pstore/blob/master/LICENSE.txt for license
// information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
/// \file http_date.hpp
/// \brief Functions to return a dated formatted for HTTP.
#ifndef PSTORE_HTTP_HTTP_DATE_HPP
#define PSTORE_HTTP_HTTP_DATE_HPP
#include <chrono>
#include <ctime>
#include <string>
namespace pstore {
namespace http {
std::string http_date (std::chrono::system_clock::time_point time);
std::string http_date (std::time_t time);
} // end namespace http
} // end namespace pstore
#endif // PSTORE_HTTP_HTTP_DATE_HPP
| 35.742857
| 82
| 0.489209
|
paulhuggett
|
f513e3c60c7f985be18935ddb5faf2b14b497f63
| 2,379
|
cpp
|
C++
|
python/NpcompModule.cpp
|
raikonenfnu/mlir-npcomp
|
29e1b2fe89848d58c9bc07e7df7ce651850a5244
|
[
"Apache-2.0"
] | null | null | null |
python/NpcompModule.cpp
|
raikonenfnu/mlir-npcomp
|
29e1b2fe89848d58c9bc07e7df7ce651850a5244
|
[
"Apache-2.0"
] | null | null | null |
python/NpcompModule.cpp
|
raikonenfnu/mlir-npcomp
|
29e1b2fe89848d58c9bc07e7df7ce651850a5244
|
[
"Apache-2.0"
] | null | null | null |
//===- NpcompModule.cpp - MLIR Python bindings ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <cstddef>
#include <unordered_map>
#include "./NpcompModule.h"
#include "./NpcompPybindUtils.h"
#include "mlir-c/BuiltinAttributes.h"
#include "mlir-c/BuiltinTypes.h"
#include "mlir-c/Diagnostics.h"
#include "npcomp-c/BasicpyTypes.h"
#include "npcomp-c/InitLLVM.h"
#include "npcomp-c/NumpyTypes.h"
#include "npcomp-c/Registration.h"
namespace {
MlirType shapedToNdArrayArrayType(MlirType shaped_type) {
if (!mlirTypeIsAShaped(shaped_type)) {
throw py::raiseValueError("type is not a shaped type");
}
return npcompNumpyNdArrayTypeGetFromShaped(shaped_type);
}
MlirType ndarrayToTensorType(MlirType ndarray_type) {
if (!npcompTypeIsANumpyNdArray(ndarray_type)) {
throw py::raiseValueError("type is not an ndarray type");
}
return npcompNumpyNdArrayTypeToTensor(ndarray_type);
}
MlirType slotObjectType(MlirContext context, const std::string &className,
const std::vector<MlirType> &slotTypes) {
MlirStringRef classNameSr{className.data(), className.size()};
return ::npcompBasicPySlotObjectTypeGet(context, classNameSr,
slotTypes.size(), slotTypes.data());
}
// TODO: Move this upstream.
void emitError(MlirLocation loc, std::string message) {
::mlirEmitError(loc, message.c_str());
}
} // namespace
PYBIND11_MODULE(_npcomp, m) {
m.doc() = "Npcomp native python bindings";
::npcompRegisterAllPasses();
::npcompInitializeLLVMCodegen();
m.def("register_all_dialects", ::npcompRegisterAllDialects);
m.def("shaped_to_ndarray_type", shapedToNdArrayArrayType);
m.def("ndarray_to_tensor_type", ndarrayToTensorType);
m.def("slot_object_type", slotObjectType);
m.def("emit_error", emitError);
// Optional backend modules.
auto backend_m = m.def_submodule("backend", "Backend support");
(void)backend_m;
#ifdef NPCOMP_ENABLE_REFJIT
auto refjit_m =
backend_m.def_submodule("refjit", "Reference CPU Jit Backend");
::npcomp::python::defineBackendRefJitModule(refjit_m);
#endif
}
| 32.148649
| 80
| 0.697352
|
raikonenfnu
|
f513e4ca1c2b159ea29dd107a50d782fc2c2ca51
| 7,446
|
cpp
|
C++
|
src/qpsolver/basis.cpp
|
WTFHCN/HiGHS
|
6cec473fc821bca0d98517a11691da8b5e1b0e51
|
[
"MIT"
] | null | null | null |
src/qpsolver/basis.cpp
|
WTFHCN/HiGHS
|
6cec473fc821bca0d98517a11691da8b5e1b0e51
|
[
"MIT"
] | null | null | null |
src/qpsolver/basis.cpp
|
WTFHCN/HiGHS
|
6cec473fc821bca0d98517a11691da8b5e1b0e51
|
[
"MIT"
] | null | null | null |
#include "basis.hpp"
#include <cassert>
#include <memory>
Basis::Basis(Runtime& rt, std::vector<HighsInt> active,
std::vector<BasisStatus> lower, std::vector<HighsInt> inactive)
: runtime(rt),
buffer_column_aq(rt.instance.num_var),
buffer_row_ep(rt.instance.num_var) {
for (HighsInt i = 0; i < active.size(); i++) {
activeconstraintidx.push_back(active[i]);
basisstatus[activeconstraintidx[i]] = lower[i];
}
for (HighsInt i : inactive) {
nonactiveconstraintsidx.push_back(i);
}
Atran = rt.instance.A.t();
build();
}
void Basis::build() {
updatessinceinvert = 0;
baseindex =
new HighsInt[activeconstraintidx.size() + nonactiveconstraintsidx.size()];
constraintindexinbasisfactor.clear();
basisfactor = HFactor();
constraintindexinbasisfactor.assign(Atran.num_row + Atran.num_col, -1);
assert(nonactiveconstraintsidx.size() + activeconstraintidx.size() ==
Atran.num_row);
HighsInt counter = 0;
for (HighsInt i : nonactiveconstraintsidx) {
baseindex[counter++] = i;
}
for (HighsInt i : activeconstraintidx) {
baseindex[counter++] = i;
}
const bool empty_matrix = (int)Atran.index.size() == 0;
if (empty_matrix) {
// The index/value vectors have size zero if the matrix has no
// columns. However, in the Windows build, referring to index 0 of a
// vector of size zero causes a failure, so resize to 1 to prevent
// this.
assert(Atran.num_col == 0);
Atran.index.resize(1);
Atran.value.resize(1);
}
basisfactor.setup(Atran.num_col, Atran.num_row, (HighsInt*)&Atran.start[0],
(HighsInt*)&Atran.index[0], (const double*)&Atran.value[0],
baseindex);
basisfactor.build();
for (size_t i = 0;
i < activeconstraintidx.size() + nonactiveconstraintsidx.size(); i++) {
constraintindexinbasisfactor[baseindex[i]] = i;
}
}
void Basis::rebuild() {
updatessinceinvert = 0;
constraintindexinbasisfactor.clear();
constraintindexinbasisfactor.assign(Atran.num_row + Atran.num_col, -1);
assert(nonactiveconstraintsidx.size() + activeconstraintidx.size() ==
Atran.num_row);
basisfactor.build();
for (size_t i = 0;
i < activeconstraintidx.size() + nonactiveconstraintsidx.size(); i++) {
constraintindexinbasisfactor[baseindex[i]] = i;
}
}
void Basis::report() {
printf("basis: ");
for (HighsInt a_ : activeconstraintidx) {
printf("%" HIGHSINT_FORMAT " ", a_);
}
printf(" - ");
for (HighsInt n_ : nonactiveconstraintsidx) {
printf("%" HIGHSINT_FORMAT " ", n_);
}
printf("\n");
}
// move that constraint into V section basis (will correspond to Nullspace
// from now on)
void Basis::deactivate(HighsInt conid) {
// printf("deact %" HIGHSINT_FORMAT "\n", conid);
assert(contains(activeconstraintidx, conid));
basisstatus.erase(conid);
remove(activeconstraintidx, conid);
nonactiveconstraintsidx.push_back(conid);
}
void Basis::activate(Runtime& rt, HighsInt conid, BasisStatus atlower,
HighsInt nonactivetoremove, Pricing* pricing) {
// printf("activ %" HIGHSINT_FORMAT "\n", conid);
if (!contains(activeconstraintidx, (HighsInt)conid)) {
basisstatus[conid] = atlower;
activeconstraintidx.push_back(conid);
} else {
printf("Degeneracy? constraint %" HIGHSINT_FORMAT
" already in basis\n",
conid);
exit(1);
}
// printf("drop %d\n", nonactivetoremove);
// remove non-active row from basis
HighsInt rowtoremove = constraintindexinbasisfactor[nonactivetoremove];
baseindex[rowtoremove] = conid;
remove(nonactiveconstraintsidx, nonactivetoremove);
updatebasis(rt, conid, nonactivetoremove, pricing);
if (updatessinceinvert != 0) {
constraintindexinbasisfactor[nonactivetoremove] = -1;
constraintindexinbasisfactor[conid] = rowtoremove;
}
}
void Basis::updatebasis(Runtime& rt, HighsInt newactivecon, HighsInt droppedcon,
Pricing* pricing) {
if (newactivecon == droppedcon) {
return;
}
HighsInt droppedcon_rowindex = constraintindexinbasisfactor[droppedcon];
Atran.extractcol(newactivecon, buffer_column_aq);
// column.report("col_pre_ftran");
HVector column_aq_hvec = vec2hvec(buffer_column_aq);
basisfactor.ftran(column_aq_hvec, 1.0);
// column.report("col_post_ftran");
Vector::unit(rt.instance.A.mat.num_col, droppedcon_rowindex, buffer_row_ep);
// row_ep.report("rowep_pre_btran");
HVector row_ep_hvec = vec2hvec(buffer_row_ep);
basisfactor.btran(row_ep_hvec, 1.0);
// row_ep.report("rowep_post_btran");
pricing->update_weights(hvec2vec(column_aq_hvec), hvec2vec(row_ep_hvec),
droppedcon, newactivecon);
HighsInt hint = 99999;
HighsInt row_out = droppedcon_rowindex;
updatessinceinvert++;
basisfactor.update(&column_aq_hvec, &row_ep_hvec, &row_out, &hint);
if (updatessinceinvert >= rt.settings.reinvertfrequency || hint != 99999) {
rebuild();
// printf("Hint: %d\n", hint);
// printf("reinvert\n");
}
}
Vector& Basis::btran(const Vector& rhs, Vector& target) const {
HVector rhs_hvec = vec2hvec(rhs);
basisfactor.btran(rhs_hvec, 1.0);
return hvec2vec(rhs_hvec, target);
}
Vector Basis::btran(const Vector& rhs) const {
HVector rhs_hvec = vec2hvec(rhs);
basisfactor.btran(rhs_hvec, 1.0);
return hvec2vec(rhs_hvec);
}
Vector& Basis::ftran(const Vector& rhs, Vector& target) const {
HVector rhs_hvec = vec2hvec(rhs);
basisfactor.ftran(rhs_hvec, 1.0);
return hvec2vec(rhs_hvec, target);
}
Vector Basis::ftran(const Vector& rhs) const {
HVector rhs_hvec = vec2hvec(rhs);
basisfactor.ftran(rhs_hvec, 1.0);
return hvec2vec(rhs_hvec);
}
Vector Basis::recomputex(const Instance& inst) {
assert(activeconstraintidx.size() == inst.num_var);
Vector rhs(inst.num_var);
for (HighsInt i = 0; i < inst.num_var; i++) {
HighsInt con = activeconstraintidx[i];
if (constraintindexinbasisfactor[con] == -1) {
printf("error\n");
}
if (basisstatus[con] == BasisStatus::ActiveAtLower) {
if (con < inst.num_con) {
rhs.value[constraintindexinbasisfactor[con]] = inst.con_lo[con];
} else {
rhs.value[constraintindexinbasisfactor[con]] =
inst.var_lo[con - inst.num_con];
}
} else {
if (con < inst.num_con) {
rhs.value[constraintindexinbasisfactor[con]] = inst.con_up[con];
// rhs.value[i] = inst.con_up[con];
} else {
rhs.value[constraintindexinbasisfactor[con]] =
inst.var_up[con - inst.num_con];
// rhs.value[i] = inst.var_up[con - inst.num_con];
}
}
rhs.index[i] = i;
rhs.num_nz++;
}
HVector rhs_hvec = vec2hvec(rhs);
basisfactor.btran(rhs_hvec, 1.0);
return hvec2vec(rhs_hvec);
}
// void Basis::write(std::string filename) {
// FILE* file = fopen(filename.c_str(), "w");
// fprintf(file, "%lu %lu\n", activeconstraintidx.size(),
// nonactiveconstraintsidx.size()); for (HighsInt i=0;
// i<activeconstraintidx.size(); i++) {
// fprintf(file, "%" HIGHSINT_FORMAT " %" HIGHSINT_FORMAT "\n",
// activeconstraintidx[i], (HighsInt)rowstatus[i]);
// }
// for (HighsInt i=0; i<nonactiveconstraintsidx.size(); i++) {
// fprintf(file, "%" HIGHSINT_FORMAT " %" HIGHSINT_FORMAT "\n",
// nonactiveconstraintsidx[i], (HighsInt)rowstatus[i]);
// }
// // TODO
// fclose(file);
// }
| 30.145749
| 80
| 0.668278
|
WTFHCN
|
f514f43dfc4e379bd2576de01936369eed88d2a8
| 14,357
|
hpp
|
C++
|
src/3rd party/boost/boost/multi_array/view.hpp
|
OLR-xray/OLR-3.0
|
b6a9bb2a0c1fb849b8c6cea2e831e1ceea5cc611
|
[
"Apache-2.0"
] | 8
|
2016-01-25T20:18:51.000Z
|
2019-03-06T07:00:04.000Z
|
src/3rd party/boost/boost/multi_array/view.hpp
|
OLR-xray/OLR-3.0
|
b6a9bb2a0c1fb849b8c6cea2e831e1ceea5cc611
|
[
"Apache-2.0"
] | null | null | null |
src/3rd party/boost/boost/multi_array/view.hpp
|
OLR-xray/OLR-3.0
|
b6a9bb2a0c1fb849b8c6cea2e831e1ceea5cc611
|
[
"Apache-2.0"
] | 3
|
2016-02-14T01:20:43.000Z
|
2021-02-03T11:19:11.000Z
|
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef BOOST_MULTI_ARRAY_VIEW_RG071301_HPP
#define BOOST_MULTI_ARRAY_VIEW_RG071301_HPP
//
// view.hpp - code for creating "views" of array data.
//
#include "boost/multi_array/base.hpp"
#include "boost/multi_array/concept_checks.hpp"
#include "boost/multi_array/iterator.hpp"
#include "boost/multi_array/storage_order.hpp"
#include "boost/multi_array/subarray.hpp"
#include "boost/multi_array/algorithm.hpp"
#include "boost/array.hpp"
#include "boost/limits.hpp"
#include <algorithm>
#include <cstddef>
#include <functional>
#include <numeric>
namespace boost {
namespace detail {
namespace multi_array {
// TPtr = const T* defaulted in base.hpp
template <typename T, std::size_t NumDims, typename TPtr>
class const_multi_array_view :
public boost::detail::multi_array::multi_array_impl_base<T,NumDims>
{
typedef boost::detail::multi_array::multi_array_impl_base<T,NumDims> super_type;
public:
typedef typename super_type::value_type value_type;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
typedef typename super_type::size_type size_type;
typedef typename super_type::difference_type difference_type;
typedef typename super_type::index index;
typedef typename super_type::extent_range extent_range;
// template typedefs
template <std::size_t NDims>
struct const_array_view {
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
};
template <std::size_t NDims>
struct array_view {
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
};
template <typename OPtr>
const_multi_array_view(const
const_multi_array_view<T,NumDims,OPtr>& other) :
base_(other.base_), origin_offset_(other.origin_offset_),
num_elements_(other.num_elements_), extent_list_(other.extent_list_),
stride_list_(other.stride_list_), index_base_list_(other.index_base_list_)
{ }
template <class BaseList>
void reindex(const BaseList& values) {
boost::copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
origin_offset_ =
this->calculate_indexing_offset(stride_list_,index_base_list_);
}
void reindex(index value) {
index_base_list_.assign(value);
origin_offset_ =
this->calculate_indexing_offset(stride_list_,index_base_list_);
}
size_type num_dimensions() const { return NumDims; }
size_type size() const { return extent_list_.front(); }
size_type max_size() const { return num_elements(); }
bool empty() const { return size() == 0; }
const size_type* shape() const {
return extent_list_.data();
}
const index* strides() const {
return stride_list_.data();
}
const T* origin() const { return base_+origin_offset_; }
size_type num_elements() const { return num_elements_; }
const index* index_bases() const {
return index_base_list_.data();
}
template <typename IndexList>
const element& operator()(IndexList indices) const {
return super_type::access_element(boost::type<const element&>(),
origin(),
indices,strides());
}
// Only allow const element access
const_reference operator[](index idx) const {
return super_type::access(boost::type<const_reference>(),
idx,origin(),
shape(),strides(),
index_bases());
}
// see generate_array_view in base.hpp
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename const_array_view<NDims>::type
operator[](const boost::detail::multi_array::
index_gen<NumDims,NDims>& indices)
const {
typedef typename const_array_view<NDims>::type return_type;
return
super_type::generate_array_view(boost::type<return_type>(),
indices,
shape(),
strides(),
index_bases(),
origin());
}
const_iterator begin() const {
return const_iterator(const_iter_base(*index_bases(),origin(),
shape(),strides(),index_bases()));
}
const_iterator end() const {
return const_iterator(const_iter_base(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases()));
}
const_reverse_iterator rbegin() const {
return const_reverse_iterator(end());
}
const_reverse_iterator rend() const {
return const_reverse_iterator(begin());
}
template <typename OPtr>
bool operator==(const
const_multi_array_view<T,NumDims,OPtr>& rhs)
const {
if(std::equal(extent_list_.begin(),
extent_list_.end(),
rhs.extent_list_.begin()))
return std::equal(begin(),end(),rhs.begin());
else return false;
}
template <typename OPtr>
bool operator<(const
const_multi_array_view<T,NumDims,OPtr>& rhs)
const {
return std::lexicographical_compare(begin(),end(),rhs.begin(),rhs.end());
}
template <typename OPtr>
bool operator!=(const
const_multi_array_view<T,NumDims,OPtr>& rhs)
const {
return !(*this == rhs);
}
template <typename OPtr>
bool operator>(const
const_multi_array_view<T,NumDims,OPtr>& rhs)
const {
return rhs < *this;
}
template <typename OPtr>
bool operator<=(const
const_multi_array_view<T,NumDims,OPtr>& rhs)
const {
return !(*this > rhs);
}
template <typename OPtr>
bool operator>=(const
const_multi_array_view<T,NumDims,OPtr>& rhs)
const {
return !(*this < rhs);
}
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
protected:
template <typename,std::size_t> friend class multi_array_impl_base;
template <typename,std::size_t,typename> friend class const_multi_array_view;
#else
public: // should be protected
#endif
// This constructor is used by multi_array_impl_base::generate_array_view
// to create strides
template <typename ExtentList, typename Index>
explicit const_multi_array_view(TPtr base,
const ExtentList& extents,
const boost::array<Index,NumDims>& strides):
base_(base), origin_offset_(0) {
index_base_list_.assign(0);
// Get the extents and strides
boost::copy_n(extents.begin(),NumDims,extent_list_.begin());
boost::copy_n(strides.begin(),NumDims,stride_list_.begin());
// Calculate the array size
num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(),
size_type(1),std::multiplies<size_type>());
assert(num_elements_ != 0);
}
typedef boost::array<size_type,NumDims> size_list;
typedef boost::array<index,NumDims> index_list;
TPtr base_;
index origin_offset_;
size_type num_elements_;
size_list extent_list_;
index_list stride_list_;
index_list index_base_list_;
private:
// const_multi_array_view cannot be assigned to (no deep copies!)
const_multi_array_view& operator=(const const_multi_array_view& other);
};
template <typename T, std::size_t NumDims>
class multi_array_view :
public const_multi_array_view<T,NumDims,T*>
{
typedef const_multi_array_view<T,NumDims,T*> super_type;
public:
typedef typename super_type::value_type value_type;
typedef typename super_type::reference reference;
typedef typename super_type::iterator iterator;
typedef typename super_type::iter_base iter_base;
typedef typename super_type::reverse_iterator reverse_iterator;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
typedef typename super_type::size_type size_type;
typedef typename super_type::difference_type difference_type;
typedef typename super_type::index index;
typedef typename super_type::extent_range extent_range;
// template typedefs
template <std::size_t NDims>
struct const_array_view {
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
};
template <std::size_t NDims>
struct array_view {
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
};
// Assignment from other ConstMultiArray types.
template <typename ConstMultiArray>
multi_array_view& operator=(const ConstMultiArray& other) {
function_requires<
boost::detail::multi_array::
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
// make sure the dimensions agree
assert(other.num_dimensions() == this->num_dimensions());
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
// iterator-based copy
std::copy(other.begin(),other.end(),begin());
return *this;
}
multi_array_view& operator=(const multi_array_view& other) {
if (&other != this) {
// make sure the dimensions agree
assert(other.num_dimensions() == this->num_dimensions());
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
// iterator-based copy
std::copy(other.begin(),other.end(),begin());
}
return *this;
}
element* origin() { return this->base_+this->origin_offset_; }
template <class IndexList>
element& operator()(const IndexList& indices) {
return super_type::access_element(boost::type<element&>(),
origin(),
indices,this->strides());
}
reference operator[](index idx) {
return super_type::access(boost::type<reference>(),
idx,origin(),
this->shape(),this->strides(),
this->index_bases());
}
// see generate_array_view in base.hpp
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename array_view<NDims>::type
operator[](const boost::detail::multi_array::
index_gen<NumDims,NDims>& indices) {
typedef typename array_view<NDims>::type return_type;
return
super_type::generate_array_view(boost::type<return_type>(),
indices,
this->shape(),
this->strides(),
this->index_bases(),
origin());
}
iterator begin() {
return iterator(iter_base(*this->index_bases(),origin(),
this->shape(),this->strides(),
this->index_bases()));
}
iterator end() {
return iterator(iter_base(*this->index_bases()+*this->shape(),origin(),
this->shape(),this->strides(),
this->index_bases()));
}
reverse_iterator rbegin() {
return reverse_iterator(end());
}
reverse_iterator rend() {
return reverse_iterator(begin());
}
// Using declarations don't seem to work for g++
// These are the proxies to work around this.
const element* origin() const { return super_type::origin(); }
template <class IndexList>
const element& operator()(const IndexList& indices) const {
return super_type::operator()(indices);
}
const_reference operator[](index idx) const {
return super_type::operator[](idx);
}
// see generate_array_view in base.hpp
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename const_array_view<NDims>::type
operator[](const boost::detail::multi_array::
index_gen<NumDims,NDims>& indices)
const {
return super_type::operator[](indices);
}
const_iterator begin() const {
return super_type::begin();
}
const_iterator end() const {
return super_type::end();
}
const_reverse_iterator rbegin() const {
return super_type::rbegin();
}
const_reverse_iterator rend() const {
return super_type::rend();
}
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
private:
template <typename,std::size_t> friend class multi_array_impl_base;
#else
public: // should be private
#endif
// constructor used by multi_array_impl_base::generate_array_view to
// generate array views
template <typename ExtentList, typename Index>
explicit multi_array_view(T* base,
const ExtentList& extents,
const boost::array<Index,NumDims>& strides) :
super_type(base,extents,strides) { }
};
} // namespace multi_array
} // namespace detail
//
// traits classes to get array_view types
//
template <typename Array, int N>
class array_view_gen {
typedef typename Array::element element;
public:
typedef boost::detail::multi_array::multi_array_view<element,N> type;
};
template <typename Array, int N>
class const_array_view_gen {
typedef typename Array::element element;
public:
typedef boost::detail::multi_array::const_multi_array_view<element,N> type;
};
} // namespace boost
#endif // BOOST_MULTI_ARRAY_VIEW_RG071301_HPP
| 31.415755
| 82
| 0.667479
|
OLR-xray
|
f51532f2627acb7402af27d8983ef8707db01a97
| 1,689
|
cpp
|
C++
|
src/service/ClockService.cpp
|
NoUITeam/TinyAndPretty
|
06cb20f1a2381fc2196674255a00fcba416ce830
|
[
"Apache-2.0"
] | null | null | null |
src/service/ClockService.cpp
|
NoUITeam/TinyAndPretty
|
06cb20f1a2381fc2196674255a00fcba416ce830
|
[
"Apache-2.0"
] | null | null | null |
src/service/ClockService.cpp
|
NoUITeam/TinyAndPretty
|
06cb20f1a2381fc2196674255a00fcba416ce830
|
[
"Apache-2.0"
] | 2
|
2022-03-10T18:14:02.000Z
|
2022-03-14T15:39:59.000Z
|
#include <service/ClockSys.h>
using namespace UTILSTD;
def_HttpEntry(API_Clock , req) {
Json j; // used for response
std::string_view action { req.queryParam("action") };
CONSOLE_LOG(true,"* api/clock called [action:%s]\n",action.data());
/* Start listening server broadcast Notification */
if (action == "c") {
j.push_back({"code" , TimeStatus::DUP}); // for
j.push_back({"msg" , "Connection Duplication!"});
return Timer::createComet(req ,
new JsonResponse{j});
/* Query Server Clock INFO */
} else if (action == "q") {
auto t_table = Timer::getVirtualTime();
j.push_back({"code" , TimeStatus::SUCC});
j.push_back({"msg" , "Query Successfully!"});
j.push_back({"data" , {
{"ratio" , (int)Timer::getTimeLineRate()} ,
{"year" , t_table[0]} ,
{"mon" , t_table[1]} ,
{"day" , t_table[2]} ,
{"week" , t_table[3]} ,
{"hour" , t_table[4]} ,
{"min" , t_table[5]} ,
{"sec" , t_table[6]}
}});
return new JsonResponse{j};
/* Modify time speed , and inform all online user*/
} else if (action == "m") {
Timer::changeTimeLineRate(
std::stoi(req.queryParam("rate").data())
);
{ // broadcast to all alive client;
Json elc;
elc.push_back({"code" , TimeStatus::BROAD});
elc.push_back({"msg" , "Time Rate Changed!"});
Timer::launchBroadCast(
new JsonResponse{elc}
);
}
j.push_back({"code" , TimeStatus::SUCC});
j.push_back({"msg" , "Modify Successfully!"});
return new JsonResponse{j};
/* No 'action' param */
} else {
j.push_back({"code" , TimeStatus::ERR});
j.push_back({"msg" , "Params Error:No 'action'"});
return new JsonResponse{j , HTTP_STATUS_400};
}
}
| 25.984615
| 68
| 0.6045
|
NoUITeam
|
f515367635491b966b97ec0d962ca8fc70091f36
| 31,374
|
cc
|
C++
|
mindspore/ccsrc/ir/func_graph.cc
|
TommyLike/mindspore
|
401dabb786a9097d6dd84f391657d266b04e9a37
|
[
"Apache-2.0"
] | 1
|
2020-05-23T07:08:46.000Z
|
2020-05-23T07:08:46.000Z
|
mindspore/ccsrc/ir/func_graph.cc
|
liyong126/mindspore
|
930a1fb0a8fa9432025442c4f4732058bb7af592
|
[
"Apache-2.0"
] | 7
|
2020-03-30T08:31:56.000Z
|
2020-04-01T09:54:39.000Z
|
mindspore/ccsrc/ir/func_graph.cc
|
liyong126/mindspore
|
930a1fb0a8fa9432025442c4f4732058bb7af592
|
[
"Apache-2.0"
] | 1
|
2020-03-30T17:07:43.000Z
|
2020-03-30T17:07:43.000Z
|
/**
* This is the C++ adaptation and derivative work of Myia (https://github.com/mila-iqia/myia/).
*
* Copyright 2019 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ir/func_graph.h"
#include <algorithm>
#include <sstream>
#include <utility>
#include "ir/manager.h"
#include "ir/func_graph_cloner.h"
#include "operator/ops.h"
#include "utils/ordered_set.h"
#include "pipeline/static_analysis/static_analysis.h"
#include "pipeline/static_analysis/abstract_function.h"
#include "debug/anf_ir_dump.h"
#include "debug/trace.h"
#include "debug/draw.h"
#include "debug/label.h"
namespace mindspore {
using mindspore::abstract::AbstractFunction;
using mindspore::abstract::AbstractFunctionPtr;
using mindspore::abstract::AnalysisContextPtr;
using mindspore::abstract::PrimitiveAbstractClosure;
using mindspore::abstract::VirtualAbstractClosure;
/*
* Methods of Graph
*/
FuncGraph::FuncGraph()
: flags_(),
transforms_(),
parameter_default_value_(),
parameters_(),
has_vararg_(false),
has_kwarg_(false),
kwonlyargs_count_(0),
hyper_param_count_(0),
is_generated_(false),
return_(nullptr),
manager_(std::weak_ptr<FuncGraphManager>()) {
debug_info_ = std::make_shared<GraphDebugInfo>();
}
AbstractFunctionPtr FuncGraph::abstract() {
AbstractBasePtrList args_spec_list;
for (auto& p : parameters_) {
MS_EXCEPTION_IF_NULL(p);
if (p->abstract() == nullptr) {
MS_LOG(ERROR) << "error!!";
return nullptr;
}
args_spec_list.push_back(p->abstract());
}
if (nullptr == output()) {
MS_LOG(ERROR) << "error func graph no output";
return nullptr;
}
return std::make_shared<VirtualAbstractClosure>(args_spec_list, output()->abstract());
}
abstract::AbstractBasePtr FuncGraph::MakeAbstractClosure(const abstract::AnalysisContextPtr& context) {
AnalysisContextPtr temp_context = context;
if (temp_context == nullptr) {
temp_context = abstract::AnalysisContext::DummyContext();
}
return std::make_shared<abstract::FuncGraphAbstractClosure>(shared_from_base<FuncGraph>(), temp_context);
}
AnfNodePtr FuncGraph::output() const {
// If return value is set, return should have two inputs.
if (return_ != nullptr && return_->inputs().size() == 2) {
return return_->input(1);
} else {
// If not set yet, return nullptr.
return nullptr;
}
}
void FuncGraph::set_output(const AnfNodePtr& value, bool force_new_ret) {
if (force_new_ret || return_ == nullptr) {
std::vector<AnfNodePtr> params({NewValueNode(prim::kPrimReturn), value});
FuncGraphPtr this_graph = shared_from_base<FuncGraph>();
return_ = this_graph->NewCNode(params);
} else {
if (manager_.lock()) {
manager_.lock()->SetEdge(return_, 1, value);
} else {
return_->set_input(1, value);
}
}
return_->set_abstract(value->abstract());
AnfNodePtr input0 = return_->input(0);
PrimitivePtr return_prim = prim::kPrimReturn;
auto f = std::make_shared<PrimitiveAbstractClosure>(return_prim, input0);
input0->set_abstract(f);
}
ParameterPtr FuncGraph::add_parameter() {
FuncGraphPtr this_func_graph = shared_from_base<FuncGraph>();
ParameterPtr p = std::make_shared<Parameter>(this_func_graph);
add_parameter(p);
return p;
}
void FuncGraph::add_parameter(const ParameterPtr& p) {
if (manager_.lock()) {
std::vector<AnfNodePtr> new_params = parameters_;
new_params.push_back(p);
manager_.lock()->SetParameters(shared_from_base<FuncGraph>(), new_params);
} else {
parameters_.push_back(p);
}
}
ParameterPtr FuncGraph::AddWeightParameter(const std::string& name) {
FuncGraphPtr this_graph = shared_from_base<FuncGraph>();
ParameterPtr p = std::make_shared<Parameter>(this_graph);
p->set_name(name);
p->debug_info()->set_name(name);
std::vector<AnfNodePtr> new_params = parameters_;
// append parameter
new_params.push_back(p);
if (manager_.lock()) {
manager_.lock()->SetParameters(shared_from_base<FuncGraph>(), new_params);
} else {
parameters_.push_back(p);
}
hyper_param_count_++;
return p;
}
bool FuncGraph::has_flag(const std::string& flag) {
if (flags_.count(flag)) {
return flags_[flag];
}
return false;
}
CNodePtr FuncGraph::NewCNode(const std::vector<AnfNodePtr>& inputs) {
CNodePtr cnode = std::make_shared<CNode>(inputs, shared_from_base<FuncGraph>());
if (has_flag(GRAPH_FLAG_HAS_EFFECT)) {
order_.push_back(cnode);
MS_LOG(INFO) << "Graph: " << ToString() << ", push back " << cnode->DebugString() << " in order.";
}
return cnode;
}
CNodePtr FuncGraph::NewCNodeWithScope(const std::vector<AnfNodePtr>& inputs, const ScopePtr& scope) {
CNodePtr app = NewCNode(inputs);
app->set_scope(scope);
return app;
}
void FuncGraph::DumpCNodeList() {
MS_LOG(INFO) << "FuncGraph " << ToString() << " has following CNode in code order:";
for (const auto& cnode : order_) {
MS_LOG(INFO) << cnode->DebugString();
}
}
std::string FuncGraph::ToString() const {
return mindspore::label_manage::Label(const_cast<FuncGraph*>(this)->shared_from_base<FuncGraph>()->debug_info());
}
GraphDebugInfoPtr FuncGraph::debug_info() {
MS_EXCEPTION_IF_NULL(this->debug_info_);
if (this->debug_info_->get_graph() == nullptr) {
this->debug_info_->set_graph(shared_from_base<FuncGraph>());
}
return this->debug_info_;
}
const AnfNodeSet& FuncGraph::nodes() {
auto mng = manager_.lock();
MS_EXCEPTION_IF_NULL(mng);
auto& nodes = mng->nodes();
return nodes[shared_from_base<FuncGraph>()];
}
const AnfNodeCounterMap& FuncGraph::value_nodes() {
auto mng = manager_.lock();
MS_EXCEPTION_IF_NULL(mng);
auto& cts = mng->valuenodes();
return cts[shared_from_base<FuncGraph>()];
}
const AnfNodeCounterMap& FuncGraph::free_variables_direct() {
auto mng = manager_.lock();
MS_EXCEPTION_IF_NULL(mng);
auto& fv_direct = mng->free_variables_direct();
return fv_direct[shared_from_base<FuncGraph>()];
}
const BaseRefCounterMap& FuncGraph::free_variables_total() {
auto mng = manager_.lock();
MS_EXCEPTION_IF_NULL(mng);
auto& fv_total = mng->free_variables_total();
return fv_total[shared_from_base<FuncGraph>()];
}
std::vector<AnfNodePtr> FuncGraph::free_variables_nodes() {
std::vector<AnfNodePtr> nodes;
const auto& fv_total = this->free_variables_total();
for (auto& p : fv_total) {
auto key = p.first;
if (utils::isa<AnfNodePtr>(key)) {
nodes.push_back(utils::cast<AnfNodePtr>(key));
}
}
return nodes;
}
std::vector<FuncGraphPtr> FuncGraph::free_variables_func_graphs() {
std::vector<FuncGraphPtr> func_graphs;
const auto& fv_total = this->free_variables_total();
for (auto& p : fv_total) {
auto key = p.first;
if (utils::isa<FuncGraphPtr>(key)) {
func_graphs.push_back(utils::cast<FuncGraphPtr>(key));
}
}
return func_graphs;
}
const FuncGraphCounterMap& FuncGraph::func_graphs_used() {
auto mng = manager_.lock();
MS_EXCEPTION_IF_NULL(mng);
auto& used = mng->func_graphs_used();
return used[shared_from_base<FuncGraph>()];
}
const FuncGraphSet& FuncGraph::func_graphs_used_total() {
auto mng = manager_.lock();
MS_EXCEPTION_IF_NULL(mng);
auto& used = mng->func_graphs_used_total(shared_from_base<FuncGraph>());
return used;
}
const FuncGraphCounterMap& FuncGraph::func_graph_users() {
auto mng = manager_.lock();
MS_EXCEPTION_IF_NULL(mng);
auto& users = mng->func_graph_users();
return users[shared_from_base<FuncGraph>()];
}
const AnfNodeCounterMap& FuncGraph::func_graph_user_cnodes() {
auto mng = manager_.lock();
MS_EXCEPTION_IF_NULL(mng);
auto& users = mng->func_graph_user_cnodes();
return users[shared_from_base<FuncGraph>()];
}
FuncGraphPtr FuncGraph::parent() {
// report the bug early.
if (manager_.lock() == nullptr) {
MS_LOG(EXCEPTION) << "BUG: no manager for this func graph: " << ToString()
<< " NodeInfo: " << trace::GetDebugInfo(debug_info());
}
auto mng = manager_.lock();
MS_EXCEPTION_IF_NULL(mng);
return mng->parent(shared_from_base<FuncGraph>());
}
const FuncGraphSet& FuncGraph::children() {
auto mng = manager_.lock();
MS_EXCEPTION_IF_NULL(mng);
return mng->children(shared_from_base<FuncGraph>());
}
const FuncGraphSet& FuncGraph::scope() {
auto mng = manager_.lock();
MS_EXCEPTION_IF_NULL(mng);
return mng->scopes(shared_from_base<FuncGraph>());
}
bool FuncGraph::recursive() {
auto mng = manager_.lock();
MS_EXCEPTION_IF_NULL(mng);
return mng->recursive(shared_from_base<FuncGraph>());
}
std::shared_ptr<std::list<FuncGraphPtr>> FuncGraph::recursive_graphs() {
auto mng = manager_.lock();
MS_EXCEPTION_IF_NULL(mng);
return mng->recursive_graphs(shared_from_base<FuncGraph>());
}
void FuncGraph::DumpFuncGraph(const std::string& path) { draw::Draw(path + ".dot", shared_from_base<FuncGraph>()); }
AnfNodePtr FuncGraph::GetDefaultValueByName(const std::string& name) {
auto itr = this->parameter_default_value_.find(name);
if (itr == parameter_default_value_.end()) {
return nullptr;
}
auto default_value = itr->second;
if (default_value == nullptr) {
MS_LOG(EXCEPTION) << "Graph parameter " << name << " not exist";
}
if (IsValueNode<NullObj>(default_value)) {
return nullptr;
}
return default_value;
}
// set the default values
void FuncGraph::SetDefaultValues(const std::vector<std::string>& name_list, const std::vector<AnfNodePtr>& value_list) {
auto all_is_null = std::all_of(value_list.begin(), value_list.end(),
[](const AnfNodePtr& node) { return IsValueNode<NullObj>(node); });
if (value_list.empty()) {
all_is_null = true;
}
for (size_t i = 0; i < name_list.size(); ++i) {
if (!all_is_null) {
this->parameter_default_value_[name_list[i]] = value_list[i];
}
}
}
void FuncGraph::ClearDefaultValues() { parameter_default_value_.clear(); }
size_t FuncGraph::GetDefaultValueCount() {
int null_count =
std::count_if(parameter_default_value_.begin(), parameter_default_value_.end(),
[](const std::pair<std::string, AnfNodePtr>& pair) { return IsValueNode<NullObj>(pair.second); });
return parameter_default_value_.size() - IntToSize(null_count);
}
AnfNodePtr FuncGraph::GetVariableArgParameter() {
if (!has_vararg_) {
return nullptr;
}
if (has_kwarg_) {
if (parameters_.size() < hyper_param_count_ + 2) {
MS_LOG(EXCEPTION) << "Length of parameters is " << parameters_.size() << ", hyper_param_count is "
<< hyper_param_count_ << ", parameters is less than 2 + hyper_param_count";
}
return parameters_[parameters_.size() - hyper_param_count_ - 2];
}
if (parameters_.size() < hyper_param_count_ + 1) {
MS_LOG(EXCEPTION) << "Length of parameters is " << parameters_.size() << ", hyper_param_count is "
<< hyper_param_count_ << ", parameters is less than 1 + hyper_param_count";
}
return parameters_[parameters_.size() - hyper_param_count_ - 1];
}
std::string FuncGraph::GetVariableArgName() {
if (!has_vararg_) {
return "";
}
if (has_kwarg_) {
if (parameters_.size() < hyper_param_count_ + 2) {
MS_LOG(EXCEPTION) << "Length of parameters is " << parameters_.size() << ", hyper_param_count is "
<< hyper_param_count_ << ", parameters is less than 2 + hyper_param_count";
}
return parameters_[parameters_.size() - hyper_param_count_ - 2]->cast<ParameterPtr>()->name();
}
if (parameters_.size() < hyper_param_count_ + 1) {
MS_LOG(EXCEPTION) << "Length of parameters is " << parameters_.size() << ", hyper_param_count is "
<< hyper_param_count_ << ", parameters is less than 1 + hyper_param_count";
}
return parameters_[parameters_.size() - hyper_param_count_ - 1]->cast<ParameterPtr>()->name();
}
AnfNodePtr FuncGraph::GetVariableKwargParameter() {
if (has_kwarg_) {
if (parameters_.size() < hyper_param_count_ + 1) {
MS_LOG(EXCEPTION) << "Length of parameters is " << parameters_.size() << ", hyper_param_count is "
<< hyper_param_count_ << ", parameters is less than 1 + hyper_param_count";
}
return parameters_[parameters_.size() - hyper_param_count_ - 1];
}
return nullptr;
}
std::string FuncGraph::GetVariableKwargName() {
if (has_kwarg_) {
if (parameters_.size() < hyper_param_count_ + 1) {
MS_LOG(EXCEPTION) << "Length of parameters is " << parameters_.size() << ", hyper_param_count is "
<< hyper_param_count_ << ", parameters is less than 1 + hyper_param_count";
}
return parameters_[parameters_.size() - hyper_param_count_ - 1]->cast<ParameterPtr>()->name();
}
return "";
}
int FuncGraph::GetPositionalArgsCount() const {
int count = SizeToInt(parameters_.size());
if (has_kwarg_) {
count--;
}
if (has_vararg_) {
count--;
}
return count - kwonlyargs_count_ - SizeToInt(hyper_param_count_);
}
AnfNodePtr FuncGraph::GetParameterByName(const std::string& name) {
for (size_t i = 0; i < parameters_.size(); ++i) {
MS_EXCEPTION_IF_NULL(parameters_[i]);
auto param_cast = parameters_[i]->cast<ParameterPtr>();
MS_EXCEPTION_IF_NULL(param_cast);
if (param_cast->name() == name) {
return parameters_[i];
}
}
return nullptr;
}
void FuncGraph::GenerateVarParams(const FuncGraphPtr& specialized_graph,
std::vector<AnfNodePtr>* specialized_parameter_list,
std::unordered_map<AnfNodePtr, AnfNodePtr>* repl_nodes, int variable_args_count,
int pos_args_input_count) {
// if there is variable argument, pass the input arguments that does not match positional args to it as a tuple
if (specialized_graph->has_vararg()) {
TraceManager::DebugTrace(
std::make_shared<TraceGenerateVarArg>(specialized_graph->GetVariableArgParameter()->debug_info()));
std::vector<AnfNodePtr> var_param_tuple_nodes;
var_param_tuple_nodes.push_back(NewValueNode(prim::kPrimMakeTuple));
if (variable_args_count < 0) {
MS_LOG(EXCEPTION) << "Function:" << this->ToString() << ", variable_args_count " << variable_args_count
<< " were given.";
}
// for python variable argument input , there is no upper limit
for (int i = 0; i < variable_args_count; ++i) {
ParameterPtr p = std::make_shared<Parameter>(specialized_graph);
std::string param_name = specialized_graph->GetVariableArgName() + std::to_string(i);
p->set_name(param_name);
MS_EXCEPTION_IF_NULL(p->debug_info());
p->debug_info()->set_name(param_name);
var_param_tuple_nodes.push_back(p);
MS_EXCEPTION_IF_NULL(specialized_parameter_list);
specialized_parameter_list->push_back(p);
}
auto var_tuple_param = specialized_graph->NewCNode(var_param_tuple_nodes);
(void)repl_nodes->emplace(specialized_graph->GetVariableArgParameter(), var_tuple_param);
TraceManager::EndTrace();
} else if (variable_args_count > 0) {
MS_LOG(EXCEPTION) << "Function:" << this->ToString() << " takes " << this->GetPositionalArgsCount()
<< " positional arguments, but " << pos_args_input_count << " were given.";
}
}
void FuncGraph::GenerateKwParams(const FuncGraphPtr& specialized_graph,
std::vector<AnfNodePtr>* specialized_parameter_list,
const std::vector<abstract::AbstractKeywordArgPtr>& kwarg_list,
std::unordered_map<AnfNodePtr, AnfNodePtr>* repl_nodes) {
std::vector<AnfNodePtr> kwarg_keys_tuple_nodes = {NewValueNode(prim::kPrimMakeTuple)};
std::vector<AnfNodePtr> kwarg_values_tuple_nodes = {NewValueNode(prim::kPrimMakeTuple)};
for (const auto& kwarg : kwarg_list) {
MS_EXCEPTION_IF_NULL(kwarg);
std::string kw_param_name = kwarg->get_key();
MS_EXCEPTION_IF_NULL(specialized_graph);
AnfNodePtr param_node = specialized_graph->GetParameterByName(kw_param_name);
// if not find correspoding parameter node
if (param_node == nullptr) {
if (!has_kwarg()) {
MS_LOG(EXCEPTION) << "Got unexpected keyword argument: " << kw_param_name;
} else {
ParameterPtr p = std::make_shared<Parameter>(specialized_graph);
std::string param_name = specialized_graph->GetVariableKwargName() + "[" + kw_param_name + "]";
MS_EXCEPTION_IF_NULL(specialized_parameter_list);
auto find_kw_arg_in_list = std::any_of(specialized_parameter_list->begin(), specialized_parameter_list->end(),
[param_name](const AnfNodePtr& node) {
MS_EXCEPTION_IF_NULL(node);
auto param = node->cast<ParameterPtr>();
return param != nullptr && param->name() == param_name;
});
if (find_kw_arg_in_list) {
MS_LOG(EXCEPTION) << "Multiply values for keyword argument:" << kw_param_name;
}
p->set_name(param_name);
p->debug_info()->set_name(param_name);
kwarg_keys_tuple_nodes.push_back(NewValueNode(kw_param_name));
auto extract_node =
specialized_graph->NewCNode({NewValueNode(prim::kPrimExtractKeywordArg), NewValueNode(kw_param_name), p});
kwarg_values_tuple_nodes.push_back(extract_node);
specialized_parameter_list->push_back(p);
}
} else {
auto node_itr = std::find(specialized_parameter_list->begin(), specialized_parameter_list->end(), param_node);
// multiply values found given for parameter
if (node_itr != specialized_parameter_list->end()) {
MS_LOG(EXCEPTION) << "Multiply values for specific argument:" << kw_param_name;
} else {
specialized_parameter_list->push_back(param_node);
auto extract_node = specialized_graph->NewCNode(
{NewValueNode(prim::kPrimExtractKeywordArg), NewValueNode(kw_param_name), param_node});
(void)repl_nodes->emplace(param_node, extract_node);
}
}
}
GenerateKwargReplNode(specialized_graph, repl_nodes, kwarg_keys_tuple_nodes, kwarg_values_tuple_nodes);
}
void FuncGraph::GenerateKwargReplNode(const FuncGraphPtr& specialized_graph,
std::unordered_map<AnfNodePtr, AnfNodePtr>* repl_nodes,
const std::vector<AnfNodePtr>& kwarg_keys_tuple_nodes,
const std::vector<AnfNodePtr>& kwarg_values_tuple_nodes) {
if (has_kwarg()) {
MS_EXCEPTION_IF_NULL(specialized_graph);
TraceManager::DebugTrace(
std::make_shared<TraceGenerateKwArg>(specialized_graph->GetVariableKwargParameter()->debug_info()));
auto make_tuple_keys = specialized_graph->NewCNode(kwarg_keys_tuple_nodes);
auto make_tuple_values = specialized_graph->NewCNode(kwarg_values_tuple_nodes);
auto make_dict_node =
specialized_graph->NewCNode({NewValueNode(prim::kPrimMakeDict), make_tuple_keys, make_tuple_values});
MS_EXCEPTION_IF_NULL(repl_nodes);
(void)repl_nodes->emplace(specialized_graph->GetVariableKwargParameter(), make_dict_node);
TraceManager::EndTrace();
}
}
bool FuncGraph::NeedGenerate(const std::vector<abstract::AbstractKeywordArgPtr>& kwarg_list) {
// if the function does not have any vararg/kwarg/kwonly/default value/kw args input
// return the original graph
if (!has_vararg() && kwonlyargs_count() == 0 && !has_kwarg() && GetDefaultValueCount() == 0 && kwarg_list.empty()) {
return false;
}
// if the graph is generated for specific input, do not need to generate again
if (is_generated()) {
return false;
}
return true;
}
void FuncGraph::GenerateDefaultValue(const FuncGraphPtr& specialized_graph,
const std::vector<AnfNodePtr>& specialized_parameter_list,
std::unordered_map<AnfNodePtr, AnfNodePtr>* repl_nodes) {
MS_EXCEPTION_IF_NULL(specialized_graph);
for (size_t i = 0; i < specialized_graph->parameters().size() - hyper_param_count(); ++i) {
auto param_node = specialized_graph->parameters()[i];
MS_EXCEPTION_IF_NULL(param_node);
auto param_name = param_node->cast<ParameterPtr>()->name();
auto node_itr = std::find(specialized_parameter_list.begin(), specialized_parameter_list.end(), param_node);
if (node_itr != specialized_parameter_list.end()) {
continue;
}
if (param_name == specialized_graph->GetVariableArgName() ||
param_name == specialized_graph->GetVariableKwargName()) {
continue;
}
auto default_value = specialized_graph->GetDefaultValueByName(param_name);
if (default_value == nullptr) {
MS_LOG(EXCEPTION) << "Miss argument input for parameter:" << param_name;
}
MS_EXCEPTION_IF_NULL(repl_nodes);
(void)repl_nodes->emplace(param_node, default_value);
}
}
FuncGraphPtr FuncGraph::GenerateGraph(const AbstractBasePtrList& args_spec_list) {
std::vector<abstract::AbstractKeywordArgPtr> kwarg_list;
size_t arguments_count = args_spec_list.size();
for (const auto& arg : args_spec_list) {
// if it is a keyword argument
MS_EXCEPTION_IF_NULL(arg);
if (arg->isa<abstract::AbstractKeywordArg>()) {
kwarg_list.push_back(dyn_cast<abstract::AbstractKeywordArg>(arg));
}
}
if (!NeedGenerate(kwarg_list)) {
return shared_from_base<FuncGraph>();
}
FuncGraphPtr specialized_graph = BasicClone(shared_from_base<FuncGraph>());
size_t kwarg_count = kwarg_list.size();
int pos_args_input_count = SizeToInt(arguments_count - kwarg_count - hyper_param_count());
int pos_args_count = std::min(pos_args_input_count, this->GetPositionalArgsCount());
int variable_args_count = pos_args_input_count - pos_args_count;
std::vector<AnfNodePtr> specialized_parameter_list;
std::unordered_map<AnfNodePtr, AnfNodePtr> repl_nodes;
// the parameters that has arg input, copy from original parameters
for (size_t i = 0; i < IntToSize(pos_args_count); ++i) {
specialized_parameter_list.push_back(specialized_graph->parameters()[i]);
}
GenerateVarParams(specialized_graph, &specialized_parameter_list, &repl_nodes, variable_args_count,
pos_args_input_count);
GenerateKwParams(specialized_graph, &specialized_parameter_list, kwarg_list, &repl_nodes);
GenerateDefaultValue(specialized_graph, specialized_parameter_list, &repl_nodes);
// append hyper parameter to specialized_parameter_list
MS_EXCEPTION_IF_NULL(specialized_graph);
auto params = specialized_graph->parameters();
(void)std::transform(params.end() - SizeToInt(hyper_param_count()), params.end(),
std::back_inserter(specialized_parameter_list), [](const AnfNodePtr& node) { return node; });
std::shared_ptr<mindspore::FuncGraphManager> manager = mindspore::Manage(specialized_graph, false);
auto tr = manager->Transact();
for (auto& node_pair : repl_nodes) {
MS_LOG(DEBUG) << "GenerateGraph replace:" << node_pair.first->DebugString() << "-"
<< node_pair.second->DebugString();
(void)tr.Replace(node_pair.first, node_pair.second);
}
tr.SetParameters(specialized_graph, specialized_parameter_list);
tr.Commit();
specialized_graph->set_has_kwarg(false);
specialized_graph->set_has_vararg(false);
specialized_graph->set_kwonlyargs_count(0);
specialized_graph->ClearDefaultValues();
specialized_graph->set_is_generate(true);
return specialized_graph;
}
void FuncGraph::add_parameter_obj_node(const AnfNodePtr& p) { paramter_obj_nodes_.push_back(p); }
std::list<CNodePtr> FuncGraph::GetOrderedCnodes(bool force_use_topo_sort) {
if (has_flag(GRAPH_FLAG_HAS_EFFECT) && !force_use_topo_sort) {
MS_LOG(DEBUG) << "Return ordered cnodes.";
return order_;
} else {
auto this_ptr = shared_from_base<FuncGraph>();
auto BelongSameGraph = std::bind(IncludeBelongGraph, this_ptr, std::placeholders::_1);
auto SuccDepends = std::bind(SuccIncludeFV, this_ptr, std::placeholders::_1);
std::list<CNodePtr> cnodes;
auto nodes = TopoSort(get_return(), SuccDepends, BelongSameGraph);
for (const auto& node : nodes) {
auto cnode = dyn_cast<CNode>(node);
if (cnode) {
cnodes.push_back(cnode);
}
}
return cnodes;
}
}
void FuncGraph::EraseUnusedNodeInOrder() {
if (has_flag(GRAPH_FLAG_HAS_EFFECT)) {
auto mng = manager_.lock();
if (mng) {
auto nodes = mng->nodes()[shared_from_base<FuncGraph>()];
// Erase unusued cnode.
for (auto it = order_.begin(); it != order_.end();) {
if (nodes.count(*it)) {
(void)it++;
} else {
MS_LOG(DEBUG) << "Remove node " << (*it)->ToString() << " in graph " << ToString() << " order.";
it = order_.erase(it);
}
}
}
}
}
void FuncGraph::EraseUnusedNodeInOrder(const AnfNodePtr& n) {
if (has_flag(GRAPH_FLAG_HAS_EFFECT) && n && n->isa<CNode>()) {
order_.remove(n->cast<CNodePtr>());
MS_LOG(DEBUG) << "Remove the node" << n->DebugString() << " from order list.";
}
}
void FuncGraph::CheckOrder() {
if (has_flag(GRAPH_FLAG_HAS_EFFECT)) {
MS_LOG(DEBUG) << "Check graph " << ToString();
for (auto it = order_.begin(); it != order_.end(); (void)it++) {
for (const auto& input_node : (*it)->inputs()) {
if (input_node && input_node->isa<CNode>() && input_node->func_graph() == shared_from_base<FuncGraph>()) {
// Need to reorder the wrong order node.
auto found = std::find(order_.begin(), it, input_node);
if (found == it) {
DumpCNodeList();
MS_LOG(EXCEPTION) << "The cnode " << (*it)->DebugString() << " order in " << ToString()
<< " doesn't obey the input denpency, "
<< "as input " << input_node->DebugString() << " is not ahead of itself.";
}
}
}
}
auto topo_sort = GetOrderedCnodes(true);
if (topo_sort.size() != order_.size()) {
DumpCNodeList();
DumpIR(ToString(), shared_from_base<FuncGraph>());
MS_LOG(INFO) << "Dump graph: " << ToString() << ".";
DumpFuncGraph(ToString());
MS_LOG(EXCEPTION) << "CNode order size " << order_.size() << " is not equal to topo sort list size "
<< topo_sort.size() << ".";
}
MS_LOG(DEBUG) << "Check order okay.";
}
}
const char kPrimHasEffect[] = "_side_effect_flag";
bool FuncGraph::HasEffect(const CNodePtr& cnode) {
auto prim = GetCNodePrimitive(cnode);
if (prim != nullptr && prim->isa<prim::DoSignaturePrimitive>()) {
auto do_sig = prim->cast<prim::DoSignaturePrimitivePtr>();
auto prim_val = do_sig->function();
if (prim_val != nullptr && prim_val->isa<Primitive>()) {
prim = prim_val->cast<PrimitivePtr>();
} else {
prim = nullptr;
}
}
if (prim != nullptr) {
auto effect_val = prim->GetAttr(kPrimHasEffect);
if (effect_val && effect_val->isa<BoolImm>()) {
auto effect_bool = GetValue<bool>(effect_val);
return effect_bool;
}
}
return false;
}
std::shared_ptr<OrderedSet<CNodePtr>> FindRoots(const std::vector<CNodePtr>& segment) {
std::shared_ptr<OrderedSet<CNodePtr>> roots = std::make_shared<OrderedSet<CNodePtr>>(segment);
for (const auto& node : segment) {
if (roots->size() == 1) {
return roots;
}
auto input_size = node->size();
for (size_t i = 0; i < input_size; i++) {
auto in_node = node->input(i);
auto in_cnode = in_node->cast<CNodePtr>();
if (in_cnode != nullptr) {
(void)roots->erase(in_cnode);
}
}
}
return roots;
}
std::shared_ptr<OrderedSet<CNodePtr>> FindLeaves(const std::vector<CNodePtr>& segment) {
std::shared_ptr<OrderedSet<CNodePtr>> nodes = std::make_shared<OrderedSet<CNodePtr>>(segment);
for (const auto& node : segment) {
if (nodes->size() == 1) {
return nodes;
}
if (IsPrimitiveCNode(node, prim::kPrimSwitch)) {
(void)nodes->erase(node);
continue;
}
auto input_size = node->size();
for (size_t i = 0; i < input_size; i++) {
auto in_node = node->input(i);
if (!in_node->isa<CNode>()) {
continue;
}
auto in_cnode = in_node->cast<CNodePtr>();
if (in_cnode != nullptr) {
if (std::find(segment.begin(), segment.end(), in_cnode) != segment.end()) {
(void)nodes->erase(node);
break;
}
}
}
}
return nodes;
}
void FuncGraph::ReleaseFullOrderToEffectOrder() {
MS_LOG(DEBUG) << "Flag has_effect " << has_flag(GRAPH_FLAG_HAS_EFFECT) << ".";
if (has_flag(GRAPH_FLAG_HAS_EFFECT)) {
std::list<AnfNodePtr> depends_order;
std::vector<CNodePtr> segment;
for (const auto& cnode : order_) {
if (IsPrimitiveCNode(cnode, prim::kPrimReturn)) {
continue;
}
if (HasEffect(cnode)) {
MS_LOG(DEBUG) << "Meet a effect node " << cnode->DebugString() << ".";
if (segment.size() > 0) {
auto roots = FindRoots(segment);
for (auto iter = roots->begin(); iter != roots->end(); (void)iter++) {
depends_order.push_back(*iter);
}
}
segment.clear();
depends_order.push_back(cnode);
} else {
MS_LOG(DEBUG) << "Meet a general node " << cnode->DebugString() << ".";
segment.push_back(cnode);
}
}
if (segment.size() > 1) {
auto roots = FindRoots(segment);
for (auto iter = roots->begin(); iter != roots->end(); (void)iter++) {
depends_order.push_back(*iter);
}
}
std::vector<AnfNodePtr> depend_inputs;
auto old_ret = output();
for (auto iter = depends_order.rbegin(); iter != depends_order.rend(); (void)iter++) {
if (*iter != old_ret) {
depend_inputs.push_back(*iter);
}
}
set_flags(GRAPH_FLAG_HAS_EFFECT, false);
set_flags(GRAPH_FLAG_EFFECT_PATIAL_ORDER, true);
if (!depend_inputs.empty()) {
SetEffectDepends(depend_inputs);
}
}
}
void FuncGraph::SetEffectDepends(const std::vector<AnfNodePtr>& depend_inputs) {
auto old_ret = output();
std::vector<AnfNodePtr> inputs{NewValueNode(prim::kPrimDepend), old_ret};
(void)inputs.insert(inputs.end(), depend_inputs.begin(), depend_inputs.end());
auto new_ret = NewCNode(inputs);
auto mng = manager();
if (mng) {
(void)mng->Replace(old_ret, new_ret);
} else {
return_->set_input(1, new_ret);
}
}
const PrimitivePtr FuncGraphTransform::func_graph_prim_ = std::make_shared<Primitive>("FuncGraph");
const char kFuncGraphFlagUndetermin[] = "Undeterminate";
} // namespace mindspore
| 37.041322
| 120
| 0.671384
|
TommyLike
|
f5168440a7bd50be36b6b0bbf912797204c8893a
| 5,934
|
hpp
|
C++
|
Source/AllProjects/CQCVoice/CQCVoice_BTSimpleCmdNodes.hpp
|
MarkStega/CQC
|
c1d0e01ec2abcaa5b8eb1899b9f0522fecee4b07
|
[
"MIT"
] | 51
|
2020-12-26T18:17:16.000Z
|
2022-03-15T04:29:35.000Z
|
Source/AllProjects/CQCVoice/CQCVoice_BTSimpleCmdNodes.hpp
|
MarkStega/CQC
|
c1d0e01ec2abcaa5b8eb1899b9f0522fecee4b07
|
[
"MIT"
] | null | null | null |
Source/AllProjects/CQCVoice/CQCVoice_BTSimpleCmdNodes.hpp
|
MarkStega/CQC
|
c1d0e01ec2abcaa5b8eb1899b9f0522fecee4b07
|
[
"MIT"
] | 4
|
2020-12-28T07:24:39.000Z
|
2021-12-29T12:09:37.000Z
|
//
// FILE NAME: CQCVoice_BTSimpleCmdNodes_.hpp
//
// AUTHOR: Dean Roddey
//
// CREATED: 01/08/2017
//
// COPYRIGHT: Charmed Quark Systems, Ltd @ 2020
//
// This software is copyrighted by 'Charmed Quark Systems, Ltd' and
// the author (Dean Roddey.) It is licensed under the MIT Open Source
// license:
//
// https://opensource.org/licenses/MIT
//
// DESCRIPTION:
//
// This is the header for some of the simpler behavior tree command nodes, which don't
// aren't part of any category sufficient to justify a separate file.
//
// CAVEATS/GOTCHAS:
//
// LOG:
//
#pragma once
#pragma CIDLIB_PACK(CIDLIBPACK)
// ---------------------------------------------------------------------------
// CLASS: TBTCmdReloadCfgNode
// PREFIX: btnode
// ---------------------------------------------------------------------------
class TBTCmdReloadCfgNode : public TBTCQCVoiceNode
{
public :
// -------------------------------------------------------------------
// Constructors and Destructor
// -------------------------------------------------------------------
TBTCmdReloadCfgNode
(
const TString& strPath
, const TString& strName
);
TBTCmdReloadCfgNode(const TBTCmdReloadCfgNode&) = delete;
~TBTCmdReloadCfgNode();
// -------------------------------------------------------------------
// Public operators
// -------------------------------------------------------------------
TBTCmdReloadCfgNode& operator=(const TBTCmdReloadCfgNode&) = delete;
// -------------------------------------------------------------------
// Public, virtual methods
// -------------------------------------------------------------------
tCIDAI::ENodeStates eRun
(
TAIBehaviorTree& btreeOwner
) override;
};
// ---------------------------------------------------------------------------
// CLASS: TBTCmdSetItToNumNode
// PREFIX: btnode
// ---------------------------------------------------------------------------
class TBTCmdSetItToNumNode : public TBTCQCVoiceNode
{
public :
// -------------------------------------------------------------------
// Constructors and Destructor
// -------------------------------------------------------------------
TBTCmdSetItToNumNode
(
const TString& strPath
, const TString& strName
);
TBTCmdSetItToNumNode(const TBTCmdSetItToNumNode&) = delete;
~TBTCmdSetItToNumNode();
// -------------------------------------------------------------------
// Public operators
// -------------------------------------------------------------------
TBTCmdSetItToNumNode& operator=(const TBTCmdSetItToNumNode&) = delete;
// -------------------------------------------------------------------
// Public, virtual methods
// -------------------------------------------------------------------
tCIDAI::ENodeStates eRun
(
TAIBehaviorTree& btreeOwner
) override;
};
// ---------------------------------------------------------------------------
// CLASS: TBTCmdSetRoomModeNode
// PREFIX: btnode
// ---------------------------------------------------------------------------
class TBTCmdSetRoomModeNode : public TBTCQCVoiceNode
{
public :
// -------------------------------------------------------------------
// Constructors and Destructor
// -------------------------------------------------------------------
TBTCmdSetRoomModeNode
(
const TString& strPath
, const TString& strName
);
TBTCmdSetRoomModeNode(const TBTCmdSetRoomModeNode&) = delete;
~TBTCmdSetRoomModeNode();
// -------------------------------------------------------------------
// Public operators
// -------------------------------------------------------------------
TBTCmdSetRoomModeNode& operator=(const TBTCmdSetRoomModeNode&) = delete;
// -------------------------------------------------------------------
// Public, virtual methods
// -------------------------------------------------------------------
tCIDAI::ENodeStates eRun
(
TAIBehaviorTree& btreeOwner
) override;
};
// ---------------------------------------------------------------------------
// CLASS: TBTCmdTurnItOffOnNode
// PREFIX: btnode
// ---------------------------------------------------------------------------
class TBTCmdTurnItOffOnNode : public TBTCQCVoiceNode
{
public :
// -------------------------------------------------------------------
// Constructors and Destructor
// -------------------------------------------------------------------
TBTCmdTurnItOffOnNode
(
const TString& strPath
, const TString& strName
);
TBTCmdTurnItOffOnNode(const TBTCmdTurnItOffOnNode&) = delete;
~TBTCmdTurnItOffOnNode();
// -------------------------------------------------------------------
// Public operators
// -------------------------------------------------------------------
TBTCmdTurnItOffOnNode& operator=(const TBTCmdTurnItOffOnNode&) = delete;
// -------------------------------------------------------------------
// Public, virtual methods
// -------------------------------------------------------------------
tCIDAI::ENodeStates eRun
(
TAIBehaviorTree& btreeOwner
) override;
};
#pragma CIDLIB_POPPACK
| 32.966667
| 87
| 0.34058
|
MarkStega
|
f518590f0e1db5be786d907b41df8b96a8d5605c
| 2,750
|
cpp
|
C++
|
pkg/Bfdp/source/Data/Tristate.cpp
|
dpkristensen/bfdm
|
1fdbdb89263b35b5ecd3bd7e24bce700910b38f9
|
[
"BSD-3-Clause"
] | 1
|
2018-07-27T17:20:59.000Z
|
2018-07-27T17:20:59.000Z
|
pkg/Bfdp/source/Data/Tristate.cpp
|
dpkristensen/bfdm
|
1fdbdb89263b35b5ecd3bd7e24bce700910b38f9
|
[
"BSD-3-Clause"
] | 10
|
2018-07-28T03:21:05.000Z
|
2019-02-21T07:09:36.000Z
|
pkg/Bfdp/source/Data/Tristate.cpp
|
dpkristensen/bfdm
|
1fdbdb89263b35b5ecd3bd7e24bce700910b38f9
|
[
"BSD-3-Clause"
] | null | null | null |
/**
BFDP Data Tristate Definitions
Copyright 2019, Daniel Kristensen, Garmin Ltd, or its subsidiaries.
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 holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// Base Includes
#include "Bfdp/Data/Tristate.hpp"
namespace Bfdp
{
namespace Data
{
Tristate::Tristate()
: mValue( Unset )
{
}
Tristate::Tristate
(
bool const aValue
)
: mValue( static_cast< char >( aValue ? True : False ) )
{
}
bool Tristate::IsFalse() const
{
return mValue == False;
}
bool Tristate::IsSet() const
{
return mValue != Unset;
}
bool Tristate::IsTrue() const
{
return mValue == True;
}
void Tristate::Reset()
{
mValue = Unset;
}
Tristate& Tristate::operator =
(
bool const aValue
)
{
mValue = static_cast< char >( aValue ? True : False );
return *this;
}
Tristate::operator ValueType() const
{
return static_cast< ValueType >( mValue );
}
} // namespace Data
} // namespace Bfdp
| 29.569892
| 82
| 0.634182
|
dpkristensen
|
f51c9af6e96aae9791fe2db516a6497f5dcbec40
| 5,115
|
cpp
|
C++
|
oneflow/core/operator/dynamic_reshape_op.cpp
|
xxg1413/oneflow
|
f2e3c85a25b8aecfb6c0c0af1737833b1a77e135
|
[
"Apache-2.0"
] | 1
|
2020-12-04T03:06:16.000Z
|
2020-12-04T03:06:16.000Z
|
oneflow/core/operator/dynamic_reshape_op.cpp
|
xxg1413/oneflow
|
f2e3c85a25b8aecfb6c0c0af1737833b1a77e135
|
[
"Apache-2.0"
] | null | null | null |
oneflow/core/operator/dynamic_reshape_op.cpp
|
xxg1413/oneflow
|
f2e3c85a25b8aecfb6c0c0af1737833b1a77e135
|
[
"Apache-2.0"
] | null | null | null |
/*
Copyright 2020 The OneFlow Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "oneflow/core/operator/operator.h"
namespace oneflow {
class DynamicReshapeOp final : public Operator {
public:
void InitFromOpConf() {
CHECK(op_conf().has_dynamic_reshape_conf());
EnrollInputBn("in");
EnrollOutputBn("out")->set_const_inplace_ibn("in");
}
const PbMessage& GetCustomizedConf() const { return op_conf().dynamic_reshape_conf(); }
Maybe<void> InferBlobDescs(std::function<BlobDesc*(const std::string&)> GetBlobDesc4BnInOp,
const ParallelContext* parallel_ctx,
const SbpSignature* sbp_signature) const {
const DynamicReshapeOpConf& conf = op_conf().dynamic_reshape_conf();
const BlobDesc* in = GetBlobDesc4BnInOp("in");
BlobDesc* out = GetBlobDesc4BnInOp("out");
*out = *in;
DimVector out_dim_vec(conf.shape().dim().begin(), conf.shape().dim().end());
if (parallel_ctx->parallel_num() > 1) {
// consistent strategy
// ONLY support sbp: S(0); and -1 must at axis 0
const auto& out_sbp_it = sbp_signature->bn_in_op2sbp_parallel().find("out");
CHECK_OR_RETURN(out_sbp_it != sbp_signature->bn_in_op2sbp_parallel().end());
const SbpParallel& out_sbp = out_sbp_it->second;
const auto& in_sbp_it = sbp_signature->bn_in_op2sbp_parallel().find("in");
CHECK_OR_RETURN(in_sbp_it != sbp_signature->bn_in_op2sbp_parallel().end());
const SbpParallel& in_sbp = in_sbp_it->second;
if (out_sbp.has_split_parallel()) {
CHECK_EQ_OR_RETURN(out_sbp.split_parallel().axis(), 0);
CHECK_EQ_OR_RETURN(out_dim_vec.at(0), -1);
CHECK_OR_RETURN(in_sbp.has_split_parallel());
CHECK_EQ_OR_RETURN(in_sbp.split_parallel().axis(), 0);
}
}
int32_t inferred_axis = -1;
int32_t product = 1;
for (int32_t i = 0; i < out_dim_vec.size(); ++i) {
if (out_dim_vec.at(i) == -1) {
CHECK_EQ_OR_RETURN(-1, inferred_axis);
inferred_axis = i;
} else {
CHECK_GT_OR_RETURN(out_dim_vec.at(i), 0);
product *= out_dim_vec.at(i);
}
}
if (inferred_axis >= 0) {
CHECK_GE_OR_RETURN(product, 1);
CHECK_EQ_OR_RETURN(in->shape().elem_cnt() % product, 0);
out_dim_vec.at(inferred_axis) = in->shape().elem_cnt() / product;
}
out->mut_shape() = Shape(out_dim_vec);
CHECK_EQ_OR_RETURN(in->shape().elem_cnt(), out->shape().elem_cnt());
return Maybe<void>::Ok();
}
private:
Maybe<void> InferBatchAxis(
std::function<OptInt64*(const std::string&)> BatchAxis4BnInOp) const override {
return NaiveInferBatchAxis(BatchAxis4BnInOp);
}
Maybe<void> GetSbpSignatures(
const std::function<Maybe<const BlobDesc*>(const std::string&)>& LogicalBlobDesc4Ibn,
const ParallelDesc& parallel_desc, SbpSignatureList* sbp_sig_list) const override {
SbpSignatureBuilder()
.Split(input_bns(), 0)
.Split(output_bns(), 0)
.Build(sbp_sig_list->mutable_sbp_signature()->Add());
return Maybe<void>::Ok();
}
};
REGISTER_OP(OperatorConf::kDynamicReshapeConf, DynamicReshapeOp);
class DynamicReshapeLikeOp final : public Operator {
public:
void InitFromOpConf() {
CHECK(op_conf().has_dynamic_reshape_like_conf());
EnrollInputBn("x");
EnrollOutputBn("y");
EnrollInputBn("like", false)->set_use_header_only(true);
}
const PbMessage& GetCustomizedConf() const { return op_conf().dynamic_reshape_like_conf(); }
Maybe<void> InferBlobDescs(std::function<BlobDesc*(const std::string&)> GetBlobDesc4BnInOp,
const ParallelContext* parallel_ctx) const {
CHECK_EQ_OR_RETURN(GetBlobDesc4BnInOp("x")->shape().elem_cnt(),
GetBlobDesc4BnInOp("like")->shape().elem_cnt());
GetBlobDesc4BnInOp("y")->CopyMetaFrom(*GetBlobDesc4BnInOp("like"));
return Maybe<void>::Ok();
}
private:
Maybe<void> InferBatchAxis(
std::function<OptInt64*(const std::string&)> BatchAxis4BnInOp) const override {
return NaiveInferBatchAxis(BatchAxis4BnInOp);
}
Maybe<void> GetSbpSignatures(
const std::function<Maybe<const BlobDesc*>(const std::string&)>& LogicalBlobDesc4Ibn,
const ParallelDesc& parallel_desc, SbpSignatureList* sbp_sig_list) const override {
SbpSignatureBuilder()
.Split(input_bns(), 0)
.Split(output_bns(), 0)
.Build(sbp_sig_list->mutable_sbp_signature()->Add());
return Maybe<void>::Ok();
}
};
REGISTER_OP(OperatorConf::kDynamicReshapeLikeConf, DynamicReshapeLikeOp);
} // namespace oneflow
| 40.275591
| 94
| 0.688172
|
xxg1413
|
f51dafececf8f15809841c2e4f83e467f2bf3e8d
| 4,671
|
cpp
|
C++
|
code/domains/interval.cpp
|
ISCAS-PMC/deepg
|
528beda0fb4e7381b3b64a26ff72a582e5754b58
|
[
"Apache-2.0"
] | null | null | null |
code/domains/interval.cpp
|
ISCAS-PMC/deepg
|
528beda0fb4e7381b3b64a26ff72a582e5754b58
|
[
"Apache-2.0"
] | 3
|
2020-09-26T01:04:30.000Z
|
2022-02-10T01:43:53.000Z
|
code/domains/interval.cpp
|
ISCAS-PMC/deepg
|
528beda0fb4e7381b3b64a26ff72a582e5754b58
|
[
"Apache-2.0"
] | 1
|
2021-03-29T15:05:29.000Z
|
2021-03-29T15:05:29.000Z
|
#include "domains/interval.h"
#include "utils/constants.h"
#include <limits>
#include <iostream>
#include <cassert>
#include <cmath>
Interval::Interval(double inf, double sup) {
assert(inf <= sup + Constants::EPS);
if (inf > sup) {
std::swap(inf, sup);
}
this->inf = inf;
this->sup = sup;
}
Interval& Interval::operator += (const Interval &other) {
this->inf += other.inf;
this->sup += other.sup;
return (*this);
}
Interval::Interval() {
this->inf = std::numeric_limits<double>::infinity();
this->sup = -std::numeric_limits<double>::infinity();
}
Interval Interval::getR() {
return {-std::numeric_limits<double>::infinity(),
std::numeric_limits<double>::infinity()};
}
bool Interval::is_empty() const {
return this->inf == std::numeric_limits<double>::infinity() &&
this->sup == -std::numeric_limits<double>::infinity();
}
Interval abs(const Interval& it) {
if (it.sup < 0) {
return Interval(-it.sup, -it.inf);
} else if (it.inf > 0) {
return Interval(it.inf, it.sup);
}
return {0, std::max(-it.inf, it.sup)};
}
Interval normalizeAngle(Interval phi) {
Interval ret = phi;
while (ret.inf > M_PI) {
ret = ret + (-2 * M_PI);
}
while (ret.inf < -M_PI) {
ret = ret + (2 * M_PI);
}
return ret;
}
bool Interval::contains(double x) const {
return x >= inf - Constants::EPS && x <= sup + Constants::EPS;
}
Interval Interval::cosine() const {
if (sup - inf >= 2*M_PI) {
return {-1, 1};
}
auto it = normalizeAngle(*this);
assert(-M_PI <= it.inf and it.inf <= M_PI);
double ret_inf = cos(it.inf);
double ret_sup = cos(it.sup);
Interval ret = Interval(std::min(ret_inf, ret_sup), std::max(ret_inf, ret_sup));
if (it.contains(M_PI)) {
ret.inf = -1;
}
if (it.contains(0) || it.contains(2*M_PI)) {
ret.sup = 1;
}
return ret;
}
Interval Interval::sine() const {
if (sup - inf >= 2*M_PI) {
return {-1, 1};
}
auto it = normalizeAngle(*this);
assert(-M_PI <= it.inf and it.inf <= M_PI);
assert(-M_PI <= it.sup and it.sup <= 3*M_PI);
double ret_inf = sin(it.inf);
double ret_sup = sin(it.sup);
Interval ret = Interval(std::min(ret_inf, ret_sup), std::max(ret_inf, ret_sup));
if (it.contains(-0.5*M_PI) || it.contains(1.5*M_PI)) {
ret.inf = -1;
}
if (it.contains(0.5*M_PI) || it.contains(2.5*M_PI)){
ret.sup = 1;
}
return ret;
}
Interval Interval::operator - () const {
return Interval(-sup, -inf);
}
Interval Interval::operator + (const Interval& other) const {
return Interval(inf + other.inf, sup + other.sup);
}
Interval Interval::operator + (double other) const {
return Interval(inf + other, sup + other);
}
Interval Interval::operator - (double other) const {
return *this + (-other);
}
Interval Interval::operator - (const Interval& other) const {
return -other + *this;
}
Interval Interval::operator * (double other) const {
if (other > 0) {
return Interval(inf * other, sup * other);
}
return {sup * other, inf * other};
}
double Interval::length() const {
return sup - inf;
}
Interval Interval::operator * (const Interval& other) const {
Interval tmp1 = (*this) * other.inf;
Interval tmp2 = (*this) * other.sup;
return {std::min(tmp1.inf, tmp2.inf), std::max(tmp1.sup, tmp2.sup)};
}
Interval Interval::meet(const Interval& other) const {
if (this->is_empty() || other.is_empty()) {
return Interval();
}
if (inf > other.sup || other.inf > sup) {
return Interval();
}
return Interval(std::max(inf, other.inf), std::min(sup, other.sup));
}
Interval Interval::join(const Interval& other) const {
return Interval(std::min(inf, other.inf), std::max(sup, other.sup));
}
// Interval Interval::join(std::vector<Interval> intervals) {
// Interval ret = intervals[0];
// for (Interval it : intervals) {
// ret = ret.join(it);
// }
// return ret;
// }
Interval operator - (const double& a, const Interval &it) {
return -it + a;
}
Interval operator + (const double& a, const Interval &it) {
return it + a;
}
Interval operator * (const double& a, const Interval &it) {
return it * a;
}
std::ostream& operator<<(std::ostream& os, const Interval& it) {
return os << "[" << it.inf << ", " << it.sup << "]";
}
Interval cos(Interval phi) {
return phi.cosine();
}
Interval sin(Interval phi) {
return phi.sine();
}
Interval Interval::pow(int k) const {
if (k == 0) {
return {1, 1};
}
Interval ret = {1, 1};
for (int j = 0; j < k; ++j) {
ret = ret * (*this);
}
return ret;
}
| 23.590909
| 84
| 0.596874
|
ISCAS-PMC
|
f51e18bedf148255e1eb544065f306899995a03b
| 3,092
|
cpp
|
C++
|
data-server/src/raft/test/cluster_test.cpp
|
13meimei/sharkstore
|
b73fd09e8cddf78fc1f690219529770b278b35b6
|
[
"Apache-2.0"
] | 1
|
2019-09-11T06:16:42.000Z
|
2019-09-11T06:16:42.000Z
|
data-server/src/raft/test/cluster_test.cpp
|
gengdaomi/sharkstore
|
1b490176846d2da98ceca07a69b6c35646567a28
|
[
"Apache-2.0"
] | null | null | null |
data-server/src/raft/test/cluster_test.cpp
|
gengdaomi/sharkstore
|
1b490176846d2da98ceca07a69b6c35646567a28
|
[
"Apache-2.0"
] | 1
|
2021-09-03T10:35:21.000Z
|
2021-09-03T10:35:21.000Z
|
#include <unistd.h>
#include <cassert>
#include <iostream>
#include <thread>
#include <functional>
#include "number_statemachine.h"
#include "raft/raft.h"
#include "raft/server.h"
using namespace sharkstore;
using namespace sharkstore::raft;
static const size_t kNodeNum = 5;
std::condition_variable g_cv;
std::mutex g_mu;
size_t g_finish_count = 0;
std::vector<Peer> g_peers;
void run_node(uint64_t node_id) {
RaftServerOptions ops;
ops.node_id = node_id;
ops.tick_interval = std::chrono::milliseconds(100);
ops.election_tick = 5;
ops.transport_options.use_inprocess_transport = true;
auto rs = CreateRaftServer(ops);
assert(rs);
auto s = rs->Start();
assert(s.ok());
auto sm = std::make_shared<raft::test::NumberStateMachine>(node_id);
RaftOptions rops;
rops.id = 1;
rops.statemachine = sm;
rops.use_memory_storage = true;
rops.peers = g_peers;
std::shared_ptr<Raft> r;
s = rs->CreateRaft(rops, &r);
std::cout << s.ToString() << std::endl;
assert(s.ok());
while (true) {
uint64_t leader;
uint64_t term;
r->GetLeaderTerm(&leader, &term);
if (leader != 0) {
break;
} else {
usleep(1000 * 100);
}
}
int reqs_count = 10000;
if (r->IsLeader()) {
for (int i = 1; i <= reqs_count; ++i) {
std::string cmd = std::to_string(i);
s = r->Submit(cmd);
assert(s.ok());
}
}
s = sm->WaitNumber(reqs_count);
assert(s.ok());
std::cout << "[NODE" << node_id << "]"
<< " wait number return: " << s.ToString() << std::endl;
r->Truncate(3);
// 本节点任务完成
{
std::lock_guard<std::mutex> lock(g_mu);
++g_finish_count;
}
g_cv.notify_all();
// 等待所有节点完成,退出
std::unique_lock<std::mutex> lock(g_mu);
while (g_finish_count < kNodeNum) {
g_cv.wait(lock);
}
};
// 测试顺序 5个节点
//
// 1) 启动2个普通节点+1个learner节点
// 2) 等待复制完成以及日志截断
// 3) 启动剩下的1个普通节点 + 1个learner节点,验证快照逻辑
int main(int argc, char* argv[]) {
if (kNodeNum < 5) {
throw std::runtime_error("node number should greater than five.");
}
// 初始化集群成员
for (uint64_t i = 1; i <= kNodeNum; ++i) {
Peer p;
if (i == 3 || i == kNodeNum - 1) {
p.type = PeerType::kLearner;
} else {
p.type = PeerType::kNormal;
}
p.node_id = i;
p.peer_id = i;
g_peers.push_back(p);
}
std::vector<std::thread> threads;
// 先启动n-2个节点
for (uint64_t i = 1; i <= kNodeNum - 2; ++i) {
threads.push_back(std::thread(std::bind(&run_node, i)));
}
// 等待n-2个节点复制完成和日志截断
{
std::unique_lock<std::mutex> lock(g_mu);
while (g_finish_count < kNodeNum - 2) {
g_cv.wait(lock);
}
}
// 启动最后两个节点,一个普通,一个learner 验证快照逻辑
threads.push_back(std::thread(std::bind(&run_node, kNodeNum - 1)));
threads.push_back(std::thread(std::bind(&run_node, kNodeNum)));
for (auto& t : threads) {
t.join();
}
}
| 22.903704
| 74
| 0.564683
|
13meimei
|
f51e1cb8dbaada4e3325782c731168f8e4f5c5a6
| 18,398
|
cpp
|
C++
|
src/platform/Linux/ThreadStackManagerImpl.cpp
|
tima-q/connectedhomeip
|
bfdbd458d86f6905b85fe7ff5c632c85d21bc010
|
[
"Apache-2.0"
] | 3
|
2021-03-01T21:37:15.000Z
|
2021-05-14T08:55:13.000Z
|
src/platform/Linux/ThreadStackManagerImpl.cpp
|
cser2016/connectedhomeip
|
55349a53c8dab9a7aaff138c8bc19a52e2df9c40
|
[
"Apache-2.0"
] | 153
|
2021-01-27T08:12:04.000Z
|
2022-02-22T14:58:29.000Z
|
src/platform/Linux/ThreadStackManagerImpl.cpp
|
cser2016/connectedhomeip
|
55349a53c8dab9a7aaff138c8bc19a52e2df9c40
|
[
"Apache-2.0"
] | 5
|
2021-01-19T15:34:29.000Z
|
2021-02-17T12:16:18.000Z
|
/*
*
* Copyright (c) 2020 Project CHIP Authors
*
* 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 <platform/internal/CHIPDeviceLayerInternal.h>
#include <platform/internal/DeviceNetworkInfo.h>
#include <app/AttributeAccessInterface.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/PlatformManager.h>
#include <platform/ThreadStackManager.h>
using namespace ::chip::app;
using namespace ::chip::app::Clusters;
namespace chip {
namespace DeviceLayer {
ThreadStackManagerImpl ThreadStackManagerImpl::sInstance;
constexpr char ThreadStackManagerImpl::kDBusOpenThreadService[];
constexpr char ThreadStackManagerImpl::kDBusOpenThreadObjectPath[];
constexpr char ThreadStackManagerImpl::kOpenthreadDeviceRoleDisabled[];
constexpr char ThreadStackManagerImpl::kOpenthreadDeviceRoleDetached[];
constexpr char ThreadStackManagerImpl::kOpenthreadDeviceRoleChild[];
constexpr char ThreadStackManagerImpl::kOpenthreadDeviceRoleRouter[];
constexpr char ThreadStackManagerImpl::kOpenthreadDeviceRoleLeader[];
constexpr char ThreadStackManagerImpl::kPropertyDeviceRole[];
ThreadStackManagerImpl::ThreadStackManagerImpl() : mAttached(false) {}
CHIP_ERROR ThreadStackManagerImpl::_InitThreadStack()
{
std::unique_ptr<GError, GErrorDeleter> err;
mProxy.reset(openthread_io_openthread_border_router_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
kDBusOpenThreadService, kDBusOpenThreadObjectPath,
nullptr, &MakeUniquePointerReceiver(err).Get()));
if (!mProxy)
{
ChipLogError(DeviceLayer, "openthread: failed to create openthread dbus proxy %s", err ? err->message : "unknown error");
return CHIP_ERROR_INTERNAL;
}
g_signal_connect(mProxy.get(), "g-properties-changed", G_CALLBACK(OnDbusPropertiesChanged), this);
// If get property is called inside dbus thread (we are going to make it so), XXX_get_XXX can be used instead of XXX_dup_XXX
// which is a little bit faster and the returned object doesn't need to be freed. Same for all following get properties.
std::unique_ptr<gchar, GFree> role(openthread_io_openthread_border_router_dup_device_role(mProxy.get()));
if (role)
{
ThreadDevcieRoleChangedHandler(role.get());
}
return CHIP_NO_ERROR;
}
void ThreadStackManagerImpl::OnDbusPropertiesChanged(OpenthreadIoOpenthreadBorderRouter * proxy, GVariant * changed_properties,
const gchar * const * invalidated_properties, gpointer user_data)
{
ThreadStackManagerImpl * me = reinterpret_cast<ThreadStackManagerImpl *>(user_data);
if (g_variant_n_children(changed_properties) > 0)
{
const gchar * key;
GVariant * value;
std::unique_ptr<GVariantIter, GVariantIterDeleter> iter;
g_variant_get(changed_properties, "a{sv}", &MakeUniquePointerReceiver(iter).Get());
if (!iter)
return;
while (g_variant_iter_loop(iter.get(), "{&sv}", &key, &value))
{
if (key == nullptr || value == nullptr)
continue;
// ownership of key and value is still holding by the iter
if (strcmp(key, kPropertyDeviceRole) == 0)
{
const gchar * value_str = g_variant_get_string(value, nullptr);
if (value_str == nullptr)
continue;
ChipLogProgress(DeviceLayer, "Thread role changed to: %s", value_str);
me->ThreadDevcieRoleChangedHandler(value_str);
}
}
}
}
void ThreadStackManagerImpl::ThreadDevcieRoleChangedHandler(const gchar * role)
{
bool attached = strcmp(role, kOpenthreadDeviceRoleDetached) != 0 && strcmp(role, kOpenthreadDeviceRoleDisabled) != 0;
ChipDeviceEvent event = ChipDeviceEvent{};
if (attached != mAttached)
{
event.Type = DeviceEventType::kThreadConnectivityChange;
event.ThreadConnectivityChange.Result =
attached ? ConnectivityChange::kConnectivity_Established : ConnectivityChange::kConnectivity_Lost;
CHIP_ERROR status = PlatformMgr().PostEvent(&event);
if (status != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Failed to post thread connectivity change: %" CHIP_ERROR_FORMAT, status.Format());
}
}
mAttached = attached;
event.Type = DeviceEventType::kThreadStateChange;
event.ThreadStateChange.RoleChanged = true;
CHIP_ERROR status = PlatformMgr().PostEvent(&event);
if (status != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Failed to post thread state change: %" CHIP_ERROR_FORMAT, status.Format());
}
}
void ThreadStackManagerImpl::_ProcessThreadActivity() {}
bool ThreadStackManagerImpl::_HaveRouteToAddress(const Inet::IPAddress & destAddr)
{
if (!mProxy || !_IsThreadAttached())
{
return false;
}
if (destAddr.IsIPv6LinkLocal())
{
return true;
}
std::unique_ptr<GVariant, GVariantDeleter> routes(openthread_io_openthread_border_router_dup_external_routes(mProxy.get()));
if (!routes)
return false;
if (g_variant_n_children(routes.get()) > 0)
{
std::unique_ptr<GVariantIter, GVariantIterDeleter> iter;
g_variant_get(routes.get(), "av", &MakeUniquePointerReceiver(iter).Get());
if (!iter)
return false;
GVariant * route;
while (g_variant_iter_loop(iter.get(), "&v", &route))
{
if (route == nullptr)
continue;
std::unique_ptr<GVariant, GVariantDeleter> prefix;
guint16 rloc16;
guchar preference;
gboolean stable;
gboolean nextHopIsThisDevice;
g_variant_get(route, "(&vqybb)", &MakeUniquePointerReceiver(prefix).Get(), &rloc16, &preference, &stable,
&nextHopIsThisDevice);
if (!prefix)
continue;
std::unique_ptr<GVariant, GVariantDeleter> address;
guchar prefixLength;
g_variant_get(prefix.get(), "(&vy)", &MakeUniquePointerReceiver(address).Get(), &prefixLength);
if (!address)
continue;
GBytes * bytes = g_variant_get_data_as_bytes(address.get()); // the ownership still hold by address
if (bytes == nullptr)
continue;
gsize size;
gconstpointer data = g_bytes_get_data(bytes, &size);
if (data == nullptr)
continue;
if (size != sizeof(struct in6_addr))
continue;
Inet::IPPrefix p;
p.IPAddr = Inet::IPAddress(*reinterpret_cast<const struct in6_addr *>(data));
p.Length = prefixLength;
if (p.MatchAddress(destAddr))
{
return true;
}
}
}
return false;
}
void ThreadStackManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
{
(void) event;
// The otbr-agent processes the Thread state handling by itself so there
// isn't much to do in the Chip stack.
}
CHIP_ERROR ThreadStackManagerImpl::_SetThreadProvision(ByteSpan netInfo)
{
VerifyOrReturnError(mProxy, CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(Thread::OperationalDataset::IsValid(netInfo), CHIP_ERROR_INVALID_ARGUMENT);
{
std::unique_ptr<GBytes, GBytesDeleter> bytes(g_bytes_new(netInfo.data(), netInfo.size()));
if (!bytes)
return CHIP_ERROR_NO_MEMORY;
std::unique_ptr<GVariant, GVariantDeleter> value(
g_variant_new_from_bytes(G_VARIANT_TYPE_BYTESTRING, bytes.release(), true));
if (!value)
return CHIP_ERROR_NO_MEMORY;
openthread_io_openthread_border_router_set_active_dataset_tlvs(mProxy.get(), value.release());
}
// post an event alerting other subsystems about change in provisioning state
ChipDeviceEvent event;
event.Type = DeviceEventType::kServiceProvisioningChange;
event.ServiceProvisioningChange.IsServiceProvisioned = true;
return PlatformMgr().PostEvent(&event);
}
CHIP_ERROR ThreadStackManagerImpl::_GetThreadProvision(ByteSpan & netInfo)
{
VerifyOrReturnError(mProxy, CHIP_ERROR_INCORRECT_STATE);
{
std::unique_ptr<GVariant, GVariantDeleter> value(
openthread_io_openthread_border_router_dup_active_dataset_tlvs(mProxy.get()));
GBytes * bytes = g_variant_get_data_as_bytes(value.get());
gsize size;
const uint8_t * data = reinterpret_cast<const uint8_t *>(g_bytes_get_data(bytes, &size));
ReturnErrorOnFailure(mDataset.Init(ByteSpan(data, size)));
}
netInfo = mDataset.AsByteSpan();
return CHIP_NO_ERROR;
}
bool ThreadStackManagerImpl::_IsThreadProvisioned()
{
return static_cast<Thread::OperationalDataset &>(mDataset).IsCommissioned();
}
void ThreadStackManagerImpl::_ErasePersistentInfo()
{
static_cast<Thread::OperationalDataset &>(mDataset).Clear();
}
bool ThreadStackManagerImpl::_IsThreadEnabled()
{
if (!mProxy)
{
return false;
}
std::unique_ptr<gchar, GFree> role(openthread_io_openthread_border_router_dup_device_role(mProxy.get()));
return (strcmp(role.get(), kOpenthreadDeviceRoleDisabled) != 0);
}
bool ThreadStackManagerImpl::_IsThreadAttached()
{
return mAttached;
}
CHIP_ERROR ThreadStackManagerImpl::_SetThreadEnabled(bool val)
{
VerifyOrReturnError(mProxy, CHIP_ERROR_INCORRECT_STATE);
if (val)
{
std::unique_ptr<GError, GErrorDeleter> err;
gboolean result =
openthread_io_openthread_border_router_call_attach_sync(mProxy.get(), nullptr, &MakeUniquePointerReceiver(err).Get());
if (err)
{
ChipLogError(DeviceLayer, "openthread: _SetThreadEnabled calling %s failed: %s", "Attach", err->message);
return CHIP_ERROR_INTERNAL;
}
if (!result)
{
ChipLogError(DeviceLayer, "openthread: _SetThreadEnabled calling %s failed: %s", "Attach", "return false");
return CHIP_ERROR_INTERNAL;
}
}
else
{
std::unique_ptr<GError, GErrorDeleter> err;
gboolean result =
openthread_io_openthread_border_router_call_reset_sync(mProxy.get(), nullptr, &MakeUniquePointerReceiver(err).Get());
if (err)
{
ChipLogError(DeviceLayer, "openthread: _SetThreadEnabled calling %s failed: %s", "Reset", err->message);
return CHIP_ERROR_INTERNAL;
}
if (!result)
{
ChipLogError(DeviceLayer, "openthread: _SetThreadEnabled calling %s failed: %s", "Reset", "return false");
return CHIP_ERROR_INTERNAL;
}
}
return CHIP_NO_ERROR;
}
ConnectivityManager::ThreadDeviceType ThreadStackManagerImpl::_GetThreadDeviceType()
{
ConnectivityManager::ThreadDeviceType type = ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported;
if (!mProxy)
{
ChipLogError(DeviceLayer, "Cannot get device role with Thread api client: %s", "");
return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported;
}
std::unique_ptr<gchar, GFree> role(openthread_io_openthread_border_router_dup_device_role(mProxy.get()));
if (!role)
return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported;
if (strcmp(role.get(), kOpenthreadDeviceRoleDetached) == 0 || strcmp(role.get(), kOpenthreadDeviceRoleDisabled) == 0)
{
return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported;
}
else if (strcmp(role.get(), kOpenthreadDeviceRoleChild) == 0)
{
std::unique_ptr<GVariant, GVariantDeleter> linkMode(openthread_io_openthread_border_router_dup_link_mode(mProxy.get()));
if (!linkMode)
return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported;
gboolean rx_on_when_idle;
gboolean device_type;
gboolean network_data;
g_variant_get(linkMode.get(), "(bbb)", &rx_on_when_idle, &device_type, &network_data);
if (!rx_on_when_idle)
{
type = ConnectivityManager::ThreadDeviceType::kThreadDeviceType_SleepyEndDevice;
}
else
{
type = device_type ? ConnectivityManager::ThreadDeviceType::kThreadDeviceType_FullEndDevice
: ConnectivityManager::ThreadDeviceType::kThreadDeviceType_MinimalEndDevice;
}
return type;
}
else if (strcmp(role.get(), kOpenthreadDeviceRoleLeader) == 0 || strcmp(role.get(), kOpenthreadDeviceRoleRouter) == 0)
{
return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_Router;
}
else
{
ChipLogError(DeviceLayer, "Unknown Thread role: %s", role.get());
return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported;
}
}
CHIP_ERROR ThreadStackManagerImpl::_SetThreadDeviceType(ConnectivityManager::ThreadDeviceType deviceType)
{
gboolean rx_on_when_idle = true;
gboolean device_type = true;
gboolean network_data = true;
VerifyOrReturnError(mProxy, CHIP_ERROR_INCORRECT_STATE);
if (deviceType == ConnectivityManager::ThreadDeviceType::kThreadDeviceType_MinimalEndDevice)
{
network_data = false;
}
else if (deviceType == ConnectivityManager::ThreadDeviceType::kThreadDeviceType_SleepyEndDevice)
{
rx_on_when_idle = false;
network_data = false;
}
if (!network_data)
{
std::unique_ptr<GVariant, GVariantDeleter> linkMode(g_variant_new("(bbb)", rx_on_when_idle, device_type, network_data));
if (!linkMode)
return CHIP_ERROR_NO_MEMORY;
openthread_io_openthread_border_router_set_link_mode(mProxy.get(), linkMode.release());
}
return CHIP_NO_ERROR;
}
#if CHIP_DEVICE_CONFIG_ENABLE_SED
CHIP_ERROR ThreadStackManagerImpl::_GetSEDPollingConfig(ConnectivityManager::SEDPollingConfig & pollingConfig)
{
(void) pollingConfig;
ChipLogError(DeviceLayer, "Polling config is not supported on linux");
return CHIP_ERROR_NOT_IMPLEMENTED;
}
CHIP_ERROR ThreadStackManagerImpl::_SetSEDPollingConfig(const ConnectivityManager::SEDPollingConfig & pollingConfig)
{
(void) pollingConfig;
ChipLogError(DeviceLayer, "Polling config is not supported on linux");
return CHIP_ERROR_NOT_IMPLEMENTED;
}
CHIP_ERROR ThreadStackManagerImpl::_RequestSEDFastPollingMode(bool onOff)
{
(void) onOff;
ChipLogError(DeviceLayer, "Polling config is not supported on linux");
return CHIP_ERROR_NOT_IMPLEMENTED;
}
#endif
bool ThreadStackManagerImpl::_HaveMeshConnectivity()
{
// TODO: Remove Weave legacy APIs
// For a leader with a child, the child is considered to have mesh connectivity
// and the leader is not, which is a very confusing definition.
// This API is Weave legacy and should be removed.
ChipLogError(DeviceLayer, "HaveMeshConnectivity has confusing behavior and shouldn't be called");
return false;
}
CHIP_ERROR ThreadStackManagerImpl::_GetAndLogThreadStatsCounters()
{
// TODO: Remove Weave legacy APIs
return CHIP_ERROR_NOT_IMPLEMENTED;
}
CHIP_ERROR ThreadStackManagerImpl::_GetAndLogThreadTopologyMinimal()
{
// TODO: Remove Weave legacy APIs
return CHIP_ERROR_NOT_IMPLEMENTED;
}
CHIP_ERROR ThreadStackManagerImpl::_GetAndLogThreadTopologyFull()
{
// TODO: Remove Weave legacy APIs
return CHIP_ERROR_NOT_IMPLEMENTED;
}
CHIP_ERROR ThreadStackManagerImpl::_GetPrimary802154MACAddress(uint8_t * buf)
{
VerifyOrReturnError(mProxy, CHIP_ERROR_INCORRECT_STATE);
guint64 extAddr = openthread_io_openthread_border_router_get_extended_address(mProxy.get());
for (size_t i = 0; i < sizeof(extAddr); i++)
{
buf[sizeof(uint64_t) - i - 1] = (extAddr & UINT8_MAX);
extAddr >>= CHAR_BIT;
}
return CHIP_NO_ERROR;
}
CHIP_ERROR ThreadStackManagerImpl::_GetExternalIPv6Address(chip::Inet::IPAddress & addr)
{
// TODO: Remove Weave legacy APIs
return CHIP_ERROR_NOT_IMPLEMENTED;
}
CHIP_ERROR ThreadStackManagerImpl::_GetPollPeriod(uint32_t & buf)
{
// TODO: Remove Weave legacy APIs
return CHIP_ERROR_NOT_IMPLEMENTED;
}
CHIP_ERROR ThreadStackManagerImpl::_JoinerStart()
{
// TODO: Remove Weave legacy APIs
return CHIP_ERROR_NOT_IMPLEMENTED;
}
void ThreadStackManagerImpl::_ResetThreadNetworkDiagnosticsCounts() {}
CHIP_ERROR ThreadStackManagerImpl::_WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId,
app::AttributeValueEncoder & encoder)
{
CHIP_ERROR err = CHIP_NO_ERROR;
switch (attributeId)
{
case ThreadNetworkDiagnostics::Attributes::NeighborTableList::Id:
case ThreadNetworkDiagnostics::Attributes::RouteTableList::Id:
case ThreadNetworkDiagnostics::Attributes::SecurityPolicy::Id:
case ThreadNetworkDiagnostics::Attributes::OperationalDatasetComponents::Id:
case ThreadNetworkDiagnostics::Attributes::ActiveNetworkFaultsList::Id: {
err = encoder.Encode(DataModel::List<EndpointId>());
break;
}
default: {
err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
break;
}
}
return err;
}
ThreadStackManager & ThreadStackMgr()
{
return chip::DeviceLayer::ThreadStackManagerImpl::sInstance;
}
ThreadStackManagerImpl & ThreadStackMgrImpl()
{
return chip::DeviceLayer::ThreadStackManagerImpl::sInstance;
}
} // namespace DeviceLayer
} // namespace chip
| 35.863548
| 130
| 0.689368
|
tima-q
|
f51e2ef53d20c18d6725d56eb06ef16a409dd327
| 1,632
|
hpp
|
C++
|
externals/numeric_bindings/boost/numeric/bindings/ublas/detail/basic_ublas_adaptor.hpp
|
ljktest/siconos
|
85b60e62beca46e6bf06bfbd65670089e86607c7
|
[
"Apache-2.0"
] | 137
|
2015-06-16T15:55:28.000Z
|
2022-03-26T06:01:59.000Z
|
externals/numeric_bindings/boost/numeric/bindings/ublas/detail/basic_ublas_adaptor.hpp
|
ljktest/siconos
|
85b60e62beca46e6bf06bfbd65670089e86607c7
|
[
"Apache-2.0"
] | 381
|
2015-09-22T15:31:08.000Z
|
2022-02-14T09:05:23.000Z
|
externals/numeric_bindings/boost/numeric/bindings/ublas/detail/basic_ublas_adaptor.hpp
|
ljktest/siconos
|
85b60e62beca46e6bf06bfbd65670089e86607c7
|
[
"Apache-2.0"
] | 30
|
2015-08-06T22:57:51.000Z
|
2022-03-02T20:30:20.000Z
|
//
// Copyright (c) 2009 Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_NUMERIC_BINDINGS_UBLAS_DETAIL_BASIC_UBLAS_ADAPTOR_HPP
#define BOOST_NUMERIC_BINDINGS_UBLAS_DETAIL_BASIC_UBLAS_ADAPTOR_HPP
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/end.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/numeric/bindings/stride.hpp>
namespace boost {
namespace numeric {
namespace bindings {
namespace detail {
template< typename T, typename Id, typename P1 = mpl::void_,
typename P2 = mpl::void_, typename P3 = mpl::void_ >
struct basic_ublas_adaptor {
typedef typename copy_const< Id, T >::type adapted_type;
typedef typename property_insert< adapted_type, P1, P2, P3 >::type property_map;
static std::ptrdiff_t size1( const Id& id ) {
return id.size1();
}
static std::ptrdiff_t size2( const Id& id ) {
return id.size2();
}
static typename result_of::begin_value< adapted_type >::type begin_value( Id& id ) {
return bindings::begin_value( id.data() );
}
static typename result_of::end_value< adapted_type >::type end_value( Id& id ) {
return bindings::end_value( id.data() );
}
static std::ptrdiff_t stride1( const Id& id ) {
return bindings::stride1( id.data() );
}
static std::ptrdiff_t stride2( const Id& id ) {
return bindings::stride2( id.data() );
}
};
} // detail
} // bindings
} // numeric
} // boost
#endif
| 26.754098
| 88
| 0.688725
|
ljktest
|
f51e46148e253dca7dab1db6cdb32bae57cf0d46
| 3,048
|
cc
|
C++
|
components/content_settings/core/browser/content_settings_utils_unittest.cc
|
xzhan96/chromium.src
|
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2
|
2019-01-28T08:09:58.000Z
|
2021-11-15T15:32:10.000Z
|
components/content_settings/core/browser/content_settings_utils_unittest.cc
|
emilio/chromium.src
|
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
components/content_settings/core/browser/content_settings_utils_unittest.cc
|
emilio/chromium.src
|
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 6
|
2020-09-23T08:56:12.000Z
|
2021-11-18T03:40:49.000Z
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/content_settings/core/browser/content_settings_utils.h"
#include <stddef.h>
#include <string>
#include "base/macros.h"
#include "components/content_settings/core/test/content_settings_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
const char* const kContentSettingNames[] = {
"default",
"allow",
"block",
"ask",
"session_only",
"detect_important_content",
};
static_assert(arraysize(kContentSettingNames) == CONTENT_SETTING_NUM_SETTINGS,
"kContentSettingNames has an unexpected number of elements");
} // namespace
TEST(ContentSettingsUtilsTest, ParsePatternString) {
content_settings::PatternPair pattern_pair;
pattern_pair = content_settings::ParsePatternString(std::string());
EXPECT_FALSE(pattern_pair.first.IsValid());
EXPECT_FALSE(pattern_pair.second.IsValid());
pattern_pair = content_settings::ParsePatternString(",");
EXPECT_FALSE(pattern_pair.first.IsValid());
EXPECT_FALSE(pattern_pair.second.IsValid());
pattern_pair = content_settings::ParsePatternString("http://www.foo.com");
EXPECT_TRUE(pattern_pair.first.IsValid());
EXPECT_EQ(pattern_pair.second, ContentSettingsPattern::Wildcard());
// This inconsistency is to recover from some broken code.
pattern_pair = content_settings::ParsePatternString("http://www.foo.com,");
EXPECT_TRUE(pattern_pair.first.IsValid());
EXPECT_FALSE(pattern_pair.second.IsValid());
pattern_pair = content_settings::ParsePatternString(
"http://www.foo.com,http://www.bar.com");
EXPECT_TRUE(pattern_pair.first.IsValid());
EXPECT_TRUE(pattern_pair.second.IsValid());
pattern_pair = content_settings::ParsePatternString(
"http://www.foo.com,http://www.bar.com,");
EXPECT_FALSE(pattern_pair.first.IsValid());
EXPECT_FALSE(pattern_pair.second.IsValid());
pattern_pair = content_settings::ParsePatternString(
"http://www.foo.com,http://www.bar.com,http://www.error.com");
EXPECT_FALSE(pattern_pair.first.IsValid());
EXPECT_FALSE(pattern_pair.second.IsValid());
}
TEST(ContentSettingsUtilsTest, ContentSettingsStringMap) {
std::string setting_string =
content_settings::ContentSettingToString(CONTENT_SETTING_NUM_SETTINGS);
EXPECT_TRUE(setting_string.empty());
for (size_t i = 0; i < arraysize(kContentSettingNames); ++i) {
ContentSetting setting = static_cast<ContentSetting>(i);
setting_string = content_settings::ContentSettingToString(setting);
EXPECT_EQ(kContentSettingNames[i], setting_string);
ContentSetting converted_setting;
if (i == 0) {
EXPECT_FALSE(content_settings::ContentSettingFromString(
kContentSettingNames[i], &converted_setting));
} else {
EXPECT_TRUE(content_settings::ContentSettingFromString(
kContentSettingNames[i], &converted_setting));
}
EXPECT_EQ(setting, converted_setting);
}
}
| 35.034483
| 78
| 0.752953
|
xzhan96
|
f51ee1c4562b4b3b9cc983fa40bb9d60f5066b76
| 530
|
cpp
|
C++
|
ffplay/app/src/main/cpp/play.cpp
|
chemoontheshy/kotlin
|
f11c06d8fe29c381cd2cb7ce15134662577cd4f9
|
[
"Apache-2.0"
] | null | null | null |
ffplay/app/src/main/cpp/play.cpp
|
chemoontheshy/kotlin
|
f11c06d8fe29c381cd2cb7ce15134662577cd4f9
|
[
"Apache-2.0"
] | null | null | null |
ffplay/app/src/main/cpp/play.cpp
|
chemoontheshy/kotlin
|
f11c06d8fe29c381cd2cb7ce15134662577cd4f9
|
[
"Apache-2.0"
] | null | null | null |
//
// Created by Administrator on 2021/3/3.
//
#include <jni.h>
extern "C"
{
#include "include/libavcodec/avcodec.h"
#include "include/libavfilter/avfilter.h"
#include "include/libavformat/avformat.h"
#include "include/libavutil/avutil.h"
#include "include/libswresample/swresample.h"
#include "include/libswscale/swscale.h"
}
extern "C" JNIEXPORT jstring JNICALL
Java_com_qchemmo_ffplay_ui_activity_MainActivity_test(
JNIEnv *env,
jobject /* this */) {
return env->NewStringUTF(swresample_configuration());
}
| 26.5
| 57
| 0.74717
|
chemoontheshy
|
f52083daf1718e5fe458f67edd515671d75eda52
| 1,226
|
hpp
|
C++
|
cpp_module_04/ex02/Brain.hpp
|
anolivei/cpp_piscine42
|
d33bfccd38ed62d393920601f7449b74836c5219
|
[
"MIT"
] | 1
|
2022-01-27T02:32:39.000Z
|
2022-01-27T02:32:39.000Z
|
cpp_module_04/ex02/Brain.hpp
|
anolivei/cpp_piscine42
|
d33bfccd38ed62d393920601f7449b74836c5219
|
[
"MIT"
] | null | null | null |
cpp_module_04/ex02/Brain.hpp
|
anolivei/cpp_piscine42
|
d33bfccd38ed62d393920601f7449b74836c5219
|
[
"MIT"
] | null | null | null |
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Brain.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: anolivei <anolivei@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/29 01:27:44 by anolivei #+# #+# */
/* Updated: 2022/01/31 18:20:57 by anolivei ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef BRAIN_HPP
#define BRAIN_HPP
#include <iostream>
class Brain
{
public:
Brain(void);
Brain(const Brain& obj);
virtual ~Brain(void);
Brain& operator=(const Brain& obj);
std::string* get_ideas(void);
protected:
std::string _ideas[100];
};
std::ostream& operator<<(std::ostream& o, const Brain& brain);
#endif
| 34.055556
| 80
| 0.272431
|
anolivei
|
f52295fa310f06318d4ac4d4addb38aa1ccee958
| 40,810
|
cpp
|
C++
|
src/intel/compiler/brw_shader.cpp
|
pundiramit/external-mesa3d
|
c342483c57fa185ff67bd5ab7d82cb884e42684e
|
[
"MIT"
] | null | null | null |
src/intel/compiler/brw_shader.cpp
|
pundiramit/external-mesa3d
|
c342483c57fa185ff67bd5ab7d82cb884e42684e
|
[
"MIT"
] | null | null | null |
src/intel/compiler/brw_shader.cpp
|
pundiramit/external-mesa3d
|
c342483c57fa185ff67bd5ab7d82cb884e42684e
|
[
"MIT"
] | null | null | null |
/*
* Copyright © 2010 Intel Corporation
*
* 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 (including the next
* paragraph) 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 "brw_cfg.h"
#include "brw_eu.h"
#include "brw_fs.h"
#include "brw_nir.h"
#include "brw_vec4_tes.h"
#include "dev/gen_debug.h"
#include "main/uniforms.h"
#include "util/macros.h"
enum brw_reg_type
brw_type_for_base_type(const struct glsl_type *type)
{
switch (type->base_type) {
case GLSL_TYPE_FLOAT16:
return BRW_REGISTER_TYPE_HF;
case GLSL_TYPE_FLOAT:
return BRW_REGISTER_TYPE_F;
case GLSL_TYPE_INT:
case GLSL_TYPE_BOOL:
case GLSL_TYPE_SUBROUTINE:
return BRW_REGISTER_TYPE_D;
case GLSL_TYPE_INT16:
return BRW_REGISTER_TYPE_W;
case GLSL_TYPE_INT8:
return BRW_REGISTER_TYPE_B;
case GLSL_TYPE_UINT:
return BRW_REGISTER_TYPE_UD;
case GLSL_TYPE_UINT16:
return BRW_REGISTER_TYPE_UW;
case GLSL_TYPE_UINT8:
return BRW_REGISTER_TYPE_UB;
case GLSL_TYPE_ARRAY:
return brw_type_for_base_type(type->fields.array);
case GLSL_TYPE_STRUCT:
case GLSL_TYPE_INTERFACE:
case GLSL_TYPE_SAMPLER:
case GLSL_TYPE_ATOMIC_UINT:
/* These should be overridden with the type of the member when
* dereferenced into. BRW_REGISTER_TYPE_UD seems like a likely
* way to trip up if we don't.
*/
return BRW_REGISTER_TYPE_UD;
case GLSL_TYPE_IMAGE:
return BRW_REGISTER_TYPE_UD;
case GLSL_TYPE_DOUBLE:
return BRW_REGISTER_TYPE_DF;
case GLSL_TYPE_UINT64:
return BRW_REGISTER_TYPE_UQ;
case GLSL_TYPE_INT64:
return BRW_REGISTER_TYPE_Q;
case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
case GLSL_TYPE_FUNCTION:
unreachable("not reached");
}
return BRW_REGISTER_TYPE_F;
}
enum brw_conditional_mod
brw_conditional_for_comparison(unsigned int op)
{
switch (op) {
case ir_binop_less:
return BRW_CONDITIONAL_L;
case ir_binop_gequal:
return BRW_CONDITIONAL_GE;
case ir_binop_equal:
case ir_binop_all_equal: /* same as equal for scalars */
return BRW_CONDITIONAL_Z;
case ir_binop_nequal:
case ir_binop_any_nequal: /* same as nequal for scalars */
return BRW_CONDITIONAL_NZ;
default:
unreachable("not reached: bad operation for comparison");
}
}
uint32_t
brw_math_function(enum opcode op)
{
switch (op) {
case SHADER_OPCODE_RCP:
return BRW_MATH_FUNCTION_INV;
case SHADER_OPCODE_RSQ:
return BRW_MATH_FUNCTION_RSQ;
case SHADER_OPCODE_SQRT:
return BRW_MATH_FUNCTION_SQRT;
case SHADER_OPCODE_EXP2:
return BRW_MATH_FUNCTION_EXP;
case SHADER_OPCODE_LOG2:
return BRW_MATH_FUNCTION_LOG;
case SHADER_OPCODE_POW:
return BRW_MATH_FUNCTION_POW;
case SHADER_OPCODE_SIN:
return BRW_MATH_FUNCTION_SIN;
case SHADER_OPCODE_COS:
return BRW_MATH_FUNCTION_COS;
case SHADER_OPCODE_INT_QUOTIENT:
return BRW_MATH_FUNCTION_INT_DIV_QUOTIENT;
case SHADER_OPCODE_INT_REMAINDER:
return BRW_MATH_FUNCTION_INT_DIV_REMAINDER;
default:
unreachable("not reached: unknown math function");
}
}
bool
brw_texture_offset(const nir_tex_instr *tex, unsigned src,
uint32_t *offset_bits_out)
{
if (!nir_src_is_const(tex->src[src].src))
return false;
const unsigned num_components = nir_tex_instr_src_size(tex, src);
/* Combine all three offsets into a single unsigned dword:
*
* bits 11:8 - U Offset (X component)
* bits 7:4 - V Offset (Y component)
* bits 3:0 - R Offset (Z component)
*/
uint32_t offset_bits = 0;
for (unsigned i = 0; i < num_components; i++) {
int offset = nir_src_comp_as_int(tex->src[src].src, i);
/* offset out of bounds; caller will handle it. */
if (offset > 7 || offset < -8)
return false;
const unsigned shift = 4 * (2 - i);
offset_bits |= (offset << shift) & (0xF << shift);
}
*offset_bits_out = offset_bits;
return true;
}
const char *
brw_instruction_name(const struct gen_device_info *devinfo, enum opcode op)
{
switch (op) {
case 0 ... NUM_BRW_OPCODES - 1:
/* The DO instruction doesn't exist on Gen6+, but we use it to mark the
* start of a loop in the IR.
*/
if (devinfo->gen >= 6 && op == BRW_OPCODE_DO)
return "do";
/* The following conversion opcodes doesn't exist on Gen8+, but we use
* then to mark that we want to do the conversion.
*/
if (devinfo->gen > 7 && op == BRW_OPCODE_F32TO16)
return "f32to16";
if (devinfo->gen > 7 && op == BRW_OPCODE_F16TO32)
return "f16to32";
assert(brw_opcode_desc(devinfo, op)->name);
return brw_opcode_desc(devinfo, op)->name;
case FS_OPCODE_FB_WRITE:
return "fb_write";
case FS_OPCODE_FB_WRITE_LOGICAL:
return "fb_write_logical";
case FS_OPCODE_REP_FB_WRITE:
return "rep_fb_write";
case FS_OPCODE_FB_READ:
return "fb_read";
case FS_OPCODE_FB_READ_LOGICAL:
return "fb_read_logical";
case SHADER_OPCODE_RCP:
return "rcp";
case SHADER_OPCODE_RSQ:
return "rsq";
case SHADER_OPCODE_SQRT:
return "sqrt";
case SHADER_OPCODE_EXP2:
return "exp2";
case SHADER_OPCODE_LOG2:
return "log2";
case SHADER_OPCODE_POW:
return "pow";
case SHADER_OPCODE_INT_QUOTIENT:
return "int_quot";
case SHADER_OPCODE_INT_REMAINDER:
return "int_rem";
case SHADER_OPCODE_SIN:
return "sin";
case SHADER_OPCODE_COS:
return "cos";
case SHADER_OPCODE_SEND:
return "send";
case SHADER_OPCODE_UNDEF:
return "undef";
case SHADER_OPCODE_TEX:
return "tex";
case SHADER_OPCODE_TEX_LOGICAL:
return "tex_logical";
case SHADER_OPCODE_TXD:
return "txd";
case SHADER_OPCODE_TXD_LOGICAL:
return "txd_logical";
case SHADER_OPCODE_TXF:
return "txf";
case SHADER_OPCODE_TXF_LOGICAL:
return "txf_logical";
case SHADER_OPCODE_TXF_LZ:
return "txf_lz";
case SHADER_OPCODE_TXL:
return "txl";
case SHADER_OPCODE_TXL_LOGICAL:
return "txl_logical";
case SHADER_OPCODE_TXL_LZ:
return "txl_lz";
case SHADER_OPCODE_TXS:
return "txs";
case SHADER_OPCODE_TXS_LOGICAL:
return "txs_logical";
case FS_OPCODE_TXB:
return "txb";
case FS_OPCODE_TXB_LOGICAL:
return "txb_logical";
case SHADER_OPCODE_TXF_CMS:
return "txf_cms";
case SHADER_OPCODE_TXF_CMS_LOGICAL:
return "txf_cms_logical";
case SHADER_OPCODE_TXF_CMS_W:
return "txf_cms_w";
case SHADER_OPCODE_TXF_CMS_W_LOGICAL:
return "txf_cms_w_logical";
case SHADER_OPCODE_TXF_UMS:
return "txf_ums";
case SHADER_OPCODE_TXF_UMS_LOGICAL:
return "txf_ums_logical";
case SHADER_OPCODE_TXF_MCS:
return "txf_mcs";
case SHADER_OPCODE_TXF_MCS_LOGICAL:
return "txf_mcs_logical";
case SHADER_OPCODE_LOD:
return "lod";
case SHADER_OPCODE_LOD_LOGICAL:
return "lod_logical";
case SHADER_OPCODE_TG4:
return "tg4";
case SHADER_OPCODE_TG4_LOGICAL:
return "tg4_logical";
case SHADER_OPCODE_TG4_OFFSET:
return "tg4_offset";
case SHADER_OPCODE_TG4_OFFSET_LOGICAL:
return "tg4_offset_logical";
case SHADER_OPCODE_SAMPLEINFO:
return "sampleinfo";
case SHADER_OPCODE_SAMPLEINFO_LOGICAL:
return "sampleinfo_logical";
case SHADER_OPCODE_IMAGE_SIZE_LOGICAL:
return "image_size_logical";
case SHADER_OPCODE_SHADER_TIME_ADD:
return "shader_time_add";
case VEC4_OPCODE_UNTYPED_ATOMIC:
return "untyped_atomic";
case SHADER_OPCODE_UNTYPED_ATOMIC_LOGICAL:
return "untyped_atomic_logical";
case SHADER_OPCODE_UNTYPED_ATOMIC_FLOAT_LOGICAL:
return "untyped_atomic_float_logical";
case VEC4_OPCODE_UNTYPED_SURFACE_READ:
return "untyped_surface_read";
case SHADER_OPCODE_UNTYPED_SURFACE_READ_LOGICAL:
return "untyped_surface_read_logical";
case VEC4_OPCODE_UNTYPED_SURFACE_WRITE:
return "untyped_surface_write";
case SHADER_OPCODE_UNTYPED_SURFACE_WRITE_LOGICAL:
return "untyped_surface_write_logical";
case SHADER_OPCODE_OWORD_BLOCK_READ_LOGICAL:
return "oword_block_read_logical";
case SHADER_OPCODE_UNALIGNED_OWORD_BLOCK_READ_LOGICAL:
return "unaligned_oword_block_read_logical";
case SHADER_OPCODE_OWORD_BLOCK_WRITE_LOGICAL:
return "oword_block_write_logical";
case SHADER_OPCODE_A64_UNTYPED_READ_LOGICAL:
return "a64_untyped_read_logical";
case SHADER_OPCODE_A64_OWORD_BLOCK_READ_LOGICAL:
return "a64_oword_block_read_logical";
case SHADER_OPCODE_A64_UNALIGNED_OWORD_BLOCK_READ_LOGICAL:
return "a64_unaligned_oword_block_read_logical";
case SHADER_OPCODE_A64_OWORD_BLOCK_WRITE_LOGICAL:
return "a64_oword_block_write_logical";
case SHADER_OPCODE_A64_UNTYPED_WRITE_LOGICAL:
return "a64_untyped_write_logical";
case SHADER_OPCODE_A64_BYTE_SCATTERED_READ_LOGICAL:
return "a64_byte_scattered_read_logical";
case SHADER_OPCODE_A64_BYTE_SCATTERED_WRITE_LOGICAL:
return "a64_byte_scattered_write_logical";
case SHADER_OPCODE_A64_UNTYPED_ATOMIC_LOGICAL:
return "a64_untyped_atomic_logical";
case SHADER_OPCODE_A64_UNTYPED_ATOMIC_INT64_LOGICAL:
return "a64_untyped_atomic_int64_logical";
case SHADER_OPCODE_A64_UNTYPED_ATOMIC_FLOAT_LOGICAL:
return "a64_untyped_atomic_float_logical";
case SHADER_OPCODE_TYPED_ATOMIC_LOGICAL:
return "typed_atomic_logical";
case SHADER_OPCODE_TYPED_SURFACE_READ_LOGICAL:
return "typed_surface_read_logical";
case SHADER_OPCODE_TYPED_SURFACE_WRITE_LOGICAL:
return "typed_surface_write_logical";
case SHADER_OPCODE_MEMORY_FENCE:
return "memory_fence";
case FS_OPCODE_SCHEDULING_FENCE:
return "scheduling_fence";
case SHADER_OPCODE_INTERLOCK:
/* For an interlock we actually issue a memory fence via sendc. */
return "interlock";
case SHADER_OPCODE_BYTE_SCATTERED_READ_LOGICAL:
return "byte_scattered_read_logical";
case SHADER_OPCODE_BYTE_SCATTERED_WRITE_LOGICAL:
return "byte_scattered_write_logical";
case SHADER_OPCODE_DWORD_SCATTERED_READ_LOGICAL:
return "dword_scattered_read_logical";
case SHADER_OPCODE_DWORD_SCATTERED_WRITE_LOGICAL:
return "dword_scattered_write_logical";
case SHADER_OPCODE_LOAD_PAYLOAD:
return "load_payload";
case FS_OPCODE_PACK:
return "pack";
case SHADER_OPCODE_GEN4_SCRATCH_READ:
return "gen4_scratch_read";
case SHADER_OPCODE_GEN4_SCRATCH_WRITE:
return "gen4_scratch_write";
case SHADER_OPCODE_GEN7_SCRATCH_READ:
return "gen7_scratch_read";
case SHADER_OPCODE_SCRATCH_HEADER:
return "scratch_header";
case SHADER_OPCODE_URB_WRITE_SIMD8:
return "gen8_urb_write_simd8";
case SHADER_OPCODE_URB_WRITE_SIMD8_PER_SLOT:
return "gen8_urb_write_simd8_per_slot";
case SHADER_OPCODE_URB_WRITE_SIMD8_MASKED:
return "gen8_urb_write_simd8_masked";
case SHADER_OPCODE_URB_WRITE_SIMD8_MASKED_PER_SLOT:
return "gen8_urb_write_simd8_masked_per_slot";
case SHADER_OPCODE_URB_READ_SIMD8:
return "urb_read_simd8";
case SHADER_OPCODE_URB_READ_SIMD8_PER_SLOT:
return "urb_read_simd8_per_slot";
case SHADER_OPCODE_FIND_LIVE_CHANNEL:
return "find_live_channel";
case FS_OPCODE_LOAD_LIVE_CHANNELS:
return "load_live_channels";
case SHADER_OPCODE_BROADCAST:
return "broadcast";
case SHADER_OPCODE_SHUFFLE:
return "shuffle";
case SHADER_OPCODE_SEL_EXEC:
return "sel_exec";
case SHADER_OPCODE_QUAD_SWIZZLE:
return "quad_swizzle";
case SHADER_OPCODE_CLUSTER_BROADCAST:
return "cluster_broadcast";
case SHADER_OPCODE_GET_BUFFER_SIZE:
return "get_buffer_size";
case VEC4_OPCODE_MOV_BYTES:
return "mov_bytes";
case VEC4_OPCODE_PACK_BYTES:
return "pack_bytes";
case VEC4_OPCODE_UNPACK_UNIFORM:
return "unpack_uniform";
case VEC4_OPCODE_DOUBLE_TO_F32:
return "double_to_f32";
case VEC4_OPCODE_DOUBLE_TO_D32:
return "double_to_d32";
case VEC4_OPCODE_DOUBLE_TO_U32:
return "double_to_u32";
case VEC4_OPCODE_TO_DOUBLE:
return "single_to_double";
case VEC4_OPCODE_PICK_LOW_32BIT:
return "pick_low_32bit";
case VEC4_OPCODE_PICK_HIGH_32BIT:
return "pick_high_32bit";
case VEC4_OPCODE_SET_LOW_32BIT:
return "set_low_32bit";
case VEC4_OPCODE_SET_HIGH_32BIT:
return "set_high_32bit";
case FS_OPCODE_DDX_COARSE:
return "ddx_coarse";
case FS_OPCODE_DDX_FINE:
return "ddx_fine";
case FS_OPCODE_DDY_COARSE:
return "ddy_coarse";
case FS_OPCODE_DDY_FINE:
return "ddy_fine";
case FS_OPCODE_LINTERP:
return "linterp";
case FS_OPCODE_PIXEL_X:
return "pixel_x";
case FS_OPCODE_PIXEL_Y:
return "pixel_y";
case FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD:
return "uniform_pull_const";
case FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD_GEN7:
return "uniform_pull_const_gen7";
case FS_OPCODE_VARYING_PULL_CONSTANT_LOAD_GEN4:
return "varying_pull_const_gen4";
case FS_OPCODE_VARYING_PULL_CONSTANT_LOAD_LOGICAL:
return "varying_pull_const_logical";
case FS_OPCODE_SET_SAMPLE_ID:
return "set_sample_id";
case FS_OPCODE_PACK_HALF_2x16_SPLIT:
return "pack_half_2x16_split";
case SHADER_OPCODE_HALT_TARGET:
return "halt_target";
case FS_OPCODE_INTERPOLATE_AT_SAMPLE:
return "interp_sample";
case FS_OPCODE_INTERPOLATE_AT_SHARED_OFFSET:
return "interp_shared_offset";
case FS_OPCODE_INTERPOLATE_AT_PER_SLOT_OFFSET:
return "interp_per_slot_offset";
case VS_OPCODE_URB_WRITE:
return "vs_urb_write";
case VS_OPCODE_PULL_CONSTANT_LOAD:
return "pull_constant_load";
case VS_OPCODE_PULL_CONSTANT_LOAD_GEN7:
return "pull_constant_load_gen7";
case VS_OPCODE_UNPACK_FLAGS_SIMD4X2:
return "unpack_flags_simd4x2";
case GS_OPCODE_URB_WRITE:
return "gs_urb_write";
case GS_OPCODE_URB_WRITE_ALLOCATE:
return "gs_urb_write_allocate";
case GS_OPCODE_THREAD_END:
return "gs_thread_end";
case GS_OPCODE_SET_WRITE_OFFSET:
return "set_write_offset";
case GS_OPCODE_SET_VERTEX_COUNT:
return "set_vertex_count";
case GS_OPCODE_SET_DWORD_2:
return "set_dword_2";
case GS_OPCODE_PREPARE_CHANNEL_MASKS:
return "prepare_channel_masks";
case GS_OPCODE_SET_CHANNEL_MASKS:
return "set_channel_masks";
case GS_OPCODE_GET_INSTANCE_ID:
return "get_instance_id";
case GS_OPCODE_FF_SYNC:
return "ff_sync";
case GS_OPCODE_SET_PRIMITIVE_ID:
return "set_primitive_id";
case GS_OPCODE_SVB_WRITE:
return "gs_svb_write";
case GS_OPCODE_SVB_SET_DST_INDEX:
return "gs_svb_set_dst_index";
case GS_OPCODE_FF_SYNC_SET_PRIMITIVES:
return "gs_ff_sync_set_primitives";
case CS_OPCODE_CS_TERMINATE:
return "cs_terminate";
case SHADER_OPCODE_BARRIER:
return "barrier";
case SHADER_OPCODE_MULH:
return "mulh";
case SHADER_OPCODE_ISUB_SAT:
return "isub_sat";
case SHADER_OPCODE_USUB_SAT:
return "usub_sat";
case SHADER_OPCODE_MOV_INDIRECT:
return "mov_indirect";
case SHADER_OPCODE_MOV_RELOC_IMM:
return "mov_reloc_imm";
case VEC4_OPCODE_URB_READ:
return "urb_read";
case TCS_OPCODE_GET_INSTANCE_ID:
return "tcs_get_instance_id";
case TCS_OPCODE_URB_WRITE:
return "tcs_urb_write";
case TCS_OPCODE_SET_INPUT_URB_OFFSETS:
return "tcs_set_input_urb_offsets";
case TCS_OPCODE_SET_OUTPUT_URB_OFFSETS:
return "tcs_set_output_urb_offsets";
case TCS_OPCODE_GET_PRIMITIVE_ID:
return "tcs_get_primitive_id";
case TCS_OPCODE_CREATE_BARRIER_HEADER:
return "tcs_create_barrier_header";
case TCS_OPCODE_SRC0_010_IS_ZERO:
return "tcs_src0<0,1,0>_is_zero";
case TCS_OPCODE_RELEASE_INPUT:
return "tcs_release_input";
case TCS_OPCODE_THREAD_END:
return "tcs_thread_end";
case TES_OPCODE_CREATE_INPUT_READ_HEADER:
return "tes_create_input_read_header";
case TES_OPCODE_ADD_INDIRECT_URB_OFFSET:
return "tes_add_indirect_urb_offset";
case TES_OPCODE_GET_PRIMITIVE_ID:
return "tes_get_primitive_id";
case RT_OPCODE_TRACE_RAY_LOGICAL:
return "rt_trace_ray_logical";
case SHADER_OPCODE_RND_MODE:
return "rnd_mode";
case SHADER_OPCODE_FLOAT_CONTROL_MODE:
return "float_control_mode";
case SHADER_OPCODE_GET_DSS_ID:
return "get_dss_id";
case SHADER_OPCODE_BTD_SPAWN_LOGICAL:
return "btd_spawn_logical";
case SHADER_OPCODE_BTD_RETIRE_LOGICAL:
return "btd_retire_logical";
}
unreachable("not reached");
}
bool
brw_saturate_immediate(enum brw_reg_type type, struct brw_reg *reg)
{
union {
unsigned ud;
int d;
float f;
double df;
} imm, sat_imm = { 0 };
const unsigned size = type_sz(type);
/* We want to either do a 32-bit or 64-bit data copy, the type is otherwise
* irrelevant, so just check the size of the type and copy from/to an
* appropriately sized field.
*/
if (size < 8)
imm.ud = reg->ud;
else
imm.df = reg->df;
switch (type) {
case BRW_REGISTER_TYPE_UD:
case BRW_REGISTER_TYPE_D:
case BRW_REGISTER_TYPE_UW:
case BRW_REGISTER_TYPE_W:
case BRW_REGISTER_TYPE_UQ:
case BRW_REGISTER_TYPE_Q:
/* Nothing to do. */
return false;
case BRW_REGISTER_TYPE_F:
sat_imm.f = SATURATE(imm.f);
break;
case BRW_REGISTER_TYPE_DF:
sat_imm.df = SATURATE(imm.df);
break;
case BRW_REGISTER_TYPE_UB:
case BRW_REGISTER_TYPE_B:
unreachable("no UB/B immediates");
case BRW_REGISTER_TYPE_V:
case BRW_REGISTER_TYPE_UV:
case BRW_REGISTER_TYPE_VF:
unreachable("unimplemented: saturate vector immediate");
case BRW_REGISTER_TYPE_HF:
unreachable("unimplemented: saturate HF immediate");
case BRW_REGISTER_TYPE_NF:
unreachable("no NF immediates");
}
if (size < 8) {
if (imm.ud != sat_imm.ud) {
reg->ud = sat_imm.ud;
return true;
}
} else {
if (imm.df != sat_imm.df) {
reg->df = sat_imm.df;
return true;
}
}
return false;
}
bool
brw_negate_immediate(enum brw_reg_type type, struct brw_reg *reg)
{
switch (type) {
case BRW_REGISTER_TYPE_D:
case BRW_REGISTER_TYPE_UD:
reg->d = -reg->d;
return true;
case BRW_REGISTER_TYPE_W:
case BRW_REGISTER_TYPE_UW: {
uint16_t value = -(int16_t)reg->ud;
reg->ud = value | (uint32_t)value << 16;
return true;
}
case BRW_REGISTER_TYPE_F:
reg->f = -reg->f;
return true;
case BRW_REGISTER_TYPE_VF:
reg->ud ^= 0x80808080;
return true;
case BRW_REGISTER_TYPE_DF:
reg->df = -reg->df;
return true;
case BRW_REGISTER_TYPE_UQ:
case BRW_REGISTER_TYPE_Q:
reg->d64 = -reg->d64;
return true;
case BRW_REGISTER_TYPE_UB:
case BRW_REGISTER_TYPE_B:
unreachable("no UB/B immediates");
case BRW_REGISTER_TYPE_UV:
case BRW_REGISTER_TYPE_V:
assert(!"unimplemented: negate UV/V immediate");
case BRW_REGISTER_TYPE_HF:
reg->ud ^= 0x80008000;
return true;
case BRW_REGISTER_TYPE_NF:
unreachable("no NF immediates");
}
return false;
}
bool
brw_abs_immediate(enum brw_reg_type type, struct brw_reg *reg)
{
switch (type) {
case BRW_REGISTER_TYPE_D:
reg->d = abs(reg->d);
return true;
case BRW_REGISTER_TYPE_W: {
uint16_t value = abs((int16_t)reg->ud);
reg->ud = value | (uint32_t)value << 16;
return true;
}
case BRW_REGISTER_TYPE_F:
reg->f = fabsf(reg->f);
return true;
case BRW_REGISTER_TYPE_DF:
reg->df = fabs(reg->df);
return true;
case BRW_REGISTER_TYPE_VF:
reg->ud &= ~0x80808080;
return true;
case BRW_REGISTER_TYPE_Q:
reg->d64 = imaxabs(reg->d64);
return true;
case BRW_REGISTER_TYPE_UB:
case BRW_REGISTER_TYPE_B:
unreachable("no UB/B immediates");
case BRW_REGISTER_TYPE_UQ:
case BRW_REGISTER_TYPE_UD:
case BRW_REGISTER_TYPE_UW:
case BRW_REGISTER_TYPE_UV:
/* Presumably the absolute value modifier on an unsigned source is a
* nop, but it would be nice to confirm.
*/
assert(!"unimplemented: abs unsigned immediate");
case BRW_REGISTER_TYPE_V:
assert(!"unimplemented: abs V immediate");
case BRW_REGISTER_TYPE_HF:
reg->ud &= ~0x80008000;
return true;
case BRW_REGISTER_TYPE_NF:
unreachable("no NF immediates");
}
return false;
}
backend_shader::backend_shader(const struct brw_compiler *compiler,
void *log_data,
void *mem_ctx,
const nir_shader *shader,
struct brw_stage_prog_data *stage_prog_data)
: compiler(compiler),
log_data(log_data),
devinfo(compiler->devinfo),
nir(shader),
stage_prog_data(stage_prog_data),
mem_ctx(mem_ctx),
cfg(NULL), idom_analysis(this),
stage(shader->info.stage)
{
debug_enabled = INTEL_DEBUG & intel_debug_flag_for_shader_stage(stage);
stage_name = _mesa_shader_stage_to_string(stage);
stage_abbrev = _mesa_shader_stage_to_abbrev(stage);
}
backend_shader::~backend_shader()
{
}
bool
backend_reg::equals(const backend_reg &r) const
{
return brw_regs_equal(this, &r) && offset == r.offset;
}
bool
backend_reg::negative_equals(const backend_reg &r) const
{
return brw_regs_negative_equal(this, &r) && offset == r.offset;
}
bool
backend_reg::is_zero() const
{
if (file != IMM)
return false;
assert(type_sz(type) > 1);
switch (type) {
case BRW_REGISTER_TYPE_HF:
assert((d & 0xffff) == ((d >> 16) & 0xffff));
return (d & 0xffff) == 0 || (d & 0xffff) == 0x8000;
case BRW_REGISTER_TYPE_F:
return f == 0;
case BRW_REGISTER_TYPE_DF:
return df == 0;
case BRW_REGISTER_TYPE_W:
case BRW_REGISTER_TYPE_UW:
assert((d & 0xffff) == ((d >> 16) & 0xffff));
return (d & 0xffff) == 0;
case BRW_REGISTER_TYPE_D:
case BRW_REGISTER_TYPE_UD:
return d == 0;
case BRW_REGISTER_TYPE_UQ:
case BRW_REGISTER_TYPE_Q:
return u64 == 0;
default:
return false;
}
}
bool
backend_reg::is_one() const
{
if (file != IMM)
return false;
assert(type_sz(type) > 1);
switch (type) {
case BRW_REGISTER_TYPE_HF:
assert((d & 0xffff) == ((d >> 16) & 0xffff));
return (d & 0xffff) == 0x3c00;
case BRW_REGISTER_TYPE_F:
return f == 1.0f;
case BRW_REGISTER_TYPE_DF:
return df == 1.0;
case BRW_REGISTER_TYPE_W:
case BRW_REGISTER_TYPE_UW:
assert((d & 0xffff) == ((d >> 16) & 0xffff));
return (d & 0xffff) == 1;
case BRW_REGISTER_TYPE_D:
case BRW_REGISTER_TYPE_UD:
return d == 1;
case BRW_REGISTER_TYPE_UQ:
case BRW_REGISTER_TYPE_Q:
return u64 == 1;
default:
return false;
}
}
bool
backend_reg::is_negative_one() const
{
if (file != IMM)
return false;
assert(type_sz(type) > 1);
switch (type) {
case BRW_REGISTER_TYPE_HF:
assert((d & 0xffff) == ((d >> 16) & 0xffff));
return (d & 0xffff) == 0xbc00;
case BRW_REGISTER_TYPE_F:
return f == -1.0;
case BRW_REGISTER_TYPE_DF:
return df == -1.0;
case BRW_REGISTER_TYPE_W:
assert((d & 0xffff) == ((d >> 16) & 0xffff));
return (d & 0xffff) == 0xffff;
case BRW_REGISTER_TYPE_D:
return d == -1;
case BRW_REGISTER_TYPE_Q:
return d64 == -1;
default:
return false;
}
}
bool
backend_reg::is_null() const
{
return file == ARF && nr == BRW_ARF_NULL;
}
bool
backend_reg::is_accumulator() const
{
return file == ARF && nr == BRW_ARF_ACCUMULATOR;
}
bool
backend_instruction::is_commutative() const
{
switch (opcode) {
case BRW_OPCODE_AND:
case BRW_OPCODE_OR:
case BRW_OPCODE_XOR:
case BRW_OPCODE_ADD:
case BRW_OPCODE_MUL:
case SHADER_OPCODE_MULH:
return true;
case BRW_OPCODE_SEL:
/* MIN and MAX are commutative. */
if (conditional_mod == BRW_CONDITIONAL_GE ||
conditional_mod == BRW_CONDITIONAL_L) {
return true;
}
/* fallthrough */
default:
return false;
}
}
bool
backend_instruction::is_3src(const struct gen_device_info *devinfo) const
{
return ::is_3src(devinfo, opcode);
}
bool
backend_instruction::is_tex() const
{
return (opcode == SHADER_OPCODE_TEX ||
opcode == FS_OPCODE_TXB ||
opcode == SHADER_OPCODE_TXD ||
opcode == SHADER_OPCODE_TXF ||
opcode == SHADER_OPCODE_TXF_LZ ||
opcode == SHADER_OPCODE_TXF_CMS ||
opcode == SHADER_OPCODE_TXF_CMS_W ||
opcode == SHADER_OPCODE_TXF_UMS ||
opcode == SHADER_OPCODE_TXF_MCS ||
opcode == SHADER_OPCODE_TXL ||
opcode == SHADER_OPCODE_TXL_LZ ||
opcode == SHADER_OPCODE_TXS ||
opcode == SHADER_OPCODE_LOD ||
opcode == SHADER_OPCODE_TG4 ||
opcode == SHADER_OPCODE_TG4_OFFSET ||
opcode == SHADER_OPCODE_SAMPLEINFO);
}
bool
backend_instruction::is_math() const
{
return (opcode == SHADER_OPCODE_RCP ||
opcode == SHADER_OPCODE_RSQ ||
opcode == SHADER_OPCODE_SQRT ||
opcode == SHADER_OPCODE_EXP2 ||
opcode == SHADER_OPCODE_LOG2 ||
opcode == SHADER_OPCODE_SIN ||
opcode == SHADER_OPCODE_COS ||
opcode == SHADER_OPCODE_INT_QUOTIENT ||
opcode == SHADER_OPCODE_INT_REMAINDER ||
opcode == SHADER_OPCODE_POW);
}
bool
backend_instruction::is_control_flow() const
{
switch (opcode) {
case BRW_OPCODE_DO:
case BRW_OPCODE_WHILE:
case BRW_OPCODE_IF:
case BRW_OPCODE_ELSE:
case BRW_OPCODE_ENDIF:
case BRW_OPCODE_BREAK:
case BRW_OPCODE_CONTINUE:
return true;
default:
return false;
}
}
bool
backend_instruction::can_do_source_mods() const
{
switch (opcode) {
case BRW_OPCODE_ADDC:
case BRW_OPCODE_BFE:
case BRW_OPCODE_BFI1:
case BRW_OPCODE_BFI2:
case BRW_OPCODE_BFREV:
case BRW_OPCODE_CBIT:
case BRW_OPCODE_FBH:
case BRW_OPCODE_FBL:
case BRW_OPCODE_ROL:
case BRW_OPCODE_ROR:
case BRW_OPCODE_SUBB:
case SHADER_OPCODE_BROADCAST:
case SHADER_OPCODE_CLUSTER_BROADCAST:
case SHADER_OPCODE_MOV_INDIRECT:
case SHADER_OPCODE_SHUFFLE:
return false;
default:
return true;
}
}
bool
backend_instruction::can_do_saturate() const
{
switch (opcode) {
case BRW_OPCODE_ADD:
case BRW_OPCODE_ASR:
case BRW_OPCODE_AVG:
case BRW_OPCODE_CSEL:
case BRW_OPCODE_DP2:
case BRW_OPCODE_DP3:
case BRW_OPCODE_DP4:
case BRW_OPCODE_DPH:
case BRW_OPCODE_F16TO32:
case BRW_OPCODE_F32TO16:
case BRW_OPCODE_LINE:
case BRW_OPCODE_LRP:
case BRW_OPCODE_MAC:
case BRW_OPCODE_MAD:
case BRW_OPCODE_MATH:
case BRW_OPCODE_MOV:
case BRW_OPCODE_MUL:
case SHADER_OPCODE_MULH:
case BRW_OPCODE_PLN:
case BRW_OPCODE_RNDD:
case BRW_OPCODE_RNDE:
case BRW_OPCODE_RNDU:
case BRW_OPCODE_RNDZ:
case BRW_OPCODE_SEL:
case BRW_OPCODE_SHL:
case BRW_OPCODE_SHR:
case FS_OPCODE_LINTERP:
case SHADER_OPCODE_COS:
case SHADER_OPCODE_EXP2:
case SHADER_OPCODE_LOG2:
case SHADER_OPCODE_POW:
case SHADER_OPCODE_RCP:
case SHADER_OPCODE_RSQ:
case SHADER_OPCODE_SIN:
case SHADER_OPCODE_SQRT:
return true;
default:
return false;
}
}
bool
backend_instruction::can_do_cmod() const
{
switch (opcode) {
case BRW_OPCODE_ADD:
case BRW_OPCODE_ADDC:
case BRW_OPCODE_AND:
case BRW_OPCODE_ASR:
case BRW_OPCODE_AVG:
case BRW_OPCODE_CMP:
case BRW_OPCODE_CMPN:
case BRW_OPCODE_DP2:
case BRW_OPCODE_DP3:
case BRW_OPCODE_DP4:
case BRW_OPCODE_DPH:
case BRW_OPCODE_F16TO32:
case BRW_OPCODE_F32TO16:
case BRW_OPCODE_FRC:
case BRW_OPCODE_LINE:
case BRW_OPCODE_LRP:
case BRW_OPCODE_LZD:
case BRW_OPCODE_MAC:
case BRW_OPCODE_MACH:
case BRW_OPCODE_MAD:
case BRW_OPCODE_MOV:
case BRW_OPCODE_MUL:
case BRW_OPCODE_NOT:
case BRW_OPCODE_OR:
case BRW_OPCODE_PLN:
case BRW_OPCODE_RNDD:
case BRW_OPCODE_RNDE:
case BRW_OPCODE_RNDU:
case BRW_OPCODE_RNDZ:
case BRW_OPCODE_SAD2:
case BRW_OPCODE_SADA2:
case BRW_OPCODE_SHL:
case BRW_OPCODE_SHR:
case BRW_OPCODE_SUBB:
case BRW_OPCODE_XOR:
case FS_OPCODE_LINTERP:
return true;
default:
return false;
}
}
bool
backend_instruction::reads_accumulator_implicitly() const
{
switch (opcode) {
case BRW_OPCODE_MAC:
case BRW_OPCODE_MACH:
case BRW_OPCODE_SADA2:
return true;
default:
return false;
}
}
bool
backend_instruction::writes_accumulator_implicitly(const struct gen_device_info *devinfo) const
{
return writes_accumulator ||
(devinfo->gen < 6 &&
((opcode >= BRW_OPCODE_ADD && opcode < BRW_OPCODE_NOP) ||
(opcode >= FS_OPCODE_DDX_COARSE && opcode <= FS_OPCODE_LINTERP))) ||
(opcode == FS_OPCODE_LINTERP &&
(!devinfo->has_pln || devinfo->gen <= 6));
}
bool
backend_instruction::has_side_effects() const
{
switch (opcode) {
case SHADER_OPCODE_SEND:
return send_has_side_effects;
case BRW_OPCODE_SYNC:
case VEC4_OPCODE_UNTYPED_ATOMIC:
case SHADER_OPCODE_UNTYPED_ATOMIC_LOGICAL:
case SHADER_OPCODE_UNTYPED_ATOMIC_FLOAT_LOGICAL:
case SHADER_OPCODE_GEN4_SCRATCH_WRITE:
case VEC4_OPCODE_UNTYPED_SURFACE_WRITE:
case SHADER_OPCODE_UNTYPED_SURFACE_WRITE_LOGICAL:
case SHADER_OPCODE_A64_UNTYPED_WRITE_LOGICAL:
case SHADER_OPCODE_A64_BYTE_SCATTERED_WRITE_LOGICAL:
case SHADER_OPCODE_A64_UNTYPED_ATOMIC_LOGICAL:
case SHADER_OPCODE_A64_UNTYPED_ATOMIC_INT64_LOGICAL:
case SHADER_OPCODE_A64_UNTYPED_ATOMIC_FLOAT_LOGICAL:
case SHADER_OPCODE_BYTE_SCATTERED_WRITE_LOGICAL:
case SHADER_OPCODE_DWORD_SCATTERED_WRITE_LOGICAL:
case SHADER_OPCODE_TYPED_ATOMIC_LOGICAL:
case SHADER_OPCODE_TYPED_SURFACE_WRITE_LOGICAL:
case SHADER_OPCODE_MEMORY_FENCE:
case SHADER_OPCODE_INTERLOCK:
case SHADER_OPCODE_URB_WRITE_SIMD8:
case SHADER_OPCODE_URB_WRITE_SIMD8_PER_SLOT:
case SHADER_OPCODE_URB_WRITE_SIMD8_MASKED:
case SHADER_OPCODE_URB_WRITE_SIMD8_MASKED_PER_SLOT:
case FS_OPCODE_FB_WRITE:
case FS_OPCODE_FB_WRITE_LOGICAL:
case FS_OPCODE_REP_FB_WRITE:
case SHADER_OPCODE_BARRIER:
case TCS_OPCODE_URB_WRITE:
case TCS_OPCODE_RELEASE_INPUT:
case SHADER_OPCODE_RND_MODE:
case SHADER_OPCODE_FLOAT_CONTROL_MODE:
case FS_OPCODE_SCHEDULING_FENCE:
case SHADER_OPCODE_OWORD_BLOCK_WRITE_LOGICAL:
case SHADER_OPCODE_A64_OWORD_BLOCK_WRITE_LOGICAL:
case SHADER_OPCODE_BTD_SPAWN_LOGICAL:
case SHADER_OPCODE_BTD_RETIRE_LOGICAL:
case RT_OPCODE_TRACE_RAY_LOGICAL:
return true;
default:
return eot;
}
}
bool
backend_instruction::is_volatile() const
{
switch (opcode) {
case SHADER_OPCODE_SEND:
return send_is_volatile;
case VEC4_OPCODE_UNTYPED_SURFACE_READ:
case SHADER_OPCODE_UNTYPED_SURFACE_READ_LOGICAL:
case SHADER_OPCODE_TYPED_SURFACE_READ_LOGICAL:
case SHADER_OPCODE_BYTE_SCATTERED_READ_LOGICAL:
case SHADER_OPCODE_DWORD_SCATTERED_READ_LOGICAL:
case SHADER_OPCODE_A64_UNTYPED_READ_LOGICAL:
case SHADER_OPCODE_A64_BYTE_SCATTERED_READ_LOGICAL:
case SHADER_OPCODE_URB_READ_SIMD8:
case SHADER_OPCODE_URB_READ_SIMD8_PER_SLOT:
case VEC4_OPCODE_URB_READ:
return true;
default:
return false;
}
}
#ifndef NDEBUG
static bool
inst_is_in_block(const bblock_t *block, const backend_instruction *inst)
{
bool found = false;
foreach_inst_in_block (backend_instruction, i, block) {
if (inst == i) {
found = true;
}
}
return found;
}
#endif
static void
adjust_later_block_ips(bblock_t *start_block, int ip_adjustment)
{
for (bblock_t *block_iter = start_block->next();
block_iter;
block_iter = block_iter->next()) {
block_iter->start_ip += ip_adjustment;
block_iter->end_ip += ip_adjustment;
}
}
void
backend_instruction::insert_after(bblock_t *block, backend_instruction *inst)
{
assert(this != inst);
if (!this->is_head_sentinel())
assert(inst_is_in_block(block, this) || !"Instruction not in block");
block->end_ip++;
adjust_later_block_ips(block, 1);
exec_node::insert_after(inst);
}
void
backend_instruction::insert_before(bblock_t *block, backend_instruction *inst)
{
assert(this != inst);
if (!this->is_tail_sentinel())
assert(inst_is_in_block(block, this) || !"Instruction not in block");
block->end_ip++;
adjust_later_block_ips(block, 1);
exec_node::insert_before(inst);
}
void
backend_instruction::insert_before(bblock_t *block, exec_list *list)
{
assert(inst_is_in_block(block, this) || !"Instruction not in block");
unsigned num_inst = list->length();
block->end_ip += num_inst;
adjust_later_block_ips(block, num_inst);
exec_node::insert_before(list);
}
void
backend_instruction::remove(bblock_t *block)
{
assert(inst_is_in_block(block, this) || !"Instruction not in block");
adjust_later_block_ips(block, -1);
if (block->start_ip == block->end_ip) {
block->cfg->remove_block(block);
} else {
block->end_ip--;
}
exec_node::remove();
}
void
backend_shader::dump_instructions() const
{
dump_instructions(NULL);
}
void
backend_shader::dump_instructions(const char *name) const
{
FILE *file = stderr;
if (name && geteuid() != 0) {
file = fopen(name, "w");
if (!file)
file = stderr;
}
if (cfg) {
int ip = 0;
foreach_block_and_inst(block, backend_instruction, inst, cfg) {
if (!(INTEL_DEBUG & DEBUG_OPTIMIZER))
fprintf(file, "%4d: ", ip++);
dump_instruction(inst, file);
}
} else {
int ip = 0;
foreach_in_list(backend_instruction, inst, &instructions) {
if (!(INTEL_DEBUG & DEBUG_OPTIMIZER))
fprintf(file, "%4d: ", ip++);
dump_instruction(inst, file);
}
}
if (file != stderr) {
fclose(file);
}
}
void
backend_shader::calculate_cfg()
{
if (this->cfg)
return;
cfg = new(mem_ctx) cfg_t(this, &this->instructions);
}
void
backend_shader::invalidate_analysis(brw::analysis_dependency_class c)
{
idom_analysis.invalidate(c);
}
extern "C" const unsigned *
brw_compile_tes(const struct brw_compiler *compiler,
void *log_data,
void *mem_ctx,
const struct brw_tes_prog_key *key,
const struct brw_vue_map *input_vue_map,
struct brw_tes_prog_data *prog_data,
nir_shader *nir,
int shader_time_index,
struct brw_compile_stats *stats,
char **error_str)
{
const struct gen_device_info *devinfo = compiler->devinfo;
const bool is_scalar = compiler->scalar_stage[MESA_SHADER_TESS_EVAL];
const unsigned *assembly;
prog_data->base.base.stage = MESA_SHADER_TESS_EVAL;
nir->info.inputs_read = key->inputs_read;
nir->info.patch_inputs_read = key->patch_inputs_read;
brw_nir_apply_key(nir, compiler, &key->base, 8, is_scalar);
brw_nir_lower_tes_inputs(nir, input_vue_map);
brw_nir_lower_vue_outputs(nir);
brw_postprocess_nir(nir, compiler, is_scalar);
brw_compute_vue_map(devinfo, &prog_data->base.vue_map,
nir->info.outputs_written,
nir->info.separate_shader, 1);
unsigned output_size_bytes = prog_data->base.vue_map.num_slots * 4 * 4;
assert(output_size_bytes >= 1);
if (output_size_bytes > GEN7_MAX_DS_URB_ENTRY_SIZE_BYTES) {
if (error_str)
*error_str = ralloc_strdup(mem_ctx, "DS outputs exceed maximum size");
return NULL;
}
prog_data->base.clip_distance_mask =
((1 << nir->info.clip_distance_array_size) - 1);
prog_data->base.cull_distance_mask =
((1 << nir->info.cull_distance_array_size) - 1) <<
nir->info.clip_distance_array_size;
/* URB entry sizes are stored as a multiple of 64 bytes. */
prog_data->base.urb_entry_size = ALIGN(output_size_bytes, 64) / 64;
prog_data->base.urb_read_length = 0;
STATIC_ASSERT(BRW_TESS_PARTITIONING_INTEGER == TESS_SPACING_EQUAL - 1);
STATIC_ASSERT(BRW_TESS_PARTITIONING_ODD_FRACTIONAL ==
TESS_SPACING_FRACTIONAL_ODD - 1);
STATIC_ASSERT(BRW_TESS_PARTITIONING_EVEN_FRACTIONAL ==
TESS_SPACING_FRACTIONAL_EVEN - 1);
prog_data->partitioning =
(enum brw_tess_partitioning) (nir->info.tess.spacing - 1);
switch (nir->info.tess.primitive_mode) {
case GL_QUADS:
prog_data->domain = BRW_TESS_DOMAIN_QUAD;
break;
case GL_TRIANGLES:
prog_data->domain = BRW_TESS_DOMAIN_TRI;
break;
case GL_ISOLINES:
prog_data->domain = BRW_TESS_DOMAIN_ISOLINE;
break;
default:
unreachable("invalid domain shader primitive mode");
}
if (nir->info.tess.point_mode) {
prog_data->output_topology = BRW_TESS_OUTPUT_TOPOLOGY_POINT;
} else if (nir->info.tess.primitive_mode == GL_ISOLINES) {
prog_data->output_topology = BRW_TESS_OUTPUT_TOPOLOGY_LINE;
} else {
/* Hardware winding order is backwards from OpenGL */
prog_data->output_topology =
nir->info.tess.ccw ? BRW_TESS_OUTPUT_TOPOLOGY_TRI_CW
: BRW_TESS_OUTPUT_TOPOLOGY_TRI_CCW;
}
if (INTEL_DEBUG & DEBUG_TES) {
fprintf(stderr, "TES Input ");
brw_print_vue_map(stderr, input_vue_map, MESA_SHADER_TESS_EVAL);
fprintf(stderr, "TES Output ");
brw_print_vue_map(stderr, &prog_data->base.vue_map,
MESA_SHADER_TESS_EVAL);
}
if (is_scalar) {
fs_visitor v(compiler, log_data, mem_ctx, &key->base,
&prog_data->base.base, nir, 8,
shader_time_index, input_vue_map);
if (!v.run_tes()) {
if (error_str)
*error_str = ralloc_strdup(mem_ctx, v.fail_msg);
return NULL;
}
prog_data->base.base.dispatch_grf_start_reg = v.payload.num_regs;
prog_data->base.dispatch_mode = DISPATCH_MODE_SIMD8;
fs_generator g(compiler, log_data, mem_ctx,
&prog_data->base.base, false, MESA_SHADER_TESS_EVAL);
if (INTEL_DEBUG & DEBUG_TES) {
g.enable_debug(ralloc_asprintf(mem_ctx,
"%s tessellation evaluation shader %s",
nir->info.label ? nir->info.label
: "unnamed",
nir->info.name));
}
g.generate_code(v.cfg, 8, v.shader_stats,
v.performance_analysis.require(), stats);
g.add_const_data(nir->constant_data, nir->constant_data_size);
assembly = g.get_assembly();
} else {
brw::vec4_tes_visitor v(compiler, log_data, key, prog_data,
nir, mem_ctx, shader_time_index);
if (!v.run()) {
if (error_str)
*error_str = ralloc_strdup(mem_ctx, v.fail_msg);
return NULL;
}
if (INTEL_DEBUG & DEBUG_TES)
v.dump_instructions();
assembly = brw_vec4_generate_assembly(compiler, log_data, mem_ctx, nir,
&prog_data->base, v.cfg,
v.performance_analysis.require(),
stats);
}
return assembly;
}
| 28.678848
| 95
| 0.697354
|
pundiramit
|
f524f836aa3e336a3f7beeb98ec2d7451dae061d
| 1,017
|
cpp
|
C++
|
src/CommandLineOpts.cpp
|
schwarzschild-radius/spmdfy
|
9b5543e3446347277f15b9fe2aee3c7f8311bc78
|
[
"MIT"
] | 6
|
2019-07-26T12:37:32.000Z
|
2021-03-13T06:18:07.000Z
|
src/CommandLineOpts.cpp
|
schwarzschild-radius/spmdfy
|
9b5543e3446347277f15b9fe2aee3c7f8311bc78
|
[
"MIT"
] | 6
|
2019-06-19T06:04:01.000Z
|
2019-08-23T11:12:31.000Z
|
src/CommandLineOpts.cpp
|
schwarzschild-radius/spmdfy
|
9b5543e3446347277f15b9fe2aee3c7f8311bc78
|
[
"MIT"
] | 1
|
2020-05-28T06:43:12.000Z
|
2020-05-28T06:43:12.000Z
|
#include <spmdfy/CommandLineOpts.hpp>
llvm::cl::OptionCategory spmdfy_options("spmdfy");
llvm::cl::opt<std::string>
output_filename("o", llvm::cl::desc("Specify Ouput Filename"),
llvm::cl::value_desc("filename"),
llvm::cl::cat(spmdfy_options));
llvm::cl::opt<bool>
verbosity("v",
llvm::cl::desc("Show commands to run and use verbose output"),
llvm::cl::cat(spmdfy_options));
llvm::cl::opt<bool> toggle_ispc_macros(
"fno-ispc-macros",
llvm::cl::desc(
"toggle generation of ispc macros in the current output file"),
llvm::cl::cat(spmdfy_options));
llvm::cl::opt<std::string> generate_ispc_macros(
"generate-ispc-macros", llvm::cl::desc("File containing ISPC Macros"),
llvm::cl::value_desc("filename"), llvm::cl::cat(spmdfy_options));
llvm::cl::opt<bool>
generate_decl("fgenerate-decls",
llvm::cl::desc("Generate only ISPC declarations"),
llvm::cl::cat(spmdfy_options));
| 36.321429
| 76
| 0.628319
|
schwarzschild-radius
|
f528d7b9702de7c753deced6729d41701c02bd75
| 1,976
|
cxx
|
C++
|
inetsrv/msmq/src/ac/quser.cxx
|
npocmaka/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 17
|
2020-11-13T13:42:52.000Z
|
2021-09-16T09:13:13.000Z
|
inetsrv/msmq/src/ac/quser.cxx
|
sancho1952007/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 2
|
2020-10-19T08:02:06.000Z
|
2020-10-19T08:23:18.000Z
|
inetsrv/msmq/src/ac/quser.cxx
|
sancho1952007/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 14
|
2020-11-14T09:43:20.000Z
|
2021-08-28T08:59:57.000Z
|
/*++
Copyright (c) 1995 Microsoft Corporation
Module Name:
quser.cxx
Abstract:
Abstruct class CUserQueue members.
Author:
Erez Haba (erezh) 1-Aug-95
Shai Kariv (shaik) 8-May-2000
Environment:
Kernel mode
Revision History:
--*/
#include "internal.h"
#include <mqformat.h>
#include "quser.h"
#include "acp.h"
#ifndef MQDUMP
#include "quser.tmh"
#endif
//---------------------------------------------------------
//
// class CUserQueue
//
//---------------------------------------------------------
DEFINE_G_TYPE(CUserQueue);
void CUserQueue::UniqueID(const QUEUE_FORMAT* pQueueID)
{
ASSERT(m_QueueID.GetType() == QUEUE_FORMAT_TYPE_UNKNOWN);
if (!ACpDupQueueFormat(*pQueueID, m_QueueID))
{
m_QueueID.UnknownID(0);
return;
}
}
bool CUserQueue::IsValidQueueFormat() const
{
return m_QueueID.IsValid();
}
void CUserQueue::Close(PFILE_OBJECT pOwner, BOOL fCloseAll)
{
Inherited::Close(pOwner, fCloseAll);
//
// Revoke owner cursors
//
for(List<CCursor>::Iterator p(m_cursors); p;)
{
CCursor* pCursor = p;
//
// N.B. The iterator 'p' is incremented here since pCursor->Close()
// removed itself from the list thus invalidating the iterator.
//
++p;
if(fCloseAll || pCursor->IsOwner(pOwner))
{
pCursor->Close();
}
}
//
// Remove sharing from queue
//
IoRemoveShareAccess(pOwner, &m_ShareInfo);
}
NTSTATUS
CUserQueue::HandleToFormatName(
LPWSTR pwzFormatName,
ULONG BufferLength,
PULONG pFormatNameLength
) const
{
return MQpQueueFormatToFormatName(
UniqueID(),
pwzFormatName,
BufferLength,
pFormatNameLength,
false
);
} // CUserQueue::HandleToFormatName
| 18.819048
| 77
| 0.543522
|
npocmaka
|
f52932e475cb43c991f96d4af68ea068edb581fe
| 9,077
|
cxx
|
C++
|
VTKExtensions/FiltersRendering/vtkDataTabulator.cxx
|
qiangwushuang/ParaView
|
f35ed90a6582e9d21924b66a905498f6a38ab4a3
|
[
"Apache-2.0",
"BSD-3-Clause"
] | null | null | null |
VTKExtensions/FiltersRendering/vtkDataTabulator.cxx
|
qiangwushuang/ParaView
|
f35ed90a6582e9d21924b66a905498f6a38ab4a3
|
[
"Apache-2.0",
"BSD-3-Clause"
] | null | null | null |
VTKExtensions/FiltersRendering/vtkDataTabulator.cxx
|
qiangwushuang/ParaView
|
f35ed90a6582e9d21924b66a905498f6a38ab4a3
|
[
"Apache-2.0",
"BSD-3-Clause"
] | null | null | null |
/*=========================================================================
Program: ParaView
Module: vtkDataTabulator.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkDataTabulator.h"
#include "vtkAttributeDataToTableFilter.h"
#include "vtkCompositeDataSet.h"
#include "vtkDataObjectTreeIterator.h"
#include "vtkExtractBlockUsingDataAssembly.h"
#include "vtkFieldData.h"
#include "vtkInformation.h"
#include "vtkInformationIntegerKey.h"
#include "vtkLogger.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkPartitionedDataSet.h"
#include "vtkPartitionedDataSetCollection.h"
#include "vtkSplitColumnComponents.h"
#include "vtkTable.h"
#include "vtkUniformGridAMR.h"
#include "vtkUniformGridAMRDataIterator.h"
#include <cassert>
#include <map>
#include <string>
namespace
{
vtkTable* NewFieldDataWrapper(vtkDataObject* dobj)
{
vtkTable* dummy = vtkTable::New();
dummy->GetFieldData()->PassData(dobj->GetFieldData());
return dummy;
}
std::map<vtkDataObject*, std::string> GenerateNameMap(vtkDataObject* dobj)
{
std::map<vtkDataObject*, std::string> result;
auto pdc = vtkPartitionedDataSetCollection::SafeDownCast(dobj);
if (!pdc)
{
return result;
}
for (unsigned int cc = 0; cc < pdc->GetNumberOfPartitionedDataSets(); ++cc)
{
if (pdc->GetPartitionedDataSet(cc) && pdc->GetMetaData(cc) &&
pdc->GetMetaData(cc)->Has(vtkCompositeDataSet::NAME()))
{
auto ptd = pdc->GetPartitionedDataSet(cc);
std::string name = pdc->GetMetaData(cc)->Get(vtkCompositeDataSet::NAME());
for (unsigned int idx = 0; idx < ptd->GetNumberOfPartitions(); ++idx)
{
if (auto part = ptd->GetPartitionAsDataObject(idx))
{
result[part] = name;
}
}
}
}
return result;
}
}
vtkStandardNewMacro(vtkDataTabulator);
vtkInformationKeyMacro(vtkDataTabulator, COMPOSITE_INDEX, Integer);
vtkInformationKeyMacro(vtkDataTabulator, HIERARCHICAL_LEVEL, Integer);
vtkInformationKeyMacro(vtkDataTabulator, HIERARCHICAL_INDEX, Integer);
//----------------------------------------------------------------------------
vtkDataTabulator::vtkDataTabulator()
: FieldAssociation(vtkDataObject::FIELD_ASSOCIATION_POINTS)
, GenerateCellConnectivity(false)
, GenerateOriginalIds(true)
, SplitComponents(false)
, SplitComponentsNamingMode(vtkSplitColumnComponents::NAMES_WITH_UNDERSCORES)
, ActiveAssemblyForSelectors(nullptr)
{
this->SetActiveAssemblyForSelectors("Hierarchy");
}
//----------------------------------------------------------------------------
vtkDataTabulator::~vtkDataTabulator()
{
this->SetActiveAssemblyForSelectors(nullptr);
}
//----------------------------------------------------------------------------
int vtkDataTabulator::FillOutputPortInformation(int, vtkInformation* info)
{
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkPartitionedDataSet");
return 1;
}
//----------------------------------------------------------------------------
void vtkDataTabulator::AddSelector(const char* selector)
{
if (selector && this->Selectors.insert(selector).second)
{
this->Modified();
}
}
//----------------------------------------------------------------------------
void vtkDataTabulator::ClearSelectors()
{
if (!this->Selectors.empty())
{
this->Selectors.clear();
this->Modified();
}
}
//----------------------------------------------------------------------------
int vtkDataTabulator::RequestData(
vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
{
auto inputDO = vtkDataObject::GetData(inputVector[0], 0);
auto outputPD = vtkPartitionedDataSet::GetData(outputVector, 0);
if (vtkSmartPointer<vtkCompositeDataSet> inputCD = vtkCompositeDataSet::SafeDownCast(inputDO))
{
if (!this->Selectors.empty())
{
vtkNew<vtkExtractBlockUsingDataAssembly> extractor;
extractor->SetAssemblyName(this->ActiveAssemblyForSelectors);
for (const auto& selector : this->Selectors)
{
extractor->AddSelector(selector.c_str());
}
extractor->SetInputData(inputCD);
extractor->Update();
inputCD = vtkCompositeDataSet::SafeDownCast(extractor->GetOutputDataObject(0));
}
// we need special handling for names for partitioned-dataset in a
// partitioned-dataset-collection. to handle that we build this map.
auto nameMap = ::GenerateNameMap(inputDO);
vtkNew<vtkPartitionedDataSet> xInput;
auto iter = inputCD->NewIterator();
auto treeIter = vtkDataObjectTreeIterator::SafeDownCast(iter);
auto amrIter = vtkUniformGridAMRDataIterator::SafeDownCast(iter);
const bool global_data =
(treeIter && this->FieldAssociation == vtkDataObject::FIELD_ASSOCIATION_NONE);
if (global_data)
{
treeIter->VisitOnlyLeavesOff();
// since root node it skipped when iterating, handle it explicitly.
if (inputCD->GetFieldData()->GetNumberOfTuples() > 0)
{
auto dummy = ::NewFieldDataWrapper(inputCD);
xInput->SetPartition(0, dummy);
dummy->FastDelete();
auto metaData = xInput->GetMetaData(0u);
metaData->Set(vtkDataTabulator::COMPOSITE_INDEX(), 0);
metaData->Set(vtkCompositeDataSet::NAME(), "root");
}
}
for (iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
{
const auto nextIdx = xInput->GetNumberOfPartitions();
auto currentDO = iter->GetCurrentDataObject();
auto currentMD = iter->GetCurrentMetaData();
if (global_data && vtkCompositeDataSet::SafeDownCast(currentDO) != nullptr)
{
if (currentDO->GetFieldData()->GetNumberOfTuples() == 0)
{
continue;
}
auto dummy = ::NewFieldDataWrapper(currentDO);
xInput->SetPartition(nextIdx, dummy);
dummy->FastDelete();
}
else
{
xInput->SetPartition(nextIdx, currentDO);
}
auto metaData = xInput->GetMetaData(nextIdx);
if (currentMD)
{
// copy existing metadata first e.g. name etc.
metaData->Copy(currentMD);
}
// now add keys to help identify original composite index.
metaData->Set(vtkDataTabulator::COMPOSITE_INDEX(), iter->GetCurrentFlatIndex());
if (amrIter)
{
metaData->Set(vtkDataTabulator::HIERARCHICAL_LEVEL(), amrIter->GetCurrentLevel());
metaData->Set(vtkDataTabulator::HIERARCHICAL_INDEX(), amrIter->GetCurrentIndex());
}
if (!metaData->Has(vtkCompositeDataSet::NAME()))
{
auto niter = nameMap.find(currentDO);
if (niter == nameMap.end())
{
// if a name doesn't exist, let's create one.
std::string name = amrIter
? "level=" + std::to_string(amrIter->GetCurrentLevel()) + " index=" +
std::to_string(amrIter->GetCurrentIndex())
: "unnamed_" + std::to_string(iter->GetCurrentFlatIndex());
metaData->Set(vtkCompositeDataSet::NAME(), name.c_str());
}
else
{
metaData->Set(vtkCompositeDataSet::NAME(), niter->second.c_str());
}
}
}
iter->Delete();
auto output = this->Transform(xInput);
outputPD->ShallowCopy(output);
}
else
{
auto block = this->Transform(inputDO);
assert(vtkCompositeDataSet::SafeDownCast(block) == nullptr);
outputPD->SetPartition(0, block);
}
return 1;
}
//----------------------------------------------------------------------------
vtkSmartPointer<vtkDataObject> vtkDataTabulator::Transform(vtkDataObject* data)
{
vtkNew<vtkAttributeDataToTableFilter> adtf;
adtf->SetInputData(data);
adtf->SetAddMetaData(true);
adtf->SetGenerateCellConnectivity(this->GenerateCellConnectivity);
adtf->SetFieldAssociation(this->FieldAssociation);
adtf->SetGenerateOriginalIds(this->GenerateOriginalIds);
if (this->SplitComponents)
{
vtkNew<vtkSplitColumnComponents> splitter;
splitter->SetInputConnection(adtf->GetOutputPort());
splitter->SetNamingMode(this->SplitComponentsNamingMode);
splitter->Update();
return splitter->GetOutputDataObject(0);
}
adtf->Update();
return adtf->GetOutputDataObject(0);
}
//----------------------------------------------------------------------------
bool vtkDataTabulator::HasInputCompositeIds(vtkPartitionedDataSet* ptd)
{
return (ptd && ptd->GetNumberOfPartitions() > 0 && ptd->HasMetaData(0u) &&
ptd->GetMetaData(0u)->Has(vtkDataTabulator::COMPOSITE_INDEX()));
}
//----------------------------------------------------------------------------
void vtkDataTabulator::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
| 32.53405
| 96
| 0.630384
|
qiangwushuang
|
f52a424e363bcda6eb162d40530d9c5c4888b416
| 20,689
|
cc
|
C++
|
src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
|
BusyJay/grpc
|
6bf5f833efe2cb9e2ecc14358dd9699cd5d05263
|
[
"Apache-2.0"
] | null | null | null |
src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
|
BusyJay/grpc
|
6bf5f833efe2cb9e2ecc14358dd9699cd5d05263
|
[
"Apache-2.0"
] | null | null | null |
src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
|
BusyJay/grpc
|
6bf5f833efe2cb9e2ecc14358dd9699cd5d05263
|
[
"Apache-2.0"
] | null | null | null |
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h"
#include <string.h>
#include "src/core/lib/security/util/json_util.h"
#include "src/core/lib/surface/api_trace.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
//
// Auth Refresh Token.
//
int grpc_auth_refresh_token_is_valid(
const grpc_auth_refresh_token *refresh_token) {
return (refresh_token != NULL) &&
strcmp(refresh_token->type, GRPC_AUTH_JSON_TYPE_INVALID);
}
grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json(
const grpc_json *json) {
grpc_auth_refresh_token result;
const char *prop_value;
int success = 0;
memset(&result, 0, sizeof(grpc_auth_refresh_token));
result.type = GRPC_AUTH_JSON_TYPE_INVALID;
if (json == NULL) {
gpr_log(GPR_ERROR, "Invalid json.");
goto end;
}
prop_value = grpc_json_get_string_property(json, "type");
if (prop_value == NULL ||
strcmp(prop_value, GRPC_AUTH_JSON_TYPE_AUTHORIZED_USER)) {
goto end;
}
result.type = GRPC_AUTH_JSON_TYPE_AUTHORIZED_USER;
if (!grpc_copy_json_string_property(json, "client_secret",
&result.client_secret) ||
!grpc_copy_json_string_property(json, "client_id", &result.client_id) ||
!grpc_copy_json_string_property(json, "refresh_token",
&result.refresh_token)) {
goto end;
}
success = 1;
end:
if (!success) grpc_auth_refresh_token_destruct(&result);
return result;
}
grpc_auth_refresh_token grpc_auth_refresh_token_create_from_string(
const char *json_string) {
char *scratchpad = gpr_strdup(json_string);
grpc_json *json = grpc_json_parse_string(scratchpad);
grpc_auth_refresh_token result =
grpc_auth_refresh_token_create_from_json(json);
if (json != NULL) grpc_json_destroy(json);
gpr_free(scratchpad);
return result;
}
void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token *refresh_token) {
if (refresh_token == NULL) return;
refresh_token->type = GRPC_AUTH_JSON_TYPE_INVALID;
if (refresh_token->client_id != NULL) {
gpr_free(refresh_token->client_id);
refresh_token->client_id = NULL;
}
if (refresh_token->client_secret != NULL) {
gpr_free(refresh_token->client_secret);
refresh_token->client_secret = NULL;
}
if (refresh_token->refresh_token != NULL) {
gpr_free(refresh_token->refresh_token);
refresh_token->refresh_token = NULL;
}
}
//
// Oauth2 Token Fetcher credentials.
//
static void oauth2_token_fetcher_destruct(grpc_exec_ctx *exec_ctx,
grpc_call_credentials *creds) {
grpc_oauth2_token_fetcher_credentials *c =
(grpc_oauth2_token_fetcher_credentials *)creds;
GRPC_MDELEM_UNREF(exec_ctx, c->access_token_md);
gpr_mu_destroy(&c->mu);
grpc_pollset_set_destroy(exec_ctx,
grpc_polling_entity_pollset_set(&c->pollent));
grpc_httpcli_context_destroy(exec_ctx, &c->httpcli_context);
}
grpc_credentials_status
grpc_oauth2_token_fetcher_credentials_parse_server_response(
grpc_exec_ctx *exec_ctx, const grpc_http_response *response,
grpc_mdelem *token_md, grpc_millis *token_lifetime) {
char *null_terminated_body = NULL;
char *new_access_token = NULL;
grpc_credentials_status status = GRPC_CREDENTIALS_OK;
grpc_json *json = NULL;
if (response == NULL) {
gpr_log(GPR_ERROR, "Received NULL response.");
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
if (response->body_length > 0) {
null_terminated_body = (char *)gpr_malloc(response->body_length + 1);
null_terminated_body[response->body_length] = '\0';
memcpy(null_terminated_body, response->body, response->body_length);
}
if (response->status != 200) {
gpr_log(GPR_ERROR, "Call to http server ended with error %d [%s].",
response->status,
null_terminated_body != NULL ? null_terminated_body : "");
status = GRPC_CREDENTIALS_ERROR;
goto end;
} else {
grpc_json *access_token = NULL;
grpc_json *token_type = NULL;
grpc_json *expires_in = NULL;
grpc_json *ptr;
json = grpc_json_parse_string(null_terminated_body);
if (json == NULL) {
gpr_log(GPR_ERROR, "Could not parse JSON from %s", null_terminated_body);
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
if (json->type != GRPC_JSON_OBJECT) {
gpr_log(GPR_ERROR, "Response should be a JSON object");
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
for (ptr = json->child; ptr; ptr = ptr->next) {
if (strcmp(ptr->key, "access_token") == 0) {
access_token = ptr;
} else if (strcmp(ptr->key, "token_type") == 0) {
token_type = ptr;
} else if (strcmp(ptr->key, "expires_in") == 0) {
expires_in = ptr;
}
}
if (access_token == NULL || access_token->type != GRPC_JSON_STRING) {
gpr_log(GPR_ERROR, "Missing or invalid access_token in JSON.");
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
if (token_type == NULL || token_type->type != GRPC_JSON_STRING) {
gpr_log(GPR_ERROR, "Missing or invalid token_type in JSON.");
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
if (expires_in == NULL || expires_in->type != GRPC_JSON_NUMBER) {
gpr_log(GPR_ERROR, "Missing or invalid expires_in in JSON.");
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
gpr_asprintf(&new_access_token, "%s %s", token_type->value,
access_token->value);
*token_lifetime = strtol(expires_in->value, NULL, 10) * GPR_MS_PER_SEC;
if (!GRPC_MDISNULL(*token_md)) GRPC_MDELEM_UNREF(exec_ctx, *token_md);
*token_md = grpc_mdelem_from_slices(
exec_ctx,
grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
grpc_slice_from_copied_string(new_access_token));
status = GRPC_CREDENTIALS_OK;
}
end:
if (status != GRPC_CREDENTIALS_OK && !GRPC_MDISNULL(*token_md)) {
GRPC_MDELEM_UNREF(exec_ctx, *token_md);
*token_md = GRPC_MDNULL;
}
if (null_terminated_body != NULL) gpr_free(null_terminated_body);
if (new_access_token != NULL) gpr_free(new_access_token);
if (json != NULL) grpc_json_destroy(json);
return status;
}
static void on_oauth2_token_fetcher_http_response(grpc_exec_ctx *exec_ctx,
void *user_data,
grpc_error *error) {
GRPC_LOG_IF_ERROR("oauth_fetch", GRPC_ERROR_REF(error));
grpc_credentials_metadata_request *r =
(grpc_credentials_metadata_request *)user_data;
grpc_oauth2_token_fetcher_credentials *c =
(grpc_oauth2_token_fetcher_credentials *)r->creds;
grpc_mdelem access_token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_credentials_status status =
grpc_oauth2_token_fetcher_credentials_parse_server_response(
exec_ctx, &r->response, &access_token_md, &token_lifetime);
// Update cache and grab list of pending requests.
gpr_mu_lock(&c->mu);
c->token_fetch_pending = false;
c->access_token_md = GRPC_MDELEM_REF(access_token_md);
c->token_expiration = status == GRPC_CREDENTIALS_OK
? grpc_exec_ctx_now(exec_ctx) + token_lifetime
: 0;
grpc_oauth2_pending_get_request_metadata *pending_request =
c->pending_requests;
c->pending_requests = NULL;
gpr_mu_unlock(&c->mu);
// Invoke callbacks for all pending requests.
while (pending_request != NULL) {
if (status == GRPC_CREDENTIALS_OK) {
grpc_credentials_mdelem_array_add(pending_request->md_array,
access_token_md);
} else {
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Error occured when fetching oauth2 token.", &error, 1);
}
GRPC_CLOSURE_SCHED(exec_ctx, pending_request->on_request_metadata, error);
grpc_polling_entity_del_from_pollset_set(
exec_ctx, pending_request->pollent,
grpc_polling_entity_pollset_set(&c->pollent));
grpc_oauth2_pending_get_request_metadata *prev = pending_request;
pending_request = pending_request->next;
gpr_free(prev);
}
GRPC_MDELEM_UNREF(exec_ctx, access_token_md);
grpc_call_credentials_unref(exec_ctx, r->creds);
grpc_credentials_metadata_request_destroy(exec_ctx, r);
}
static bool oauth2_token_fetcher_get_request_metadata(
grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds,
grpc_polling_entity *pollent, grpc_auth_metadata_context context,
grpc_credentials_mdelem_array *md_array, grpc_closure *on_request_metadata,
grpc_error **error) {
grpc_oauth2_token_fetcher_credentials *c =
(grpc_oauth2_token_fetcher_credentials *)creds;
// Check if we can use the cached token.
grpc_millis refresh_threshold =
GRPC_SECURE_TOKEN_REFRESH_THRESHOLD_SECS * GPR_MS_PER_SEC;
grpc_mdelem cached_access_token_md = GRPC_MDNULL;
gpr_mu_lock(&c->mu);
if (!GRPC_MDISNULL(c->access_token_md) &&
(c->token_expiration + grpc_exec_ctx_now(exec_ctx) > refresh_threshold)) {
cached_access_token_md = GRPC_MDELEM_REF(c->access_token_md);
}
if (!GRPC_MDISNULL(cached_access_token_md)) {
gpr_mu_unlock(&c->mu);
grpc_credentials_mdelem_array_add(md_array, cached_access_token_md);
GRPC_MDELEM_UNREF(exec_ctx, cached_access_token_md);
return true;
}
// Couldn't get the token from the cache.
// Add request to c->pending_requests and start a new fetch if needed.
grpc_oauth2_pending_get_request_metadata *pending_request =
(grpc_oauth2_pending_get_request_metadata *)gpr_malloc(
sizeof(*pending_request));
pending_request->md_array = md_array;
pending_request->on_request_metadata = on_request_metadata;
pending_request->pollent = pollent;
grpc_polling_entity_add_to_pollset_set(
exec_ctx, pollent, grpc_polling_entity_pollset_set(&c->pollent));
pending_request->next = c->pending_requests;
c->pending_requests = pending_request;
bool start_fetch = false;
if (!c->token_fetch_pending) {
c->token_fetch_pending = true;
start_fetch = true;
}
gpr_mu_unlock(&c->mu);
if (start_fetch) {
grpc_call_credentials_ref(creds);
c->fetch_func(exec_ctx, grpc_credentials_metadata_request_create(creds),
&c->httpcli_context, &c->pollent,
on_oauth2_token_fetcher_http_response,
grpc_exec_ctx_now(exec_ctx) + refresh_threshold);
}
return false;
}
static void oauth2_token_fetcher_cancel_get_request_metadata(
grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds,
grpc_credentials_mdelem_array *md_array, grpc_error *error) {
grpc_oauth2_token_fetcher_credentials *c =
(grpc_oauth2_token_fetcher_credentials *)creds;
gpr_mu_lock(&c->mu);
grpc_oauth2_pending_get_request_metadata *prev = NULL;
grpc_oauth2_pending_get_request_metadata *pending_request =
c->pending_requests;
while (pending_request != NULL) {
if (pending_request->md_array == md_array) {
// Remove matching pending request from the list.
if (prev != NULL) {
prev->next = pending_request->next;
} else {
c->pending_requests = pending_request->next;
}
// Invoke the callback immediately with an error.
GRPC_CLOSURE_SCHED(exec_ctx, pending_request->on_request_metadata,
GRPC_ERROR_REF(error));
gpr_free(pending_request);
break;
}
prev = pending_request;
pending_request = pending_request->next;
}
gpr_mu_unlock(&c->mu);
GRPC_ERROR_UNREF(error);
}
static void init_oauth2_token_fetcher(grpc_oauth2_token_fetcher_credentials *c,
grpc_fetch_oauth2_func fetch_func) {
memset(c, 0, sizeof(grpc_oauth2_token_fetcher_credentials));
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_OAUTH2;
gpr_ref_init(&c->base.refcount, 1);
gpr_mu_init(&c->mu);
c->token_expiration = 0;
c->fetch_func = fetch_func;
c->pollent =
grpc_polling_entity_create_from_pollset_set(grpc_pollset_set_create());
grpc_httpcli_context_init(&c->httpcli_context);
}
//
// Google Compute Engine credentials.
//
static grpc_call_credentials_vtable compute_engine_vtable = {
oauth2_token_fetcher_destruct, oauth2_token_fetcher_get_request_metadata,
oauth2_token_fetcher_cancel_get_request_metadata};
static void compute_engine_fetch_oauth2(
grpc_exec_ctx *exec_ctx, grpc_credentials_metadata_request *metadata_req,
grpc_httpcli_context *httpcli_context, grpc_polling_entity *pollent,
grpc_iomgr_cb_func response_cb, grpc_millis deadline) {
grpc_http_header header = {(char *)"Metadata-Flavor", (char *)"Google"};
grpc_httpcli_request request;
memset(&request, 0, sizeof(grpc_httpcli_request));
request.host = (char *)GRPC_COMPUTE_ENGINE_METADATA_HOST;
request.http.path = (char *)GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH;
request.http.hdr_count = 1;
request.http.hdrs = &header;
/* TODO(ctiller): Carry the resource_quota in ctx and share it with the host
channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */
grpc_resource_quota *resource_quota =
grpc_resource_quota_create("oauth2_credentials");
grpc_httpcli_get(
exec_ctx, httpcli_context, pollent, resource_quota, &request, deadline,
GRPC_CLOSURE_CREATE(response_cb, metadata_req, grpc_schedule_on_exec_ctx),
&metadata_req->response);
grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
}
grpc_call_credentials *grpc_google_compute_engine_credentials_create(
void *reserved) {
grpc_oauth2_token_fetcher_credentials *c =
(grpc_oauth2_token_fetcher_credentials *)gpr_malloc(
sizeof(grpc_oauth2_token_fetcher_credentials));
GRPC_API_TRACE("grpc_compute_engine_credentials_create(reserved=%p)", 1,
(reserved));
GPR_ASSERT(reserved == NULL);
init_oauth2_token_fetcher(c, compute_engine_fetch_oauth2);
c->base.vtable = &compute_engine_vtable;
return &c->base;
}
//
// Google Refresh Token credentials.
//
static void refresh_token_destruct(grpc_exec_ctx *exec_ctx,
grpc_call_credentials *creds) {
grpc_google_refresh_token_credentials *c =
(grpc_google_refresh_token_credentials *)creds;
grpc_auth_refresh_token_destruct(&c->refresh_token);
oauth2_token_fetcher_destruct(exec_ctx, &c->base.base);
}
static grpc_call_credentials_vtable refresh_token_vtable = {
refresh_token_destruct, oauth2_token_fetcher_get_request_metadata,
oauth2_token_fetcher_cancel_get_request_metadata};
static void refresh_token_fetch_oauth2(
grpc_exec_ctx *exec_ctx, grpc_credentials_metadata_request *metadata_req,
grpc_httpcli_context *httpcli_context, grpc_polling_entity *pollent,
grpc_iomgr_cb_func response_cb, grpc_millis deadline) {
grpc_google_refresh_token_credentials *c =
(grpc_google_refresh_token_credentials *)metadata_req->creds;
grpc_http_header header = {(char *)"Content-Type",
(char *)"application/x-www-form-urlencoded"};
grpc_httpcli_request request;
char *body = NULL;
gpr_asprintf(&body, GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING,
c->refresh_token.client_id, c->refresh_token.client_secret,
c->refresh_token.refresh_token);
memset(&request, 0, sizeof(grpc_httpcli_request));
request.host = (char *)GRPC_GOOGLE_OAUTH2_SERVICE_HOST;
request.http.path = (char *)GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH;
request.http.hdr_count = 1;
request.http.hdrs = &header;
request.handshaker = &grpc_httpcli_ssl;
/* TODO(ctiller): Carry the resource_quota in ctx and share it with the host
channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */
grpc_resource_quota *resource_quota =
grpc_resource_quota_create("oauth2_credentials_refresh");
grpc_httpcli_post(
exec_ctx, httpcli_context, pollent, resource_quota, &request, body,
strlen(body), deadline,
GRPC_CLOSURE_CREATE(response_cb, metadata_req, grpc_schedule_on_exec_ctx),
&metadata_req->response);
grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
gpr_free(body);
}
grpc_call_credentials *
grpc_refresh_token_credentials_create_from_auth_refresh_token(
grpc_auth_refresh_token refresh_token) {
grpc_google_refresh_token_credentials *c;
if (!grpc_auth_refresh_token_is_valid(&refresh_token)) {
gpr_log(GPR_ERROR, "Invalid input for refresh token credentials creation");
return NULL;
}
c = (grpc_google_refresh_token_credentials *)gpr_zalloc(
sizeof(grpc_google_refresh_token_credentials));
init_oauth2_token_fetcher(&c->base, refresh_token_fetch_oauth2);
c->base.base.vtable = &refresh_token_vtable;
c->refresh_token = refresh_token;
return &c->base.base;
}
static char *create_loggable_refresh_token(grpc_auth_refresh_token *token) {
if (strcmp(token->type, GRPC_AUTH_JSON_TYPE_INVALID) == 0) {
return gpr_strdup("<Invalid json token>");
}
char *loggable_token = NULL;
gpr_asprintf(&loggable_token,
"{\n type: %s\n client_id: %s\n client_secret: "
"<redacted>\n refresh_token: <redacted>\n}",
token->type, token->client_id);
return loggable_token;
}
grpc_call_credentials *grpc_google_refresh_token_credentials_create(
const char *json_refresh_token, void *reserved) {
grpc_auth_refresh_token token =
grpc_auth_refresh_token_create_from_string(json_refresh_token);
if (GRPC_TRACER_ON(grpc_api_trace)) {
char *loggable_token = create_loggable_refresh_token(&token);
gpr_log(GPR_INFO,
"grpc_refresh_token_credentials_create(json_refresh_token=%s, "
"reserved=%p)",
loggable_token, reserved);
gpr_free(loggable_token);
}
GPR_ASSERT(reserved == NULL);
return grpc_refresh_token_credentials_create_from_auth_refresh_token(token);
}
//
// Oauth2 Access Token credentials.
//
static void access_token_destruct(grpc_exec_ctx *exec_ctx,
grpc_call_credentials *creds) {
grpc_access_token_credentials *c = (grpc_access_token_credentials *)creds;
GRPC_MDELEM_UNREF(exec_ctx, c->access_token_md);
}
static bool access_token_get_request_metadata(
grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds,
grpc_polling_entity *pollent, grpc_auth_metadata_context context,
grpc_credentials_mdelem_array *md_array, grpc_closure *on_request_metadata,
grpc_error **error) {
grpc_access_token_credentials *c = (grpc_access_token_credentials *)creds;
grpc_credentials_mdelem_array_add(md_array, c->access_token_md);
return true;
}
static void access_token_cancel_get_request_metadata(
grpc_exec_ctx *exec_ctx, grpc_call_credentials *c,
grpc_credentials_mdelem_array *md_array, grpc_error *error) {
GRPC_ERROR_UNREF(error);
}
static grpc_call_credentials_vtable access_token_vtable = {
access_token_destruct, access_token_get_request_metadata,
access_token_cancel_get_request_metadata};
grpc_call_credentials *grpc_access_token_credentials_create(
const char *access_token, void *reserved) {
grpc_access_token_credentials *c =
(grpc_access_token_credentials *)gpr_zalloc(
sizeof(grpc_access_token_credentials));
GRPC_API_TRACE(
"grpc_access_token_credentials_create(access_token=<redacted>, "
"reserved=%p)",
1, (reserved));
GPR_ASSERT(reserved == NULL);
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_OAUTH2;
c->base.vtable = &access_token_vtable;
gpr_ref_init(&c->base.refcount, 1);
char *token_md_value;
gpr_asprintf(&token_md_value, "Bearer %s", access_token);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
c->access_token_md = grpc_mdelem_from_slices(
&exec_ctx, grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
grpc_slice_from_copied_string(token_md_value));
grpc_exec_ctx_finish(&exec_ctx);
gpr_free(token_md_value);
return &c->base;
}
| 38.671028
| 80
| 0.731887
|
BusyJay
|
f52be7b2de907b85f6774c761857416c74034d66
| 2,507
|
cpp
|
C++
|
orig/07/listing_07.12.cpp
|
plaice/Williams
|
509349bc07bb0905387e93966e83b304900bb2c4
|
[
"BSL-1.0"
] | 5
|
2016-11-15T21:56:46.000Z
|
2018-05-05T21:34:25.000Z
|
orig/07/listing_07.12.cpp
|
plaice/Williams
|
509349bc07bb0905387e93966e83b304900bb2c4
|
[
"BSL-1.0"
] | null | null | null |
orig/07/listing_07.12.cpp
|
plaice/Williams
|
509349bc07bb0905387e93966e83b304900bb2c4
|
[
"BSL-1.0"
] | null | null | null |
#include <atomic>
#include <memory>
template<typename T>
class lock_free_stack
{
private:
struct node;
struct counted_node_ptr
{
int external_count;
node* ptr;
};
struct node
{
std::shared_ptr<T> data;
std::atomic<int> internal_count;
counted_node_ptr next;
node(T const& data_):
data(std::make_shared<T>(data_)),
internal_count(0)
{}
};
std::atomic<counted_node_ptr> head;
void increase_head_count(counted_node_ptr& old_counter)
{
counted_node_ptr new_counter;
do
{
new_counter=old_counter;
++new_counter.external_count;
}
while(!head.compare_exchange_strong(
old_counter,new_counter,
std::memory_order_acquire,
std::memory_order_relaxed));
old_counter.external_count=new_counter.external_count;
}
public:
~lock_free_stack()
{
while(pop());
}
void push(T const& data)
{
counted_node_ptr new_node;
new_node.ptr=new node(data);
new_node.external_count=1;
new_node.ptr->next=head.load(std::memory_order_relaxed);
while(!head.compare_exchange_weak(
new_node.ptr->next,new_node,
std::memory_order_release,
std::memory_order_relaxed));
}
std::shared_ptr<T> pop()
{
counted_node_ptr old_head=
head.load(std::memory_order_relaxed);
for(;;)
{
increase_head_count(old_head);
node* const ptr=old_head.ptr;
if(!ptr)
{
return std::shared_ptr<T>();
}
if(head.compare_exchange_strong(
old_head,ptr->next,std::memory_order_relaxed))
{
std::shared_ptr<T> res;
res.swap(ptr->data);
int const count_increase=old_head.external_count-2;
if(ptr->internal_count.fetch_add(
count_increase,std::memory_order_release)==-count_increase)
{
delete ptr;
}
return res;
}
else if(ptr->internal_count.fetch_add(
-1,std::memory_order_relaxed)==1)
{
ptr->internal_count.load(std::memory_order_acquire);
delete ptr;
}
}
}
};
| 28.168539
| 82
| 0.526526
|
plaice
|
f52d8339b0eb2f09a2e85c44c3d8c98e51047226
| 4,936
|
cc
|
C++
|
src/lib/log/tests/buffer_appender_unittest.cc
|
svenauhagen/kea
|
8a575ad46dee1487364fad394e7a325337200839
|
[
"Apache-2.0"
] | 273
|
2015-01-22T14:14:42.000Z
|
2022-03-13T10:27:44.000Z
|
src/lib/log/tests/buffer_appender_unittest.cc
|
jxiaobin/kea
|
1987a50a458921f9e5ac84cb612782c07f3b601d
|
[
"Apache-2.0"
] | 104
|
2015-01-16T16:37:06.000Z
|
2021-08-08T19:38:45.000Z
|
src/lib/log/tests/buffer_appender_unittest.cc
|
jxiaobin/kea
|
1987a50a458921f9e5ac84cb612782c07f3b601d
|
[
"Apache-2.0"
] | 133
|
2015-02-21T14:06:39.000Z
|
2022-02-27T08:56:40.000Z
|
// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
#include <gtest/gtest.h>
#include <log/macros.h>
#include <log/logger_support.h>
#include <log/log_messages.h>
#include <log/buffer_appender_impl.h>
#include <log4cplus/loggingmacros.h>
#include <log4cplus/logger.h>
#include <log4cplus/nullappender.h>
#include <log4cplus/spi/loggingevent.h>
using namespace isc::log;
using namespace isc::log::internal;
namespace isc {
namespace log {
/// \brief Specialized test class
///
/// In order to test append() somewhat directly, this
/// class implements one more method (addEvent)
class TestBufferAppender : public BufferAppender {
public:
void addEvent(const log4cplus::spi::InternalLoggingEvent& event) {
append(event);
}
};
class BufferAppenderTest : public ::testing::Test {
protected:
BufferAppenderTest() : buffer_appender1(new TestBufferAppender()),
appender1(buffer_appender1),
buffer_appender2(new TestBufferAppender()),
appender2(buffer_appender2),
logger(log4cplus::Logger::getInstance("buffer"))
{
logger.setLogLevel(log4cplus::TRACE_LOG_LEVEL);
}
~BufferAppenderTest() {
// If any log messages are left, we don't care, get rid of them,
// by flushing them to a null appender
// Given the 'messages should not get lost' approach of the logging
// system, not flushing them to a null appender would cause them
// to be dumped to stdout as the test is destroyed, making
// unnecessarily messy test output.
log4cplus::SharedAppenderPtr null_appender(
new log4cplus::NullAppender());
logger.removeAllAppenders();
logger.addAppender(null_appender);
buffer_appender1->flush();
buffer_appender2->flush();
}
TestBufferAppender* buffer_appender1;
log4cplus::SharedAppenderPtr appender1;
TestBufferAppender* buffer_appender2;
log4cplus::SharedAppenderPtr appender2;
log4cplus::Logger logger;
};
// Test that log events are indeed stored, and that they are
// flushed to the new appenders of their logger
TEST_F(BufferAppenderTest, flush) {
ASSERT_EQ(0, buffer_appender1->getBufferSize());
ASSERT_EQ(0, buffer_appender2->getBufferSize());
// Create a Logger, log a few messages with the first appender
logger.addAppender(appender1);
LOG4CPLUS_INFO(logger, "Foo");
ASSERT_EQ(1, buffer_appender1->getBufferSize());
LOG4CPLUS_INFO(logger, "Foo");
ASSERT_EQ(2, buffer_appender1->getBufferSize());
LOG4CPLUS_INFO(logger, "Foo");
ASSERT_EQ(3, buffer_appender1->getBufferSize());
// Second buffer should still be empty
ASSERT_EQ(0, buffer_appender2->getBufferSize());
// Replace the appender by the second one, and call flush;
// this should cause all events to be moved to the second buffer
logger.removeAllAppenders();
logger.addAppender(appender2);
buffer_appender1->flush();
ASSERT_EQ(0, buffer_appender1->getBufferSize());
ASSERT_EQ(3, buffer_appender2->getBufferSize());
}
// Once flushed, logging new messages with the same buffer should fail
TEST_F(BufferAppenderTest, addAfterFlush) {
logger.addAppender(appender1);
buffer_appender1->flush();
EXPECT_THROW(LOG4CPLUS_INFO(logger, "Foo"), LogBufferAddAfterFlush);
// It should not have been added
ASSERT_EQ(0, buffer_appender1->getBufferSize());
// But logging should work again as long as a different buffer is used
logger.removeAllAppenders();
logger.addAppender(appender2);
LOG4CPLUS_INFO(logger, "Foo");
ASSERT_EQ(1, buffer_appender2->getBufferSize());
}
TEST_F(BufferAppenderTest, addDirectly) {
// A few direct calls
log4cplus::spi::InternalLoggingEvent event("buffer",
log4cplus::INFO_LOG_LEVEL,
"Bar", "file", 123);
buffer_appender1->addEvent(event);
ASSERT_EQ(1, buffer_appender1->getBufferSize());
// Do one from a smaller scope to make sure destruction doesn't harm
{
log4cplus::spi::InternalLoggingEvent event2("buffer",
log4cplus::INFO_LOG_LEVEL,
"Bar", "file", 123);
buffer_appender1->addEvent(event2);
}
ASSERT_EQ(2, buffer_appender1->getBufferSize());
// And flush them to the next
logger.removeAllAppenders();
logger.addAppender(appender2);
buffer_appender1->flush();
ASSERT_EQ(0, buffer_appender1->getBufferSize());
ASSERT_EQ(2, buffer_appender2->getBufferSize());
}
}
}
| 35.510791
| 78
| 0.67423
|
svenauhagen
|
f52d93a2e062ff8571612c32c27b77969093c9c3
| 2,101
|
hpp
|
C++
|
tstl/include/stack.hpp
|
ArdenyUser/ArdenWareOS
|
e09261093ba469d2291554c026037351bba28ab0
|
[
"MIT"
] | 1,574
|
2015-01-15T16:35:30.000Z
|
2022-03-29T07:27:49.000Z
|
tstl/include/stack.hpp
|
bgwilf/thor-os
|
2dc0fef72595598aff7e5f950809042104f29b48
|
[
"MIT"
] | 43
|
2016-08-23T16:22:29.000Z
|
2022-03-09T10:28:05.000Z
|
tstl/include/stack.hpp
|
bgwilf/thor-os
|
2dc0fef72595598aff7e5f950809042104f29b48
|
[
"MIT"
] | 196
|
2016-02-17T10:52:24.000Z
|
2022-03-28T17:41:29.000Z
|
//=======================================================================
// Copyright Baptiste Wicht 2013-2018.
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
// http://www.opensource.org/licenses/MIT)
//=======================================================================
#ifndef STL_STACK_H
#define STL_STACK_H
#include <vector.hpp>
#include <types.hpp>
namespace std {
/*!
* \brief Container adapter to provide a stack (LIFO)
*/
template<typename T, typename C = std::vector<T>>
struct stack {
using reference_type = typename C::reference_type;
using const_reference_type = typename C::const_reference_type;
/*!
* \brief Indicates if the stack is empty
*/
bool empty() const {
return size() == 0;
}
/*!
* \brief Returns the size of the stack
*/
size_t size() const {
return container.size();
}
/*!
* \brief Adds the element at the top of the stack
* \param value The element to add on the stack
*/
void push(T&& value){
container.push_back(std::move(value));
}
/*!
* \brief Adds the element at the top of the stack
* \param value The element to add on the stack
*/
void push(const T& value){
container.push_back(value);
}
/*!
* \brief Create a new element inplace onto the stack
*/
template<typename... Args>
reference_type emplace(Args&&... args){
return container.emplace_back(std::forward<Args>(args)...);
}
/*!
* \brief Removes the element at the top of the stack
*/
void pop(){
container.pop_back();
}
/*!
* \brief Returns a reference to the element at the top of the stack
*/
reference_type top(){
return container.back();
}
/*!
* \brief Returns a const reference to the element at the top of the stack
*/
const_reference_type top() const {
return container.back();
}
private:
C container; ///< The underlying container
};
} //end of namespace std
#endif
| 23.344444
| 78
| 0.568777
|
ArdenyUser
|
f52e2418091bfc9c0e9ace94636dd31cc4936a95
| 6,356
|
cpp
|
C++
|
qcom-caf/display/libhistogram/histogram_collector.cpp
|
Havoc-Devices/android_device_motorola_sm7250-common
|
c957b40642f2c2a6b174832e3a19e823aa25363f
|
[
"FTL"
] | 4
|
2020-12-17T13:39:05.000Z
|
2022-02-11T10:24:58.000Z
|
qcom-caf/display/libhistogram/histogram_collector.cpp
|
Havoc-Devices/android_device_motorola_sm7250-common
|
c957b40642f2c2a6b174832e3a19e823aa25363f
|
[
"FTL"
] | null | null | null |
qcom-caf/display/libhistogram/histogram_collector.cpp
|
Havoc-Devices/android_device_motorola_sm7250-common
|
c957b40642f2c2a6b174832e3a19e823aa25363f
|
[
"FTL"
] | 4
|
2021-01-07T12:31:21.000Z
|
2021-12-27T19:08:12.000Z
|
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <fcntl.h>
#include <log/log.h>
#include <pthread.h>
#include <sys/epoll.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <chrono>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <memory>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <drm/msm_drm.h>
#include <drm/msm_drm_pp.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include "histogram_collector.h"
#include "ringbuffer.h"
constexpr static auto implementation_defined_max_frame_ringbuffer = 300;
histogram::HistogramCollector::HistogramCollector()
: histogram(histogram::Ringbuffer::create(implementation_defined_max_frame_ringbuffer,
std::make_unique<histogram::DefaultTimeKeeper>())) {}
histogram::HistogramCollector::~HistogramCollector() {
stop();
}
namespace {
static constexpr size_t numBuckets = 8;
static_assert((HIST_V_SIZE % numBuckets) == 0,
"histogram cannot be rebucketed to smaller number of buckets");
static constexpr int bucket_compression = HIST_V_SIZE / numBuckets;
std::array<uint64_t, numBuckets> rebucketTo8Buckets(
std::array<uint64_t, HIST_V_SIZE> const &frame) {
std::array<uint64_t, numBuckets> bins;
bins.fill(0);
for (auto i = 0u; i < HIST_V_SIZE; i++)
bins[i / bucket_compression] += frame[i];
return bins;
}
} // namespace
std::string histogram::HistogramCollector::Dump() const {
uint64_t num_frames = 0;
std::array<uint64_t, HIST_V_SIZE> all_sample_buckets;
std::tie(num_frames, all_sample_buckets) = histogram->collect_cumulative();
std::array<uint64_t, numBuckets> samples = rebucketTo8Buckets(all_sample_buckets);
std::stringstream ss;
ss << "Color Sampling, dark (0.0) to light (1.0): sampled frames: " << num_frames << '\n';
if (num_frames == 0) {
ss << "\tno color statistics collected\n";
return ss.str();
}
ss << std::fixed << std::setprecision(3);
ss << "\tbucket\t\t: # of displayed pixels at bucket value\n";
for (auto i = 0u; i < samples.size(); i++) {
ss << "\t" << i / static_cast<float>(samples.size()) << " to "
<< (i + 1) / static_cast<float>(samples.size()) << "\t: " << samples[i] << '\n';
}
return ss.str();
}
HWC2::Error histogram::HistogramCollector::collect(
uint64_t max_frames, uint64_t timestamp,
int32_t out_samples_size[NUM_HISTOGRAM_COLOR_COMPONENTS],
uint64_t *out_samples[NUM_HISTOGRAM_COLOR_COMPONENTS], uint64_t *out_num_frames) const {
if (!out_samples_size || !out_num_frames)
return HWC2::Error::BadParameter;
out_samples_size[0] = 0;
out_samples_size[1] = 0;
out_samples_size[2] = numBuckets;
out_samples_size[3] = 0;
uint64_t num_frames = 0;
std::array<uint64_t, HIST_V_SIZE> samples;
if (max_frames == 0 && timestamp == 0) {
std::tie(num_frames, samples) = histogram->collect_cumulative();
} else if (max_frames == 0) {
std::tie(num_frames, samples) = histogram->collect_after(timestamp);
} else if (timestamp == 0) {
std::tie(num_frames, samples) = histogram->collect_max(max_frames);
} else {
std::tie(num_frames, samples) = histogram->collect_max_after(timestamp, max_frames);
}
auto samples_rebucketed = rebucketTo8Buckets(samples);
*out_num_frames = num_frames;
if (out_samples && out_samples[2])
memcpy(out_samples[2], samples_rebucketed.data(), sizeof(uint64_t) * samples_rebucketed.size());
return HWC2::Error::None;
}
HWC2::Error histogram::HistogramCollector::getAttributes(int32_t *format, int32_t *dataspace,
uint8_t *supported_components) const {
if (!format || !dataspace || !supported_components)
return HWC2::Error::BadParameter;
*format = HAL_PIXEL_FORMAT_HSV_888;
*dataspace = HAL_DATASPACE_UNKNOWN;
*supported_components = HWC2_FORMAT_COMPONENT_2;
return HWC2::Error::None;
}
void histogram::HistogramCollector::start() {
start(implementation_defined_max_frame_ringbuffer);
}
void histogram::HistogramCollector::start(uint64_t max_frames) {
std::unique_lock<decltype(mutex)> lk(mutex);
if (started) {
return;
}
started = true;
histogram =
histogram::Ringbuffer::create(max_frames, std::make_unique<histogram::DefaultTimeKeeper>());
monitoring_thread = std::thread(&HistogramCollector::blob_processing_thread, this);
}
void histogram::HistogramCollector::stop() {
std::unique_lock<decltype(mutex)> lk(mutex);
if (!started) {
return;
}
started = false;
cv.notify_all();
lk.unlock();
if (monitoring_thread.joinable())
monitoring_thread.join();
}
void histogram::HistogramCollector::notify_histogram_event(int blob_source_fd, BlobId id) {
std::unique_lock<decltype(mutex)> lk(mutex);
if (!started) {
ALOGW("Discarding event blob-id: %X", id);
return;
}
if (work_available) {
ALOGI("notified of histogram event before consuming last one. prior event discarded");
}
work_available = true;
blobwork = HistogramCollector::BlobWork{blob_source_fd, id};
cv.notify_all();
}
void histogram::HistogramCollector::blob_processing_thread() {
pthread_setname_np(pthread_self(), "histogram_blob");
std::unique_lock<decltype(mutex)> lk(mutex);
while (true) {
cv.wait(lk, [this] { return !started || work_available; });
if (!started) {
return;
}
auto work = blobwork;
work_available = false;
lk.unlock();
drmModePropertyBlobPtr blob = drmModeGetPropertyBlob(work.fd, work.id);
if (!blob || !blob->data) {
lk.lock();
continue;
}
histogram->insert(*static_cast<struct drm_msm_hist *>(blob->data));
drmModeFreePropertyBlob(blob);
lk.lock();
}
}
| 30.705314
| 100
| 0.696665
|
Havoc-Devices
|
f52f9daac85badd14ed77a9dd5f2926218f2c88b
| 8,335
|
cpp
|
C++
|
tests/Loading/Theme.cpp
|
dmg103/TGUI
|
ed2ac830c399b8b579dc67493823551dbf966d63
|
[
"Zlib"
] | null | null | null |
tests/Loading/Theme.cpp
|
dmg103/TGUI
|
ed2ac830c399b8b579dc67493823551dbf966d63
|
[
"Zlib"
] | null | null | null |
tests/Loading/Theme.cpp
|
dmg103/TGUI
|
ed2ac830c399b8b579dc67493823551dbf966d63
|
[
"Zlib"
] | null | null | null |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus' Graphical User Interface
// Copyright (C) 2012-2022 Bruno Van de Velde (vdv_b@tgui.eu)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "Tests.hpp"
#include <TGUI/Loading/Theme.hpp>
#include <TGUI/Widgets/Label.hpp>
// TODO: Reloading theme
TEST_CASE("[Theme]")
{
SECTION("Loading")
{
SECTION("Renderers are shared")
{
tgui::Theme theme;
REQUIRE(theme.getPrimary() == "");
REQUIRE_NOTHROW(theme.getRenderer("Button"));
REQUIRE_NOTHROW(theme.load("resources/Black.txt"));
REQUIRE(theme.getPrimary() == "resources/Black.txt");
REQUIRE_NOTHROW(theme.getRenderer("EditBox"));
auto theme2 = tgui::Theme::create("resources/Black.txt");
REQUIRE(theme2->getPrimary() == "resources/Black.txt");
REQUIRE_NOTHROW(theme2->getRenderer("CheckBox"));
}
SECTION("nonexistent file")
{
REQUIRE_THROWS_AS(tgui::Theme("nonexistent_file"), tgui::Exception);
tgui::Theme theme;
REQUIRE_THROWS_AS(theme.load("nonexistent_file"), tgui::Exception);
}
SECTION("nonexistent section")
{
// White theme is created on the fly as it uses default values
tgui::Theme theme1;
REQUIRE(theme1.getRenderer("nonexistent_section")->propertyValuePairs.empty());
// Other themes on the other hand will let the ThemeLoader handle it
tgui::Theme theme2("resources/Black.txt");
REQUIRE_THROWS_AS(theme2.getRenderer("nonexistent_section"), tgui::Exception);
}
}
SECTION("Adding and removing renderers")
{
auto data = std::make_shared<tgui::RendererData>();
data->propertyValuePairs["TextColor"] = {tgui::Color(255, 0, 255, 200)};
tgui::Theme theme;
REQUIRE(theme.getRenderer("Label1")->propertyValuePairs.empty());
REQUIRE(theme.getRenderer("Label2")->propertyValuePairs.empty());
theme.addRenderer("Label1", data);
REQUIRE(theme.getRenderer("Label1")->propertyValuePairs.size() == 1);
REQUIRE(theme.getRenderer("Label1")->propertyValuePairs["TextColor"].getColor() == tgui::Color(255, 0, 255, 200));
REQUIRE(theme.getRenderer("Label2")->propertyValuePairs.empty());
REQUIRE(theme.removeRenderer("Label1"));
REQUIRE(theme.getRenderer("Label1")->propertyValuePairs.empty());
REQUIRE(!theme.removeRenderer("nonexistent"));
}
SECTION("Renderers are shared")
{
tgui::Theme theme{"resources/Black.txt"};
SECTION("With widgets")
{
SECTION("Using getSharedRenderer")
{
auto label1 = tgui::Label::create();
label1->getSharedRenderer()->setTextColor("red");
REQUIRE(label1->getSharedRenderer()->getTextColor() == tgui::Color::Red);
label1->setRenderer(theme.getRenderer("Label"));
REQUIRE(label1->getSharedRenderer()->getTextColor() != tgui::Color::Red);
label1->getSharedRenderer()->setTextColor("green");
REQUIRE(label1->getSharedRenderer()->getTextColor() == tgui::Color::Green);
auto label2 = tgui::Label::create();
label2->getSharedRenderer()->setTextColor("blue");
REQUIRE(label2->getSharedRenderer()->getTextColor() == tgui::Color::Blue);
label2->setRenderer(theme.getRenderer("Label"));
REQUIRE(label1->getSharedRenderer()->getTextColor() == tgui::Color::Green);
// Changing the renderer of one label affects the look of the other one
label1->getSharedRenderer()->setTextColor("yellow");
REQUIRE(label2->getSharedRenderer()->getTextColor() == tgui::Color::Yellow);
// We messed with the default theme, so reset it to not affect other tests
tgui::Theme::setDefault(nullptr);
}
SECTION("Using getRenderer")
{
auto label1 = tgui::Label::create();
label1->getRenderer()->setTextColor("red");
REQUIRE(label1->getRenderer()->getTextColor() == tgui::Color::Red);
label1->setRenderer(theme.getRenderer("Label"));
REQUIRE(label1->getRenderer()->getTextColor() != tgui::Color::Red);
label1->getRenderer()->setTextColor("green");
REQUIRE(label1->getRenderer()->getTextColor() == tgui::Color::Green);
auto label2 = tgui::Label::create();
label2->getRenderer()->setTextColor("blue");
REQUIRE(label2->getRenderer()->getTextColor() == tgui::Color::Blue);
label2->setRenderer(theme.getRenderer("Label"));
REQUIRE(label1->getRenderer()->getTextColor() == tgui::Color::Green);
// Changing the renderer of one label does not affect the other one
label1->getRenderer()->setTextColor("yellow");
REQUIRE(label2->getRenderer()->getTextColor() != tgui::Color::Yellow);
}
}
SECTION("Without widgets")
{
REQUIRE(tgui::LabelRenderer(theme.getRenderer("Label")).getTextColor() != tgui::Color::Cyan);
tgui::LabelRenderer(theme.getRenderer("Label")).setTextColor(tgui::Color::Cyan);
REQUIRE(tgui::LabelRenderer(theme.getRenderer("Label")).getTextColor() == tgui::Color::Cyan);
REQUIRE(theme.getRenderer("Label")->propertyValuePairs["TextColor"].getColor() == tgui::Color::Cyan);
}
}
SECTION("setThemeLoader")
{
struct CustomThemeLoader : public tgui::BaseThemeLoader
{
void preload(const tgui::String& one) override
{
REQUIRE(one == "resources/Black.txt");
preloadCount++;
}
const std::map<tgui::String, tgui::String>& load(const tgui::String& one, const tgui::String& two) override
{
if (one != "")
{
REQUIRE(one == "resources/Black.txt");
REQUIRE(two == "EditBox");
}
else
REQUIRE(two == "Button");
loadCount++;
return retVal;
}
bool canLoad(const tgui::String&, const tgui::String&) override
{
return true;
}
std::map<tgui::String, tgui::String> retVal;
unsigned int preloadCount = 0;
unsigned int loadCount = 0;
};
auto loader = std::make_shared<CustomThemeLoader>();
tgui::Theme::setThemeLoader(loader);
REQUIRE(tgui::Theme::getThemeLoader() == loader);
tgui::Theme theme1;
theme1.getRenderer("Button");
tgui::Theme theme2("resources/Black.txt");
theme2.getRenderer("EditBox");
tgui::Theme::setThemeLoader(std::make_shared<tgui::DefaultThemeLoader>());
REQUIRE(tgui::Theme::getThemeLoader() != loader);
REQUIRE(loader->preloadCount == 1);
REQUIRE(loader->loadCount == 2);
}
}
| 39.880383
| 129
| 0.574325
|
dmg103
|
f52fd92cd26d6c15a6b524d4a28644e6219fde2d
| 18,960
|
cpp
|
C++
|
test/entt/entity/sparse_set.cpp
|
janisozaur/entt
|
be3597524f07ee502be8784ed193812ce4fb9cb9
|
[
"MIT"
] | 32
|
2018-05-14T23:26:54.000Z
|
2020-06-14T10:13:20.000Z
|
ext/entt-3.1.1/test/entt/entity/sparse_set.cpp
|
blockspacer/bootstrap-redux
|
2d0e0d7d2b1f6f203c3dd01f6929805042db8ec7
|
[
"MIT"
] | 79
|
2018-08-01T11:50:45.000Z
|
2020-11-17T13:40:06.000Z
|
ext/entt-3.1.1/test/entt/entity/sparse_set.cpp
|
blockspacer/bootstrap-redux
|
2d0e0d7d2b1f6f203c3dd01f6929805042db8ec7
|
[
"MIT"
] | 14
|
2021-01-08T05:05:19.000Z
|
2022-03-27T14:56:56.000Z
|
#include <cstdint>
#include <utility>
#include <iterator>
#include <type_traits>
#include <gtest/gtest.h>
#include <entt/entity/sparse_set.hpp>
#include <entt/entity/fwd.hpp>
struct empty_type {};
struct boxed_int { int value; };
TEST(SparseSet, Functionalities) {
entt::sparse_set<entt::entity> set;
set.reserve(42);
ASSERT_EQ(set.capacity(), 42);
ASSERT_TRUE(set.empty());
ASSERT_EQ(set.size(), 0u);
ASSERT_EQ(std::as_const(set).begin(), std::as_const(set).end());
ASSERT_EQ(set.begin(), set.end());
ASSERT_FALSE(set.has(entt::entity{0}));
ASSERT_FALSE(set.has(entt::entity{42}));
set.construct(entt::entity{42});
ASSERT_EQ(set.index(entt::entity{42}), 0u);
ASSERT_FALSE(set.empty());
ASSERT_EQ(set.size(), 1u);
ASSERT_NE(std::as_const(set).begin(), std::as_const(set).end());
ASSERT_NE(set.begin(), set.end());
ASSERT_FALSE(set.has(entt::entity{0}));
ASSERT_TRUE(set.has(entt::entity{42}));
ASSERT_EQ(set.index(entt::entity{42}), 0u);
set.destroy(entt::entity{42});
ASSERT_TRUE(set.empty());
ASSERT_EQ(set.size(), 0u);
ASSERT_EQ(std::as_const(set).begin(), std::as_const(set).end());
ASSERT_EQ(set.begin(), set.end());
ASSERT_FALSE(set.has(entt::entity{0}));
ASSERT_FALSE(set.has(entt::entity{42}));
set.construct(entt::entity{42});
ASSERT_FALSE(set.empty());
ASSERT_EQ(set.index(entt::entity{42}), 0u);
ASSERT_TRUE(std::is_move_constructible_v<decltype(set)>);
ASSERT_TRUE(std::is_move_assignable_v<decltype(set)>);
entt::sparse_set<entt::entity> cpy{set};
set = cpy;
ASSERT_FALSE(set.empty());
ASSERT_FALSE(cpy.empty());
ASSERT_EQ(set.index(entt::entity{42}), 0u);
ASSERT_EQ(cpy.index(entt::entity{42}), 0u);
entt::sparse_set<entt::entity> other{std::move(set)};
set = std::move(other);
other = std::move(set);
ASSERT_TRUE(set.empty());
ASSERT_FALSE(other.empty());
ASSERT_EQ(other.index(entt::entity{42}), 0u);
other.reset();
ASSERT_TRUE(other.empty());
ASSERT_EQ(other.size(), 0u);
ASSERT_EQ(std::as_const(other).begin(), std::as_const(other).end());
ASSERT_EQ(other.begin(), other.end());
ASSERT_FALSE(other.has(entt::entity{0}));
ASSERT_FALSE(other.has(entt::entity{42}));
}
TEST(SparseSet, Pagination) {
entt::sparse_set<entt::entity> set;
constexpr auto entt_per_page = ENTT_PAGE_SIZE / sizeof(std::underlying_type_t<entt::entity>);
ASSERT_EQ(set.extent(), 0);
set.construct(entt::entity{entt_per_page-1});
ASSERT_EQ(set.extent(), entt_per_page);
ASSERT_TRUE(set.has(entt::entity{entt_per_page-1}));
set.construct(entt::entity{entt_per_page});
ASSERT_EQ(set.extent(), 2 * entt_per_page);
ASSERT_TRUE(set.has(entt::entity{entt_per_page-1}));
ASSERT_TRUE(set.has(entt::entity{entt_per_page}));
ASSERT_FALSE(set.has(entt::entity{entt_per_page+1}));
set.destroy(entt::entity{entt_per_page-1});
ASSERT_EQ(set.extent(), 2 * entt_per_page);
ASSERT_FALSE(set.has(entt::entity{entt_per_page-1}));
ASSERT_TRUE(set.has(entt::entity{entt_per_page}));
set.shrink_to_fit();
set.destroy(entt::entity{entt_per_page});
ASSERT_EQ(set.extent(), 2 * entt_per_page);
ASSERT_FALSE(set.has(entt::entity{entt_per_page-1}));
ASSERT_FALSE(set.has(entt::entity{entt_per_page}));
set.shrink_to_fit();
ASSERT_EQ(set.extent(), 0);
}
TEST(SparseSet, BatchAdd) {
entt::sparse_set<entt::entity> set;
entt::entity entities[2];
entities[0] = entt::entity{3};
entities[1] = entt::entity{42};
set.construct(entt::entity{12});
set.batch(std::begin(entities), std::end(entities));
set.construct(entt::entity{24});
ASSERT_TRUE(set.has(entities[0]));
ASSERT_TRUE(set.has(entities[1]));
ASSERT_FALSE(set.has(entt::entity{0}));
ASSERT_FALSE(set.has(entt::entity{9}));
ASSERT_TRUE(set.has(entt::entity{12}));
ASSERT_TRUE(set.has(entt::entity{24}));
ASSERT_FALSE(set.empty());
ASSERT_EQ(set.size(), 4u);
ASSERT_EQ(set.index(entt::entity{12}), 0u);
ASSERT_EQ(set.index(entities[0]), 1u);
ASSERT_EQ(set.index(entities[1]), 2u);
ASSERT_EQ(set.index(entt::entity{24}), 3u);
ASSERT_EQ(set.data()[set.index(entt::entity{12})], entt::entity{12});
ASSERT_EQ(set.data()[set.index(entities[0])], entities[0]);
ASSERT_EQ(set.data()[set.index(entities[1])], entities[1]);
ASSERT_EQ(set.data()[set.index(entt::entity{24})], entt::entity{24});
}
TEST(SparseSet, Iterator) {
using iterator_type = typename entt::sparse_set<entt::entity>::iterator_type;
entt::sparse_set<entt::entity> set;
set.construct(entt::entity{3});
iterator_type end{set.begin()};
iterator_type begin{};
begin = set.end();
std::swap(begin, end);
ASSERT_EQ(begin, set.begin());
ASSERT_EQ(end, set.end());
ASSERT_NE(begin, end);
ASSERT_EQ(begin++, set.begin());
ASSERT_EQ(begin--, set.end());
ASSERT_EQ(begin+1, set.end());
ASSERT_EQ(end-1, set.begin());
ASSERT_EQ(++begin, set.end());
ASSERT_EQ(--begin, set.begin());
ASSERT_EQ(begin += 1, set.end());
ASSERT_EQ(begin -= 1, set.begin());
ASSERT_EQ(begin + (end - begin), set.end());
ASSERT_EQ(begin - (begin - end), set.end());
ASSERT_EQ(end - (end - begin), set.begin());
ASSERT_EQ(end + (begin - end), set.begin());
ASSERT_EQ(begin[0], *set.begin());
ASSERT_LT(begin, end);
ASSERT_LE(begin, set.begin());
ASSERT_GT(end, begin);
ASSERT_GE(end, set.end());
ASSERT_EQ(*begin, entt::entity{3});
ASSERT_EQ(*begin.operator->(), entt::entity{3});
}
TEST(SparseSet, Find) {
entt::sparse_set<entt::entity> set;
set.construct(entt::entity{3});
set.construct(entt::entity{42});
set.construct(entt::entity{99});
ASSERT_NE(set.find(entt::entity{3}), set.end());
ASSERT_NE(set.find(entt::entity{42}), set.end());
ASSERT_NE(set.find(entt::entity{99}), set.end());
ASSERT_EQ(set.find(entt::entity{0}), set.end());
auto it = set.find(entt::entity{99});
ASSERT_EQ(*it, entt::entity{99});
ASSERT_EQ(*(++it), entt::entity{42});
ASSERT_EQ(*(++it), entt::entity{3});
ASSERT_EQ(++it, set.end());
ASSERT_EQ(++set.find(entt::entity{3}), set.end());
}
TEST(SparseSet, Data) {
entt::sparse_set<entt::entity> set;
set.construct(entt::entity{3});
set.construct(entt::entity{12});
set.construct(entt::entity{42});
ASSERT_EQ(set.index(entt::entity{3}), 0u);
ASSERT_EQ(set.index(entt::entity{12}), 1u);
ASSERT_EQ(set.index(entt::entity{42}), 2u);
ASSERT_EQ(*(set.data() + 0u), entt::entity{3});
ASSERT_EQ(*(set.data() + 1u), entt::entity{12});
ASSERT_EQ(*(set.data() + 2u), entt::entity{42});
}
TEST(SparseSet, SortOrdered) {
entt::sparse_set<entt::entity> set;
set.construct(entt::entity{42});
set.construct(entt::entity{12});
set.construct(entt::entity{9});
set.construct(entt::entity{7});
set.construct(entt::entity{3});
ASSERT_EQ(*(set.data() + 0u), entt::entity{42});
ASSERT_EQ(*(set.data() + 1u), entt::entity{12});
ASSERT_EQ(*(set.data() + 2u), entt::entity{9});
ASSERT_EQ(*(set.data() + 3u), entt::entity{7});
ASSERT_EQ(*(set.data() + 4u), entt::entity{3});
set.sort(set.begin(), set.end(), [](const auto lhs, const auto rhs) {
return std::underlying_type_t<entt::entity>(lhs) < std::underlying_type_t<entt::entity>(rhs);
});
ASSERT_EQ(*(set.data() + 0u), entt::entity{42});
ASSERT_EQ(*(set.data() + 1u), entt::entity{12});
ASSERT_EQ(*(set.data() + 2u), entt::entity{9});
ASSERT_EQ(*(set.data() + 3u), entt::entity{7});
ASSERT_EQ(*(set.data() + 4u), entt::entity{3});
auto begin = set.begin();
auto end = set.end();
ASSERT_EQ(*(begin++), entt::entity{3});
ASSERT_EQ(*(begin++), entt::entity{7});
ASSERT_EQ(*(begin++), entt::entity{9});
ASSERT_EQ(*(begin++), entt::entity{12});
ASSERT_EQ(*(begin++), entt::entity{42});
ASSERT_EQ(begin, end);
}
TEST(SparseSet, SortReverse) {
entt::sparse_set<entt::entity> set;
set.construct(entt::entity{3});
set.construct(entt::entity{7});
set.construct(entt::entity{9});
set.construct(entt::entity{12});
set.construct(entt::entity{42});
ASSERT_EQ(*(set.data() + 0u), entt::entity{3});
ASSERT_EQ(*(set.data() + 1u), entt::entity{7});
ASSERT_EQ(*(set.data() + 2u), entt::entity{9});
ASSERT_EQ(*(set.data() + 3u), entt::entity{12});
ASSERT_EQ(*(set.data() + 4u), entt::entity{42});
set.sort(set.begin(), set.end(), [](const auto lhs, const auto rhs) {
return std::underlying_type_t<entt::entity>(lhs) < std::underlying_type_t<entt::entity>(rhs);
});
ASSERT_EQ(*(set.data() + 0u), entt::entity{42});
ASSERT_EQ(*(set.data() + 1u), entt::entity{12});
ASSERT_EQ(*(set.data() + 2u), entt::entity{9});
ASSERT_EQ(*(set.data() + 3u), entt::entity{7});
ASSERT_EQ(*(set.data() + 4u), entt::entity{3});
auto begin = set.begin();
auto end = set.end();
ASSERT_EQ(*(begin++), entt::entity{3});
ASSERT_EQ(*(begin++), entt::entity{7});
ASSERT_EQ(*(begin++), entt::entity{9});
ASSERT_EQ(*(begin++), entt::entity{12});
ASSERT_EQ(*(begin++), entt::entity{42});
ASSERT_EQ(begin, end);
}
TEST(SparseSet, SortUnordered) {
entt::sparse_set<entt::entity> set;
set.construct(entt::entity{9});
set.construct(entt::entity{7});
set.construct(entt::entity{3});
set.construct(entt::entity{12});
set.construct(entt::entity{42});
ASSERT_EQ(*(set.data() + 0u), entt::entity{9});
ASSERT_EQ(*(set.data() + 1u), entt::entity{7});
ASSERT_EQ(*(set.data() + 2u), entt::entity{3});
ASSERT_EQ(*(set.data() + 3u), entt::entity{12});
ASSERT_EQ(*(set.data() + 4u), entt::entity{42});
set.sort(set.begin(), set.end(), [](const auto lhs, const auto rhs) {
return std::underlying_type_t<entt::entity>(lhs) < std::underlying_type_t<entt::entity>(rhs);
});
ASSERT_EQ(*(set.data() + 0u), entt::entity{42});
ASSERT_EQ(*(set.data() + 1u), entt::entity{12});
ASSERT_EQ(*(set.data() + 2u), entt::entity{9});
ASSERT_EQ(*(set.data() + 3u), entt::entity{7});
ASSERT_EQ(*(set.data() + 4u), entt::entity{3});
auto begin = set.begin();
auto end = set.end();
ASSERT_EQ(*(begin++), entt::entity{3});
ASSERT_EQ(*(begin++), entt::entity{7});
ASSERT_EQ(*(begin++), entt::entity{9});
ASSERT_EQ(*(begin++), entt::entity{12});
ASSERT_EQ(*(begin++), entt::entity{42});
ASSERT_EQ(begin, end);
}
TEST(SparseSet, SortRange) {
entt::sparse_set<entt::entity> set;
set.construct(entt::entity{9});
set.construct(entt::entity{7});
set.construct(entt::entity{3});
set.construct(entt::entity{12});
set.construct(entt::entity{42});
ASSERT_EQ(*(set.data() + 0u), entt::entity{9});
ASSERT_EQ(*(set.data() + 1u), entt::entity{7});
ASSERT_EQ(*(set.data() + 2u), entt::entity{3});
ASSERT_EQ(*(set.data() + 3u), entt::entity{12});
ASSERT_EQ(*(set.data() + 4u), entt::entity{42});
set.sort(set.end(), set.end(), [](const auto lhs, const auto rhs) {
return std::underlying_type_t<entt::entity>(lhs) < std::underlying_type_t<entt::entity>(rhs);
});
ASSERT_EQ(*(set.data() + 0u), entt::entity{9});
ASSERT_EQ(*(set.data() + 1u), entt::entity{7});
ASSERT_EQ(*(set.data() + 2u), entt::entity{3});
ASSERT_EQ(*(set.data() + 3u), entt::entity{12});
ASSERT_EQ(*(set.data() + 4u), entt::entity{42});
set.sort(set.begin(), set.begin(), [](const auto lhs, const auto rhs) {
return std::underlying_type_t<entt::entity>(lhs) < std::underlying_type_t<entt::entity>(rhs);
});
ASSERT_EQ(*(set.data() + 0u), entt::entity{9});
ASSERT_EQ(*(set.data() + 1u), entt::entity{7});
ASSERT_EQ(*(set.data() + 2u), entt::entity{3});
ASSERT_EQ(*(set.data() + 3u), entt::entity{12});
ASSERT_EQ(*(set.data() + 4u), entt::entity{42});
set.sort(set.begin()+2, set.begin()+3, [](const auto lhs, const auto rhs) {
return std::underlying_type_t<entt::entity>(lhs) < std::underlying_type_t<entt::entity>(rhs);
});
ASSERT_EQ(*(set.data() + 0u), entt::entity{9});
ASSERT_EQ(*(set.data() + 1u), entt::entity{7});
ASSERT_EQ(*(set.data() + 2u), entt::entity{3});
ASSERT_EQ(*(set.data() + 3u), entt::entity{12});
ASSERT_EQ(*(set.data() + 4u), entt::entity{42});
set.sort(++set.begin(), --set.end(), [](const auto lhs, const auto rhs) {
return std::underlying_type_t<entt::entity>(lhs) < std::underlying_type_t<entt::entity>(rhs);
});
ASSERT_EQ(*(set.data() + 0u), entt::entity{9});
ASSERT_EQ(*(set.data() + 1u), entt::entity{12});
ASSERT_EQ(*(set.data() + 2u), entt::entity{7});
ASSERT_EQ(*(set.data() + 3u), entt::entity{3});
ASSERT_EQ(*(set.data() + 4u), entt::entity{42});
auto begin = set.begin();
auto end = set.end();
ASSERT_EQ(*(begin++), entt::entity{42});
ASSERT_EQ(*(begin++), entt::entity{3});
ASSERT_EQ(*(begin++), entt::entity{7});
ASSERT_EQ(*(begin++), entt::entity{12});
ASSERT_EQ(*(begin++), entt::entity{9});
ASSERT_EQ(begin, end);
}
TEST(SparseSet, RespectDisjoint) {
entt::sparse_set<entt::entity> lhs;
entt::sparse_set<entt::entity> rhs;
lhs.construct(entt::entity{3});
lhs.construct(entt::entity{12});
lhs.construct(entt::entity{42});
ASSERT_EQ(lhs.index(entt::entity{3}), 0u);
ASSERT_EQ(lhs.index(entt::entity{12}), 1u);
ASSERT_EQ(lhs.index(entt::entity{42}), 2u);
lhs.respect(rhs);
ASSERT_EQ(std::as_const(lhs).index(entt::entity{3}), 0u);
ASSERT_EQ(std::as_const(lhs).index(entt::entity{12}), 1u);
ASSERT_EQ(std::as_const(lhs).index(entt::entity{42}), 2u);
}
TEST(SparseSet, RespectOverlap) {
entt::sparse_set<entt::entity> lhs;
entt::sparse_set<entt::entity> rhs;
lhs.construct(entt::entity{3});
lhs.construct(entt::entity{12});
lhs.construct(entt::entity{42});
rhs.construct(entt::entity{12});
ASSERT_EQ(lhs.index(entt::entity{3}), 0u);
ASSERT_EQ(lhs.index(entt::entity{12}), 1u);
ASSERT_EQ(lhs.index(entt::entity{42}), 2u);
lhs.respect(rhs);
ASSERT_EQ(std::as_const(lhs).index(entt::entity{3}), 0u);
ASSERT_EQ(std::as_const(lhs).index(entt::entity{12}), 2u);
ASSERT_EQ(std::as_const(lhs).index(entt::entity{42}), 1u);
}
TEST(SparseSet, RespectOrdered) {
entt::sparse_set<entt::entity> lhs;
entt::sparse_set<entt::entity> rhs;
lhs.construct(entt::entity{1});
lhs.construct(entt::entity{2});
lhs.construct(entt::entity{3});
lhs.construct(entt::entity{4});
lhs.construct(entt::entity{5});
ASSERT_EQ(lhs.index(entt::entity{1}), 0u);
ASSERT_EQ(lhs.index(entt::entity{2}), 1u);
ASSERT_EQ(lhs.index(entt::entity{3}), 2u);
ASSERT_EQ(lhs.index(entt::entity{4}), 3u);
ASSERT_EQ(lhs.index(entt::entity{5}), 4u);
rhs.construct(entt::entity{6});
rhs.construct(entt::entity{1});
rhs.construct(entt::entity{2});
rhs.construct(entt::entity{3});
rhs.construct(entt::entity{4});
rhs.construct(entt::entity{5});
ASSERT_EQ(rhs.index(entt::entity{6}), 0u);
ASSERT_EQ(rhs.index(entt::entity{1}), 1u);
ASSERT_EQ(rhs.index(entt::entity{2}), 2u);
ASSERT_EQ(rhs.index(entt::entity{3}), 3u);
ASSERT_EQ(rhs.index(entt::entity{4}), 4u);
ASSERT_EQ(rhs.index(entt::entity{5}), 5u);
rhs.respect(lhs);
ASSERT_EQ(rhs.index(entt::entity{6}), 0u);
ASSERT_EQ(rhs.index(entt::entity{1}), 1u);
ASSERT_EQ(rhs.index(entt::entity{2}), 2u);
ASSERT_EQ(rhs.index(entt::entity{3}), 3u);
ASSERT_EQ(rhs.index(entt::entity{4}), 4u);
ASSERT_EQ(rhs.index(entt::entity{5}), 5u);
}
TEST(SparseSet, RespectReverse) {
entt::sparse_set<entt::entity> lhs;
entt::sparse_set<entt::entity> rhs;
lhs.construct(entt::entity{1});
lhs.construct(entt::entity{2});
lhs.construct(entt::entity{3});
lhs.construct(entt::entity{4});
lhs.construct(entt::entity{5});
ASSERT_EQ(lhs.index(entt::entity{1}), 0u);
ASSERT_EQ(lhs.index(entt::entity{2}), 1u);
ASSERT_EQ(lhs.index(entt::entity{3}), 2u);
ASSERT_EQ(lhs.index(entt::entity{4}), 3u);
ASSERT_EQ(lhs.index(entt::entity{5}), 4u);
rhs.construct(entt::entity{5});
rhs.construct(entt::entity{4});
rhs.construct(entt::entity{3});
rhs.construct(entt::entity{2});
rhs.construct(entt::entity{1});
rhs.construct(entt::entity{6});
ASSERT_EQ(rhs.index(entt::entity{5}), 0u);
ASSERT_EQ(rhs.index(entt::entity{4}), 1u);
ASSERT_EQ(rhs.index(entt::entity{3}), 2u);
ASSERT_EQ(rhs.index(entt::entity{2}), 3u);
ASSERT_EQ(rhs.index(entt::entity{1}), 4u);
ASSERT_EQ(rhs.index(entt::entity{6}), 5u);
rhs.respect(lhs);
ASSERT_EQ(rhs.index(entt::entity{6}), 0u);
ASSERT_EQ(rhs.index(entt::entity{1}), 1u);
ASSERT_EQ(rhs.index(entt::entity{2}), 2u);
ASSERT_EQ(rhs.index(entt::entity{3}), 3u);
ASSERT_EQ(rhs.index(entt::entity{4}), 4u);
ASSERT_EQ(rhs.index(entt::entity{5}), 5u);
}
TEST(SparseSet, RespectUnordered) {
entt::sparse_set<entt::entity> lhs;
entt::sparse_set<entt::entity> rhs;
lhs.construct(entt::entity{1});
lhs.construct(entt::entity{2});
lhs.construct(entt::entity{3});
lhs.construct(entt::entity{4});
lhs.construct(entt::entity{5});
ASSERT_EQ(lhs.index(entt::entity{1}), 0u);
ASSERT_EQ(lhs.index(entt::entity{2}), 1u);
ASSERT_EQ(lhs.index(entt::entity{3}), 2u);
ASSERT_EQ(lhs.index(entt::entity{4}), 3u);
ASSERT_EQ(lhs.index(entt::entity{5}), 4u);
rhs.construct(entt::entity{3});
rhs.construct(entt::entity{2});
rhs.construct(entt::entity{6});
rhs.construct(entt::entity{1});
rhs.construct(entt::entity{4});
rhs.construct(entt::entity{5});
ASSERT_EQ(rhs.index(entt::entity{3}), 0u);
ASSERT_EQ(rhs.index(entt::entity{2}), 1u);
ASSERT_EQ(rhs.index(entt::entity{6}), 2u);
ASSERT_EQ(rhs.index(entt::entity{1}), 3u);
ASSERT_EQ(rhs.index(entt::entity{4}), 4u);
ASSERT_EQ(rhs.index(entt::entity{5}), 5u);
rhs.respect(lhs);
ASSERT_EQ(rhs.index(entt::entity{6}), 0u);
ASSERT_EQ(rhs.index(entt::entity{1}), 1u);
ASSERT_EQ(rhs.index(entt::entity{2}), 2u);
ASSERT_EQ(rhs.index(entt::entity{3}), 3u);
ASSERT_EQ(rhs.index(entt::entity{4}), 4u);
ASSERT_EQ(rhs.index(entt::entity{5}), 5u);
}
TEST(SparseSet, CanModifyDuringIteration) {
entt::sparse_set<entt::entity> set;
set.construct(entt::entity{0});
ASSERT_EQ(set.capacity(), entt::sparse_set<entt::entity>::size_type{1});
const auto it = set.begin();
set.reserve(entt::sparse_set<entt::entity>::size_type{2});
ASSERT_EQ(set.capacity(), entt::sparse_set<entt::entity>::size_type{2});
// this should crash with asan enabled if we break the constraint
const auto entity = *it;
(void)entity;
}
| 32.859619
| 101
| 0.626477
|
janisozaur
|
f5321f64e7f49d4587a2dd0b49a6011a78ca7bce
| 280
|
cpp
|
C++
|
src/align/AlignConfig.cpp
|
PacificBiosciences/pbcopper
|
ba98ddd79371c2218ca5110d07d5f881c995ff93
|
[
"BSD-3-Clause-Clear"
] | 5
|
2018-01-15T13:40:30.000Z
|
2021-01-19T18:28:30.000Z
|
src/align/AlignConfig.cpp
|
PacificBiosciences/pbcopper
|
ba98ddd79371c2218ca5110d07d5f881c995ff93
|
[
"BSD-3-Clause-Clear"
] | 4
|
2016-09-20T20:25:14.000Z
|
2020-12-22T19:21:49.000Z
|
src/align/AlignConfig.cpp
|
PacificBiosciences/pbcopper
|
ba98ddd79371c2218ca5110d07d5f881c995ff93
|
[
"BSD-3-Clause-Clear"
] | 7
|
2017-05-15T08:47:02.000Z
|
2021-04-28T18:38:09.000Z
|
#include <pbcopper/align/AlignConfig.h>
namespace PacBio {
namespace Align {
AlignParams AlignParams::Default() { return {0, -1, -1, -1}; }
AlignConfig AlignConfig::Default() { return {AlignParams::Default(), AlignMode::GLOBAL}; }
} // namespace Align
} // namespace PacBio
| 23.333333
| 90
| 0.703571
|
PacificBiosciences
|
f53304f674c010aee4612a768253bd2b3e8a1f7d
| 3,748
|
hpp
|
C++
|
include/Shader.hpp
|
luanfagu/raylib-cpp
|
2524151b7d03262499660a8e696e126430a6ae0e
|
[
"Zlib"
] | 253
|
2019-03-20T16:15:21.000Z
|
2022-03-28T06:04:48.000Z
|
include/Shader.hpp
|
luanfagu/raylib-cpp
|
2524151b7d03262499660a8e696e126430a6ae0e
|
[
"Zlib"
] | 96
|
2019-08-19T22:12:28.000Z
|
2022-03-29T00:25:54.000Z
|
include/Shader.hpp
|
luanfagu/raylib-cpp
|
2524151b7d03262499660a8e696e126430a6ae0e
|
[
"Zlib"
] | 56
|
2019-09-09T04:39:50.000Z
|
2022-03-28T17:42:46.000Z
|
#ifndef RAYLIB_CPP_INCLUDE_SHADER_HPP_
#define RAYLIB_CPP_INCLUDE_SHADER_HPP_
#include <string>
#include "./raylib.hpp"
#include "./raylib-cpp-utils.hpp"
#include "Texture.hpp"
namespace raylib {
/**
* Shader type (generic)
*/
class Shader : public ::Shader {
public:
Shader(const ::Shader& shader) {
set(shader);
}
Shader(unsigned int id, int* locs = nullptr) : ::Shader{id, locs} {}
Shader(const std::string& vsFileName, const std::string& fsFileName) {
set(::LoadShader(vsFileName.c_str(), fsFileName.c_str()));
}
Shader(const Shader&) = delete;
Shader(Shader&& other) {
set(other);
other.id = 0;
other.locs = nullptr;
}
/**
* Load shader from files and bind default locations.
*/
static ::Shader Load(const std::string& vsFileName, const std::string& fsFileName) {
return ::LoadShader(vsFileName.c_str(), fsFileName.c_str());
}
static ::Shader LoadFromMemory(const std::string& vsCode, const std::string& fsCode) {
return ::LoadShaderFromMemory(vsCode.c_str(), fsCode.c_str());
}
GETTERSETTER(unsigned int, Id, id)
GETTERSETTER(int*, Locs, locs)
Shader& operator=(const ::Shader& shader) {
set(shader);
return *this;
}
Shader& operator=(const Shader&) = delete;
Shader& operator=(Shader&& other) {
if (this != &other) {
return *this;
}
Unload();
set(other);
other.id = 0;
other.locs = nullptr;
}
~Shader() {
Unload();
}
void Unload() {
if (locs != nullptr) {
::UnloadShader(*this);
}
}
/**
* Begin custom shader drawing.
*/
inline Shader& BeginMode() {
::BeginShaderMode(*this);
return *this;
}
/**
* End custom shader drawing (use default shader).
*/
inline Shader& EndMode() {
::EndShaderMode();
return *this;
}
/**
* Get shader uniform location
*
* @see GetShaderLocation()
*/
inline int GetLocation(const std::string& uniformName) const {
return ::GetShaderLocation(*this, uniformName.c_str());
}
/**
* Get shader attribute location
*
* @see GetShaderLocationAttrib()
*/
inline int GetLocationAttrib(const std::string& attribName) const {
return ::GetShaderLocationAttrib(*this, attribName.c_str());
}
/**
* Set shader uniform value
*
* @see SetShaderValue()
*/
inline Shader& SetValue(int uniformLoc, const std::string& value, int uniformType) {
::SetShaderValue(*this, uniformLoc, value.c_str(), uniformType);
return *this;
}
/**
* Set shader uniform value vector
*
* @see SetShaderValueV()
*/
inline Shader& SetValue(int uniformLoc, const std::string& value, int uniformType, int count) {
::SetShaderValueV(*this, uniformLoc, value.c_str(), uniformType, count);
return *this;
}
/**
* Set shader uniform value (matrix 4x4)
*
* @see SetShaderValueMatrix()
*/
inline Shader& SetValue(int uniformLoc, const ::Matrix& mat) {
::SetShaderValueMatrix(*this, uniformLoc, mat);
return *this;
}
/**
* Set shader uniform value for texture
*
* @see SetShaderValueTexture()
*/
inline Shader& SetValue(int uniformLoc, const ::Texture2D& texture) {
::SetShaderValueTexture(*this, uniformLoc, texture);
return *this;
}
private:
inline void set(const ::Shader& shader) {
id = shader.id;
locs = shader.locs;
}
};
} // namespace raylib
#endif // RAYLIB_CPP_INCLUDE_SHADER_HPP_
| 23.279503
| 99
| 0.585112
|
luanfagu
|
f5336b7e22febf505e104463a959d705b72f8ba2
| 482
|
cpp
|
C++
|
Section 08/Account/Account/Checking.cpp
|
yhaydar/beg_mod_cpp
|
6db3538d3f7d4484f7ce39065e13736a9676185a
|
[
"MIT"
] | null | null | null |
Section 08/Account/Account/Checking.cpp
|
yhaydar/beg_mod_cpp
|
6db3538d3f7d4484f7ce39065e13736a9676185a
|
[
"MIT"
] | null | null | null |
Section 08/Account/Account/Checking.cpp
|
yhaydar/beg_mod_cpp
|
6db3538d3f7d4484f7ce39065e13736a9676185a
|
[
"MIT"
] | null | null | null |
#include "Checking.h"
#include <iostream>
Checking::Checking(const std::string &name, float balance, float minbalance):
m_MinimumBalance(minbalance), Account(name, balance){
}
Checking::~Checking() {
}
void Checking::Withdraw(float amount) {
if ((m_Balance - amount) > m_MinimumBalance) {
Account::Withdraw(amount);
}
else {
std::cout << "Invalid amount" << std::endl;
}
}
float Checking::GetMinimumBalance() const {
return m_MinimumBalance;
}
| 20.083333
| 78
| 0.674274
|
yhaydar
|
f533d6c68be3875b89f69036fbf59b35aba1b5b3
| 9,561
|
cpp
|
C++
|
src/jnc_ext/jnc_io_devmon/jnc_io_DeviceMonitor.cpp
|
project-kotinos/vovkos___jancy
|
7050c9edba3185f8293b3e06766f31970ff1ed1a
|
[
"MIT"
] | null | null | null |
src/jnc_ext/jnc_io_devmon/jnc_io_DeviceMonitor.cpp
|
project-kotinos/vovkos___jancy
|
7050c9edba3185f8293b3e06766f31970ff1ed1a
|
[
"MIT"
] | null | null | null |
src/jnc_ext/jnc_io_devmon/jnc_io_DeviceMonitor.cpp
|
project-kotinos/vovkos___jancy
|
7050c9edba3185f8293b3e06766f31970ff1ed1a
|
[
"MIT"
] | null | null | null |
#include "pch.h"
#include "jnc_io_DeviceMonitor.h"
#include "jnc_io_DevMonLib.h"
#include "jnc_Error.h"
namespace jnc {
namespace io {
//..............................................................................
JNC_DEFINE_OPAQUE_CLASS_TYPE(
DeviceMonitor,
"io.DeviceMonitor",
g_devMonLibGuid,
DevMonLibTypeCacheSlot_DeviceMonitor,
DeviceMonitor,
&DeviceMonitor::markOpaqueGcRoots
)
JNC_BEGIN_TYPE_FUNCTION_MAP(DeviceMonitor)
JNC_MAP_CONSTRUCTOR(&sl::construct<DeviceMonitor>)
JNC_MAP_DESTRUCTOR(&sl::destruct<DeviceMonitor>)
JNC_MAP_AUTOGET_PROPERTY("m_readParallelism", &DeviceMonitor::setReadParallelism)
JNC_MAP_AUTOGET_PROPERTY("m_readBlockSize", &DeviceMonitor::setReadBlockSize)
JNC_MAP_AUTOGET_PROPERTY("m_readBufferSize", &DeviceMonitor::setReadBufferSize)
JNC_MAP_AUTOGET_PROPERTY("m_pendingNotifySizeLimit", &DeviceMonitor::setPendingNotifySizeLimit)
JNC_MAP_AUTOGET_PROPERTY("m_isEnabled", &DeviceMonitor::setEnabled)
JNC_MAP_AUTOGET_PROPERTY("m_fileNameFilter", &DeviceMonitor::setFileNameFilter)
JNC_MAP_FUNCTION("open", &DeviceMonitor::open)
JNC_MAP_FUNCTION("close", &DeviceMonitor::close)
JNC_MAP_FUNCTION("connect", &DeviceMonitor::connect)
JNC_MAP_FUNCTION("setIoctlDescTable", &DeviceMonitor::setIoctlDescTable)
JNC_MAP_FUNCTION("read", &DeviceMonitor::read)
JNC_MAP_FUNCTION("wait", &DeviceMonitor::wait)
JNC_MAP_FUNCTION("cancelWait", &DeviceMonitor::cancelWait)
JNC_MAP_FUNCTION("blockingWait", &DeviceMonitor::blockingWait)
JNC_END_TYPE_FUNCTION_MAP()
//..............................................................................
DeviceMonitor::DeviceMonitor()
{
m_readParallelism = Def_ReadParallelism;
m_readBlockSize = Def_ReadBlockSize;
m_readBufferSize = Def_ReadBufferSize;
m_pendingNotifySizeLimit = Def_PendingNotifySizeLimit;
m_readBuffer.setBufferSize(Def_ReadBufferSize);
#if (_AXL_OS_WIN)
m_overlappedIo = NULL;
#endif
}
bool
JNC_CDECL
DeviceMonitor::setPendingNotifySizeLimit(size_t limit)
{
if (!m_isConnected)
{
m_pendingNotifySizeLimit = limit;
return true;
}
bool result = m_monitor.setPendingNotifySizeLimit(limit);
if (!result)
return false;
m_pendingNotifySizeLimit = limit;
return true;
}
bool
JNC_CDECL
DeviceMonitor::setFileNameFilter(DataPtr filterPtr)
{
if (!m_isConnected)
{
setError(err::SystemErrorCode_InvalidDeviceState);
return true;
}
const char* filter = (const char*) filterPtr.m_p;
bool result = m_monitor.setFileNameFilter(filter);
if (!result)
return false;
m_fileNameFilterPtr = strDup(filter);
return true;
}
bool
JNC_CDECL
DeviceMonitor::setEnabled(bool isEnabled)
{
if (!m_isConnected)
{
setError(err::SystemErrorCode_InvalidDeviceState);
return true;
}
bool result = isEnabled ? m_monitor.enable() : m_monitor.disable();
if (!result)
return false;
m_isEnabled = isEnabled;
return true;
}
bool
JNC_CDECL
DeviceMonitor::open()
{
close();
bool result = m_monitor.open();
if (!result)
return false;
#if (_AXL_OS_WIN)
ASSERT(!m_overlappedIo);
m_overlappedIo = AXL_MEM_NEW(OverlappedIo);
#endif
AsyncIoDevice::open();
m_ioThread.start();
return true;
}
void
JNC_CDECL
DeviceMonitor::close()
{
if (!m_monitor.isOpen())
return;
m_lock.lock();
m_ioThreadFlags |= IoThreadFlag_Closing;
wakeIoThread();
m_lock.unlock();
GcHeap* gcHeap = m_runtime->getGcHeap();
gcHeap->enterWaitRegion();
m_ioThread.waitAndClose();
gcHeap->leaveWaitRegion();
m_monitor.close();
AsyncIoDevice::close();
m_isConnected = false;
m_isEnabled = false;
m_deviceNamePtr = g_nullDataPtr;
m_fileNameFilterPtr = g_nullDataPtr;
#if (_AXL_OS_WIN)
if (m_overlappedIo)
{
AXL_MEM_DELETE(m_overlappedIo);
m_overlappedIo = NULL;
}
#endif
}
bool
JNC_CDECL
DeviceMonitor::connect(DataPtr deviceNamePtr)
{
bool result =
m_monitor.connect((const char*) deviceNamePtr.m_p) &&
m_monitor.setPendingNotifySizeLimit(m_pendingNotifySizeLimit);
if (!result)
return false;
#if (_JNC_OS_WIN)
dm::DeviceInfo deviceInfo;
m_monitor.getTargetDeviceInfo(&deviceInfo);
m_deviceNamePtr = strDup(deviceInfo.m_deviceName);
#elif (_JNC_OS_LINUX)
dm::HookInfo hookInfo;
m_monitor.getTargetHookInfo(&hookInfo);
m_deviceNamePtr = strDup(hookInfo.m_fileName);
#endif
m_lock.lock();
m_ioThreadFlags |= IoThreadFlag_Connected;
wakeIoThread();
m_lock.unlock();
m_isConnected = true;
return true;
}
bool
JNC_CDECL
DeviceMonitor::setIoctlDescTable(
DataPtr ioctlDescPtr,
size_t count
)
{
#if (_JNC_OS_POSIX)
const dm_IoctlDesc* ioctlDesc = (const dm_IoctlDesc*) ioctlDescPtr.m_p;
bool result = m_monitor.setIoctlDescTable(ioctlDesc, count);
if (!result)
return false;
#endif
return true;
}
bool
DeviceMonitor::connectLoop()
{
for (;;)
{
sleepIoThread();
m_lock.lock();
if (m_ioThreadFlags & IoThreadFlag_Closing)
{
m_lock.unlock();
return false;
}
if (m_ioThreadFlags & IoThreadFlag_Connected)
{
m_lock.unlock();
return true;
}
m_lock.unlock();
}
}
#if (_JNC_OS_WIN)
void
DeviceMonitor::ioThreadFunc()
{
ASSERT(m_monitor.isOpen() && m_overlappedIo);
bool result = connectLoop();
if (!result)
return;
HANDLE waitTable[2] =
{
m_ioThreadEvent.m_event,
NULL, // placeholder for read completion event
};
size_t waitCount = 1; // always 1 or 2
m_ioThreadEvent.signal(); // do initial update of active events
// read loop
for (;;)
{
DWORD waitResult = ::WaitForMultipleObjects(waitCount, waitTable, false, INFINITE);
if (waitResult == WAIT_FAILED)
{
setIoErrorEvent(err::getLastSystemErrorCode());
return;
}
// do as much as we can without lock
while (!m_overlappedIo->m_activeOverlappedReadList.isEmpty())
{
OverlappedRead* read = *m_overlappedIo->m_activeOverlappedReadList.getHead();
result = read->m_overlapped.m_completionEvent.wait(0);
if (!result)
break;
dword_t actualSize;
result = m_monitor.getOverlappedResult(&read->m_overlapped, &actualSize);
if (!result)
{
setIoErrorEvent();
return;
}
read->m_overlapped.m_completionEvent.reset();
m_overlappedIo->m_activeOverlappedReadList.remove(read);
// only the main read buffer must be lock-protected
m_lock.lock();
addToReadBuffer(read->m_buffer, actualSize);
m_lock.unlock();
read->m_overlapped.m_completionEvent.reset();
m_overlappedIo->m_overlappedReadPool.put(read);
}
m_lock.lock();
if (m_ioThreadFlags & IoThreadFlag_Closing)
{
m_lock.unlock();
break;
}
uint_t prevActiveEvents = m_activeEvents;
m_activeEvents = 0;
updateReadWriteBufferEvents();
// take snapshots before releasing the lock
bool isReadBufferFull = m_readBuffer.isFull();
size_t readParallelism = m_readParallelism;
size_t readBlockSize = m_readBlockSize;
if (m_activeEvents != prevActiveEvents)
processWaitLists_l();
else
m_lock.unlock();
size_t activeReadCount = m_overlappedIo->m_activeOverlappedReadList.getCount();
if (!isReadBufferFull && activeReadCount < readParallelism)
{
size_t newReadCount = readParallelism - activeReadCount;
for (size_t i = 0; i < newReadCount; i++)
{
OverlappedRead* read = m_overlappedIo->m_overlappedReadPool.get();
result =
read->m_buffer.setCount(readBlockSize) &&
m_monitor.overlappedRead(read->m_buffer, readBlockSize, &read->m_overlapped);
if (!result)
{
setIoErrorEvent();
return;
}
m_overlappedIo->m_activeOverlappedReadList.insertTail(read);
}
}
if (m_overlappedIo->m_activeOverlappedReadList.isEmpty())
{
waitCount = 1;
}
else
{
// wait-table may already hold correct value -- but there's no harm in writing it over
OverlappedRead* read = *m_overlappedIo->m_activeOverlappedReadList.getHead();
waitTable[1] = read->m_overlapped.m_completionEvent.m_event;
waitCount = 2;
}
}
}
#elif (_JNC_OS_POSIX)
void
DeviceMonitor::ioThreadFunc()
{
ASSERT(m_monitor.isOpen());
int result = connectLoop();
if (!result)
return;
int selectFd = AXL_MAX(m_monitor.m_device, m_ioThreadSelfPipe.m_readFile) + 1;
sl::Array<char> readBlock;
readBlock.setCount(Def_ReadBlockSize);
bool canReadMonitor = false;
// read loop
for (;;)
{
fd_set readSet = { 0 };
FD_SET(m_ioThreadSelfPipe.m_readFile, &readSet);
if (!canReadMonitor)
FD_SET(m_monitor.m_device, &readSet);
result = ::select(selectFd, &readSet, NULL, NULL, NULL);
if (result == -1)
break;
if (FD_ISSET(m_ioThreadSelfPipe.m_readFile, &readSet))
{
char buffer[256];
m_ioThreadSelfPipe.read(buffer, sizeof(buffer));
}
if (FD_ISSET(m_monitor.m_device, &readSet))
canReadMonitor = true;
m_lock.lock();
if (m_ioThreadFlags & IoThreadFlag_Closing)
{
m_lock.unlock();
return;
}
uint_t prevActiveEvents = m_activeEvents;
m_activeEvents = 0;
readBlock.setCount(m_readBlockSize); // update read block size
while (canReadMonitor && !m_readBuffer.isFull())
{
ssize_t actualSize = ::read(m_monitor.m_device, readBlock, readBlock.getCount());
if (actualSize == -1)
{
if (errno == EAGAIN)
{
canReadMonitor = false;
}
else
{
setIoErrorEvent_l(err::Errno(errno));
return;
}
}
else
{
addToReadBuffer(readBlock, actualSize);
}
}
updateReadWriteBufferEvents();
if (m_activeEvents != prevActiveEvents)
processWaitLists_l();
else
m_lock.unlock();
}
}
#endif
//..............................................................................
} // namespace io
} // namespace jnc
| 21.246667
| 96
| 0.709131
|
project-kotinos
|
f535aa491fc4c96706a4d1b2fc377d86105e211e
| 3,032
|
cpp
|
C++
|
aws-cpp-sdk-sdb/source/model/DeletableItem.cpp
|
curiousjgeorge/aws-sdk-cpp
|
09b65deba03cfbef9a1e5d5986aa4de71bc03cd8
|
[
"Apache-2.0"
] | 2
|
2019-03-11T15:50:55.000Z
|
2020-02-27T11:40:27.000Z
|
aws-cpp-sdk-sdb/source/model/DeletableItem.cpp
|
curiousjgeorge/aws-sdk-cpp
|
09b65deba03cfbef9a1e5d5986aa4de71bc03cd8
|
[
"Apache-2.0"
] | 18
|
2018-05-15T16:41:07.000Z
|
2018-05-21T00:46:30.000Z
|
aws-cpp-sdk-sdb/source/model/DeletableItem.cpp
|
curiousjgeorge/aws-sdk-cpp
|
09b65deba03cfbef9a1e5d5986aa4de71bc03cd8
|
[
"Apache-2.0"
] | 1
|
2021-10-01T15:29:44.000Z
|
2021-10-01T15:29:44.000Z
|
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 <aws/sdb/model/DeletableItem.h>
#include <aws/core/utils/xml/XmlSerializer.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <utility>
using namespace Aws::Utils::Xml;
using namespace Aws::Utils;
namespace Aws
{
namespace SimpleDB
{
namespace Model
{
DeletableItem::DeletableItem() :
m_nameHasBeenSet(false),
m_attributesHasBeenSet(false)
{
}
DeletableItem::DeletableItem(const XmlNode& xmlNode) :
m_nameHasBeenSet(false),
m_attributesHasBeenSet(false)
{
*this = xmlNode;
}
DeletableItem& DeletableItem::operator =(const XmlNode& xmlNode)
{
XmlNode resultNode = xmlNode;
if(!resultNode.IsNull())
{
XmlNode nameNode = resultNode.FirstChild("ItemName");
if(!nameNode.IsNull())
{
m_name = StringUtils::Trim(nameNode.GetText().c_str());
m_nameHasBeenSet = true;
}
XmlNode attributesNode = resultNode.FirstChild("Attribute");
if(!attributesNode.IsNull())
{
XmlNode attributeMember = attributesNode;
while(!attributeMember.IsNull())
{
m_attributes.push_back(attributeMember);
attributeMember = attributeMember.NextNode("Attribute");
}
m_attributesHasBeenSet = true;
}
}
return *this;
}
void DeletableItem::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
{
if(m_nameHasBeenSet)
{
oStream << location << index << locationValue << ".Name=" << StringUtils::URLEncode(m_name.c_str()) << "&";
}
if(m_attributesHasBeenSet)
{
unsigned attributesIdx = 1;
for(auto& item : m_attributes)
{
Aws::StringStream attributesSs;
attributesSs << location << index << locationValue << ".Attribute." << attributesIdx++;
item.OutputToStream(oStream, attributesSs.str().c_str());
}
}
}
void DeletableItem::OutputToStream(Aws::OStream& oStream, const char* location) const
{
if(m_nameHasBeenSet)
{
oStream << location << ".Name=" << StringUtils::URLEncode(m_name.c_str()) << "&";
}
if(m_attributesHasBeenSet)
{
unsigned attributesIdx = 1;
for(auto& item : m_attributes)
{
Aws::StringStream attributesSs;
attributesSs << location << ".Attribute." << attributesIdx++;
item.OutputToStream(oStream, attributesSs.str().c_str());
}
}
}
} // namespace Model
} // namespace SimpleDB
} // namespace Aws
| 26.137931
| 128
| 0.685356
|
curiousjgeorge
|
f53c15bc31e4da9f183654622f49ad6989294f77
| 2,302
|
hxx
|
C++
|
opencascade/STEPEdit_EditSDR.hxx
|
valgur/OCP
|
2f7d9da73a08e4ffe80883614aedacb27351134f
|
[
"Apache-2.0"
] | 117
|
2020-03-07T12:07:05.000Z
|
2022-03-27T07:35:22.000Z
|
opencascade/STEPEdit_EditSDR.hxx
|
CadQuery/cpp-py-bindgen
|
66e7376d3a27444393fc99acbdbef40bbc7031ae
|
[
"Apache-2.0"
] | 66
|
2019-12-20T16:07:36.000Z
|
2022-03-15T21:56:10.000Z
|
opencascade/STEPEdit_EditSDR.hxx
|
CadQuery/cpp-py-bindgen
|
66e7376d3a27444393fc99acbdbef40bbc7031ae
|
[
"Apache-2.0"
] | 76
|
2020-03-16T01:47:46.000Z
|
2022-03-21T16:37:07.000Z
|
// Created on: 1998-07-29
// Created by: Administrateur Atelier XSTEP
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _STEPEdit_EditSDR_HeaderFile
#define _STEPEdit_EditSDR_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <IFSelect_Editor.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
class TCollection_AsciiString;
class IFSelect_EditForm;
class TCollection_HAsciiString;
class Standard_Transient;
class Interface_InterfaceModel;
class STEPEdit_EditSDR;
DEFINE_STANDARD_HANDLE(STEPEdit_EditSDR, IFSelect_Editor)
//! EditSDR is an Editor fit for a Shape Definition Representation
//! which designates a Product Definition
class STEPEdit_EditSDR : public IFSelect_Editor
{
public:
Standard_EXPORT STEPEdit_EditSDR();
Standard_EXPORT TCollection_AsciiString Label() const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean Recognize (const Handle(IFSelect_EditForm)& form) const Standard_OVERRIDE;
Standard_EXPORT Handle(TCollection_HAsciiString) StringValue (const Handle(IFSelect_EditForm)& form, const Standard_Integer num) const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean Apply (const Handle(IFSelect_EditForm)& form, const Handle(Standard_Transient)& ent, const Handle(Interface_InterfaceModel)& model) const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean Load (const Handle(IFSelect_EditForm)& form, const Handle(Standard_Transient)& ent, const Handle(Interface_InterfaceModel)& model) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(STEPEdit_EditSDR,IFSelect_Editor)
protected:
private:
};
#endif // _STEPEdit_EditSDR_HeaderFile
| 28.775
| 191
| 0.807993
|
valgur
|
f54092e95874d44dfe8b19bceaa89191604b7c61
| 4,050
|
cpp
|
C++
|
src/devices/bus/einstein/pipe/pipe.cpp
|
Robbbert/messui
|
49b756e2140d8831bc81335298ee8c5471045e79
|
[
"BSD-3-Clause"
] | 26
|
2015-03-31T06:25:51.000Z
|
2021-12-14T09:29:04.000Z
|
src/devices/bus/einstein/pipe/pipe.cpp
|
Robbbert/messui
|
49b756e2140d8831bc81335298ee8c5471045e79
|
[
"BSD-3-Clause"
] | null | null | null |
src/devices/bus/einstein/pipe/pipe.cpp
|
Robbbert/messui
|
49b756e2140d8831bc81335298ee8c5471045e79
|
[
"BSD-3-Clause"
] | 10
|
2015-03-27T05:45:51.000Z
|
2022-02-04T06:57:36.000Z
|
// license: GPL-2.0+
// copyright-holders: Dirk Best
/***************************************************************************
Einstein "Tatung Pipe"
***************************************************************************/
#include "emu.h"
#include "pipe.h"
// supported devices
#include "silicon_disc.h"
#include "speculator.h"
#include "tk02.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(TATUNG_PIPE, tatung_pipe_device, "tatung_pipe", "Tatung Pipe Slot")
//**************************************************************************
// SLOT DEVICE
//**************************************************************************
//-------------------------------------------------
// tatung_pipe_device - constructor
//-------------------------------------------------
tatung_pipe_device::tatung_pipe_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, TATUNG_PIPE, tag, owner, clock),
device_single_card_slot_interface<device_tatung_pipe_interface>(mconfig, *this),
m_program(*this, finder_base::DUMMY_TAG, -1),
m_io(*this, finder_base::DUMMY_TAG, -1),
m_card(nullptr),
m_int_handler(*this),
m_nmi_handler(*this),
m_reset_handler(*this)
{
}
//-------------------------------------------------
// tatung_pipe_device - destructor
//-------------------------------------------------
tatung_pipe_device::~tatung_pipe_device()
{
}
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void tatung_pipe_device::device_config_complete()
{
// for passthrough connectors, use the parent slot's spaces
if (dynamic_cast<device_tatung_pipe_interface *>(owner()) != nullptr)
{
auto parent = dynamic_cast<tatung_pipe_device *>(owner()->owner());
if (parent != nullptr)
{
if (m_program.finder_tag() == finder_base::DUMMY_TAG)
m_program.set_tag(parent->m_program, parent->m_program.spacenum());
if (m_io.finder_tag() == finder_base::DUMMY_TAG)
m_io.set_tag(parent->m_io, parent->m_io.spacenum());
}
}
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void tatung_pipe_device::device_start()
{
// get inserted module
m_card = get_card_device();
// resolve callbacks
m_int_handler.resolve_safe();
m_nmi_handler.resolve_safe();
m_reset_handler.resolve_safe();
}
//-------------------------------------------------
// host to module interface
//-------------------------------------------------
WRITE_LINE_MEMBER( tatung_pipe_device::host_int_w )
{
if (m_card)
m_card->int_w(state);
}
//**************************************************************************
// CARD INTERFACE
//**************************************************************************
//-------------------------------------------------
// device_tatung_pipe_interface - constructor
//-------------------------------------------------
device_tatung_pipe_interface::device_tatung_pipe_interface(const machine_config &mconfig, device_t &device) :
device_interface(device, "tatungpipe")
{
m_slot = dynamic_cast<tatung_pipe_device *>(device.owner());
}
//-------------------------------------------------
// ~device_tatung_pipe_interface - destructor
//-------------------------------------------------
device_tatung_pipe_interface::~device_tatung_pipe_interface()
{
}
//**************************************************************************
// SLOT INTERFACE
//**************************************************************************
void tatung_pipe_cards(device_slot_interface &device)
{
device.option_add("silicon_disc", EINSTEIN_SILICON_DISC);
device.option_add("speculator", EINSTEIN_SPECULATOR);
device.option_add("tk02", TK02_80COL);
}
| 30.223881
| 121
| 0.475062
|
Robbbert
|
f540f1881927ec696773f461f865af19c68dcb0c
| 1,171
|
cc
|
C++
|
src/ledger/bin/app/fidl/serialization_size.cc
|
zhangpf/fuchsia-rs
|
903568f28ddf45f09157ead36d61b50322c9cf49
|
[
"BSD-3-Clause"
] | 3
|
2020-08-02T04:46:18.000Z
|
2020-08-07T10:10:53.000Z
|
src/ledger/bin/app/fidl/serialization_size.cc
|
zhangpf/fuchsia-rs
|
903568f28ddf45f09157ead36d61b50322c9cf49
|
[
"BSD-3-Clause"
] | 16
|
2020-09-04T19:01:11.000Z
|
2021-05-28T03:23:09.000Z
|
src/ledger/bin/app/fidl/serialization_size.cc
|
ZVNexus/fuchsia
|
c5610ad15208208c98693618a79c705af935270c
|
[
"BSD-3-Clause"
] | 1
|
2020-08-07T10:11:49.000Z
|
2020-08-07T10:11:49.000Z
|
// Copyright 2017 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/ledger/bin/app/fidl/serialization_size.h"
namespace ledger {
namespace fidl_serialization {
size_t GetByteVectorSize(size_t vector_length) { return Align(vector_length) + kVectorHeaderSize; }
size_t GetEntrySize(size_t key_length) {
size_t key_size = GetByteVectorSize(key_length);
size_t object_size = Align(kMemoryObjectSize);
return key_size + object_size + Align(kPriorityEnumSize);
}
size_t GetInlinedEntrySize(const InlinedEntry& entry) {
size_t key_size = GetByteVectorSize(entry.key.size());
size_t object_size = kPointerSize;
if (entry.inlined_value) {
object_size += GetByteVectorSize(entry.inlined_value->value.size());
}
return key_size + object_size + Align(kPriorityEnumSize);
}
size_t GetDiffEntrySize(size_t key_length, int number_of_values) {
size_t key_size = GetByteVectorSize(key_length);
return key_size + number_of_values * (Align(kMemoryObjectSize) + Align(kPriorityEnumSize));
}
} // namespace fidl_serialization
} // namespace ledger
| 34.441176
| 99
| 0.777114
|
zhangpf
|
f542181485fa161c8bbe41cfc72ddb924c462cce
| 1,041
|
inl
|
C++
|
headers/Impl/DocumentPreviewCache.inl
|
SunYe1234/PDFNetNew
|
110af493387b866e765e877c8cacae72bafc4cf8
|
[
"Apache-2.0"
] | null | null | null |
headers/Impl/DocumentPreviewCache.inl
|
SunYe1234/PDFNetNew
|
110af493387b866e765e877c8cacae72bafc4cf8
|
[
"Apache-2.0"
] | null | null | null |
headers/Impl/DocumentPreviewCache.inl
|
SunYe1234/PDFNetNew
|
110af493387b866e765e877c8cacae72bafc4cf8
|
[
"Apache-2.0"
] | null | null | null |
inline void DocumentPreviewCache::Initialize(UInt64 max_cache_bytes, double max_disk_percentage)
{
REX(TRN_DocumentPreviewCacheInitialize(max_cache_bytes, max_disk_percentage));
}
inline void DocumentPreviewCache::GetBitmapWithPath(const UString& filepath, UInt32 min_x_size, UInt32 min_y_size, PreviewHandler proc, void* custom_data)
{
REX(TRN_DocumentPreviewCacheGetBitmapWithPath((TRN_UString)filepath.mp_impl, min_x_size, min_y_size, (TRN_PreviewHandler)proc, custom_data));
}
inline void DocumentPreviewCache::CancelAllRequests()
{
REX(TRN_DocumentPreviewCacheCancelAllRequests());
}
inline void DocumentPreviewCache::CancelRequest(const UString& filepath)
{
REX(TRN_DocumentPreviewCacheCancelRequest((TRN_UString)filepath.mp_impl));
}
inline void DocumentPreviewCache::IrrelevantChangeMade(const UString& filepath)
{
REX(TRN_DocumentPreviewCacheIrrelevantChangeMade((TRN_UString)filepath.mp_impl));
}
inline void DocumentPreviewCache::ClearCache()
{
REX(TRN_DocumentPreviewCacheClearCache());
}
| 34.7
| 155
| 0.818444
|
SunYe1234
|
f5436a0c2df0ef47e94a69fb78abb78615639f6c
| 1,000
|
cc
|
C++
|
src/third_party/dart/runtime/bin/extensions_macos.cc
|
rhencke/engine
|
1016db292c4e73374a0a11536b18303c9522a224
|
[
"BSD-3-Clause"
] | 21
|
2021-06-04T21:08:21.000Z
|
2022-03-04T14:21:34.000Z
|
src/third_party/dart/runtime/bin/extensions_macos.cc
|
rhencke/engine
|
1016db292c4e73374a0a11536b18303c9522a224
|
[
"BSD-3-Clause"
] | 4
|
2020-04-20T11:16:42.000Z
|
2020-04-20T11:18:30.000Z
|
src/third_party/dart/runtime/bin/extensions_macos.cc
|
rhencke/engine
|
1016db292c4e73374a0a11536b18303c9522a224
|
[
"BSD-3-Clause"
] | 9
|
2021-03-16T09:29:26.000Z
|
2022-01-06T08:38:10.000Z
|
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "platform/globals.h"
#if defined(HOST_OS_MACOS)
#include <dlfcn.h> // NOLINT
#include "bin/extensions.h"
#include "platform/assert.h"
namespace dart {
namespace bin {
void* Extensions::LoadExtensionLibrary(const char* library_file) {
return dlopen(library_file, RTLD_LAZY);
}
void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) {
dlerror();
return dlsym(lib_handle, symbol);
}
void Extensions::UnloadLibrary(void* lib_handle) {
dlerror();
int result = dlclose(lib_handle);
ASSERT(result == 0);
}
Dart_Handle Extensions::GetError() {
const char* err_str = dlerror();
if (err_str != NULL) {
return Dart_NewApiError(err_str);
}
return Dart_Null();
}
} // namespace bin
} // namespace dart
#endif // defined(HOST_OS_MACOS)
| 23.255814
| 77
| 0.718
|
rhencke
|
f54424576ac1d1e5e513f63901a9042a9e57ff19
| 1,888
|
cpp
|
C++
|
SourceFiles/Item.cpp
|
JamesBremner/Pack
|
bf968bafbff01f908e5c27919c475d404d2dceeb
|
[
"MIT"
] | 19
|
2015-11-08T01:01:11.000Z
|
2021-06-28T23:10:14.000Z
|
SourceFiles/Item.cpp
|
JamesBremner/Pack
|
bf968bafbff01f908e5c27919c475d404d2dceeb
|
[
"MIT"
] | 7
|
2016-03-28T05:03:31.000Z
|
2020-07-09T13:55:57.000Z
|
SourceFiles/Item.cpp
|
JamesBremner/Pack
|
bf968bafbff01f908e5c27919c475d404d2dceeb
|
[
"MIT"
] | 9
|
2015-04-30T04:19:19.000Z
|
2017-10-22T12:09:12.000Z
|
#include "cPackEngine.h"
int Item::nextPackSeq = 0;
Item::Item()
: myBinProgID( -1 )
, mySpinAxis( 0 )
, mySupport( 0 )
{
}
Item::Item(const Item& orig)
{
}
Item::~Item()
{
}
int Item::RotationConstraints()
{
return myRotationConstraints;
}
int Item::PositionConstraints()
{
return myPositionConstraints;
}
void Item::set_constraints( int value )
{
myRotationConstraints = value % 100;
myPositionConstraints = value / 100;
}
bool Item::IsSpinAllowed( int axis )
{
// chack for any rotation constraint
if( ! myRotationConstraints )
return true;
// check for no rotation constraint
if( myRotationConstraints == 7 )
return false;
// check for single axis rotation constraint
switch( axis )
{
case 1:
if( myRotationConstraints == 2 ||
myRotationConstraints == 4 ||
myRotationConstraints == 6 )
return true;
break;
case 2:
if( myRotationConstraints == 3 ||
myRotationConstraints == 5 ||
myRotationConstraints == 6 )
return true;
break;
case 3:
if( myRotationConstraints == 1 ||
myRotationConstraints == 4 ||
myRotationConstraints == 5 )
return true;
break;
}
return false;
}
void Item::Print()
{
cout << "Item " << id() << " " << progid() << " in bin " << myBinProgID <<
" location " << myWLocation << "," << myHLocation << "," << myLLocation
<< " sides " << side_1()->size() <<" " << side_2()->size() <<" "<< side_3()->size()
<< " orig " << origSide1()->size() <<" "<< origSide2()->size() <<" "<< origSide3()->size()
<< " os " << side_1()->orig_side() <<" "<< side_2()->orig_side() <<" "<< side_3()->orig_side()
<< " spin " << mySpinAxis
<< endl;
}
| 23.308642
| 103
| 0.532839
|
JamesBremner
|
f547dfe7bb5662f9ecc7cd88eb44a2d073e92758
| 44,125
|
cpp
|
C++
|
arangod/Cluster/Maintenance.cpp
|
amwolff/arangodb
|
86458580d8070c80b130157693d70e9cda6a835f
|
[
"Apache-2.0"
] | null | null | null |
arangod/Cluster/Maintenance.cpp
|
amwolff/arangodb
|
86458580d8070c80b130157693d70e9cda6a835f
|
[
"Apache-2.0"
] | null | null | null |
arangod/Cluster/Maintenance.cpp
|
amwolff/arangodb
|
86458580d8070c80b130157693d70e9cda6a835f
|
[
"Apache-2.0"
] | null | null | null |
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2014-2018 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// 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.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Kaveh Vahedipour
/// @author Matthew Von-Maszewski
////////////////////////////////////////////////////////////////////////////////
#include "Cluster/Maintenance.h"
#include "Agency/AgencyStrings.h"
#include "ApplicationFeatures/ApplicationServer.h"
#include "Basics/StringUtils.h"
#include "Basics/VelocyPackHelper.h"
#include "Cluster/ClusterFeature.h"
#include "Cluster/ClusterInfo.h"
#include "Cluster/FollowerInfo.h"
#include "Indexes/Index.h"
#include "Logger/Logger.h"
#include "Utils/DatabaseGuard.h"
#include "VocBase/LogicalCollection.h"
#include "VocBase/Methods/Databases.h"
#include <velocypack/Collection.h>
#include <velocypack/Compare.h>
#include <velocypack/Iterator.h>
#include <velocypack/Slice.h>
#include <velocypack/velocypack-aliases.h>
#include <algorithm>
#include <regex>
using namespace arangodb;
using namespace arangodb::consensus;
using namespace arangodb::basics;
using namespace arangodb::maintenance;
using namespace arangodb::methods;
using namespace arangodb::basics::StringUtils;
static std::vector<std::string> const cmp{JOURNAL_SIZE, WAIT_FOR_SYNC, DO_COMPACT, INDEX_BUCKETS};
static VPackValue const VP_DELETE("delete");
static VPackValue const VP_SET("set");
static int indexOf(VPackSlice const& slice, std::string const& val) {
if (slice.isArray()) {
int counter = 0;
for (auto const& entry : VPackArrayIterator(slice)) {
if (entry.isString()) {
if (entry.copyString() == val) {
return counter;
}
}
counter++;
}
}
return -1;
}
static std::shared_ptr<VPackBuilder> createProps(VPackSlice const& s) {
TRI_ASSERT(s.isObject());
return std::make_shared<VPackBuilder>(
arangodb::velocypack::Collection::remove(s, std::unordered_set<std::string>({ID, NAME})));
}
static std::shared_ptr<VPackBuilder> compareRelevantProps(VPackSlice const& first,
VPackSlice const& second) {
auto result = std::make_shared<VPackBuilder>();
{
VPackObjectBuilder b(result.get());
for (auto const& property : cmp) {
auto const& planned = first.get(property);
if (planned != second.get(property)) { // Register any change
result->add(property, planned);
}
}
}
return result;
}
static VPackBuilder compareIndexes(std::string const& dbname, std::string const& collname,
std::string const& shname,
VPackSlice const& plan, VPackSlice const& local,
MaintenanceFeature::errors_t const& errors,
std::unordered_set<std::string>& indis) {
VPackBuilder builder;
{
VPackArrayBuilder a(&builder);
if (plan.isArray()) {
for (auto const& pindex : VPackArrayIterator(plan)) {
// Skip primary and edge indexes
auto const& ptype = pindex.get(StaticStrings::IndexType).copyString();
if (ptype == PRIMARY || ptype == EDGE) {
continue;
}
VPackSlice planId = pindex.get(ID);
TRI_ASSERT(planId.isString());
std::string planIdS = planId.copyString();
std::string planIdWithColl = shname + "/" + planIdS;
indis.emplace(planIdWithColl);
// See, if we already have an index with the id given in the Plan:
bool found = false;
if (local.isArray()) {
for (auto const& lindex : VPackArrayIterator(local)) {
// Skip primary and edge indexes
auto const& ltype = lindex.get(StaticStrings::IndexType).copyString();
if (ltype == PRIMARY || ltype == EDGE) {
continue;
}
VPackSlice localId = lindex.get(ID);
TRI_ASSERT(localId.isString());
// The local ID has the form <collectionName>/<ID>, to compare,
// we need to extract the local ID:
std::string localIdS = localId.copyString();
auto pos = localIdS.find('/');
if (pos != std::string::npos) {
localIdS = localIdS.substr(pos + 1);
}
if (localIdS == planIdS) {
// Already have this id, so abort search:
found = true;
// We should be done now, this index already exists, and since
// one cannot legally change the properties of an index, we
// should be fine. However, for robustness sake, we compare,
// if the local index found actually has the right properties,
// if not, we schedule a dropIndex action:
if (!arangodb::Index::Compare(pindex, lindex)) {
// To achieve this, we remove the long version of the ID
// from the indis set. This way, the local index will be
// dropped further down in handleLocalShard:
indis.erase(planIdWithColl);
}
break;
}
}
}
if (!found) {
// Finally check if we have an error for this index:
bool haveError = false;
std::string errorKey = dbname + "/" + collname + "/" + shname;
auto it1 = errors.indexes.find(errorKey);
if (it1 != errors.indexes.end()) {
auto it2 = it1->second.find(planIdS);
if (it2 != it1->second.end()) {
haveError = true;
}
}
if (!haveError) {
builder.add(pindex);
} else {
LOG_TOPIC("ceb3d", DEBUG, Logger::MAINTENANCE)
<< "Previous failure exists for index " << planIdS
<< " on shard " << dbname << "/" << shname << " for central "
<< dbname << "/" << collname << "- skipping";
}
}
}
}
}
return builder;
}
void handlePlanShard(VPackSlice const& cprops, VPackSlice const& ldb,
std::string const& dbname, std::string const& colname,
std::string const& shname, std::string const& serverId,
std::string const& leaderId, std::unordered_set<std::string>& commonShrds,
std::unordered_set<std::string>& indis,
MaintenanceFeature::errors_t& errors, MaintenanceFeature& feature,
std::vector<ActionDescription>& actions) {
bool shouldBeLeading = serverId == leaderId;
commonShrds.emplace(shname);
auto props = createProps(cprops); // Only once might need often!
if (ldb.hasKey(shname)) { // Have local collection with that name
auto const lcol = ldb.get(shname);
bool leading = lcol.get(THE_LEADER).copyString().empty();
auto const properties = compareRelevantProps(cprops, lcol);
auto fullShardLabel = dbname + "/" + colname + "/" + shname;
// Check if there is some in-sync-follower which is no longer in the Plan:
std::string followersToDropString;
if (leading && shouldBeLeading) {
VPackSlice shards = cprops.get("shards");
if (shards.isObject()) {
VPackSlice planServers = shards.get(shname);
if (planServers.isArray()) {
VPackSlice inSyncFollowers = lcol.get("servers");
if (inSyncFollowers.isArray()) {
// Now we have two server lists, we are looking for a server
// which does not occur in the plan, but is in the followers
// at an index > 0:
std::unordered_set<std::string> followersToDrop;
for (auto const& q : VPackArrayIterator(inSyncFollowers)) {
followersToDrop.insert(q.copyString());
}
for (auto const& p : VPackArrayIterator(planServers)) {
if (p.isString()) {
followersToDrop.erase(p.copyString());
}
}
// Everything remaining in followersToDrop is something we
// need to act on
for (auto const& r : followersToDrop) {
if (!followersToDropString.empty()) {
followersToDropString.push_back(',');
}
followersToDropString += r;
}
}
}
}
}
// If comparison has brought any updates
if (properties->slice() != VPackSlice::emptyObjectSlice() ||
leading != shouldBeLeading || !followersToDropString.empty()) {
if (errors.shards.find(fullShardLabel) == errors.shards.end()) {
actions.emplace_back(ActionDescription(
std::map<std::string, std::string>{
{NAME, UPDATE_COLLECTION},
{DATABASE, dbname},
{COLLECTION, colname},
{SHARD, shname},
{THE_LEADER, shouldBeLeading ? std::string() : leaderId},
{SERVER_ID, serverId},
{LOCAL_LEADER, lcol.get(THE_LEADER).copyString()},
{FOLLOWERS_TO_DROP, followersToDropString}},
properties));
} else {
LOG_TOPIC("0285b", DEBUG, Logger::MAINTENANCE)
<< "Previous failure exists for local shard " << dbname << "/" << shname
<< "for central " << dbname << "/" << colname << "- skipping";
}
}
// Indexes
if (cprops.hasKey(INDEXES)) {
auto const& pindexes = cprops.get(INDEXES);
auto const& lindexes = lcol.get(INDEXES);
auto difference =
compareIndexes(dbname, colname, shname, pindexes, lindexes, errors, indis);
// Index errors are checked in `compareIndexes`. THe loop below only
// cares about those indexes that have no error.
if (difference.slice().isArray()) {
for (auto const& index : VPackArrayIterator(difference.slice())) {
actions.emplace_back(
ActionDescription({{NAME, "EnsureIndex"},
{DATABASE, dbname},
{COLLECTION, colname},
{SHARD, shname},
{StaticStrings::IndexType,
index.get(StaticStrings::IndexType).copyString()},
{FIELDS, index.get(FIELDS).toJson()},
{ID, index.get(ID).copyString()}},
std::make_shared<VPackBuilder>(index)));
}
}
}
} else { // Create the sucker, if not a previous error stops us
if (errors.shards.find(dbname + "/" + colname + "/" + shname) ==
errors.shards.end()) {
actions.emplace_back(
ActionDescription({{NAME, CREATE_COLLECTION},
{COLLECTION, colname},
{SHARD, shname},
{DATABASE, dbname},
{SERVER_ID, serverId},
{THE_LEADER, shouldBeLeading ? std::string() : leaderId}},
props));
} else {
LOG_TOPIC("c1d8e", DEBUG, Logger::MAINTENANCE)
<< "Previous failure exists for creating local shard " << dbname << "/"
<< shname << "for central " << dbname << "/" << colname << "- skipping";
}
}
}
void handleLocalShard(std::string const& dbname, std::string const& colname,
VPackSlice const& cprops, VPackSlice const& shardMap,
std::unordered_set<std::string>& commonShrds,
std::unordered_set<std::string>& indis, std::string const& serverId,
std::vector<ActionDescription>& actions) {
std::unordered_set<std::string>::const_iterator it;
std::string plannedLeader;
if (shardMap.hasKey(colname) && shardMap.get(colname).isArray()) {
plannedLeader = shardMap.get(colname)[0].copyString();
}
bool localLeader = cprops.get(THE_LEADER).copyString().empty();
if (plannedLeader == UNDERSCORE + serverId && localLeader) {
actions.emplace_back(ActionDescription(
{{NAME, "ResignShardLeadership"}, {DATABASE, dbname}, {SHARD, colname}}));
} else {
bool drop = false;
// check if shard is in plan, if not drop it
if (commonShrds.empty()) {
drop = true;
} else {
it = std::find(commonShrds.begin(), commonShrds.end(), colname);
if (it == commonShrds.end()) {
drop = true;
}
}
if (drop) {
actions.emplace_back(ActionDescription(
{{NAME, DROP_COLLECTION}, {DATABASE, dbname}, {COLLECTION, colname}}));
} else {
// The shard exists in both Plan and Local
commonShrds.erase(it); // it not a common shard?
// We only drop indexes, when collection is not being dropped already
if (cprops.hasKey(INDEXES)) {
if (cprops.get(INDEXES).isArray()) {
for (auto const& index : VPackArrayIterator(cprops.get(INDEXES))) {
auto const& type = index.get(StaticStrings::IndexType).copyString();
if (type != PRIMARY && type != EDGE) {
std::string const id = index.get(ID).copyString();
// check if index is in plan
if (indis.find(colname + "/" + id) != indis.end() ||
indis.find(id) != indis.end()) {
indis.erase(id);
} else {
actions.emplace_back(ActionDescription(
{{NAME, "DropIndex"}, {DATABASE, dbname}, {COLLECTION, colname}, {"index", id}}));
}
}
}
}
}
}
}
}
/// @brief Get a map shardName -> servers
VPackBuilder getShardMap(VPackSlice const& plan) {
VPackBuilder shardMap;
{
VPackObjectBuilder o(&shardMap);
for (auto database : VPackObjectIterator(plan)) {
for (auto collection : VPackObjectIterator(database.value)) {
for (auto shard : VPackObjectIterator(collection.value.get(SHARDS))) {
std::string const shName = shard.key.copyString();
shardMap.add(shName, shard.value);
}
}
}
}
return shardMap;
}
struct NotEmpty {
bool operator()(const std::string& s) { return !s.empty(); }
};
/// @brief calculate difference between plan and local for for databases
arangodb::Result arangodb::maintenance::diffPlanLocal(
VPackSlice const& plan, VPackSlice const& local,
std::string const& serverId, MaintenanceFeature::errors_t& errors,
MaintenanceFeature& feature, std::vector<ActionDescription>& actions) {
arangodb::Result result;
std::unordered_set<std::string> commonShrds; // Intersection collections plan&local
std::unordered_set<std::string> indis; // Intersection indexes plan&local
// Plan to local mismatch ----------------------------------------------------
// Create or modify if local databases are affected
auto pdbs = plan.get(DATABASES);
for (auto const& pdb : VPackObjectIterator(pdbs)) {
auto const& dbname = pdb.key.copyString();
if (!local.hasKey(dbname)) {
if (errors.databases.find(dbname) == errors.databases.end()) {
actions.emplace_back(
ActionDescription({{std::string(NAME), std::string(CREATE_DATABASE)},
{std::string(DATABASE), std::string(dbname)}}));
} else {
LOG_TOPIC("3a6a8", DEBUG, Logger::MAINTENANCE)
<< "Previous failure exists for creating database " << dbname << "skipping";
}
}
}
// Drop databases, which are no longer in plan
for (auto const& ldb : VPackObjectIterator(local)) {
auto const& dbname = ldb.key.copyString();
if (!plan.hasKey(std::vector<std::string>{DATABASES, dbname})) {
actions.emplace_back(
ActionDescription({{std::string(NAME), std::string(DROP_DATABASE)},
{std::string(DATABASE), std::string(dbname)}}));
}
}
// Check errors for databases, which are no longer in plan and remove from
// errors
for (auto& database : errors.databases) {
if (!plan.hasKey(std::vector<std::string>{DATABASES, database.first})) {
database.second.reset();
}
}
// Create or modify if local collections are affected
pdbs = plan.get(COLLECTIONS);
for (auto const& pdb : VPackObjectIterator(pdbs)) { // for each db in Plan
auto const& dbname = pdb.key.copyString();
if (local.hasKey(dbname)) { // have database in both
auto const& ldb = local.get(dbname);
for (auto const& pcol : VPackObjectIterator(pdb.value)) { // for each plan collection
auto const& cprops = pcol.value;
for (auto const& shard : VPackObjectIterator(cprops.get(SHARDS))) { // for each shard in plan collection
if (shard.value.isArray()) {
for (auto const& dbs : VPackArrayIterator(shard.value)) { // for each db server with that shard
// We only care for shards, where we find us as "serverId" or
// "_serverId"
if (dbs.isEqualString(serverId) || dbs.isEqualString(UNDERSCORE + serverId)) {
// at this point a shard is in plan, we have the db for it
handlePlanShard(cprops, ldb, dbname, pcol.key.copyString(),
shard.key.copyString(), serverId,
shard.value[0].copyString(), commonShrds, indis,
errors, feature, actions);
break;
}
}
} // else if(!shard.value.isArray()) - intentionally do nothing
}
}
}
}
// At this point commonShrds contains all shards that eventually reside on
// this server, are in Plan and their database is present
// Compare local to plan -----------------------------------------------------
auto const shardMap = getShardMap(pdbs); // plan shards -> servers
for (auto const& db : VPackObjectIterator(local)) { // for each local databases
auto const& dbname = db.key.copyString();
if (pdbs.hasKey(dbname)) { // if in plan
for (auto const& sh : VPackObjectIterator(db.value)) { // for each local shard
std::string shName = sh.key.copyString();
handleLocalShard(dbname, shName, sh.value, shardMap.slice(),
commonShrds, indis, serverId, actions);
}
}
}
// See if shard errors can be thrown out:
for (auto& shard : errors.shards) {
std::vector<std::string> path = split(shard.first, '/');
path.pop_back(); // Get rid of shard
if (!pdbs.hasKey(path)) { // we can drop the local error
shard.second.reset();
}
}
// See if index errors can be thrown out:
for (auto& shard : errors.indexes) {
std::vector<std::string> path = split(shard.first, '/'); // dbname, collection, shardid
path.pop_back(); // dbname, collection
path.emplace_back(INDEXES); // dbname, collection, indexes
VPackSlice indexes = pdbs.get(path);
if (!indexes.isArray()) { // collection gone, can drop errors
for (auto& index : shard.second) {
index.second.reset();
}
} else { // need to look at individual errors and indexes:
for (auto& p : shard.second) {
std::string const& id = p.first;
bool found = false;
for (auto const& ind : VPackArrayIterator(indexes)) {
if (ind.get(ID).copyString() == id) {
found = true;
break;
}
}
if (!found) {
p.second.reset();
}
}
}
}
return result;
}
/// @brief handle plan for local databases
arangodb::Result arangodb::maintenance::executePlan(VPackSlice const& plan,
VPackSlice const& local,
std::string const& serverId,
MaintenanceFeature& feature,
VPackBuilder& report) {
arangodb::Result result;
// Errors from maintenance feature
MaintenanceFeature::errors_t errors;
result = feature.copyAllErrors(errors);
if (!result.ok()) {
LOG_TOPIC("9039d", ERR, Logger::MAINTENANCE)
<< "phaseOne: failed to acquire copy of errors from maintenance "
"feature.";
return result;
}
// build difference between plan and local
std::vector<ActionDescription> actions;
report.add(VPackValue(AGENCY));
{
VPackArrayBuilder a(&report);
diffPlanLocal(plan, local, serverId, errors, feature, actions);
}
for (auto const& i : errors.databases) {
if (i.second == nullptr) {
feature.removeDBError(i.first);
}
}
for (auto const& i : errors.shards) {
if (i.second == nullptr) {
feature.removeShardError(i.first);
}
}
for (auto const& i : errors.indexes) {
std::unordered_set<std::string> tmp;
for (auto const& index : i.second) {
if (index.second == nullptr) {
tmp.emplace(index.first);
}
}
if (!tmp.empty()) {
feature.removeIndexErrors(i.first, tmp);
}
}
TRI_ASSERT(report.isOpenObject());
report.add(VPackValue(ACTIONS));
{
VPackArrayBuilder a(&report);
// enact all
for (auto const& action : actions) {
LOG_TOPIC("8513c", DEBUG, Logger::MAINTENANCE) << "adding action " << action << " to feature ";
{
VPackObjectBuilder b(&report);
action.toVelocyPack(report);
}
feature.addAction(std::make_shared<ActionDescription>(action), false);
}
}
return result;
}
/// @brief add new database to current
void addDatabaseToTransactions(std::string const& name, Transactions& transactions) {
// [ {"dbPath":{}}, {"dbPath":{"oldEmpty":true}} ]
std::string dbPath = CURRENT_COLLECTIONS + name;
VPackBuilder operation; // create database in current
{
VPackObjectBuilder b(&operation);
operation.add(dbPath, VPackSlice::emptyObjectSlice());
}
VPackBuilder precondition;
{
VPackObjectBuilder b(&precondition);
precondition.add(VPackValue(dbPath));
{
VPackObjectBuilder bb(&precondition);
precondition.add("oldEmpty", VPackValue(true));
}
}
transactions.push_back({operation, precondition});
}
/// @brief report local to current
arangodb::Result arangodb::maintenance::diffLocalCurrent(VPackSlice const& local,
VPackSlice const& current,
std::string const& serverId,
Transactions& transactions) {
arangodb::Result result;
auto const& cdbs = current;
// Iterate over local databases
for (auto const& ldbo : VPackObjectIterator(local)) {
std::string dbname = ldbo.key.copyString();
// VPackSlice ldb = ldbo.value;
// Current has this database
if (cdbs.hasKey(dbname)) {
} else {
// Create new database in current
addDatabaseToTransactions(dbname, transactions);
}
}
return result;
}
/// @brief Phase one: Compare plan and local and create descriptions
arangodb::Result arangodb::maintenance::phaseOne(VPackSlice const& plan,
VPackSlice const& local,
std::string const& serverId,
MaintenanceFeature& feature,
VPackBuilder& report) {
arangodb::Result result;
report.add(VPackValue(PHASE_ONE));
{
VPackObjectBuilder por(&report);
// Execute database changes
try {
result = executePlan(plan, local, serverId, feature, report);
} catch (std::exception const& e) {
LOG_TOPIC("55938", ERR, Logger::MAINTENANCE) << "Error executing plan: " << e.what()
<< ". " << __FILE__ << ":" << __LINE__;
}
}
report.add(VPackValue(PLAN));
{
VPackObjectBuilder p(&report);
report.add("Version", plan.get("Version"));
}
return result;
}
static VPackBuilder removeSelectivityEstimate(VPackSlice const& index) {
TRI_ASSERT(index.isObject());
return arangodb::velocypack::Collection::remove(index, std::unordered_set<std::string>(
{SELECTIVITY_ESTIMATE}));
}
static VPackBuilder assembleLocalCollectionInfo(
VPackSlice const& info, VPackSlice const& planServers,
std::string const& database, std::string const& shard,
std::string const& ourselves, MaintenanceFeature::errors_t const& allErrors) {
VPackBuilder ret;
try {
DatabaseGuard guard(database);
auto vocbase = &guard.database();
auto collection = vocbase->lookupCollection(shard);
if (collection == nullptr) {
std::string errorMsg(
"Maintenance::assembleLocalCollectionInfo: Failed to lookup "
"collection ");
errorMsg += shard;
LOG_TOPIC("33a3b", DEBUG, Logger::MAINTENANCE) << errorMsg;
{ VPackObjectBuilder o(&ret); }
return ret;
}
std::string errorKey =
database + "/" + std::to_string(collection->planId()) + "/" + shard;
{
VPackObjectBuilder r(&ret);
auto it = allErrors.shards.find(errorKey);
if (it == allErrors.shards.end()) {
ret.add(StaticStrings::Error, VPackValue(false));
ret.add(StaticStrings::ErrorMessage, VPackValue(std::string()));
ret.add(StaticStrings::ErrorNum, VPackValue(0));
} else {
VPackSlice errs(static_cast<uint8_t const*>(it->second->data()));
ret.add(StaticStrings::Error, errs.get(StaticStrings::Error));
ret.add(StaticStrings::ErrorNum, errs.get(StaticStrings::ErrorNum));
ret.add(StaticStrings::ErrorMessage, errs.get(StaticStrings::ErrorMessage));
}
ret.add(VPackValue(INDEXES));
{
VPackArrayBuilder ixs(&ret);
if (info.get(INDEXES).isArray()) {
auto it1 = allErrors.indexes.find(errorKey);
std::unordered_set<std::string> indexesDone;
// First the indexes as they are in Local, potentially replaced
// by an error:
for (auto const& index : VPackArrayIterator(info.get(INDEXES))) {
std::string id = index.get(ID).copyString();
indexesDone.insert(id);
if (it1 != allErrors.indexes.end()) {
auto it2 = it1->second.find(id);
if (it2 != it1->second.end()) {
// Add the error instead:
ret.add(VPackSlice(static_cast<uint8_t const*>(it2->second->data())));
continue;
}
}
ret.add(removeSelectivityEstimate(index).slice());
}
// Now all the errors for this shard, for which there is no index:
if (it1 != allErrors.indexes.end()) {
for (auto const& p : it1->second) {
if (indexesDone.find(p.first) == indexesDone.end()) {
ret.add(VPackSlice(static_cast<uint8_t const*>(p.second->data())));
}
}
}
}
}
ret.add(VPackValue(SERVERS));
{
VPackArrayBuilder a(&ret);
ret.add(VPackValue(ourselves));
// planServers may be `none` in the case that the shard is not contained
// in Plan, but in local.
if (planServers.isArray()) {
std::shared_ptr<std::vector<std::string> const> current =
collection->followers()->get();
for (auto const& server : *current) {
ret.add(VPackValue(server));
}
}
}
}
return ret;
} catch (std::exception const& e) {
std::string errorMsg(
"Maintenance::assembleLocalCollectionInfo: Failed to lookup database ");
errorMsg += database;
errorMsg += ", exception: ";
errorMsg += e.what();
LOG_TOPIC("7fe5d", WARN, Logger::MAINTENANCE) << errorMsg;
{ VPackObjectBuilder o(&ret); }
return ret;
}
}
bool equivalent(VPackSlice const& local, VPackSlice const& current) {
for (auto const& i : VPackObjectIterator(local)) {
if (!VPackNormalizedCompare::equals(i.value, current.get(i.key.copyString()))) {
return false;
}
}
return true;
}
static VPackBuilder assembleLocalDatabaseInfo(std::string const& database,
MaintenanceFeature::errors_t const& allErrors) {
// This creates the VelocyPack that is put into
// /Current/Databases/<dbname>/<serverID> for a database.
VPackBuilder ret;
try {
DatabaseGuard guard(database);
auto vocbase = &guard.database();
{
VPackObjectBuilder o(&ret);
auto it = allErrors.databases.find(database);
if (it == allErrors.databases.end()) {
ret.add(StaticStrings::Error, VPackValue(false));
ret.add(StaticStrings::ErrorNum, VPackValue(0));
ret.add(StaticStrings::ErrorMessage, VPackValue(""));
} else {
VPackSlice errs(static_cast<uint8_t const*>(it->second->data()));
ret.add(StaticStrings::Error, errs.get(StaticStrings::Error));
ret.add(StaticStrings::ErrorNum, errs.get(StaticStrings::ErrorNum));
ret.add(StaticStrings::ErrorMessage, errs.get(StaticStrings::ErrorMessage));
}
ret.add(ID, VPackValue(std::to_string(vocbase->id())));
ret.add("name", VPackValue(vocbase->name()));
}
return ret;
} catch (std::exception const& e) {
std::string errorMsg(
"Maintenance::assembleLocalDatabaseInfo: Failed to lookup database ");
errorMsg += database;
errorMsg += ", exception: ";
errorMsg += e.what();
LOG_TOPIC("989b6", DEBUG, Logger::MAINTENANCE) << errorMsg;
{ VPackObjectBuilder o(&ret); }
return ret;
}
}
// updateCurrentForCollections
// diff current and local and prepare agency transactions or whatever
// to update current. Will report the errors created locally to the agency
arangodb::Result arangodb::maintenance::reportInCurrent(
VPackSlice const& plan, VPackSlice const& cur, VPackSlice const& local,
MaintenanceFeature::errors_t const& allErrors, std::string const& serverId,
VPackBuilder& report) {
arangodb::Result result;
auto shardMap = getShardMap(plan.get(COLLECTIONS));
auto pdbs = plan.get(COLLECTIONS);
for (auto const& database : VPackObjectIterator(local)) {
auto const dbName = database.key.copyString();
std::vector<std::string> const cdbpath{DATABASES, dbName, serverId};
if (!cur.hasKey(cdbpath)) {
auto const localDatabaseInfo = assembleLocalDatabaseInfo(dbName, allErrors);
if (!localDatabaseInfo.slice().isEmptyObject()) {
report.add(VPackValue(CURRENT_DATABASES + dbName + "/" + serverId));
{
VPackObjectBuilder o(&report);
report.add(OP, VP_SET);
report.add("payload", localDatabaseInfo.slice());
}
}
}
for (auto const& shard : VPackObjectIterator(database.value)) {
auto const shName = shard.key.copyString();
auto const shSlice = shard.value;
auto const colName = shSlice.get(StaticStrings::DataSourcePlanId).copyString();
VPackBuilder error;
if (shSlice.get(THE_LEADER).copyString().empty()) { // Leader
auto const localCollectionInfo =
assembleLocalCollectionInfo(shSlice, shardMap.slice().get(shName),
dbName, shName, serverId, allErrors);
// Collection no longer exists
if (localCollectionInfo.slice().isEmptyObject()) {
continue;
}
auto cp = std::vector<std::string>{COLLECTIONS, dbName, colName, shName};
auto inCurrent = cur.hasKey(cp);
if (!inCurrent || !equivalent(localCollectionInfo.slice(), cur.get(cp))) {
report.add(VPackValue(CURRENT_COLLECTIONS + dbName + "/" + colName + "/" + shName));
{
VPackObjectBuilder o(&report);
report.add(OP, VP_SET);
report.add("payload", localCollectionInfo.slice());
}
}
} else { // Follower
auto servers =
std::vector<std::string>{COLLECTIONS, dbName, colName, shName, SERVERS};
if (cur.hasKey(servers)) {
auto s = cur.get(servers);
if (s.isArray() && cur.get(servers)[0].copyString() == serverId) {
// We are in the situation after a restart, that we do not know
// who the leader is because FollowerInfo is not updated yet.
// Hence, in the case we are the Leader in Plan but do not
// know it yet, do nothing here.
if (shSlice.get("theLeaderTouched").isTrue()) {
// we were previously leader and we are done resigning.
// update current and let supervision handle the rest
VPackBuilder ns;
{
VPackArrayBuilder a(&ns);
if (s.isArray()) {
bool front = true;
for (auto const& i : VPackArrayIterator(s)) {
ns.add(VPackValue((!front) ? i.copyString()
: UNDERSCORE + i.copyString()));
front = false;
}
}
}
report.add(VPackValue(CURRENT_COLLECTIONS + dbName + "/" +
colName + "/" + shName + "/" + SERVERS));
{
VPackObjectBuilder o(&report);
report.add(OP, VP_SET);
report.add("payload", ns.slice());
}
}
}
}
}
}
}
// UpdateCurrentForDatabases
auto cdbs = cur.get(DATABASES);
for (auto const& database : VPackObjectIterator(cdbs)) {
auto const dbName = database.key.copyString();
if (!database.value.isObject()) {
continue;
}
VPackSlice myEntry = database.value.get(serverId);
if (!myEntry.isNone()) {
// Database no longer in Plan and local
if (!local.hasKey(dbName) && !pdbs.hasKey(dbName)) {
// This covers the case that the database is neither in Local nor in
// Plan. It remains to make sure an error is reported to Current if
// there is a database in the Plan but not in Local
report.add(VPackValue(CURRENT_DATABASES + dbName + "/" + serverId));
{
VPackObjectBuilder o(&report);
report.add(OP, VP_DELETE);
}
// We delete all under /Current/Collections/<dbName>, it does not
// hurt if every DBserver does this, since it is an idempotent
// operation.
report.add(VPackValue(CURRENT_COLLECTIONS + dbName));
{
VPackObjectBuilder o(&report);
report.add(OP, VP_DELETE);
}
}
}
}
// UpdateCurrentForCollections
auto curcolls = cur.get(COLLECTIONS);
for (auto const& database : VPackObjectIterator(curcolls)) {
auto const dbName = database.key.copyString();
// UpdateCurrentForCollections (Current/Collections/Collection)
for (auto const& collection : VPackObjectIterator(database.value)) {
auto const colName = collection.key.copyString();
for (auto const& shard : VPackObjectIterator(collection.value)) {
auto const shName = shard.key.copyString();
// Shard in current and has servers
if (shard.value.hasKey(SERVERS)) {
auto servers = shard.value.get(SERVERS);
if (servers.isArray() && servers.length() > 0 // servers in current
&& servers[0].copyString() == serverId // we are leading
&& !local.hasKey(std::vector<std::string>{dbName, shName}) // no local collection
&& !shardMap.slice().hasKey(shName)) { // no such shard in plan
report.add(VPackValue(CURRENT_COLLECTIONS + dbName + "/" + colName + "/" + shName));
{
VPackObjectBuilder o(&report);
report.add(OP, VP_DELETE);
}
}
}
}
}
}
// Let's find database errors for databases which do not occur in Local
// but in Plan:
VPackSlice planDatabases = plan.get(DATABASES);
VPackSlice curDatabases = cur.get(DATABASES);
if (planDatabases.isObject() && curDatabases.isObject()) {
for (auto const& p : allErrors.databases) {
VPackSlice planDbEntry = planDatabases.get(p.first);
VPackSlice curDbEntry = curDatabases.get(p.first);
if (planDbEntry.isObject() && curDbEntry.isNone()) {
// Need to create an error entry:
report.add(VPackValue(CURRENT_DATABASES + p.first + "/" + serverId));
{
VPackObjectBuilder o(&report);
report.add(OP, VP_SET);
report.add(VPackSlice("payload"));
{
VPackObjectBuilder pp(&report);
VPackSlice errs(static_cast<uint8_t const*>(p.second->data()));
report.add(StaticStrings::Error, errs.get(StaticStrings::Error));
report.add(StaticStrings::ErrorNum, errs.get(StaticStrings::ErrorNum));
report.add(StaticStrings::ErrorMessage, errs.get(StaticStrings::ErrorMessage));
}
}
}
}
}
// Finally, let's find shard errors for shards which do not occur in
// Local but in Plan, we need to make sure that these errors are reported
// in Current:
for (auto const& p : allErrors.shards) {
// First split the key:
std::string const& key = p.first;
auto pos = key.find('/');
TRI_ASSERT(pos != std::string::npos);
std::string d = key.substr(0, pos); // database
auto pos2 = key.find('/', pos + 1); // collection
TRI_ASSERT(pos2 != std::string::npos);
std::string c = key.substr(pos + 1, pos2);
std::string s = key.substr(pos2 + 1); // shard name
// Now find out if the shard appears in the Plan but not in Local:
VPackSlice inPlan = pdbs.get(std::vector<std::string>({d, c, "shards", s}));
VPackSlice inLoc = local.get(std::vector<std::string>({d, s}));
if (inPlan.isObject() && inLoc.isNone()) {
VPackSlice inCur = curcolls.get(std::vector<std::string>({d, c, s}));
VPackSlice theErr(static_cast<uint8_t const*>(p.second->data()));
if (inCur.isNone() || !equivalent(theErr, inCur)) {
report.add(VPackValue(CURRENT_COLLECTIONS + d + "/" + c + "/" + s));
{
VPackObjectBuilder o(&report);
report.add(OP, VP_SET);
report.add("payload", theErr);
}
}
}
}
return result;
}
arangodb::Result arangodb::maintenance::syncReplicatedShardsWithLeaders(
VPackSlice const& plan, VPackSlice const& current, VPackSlice const& local,
std::string const& serverId, MaintenanceFeature& feature,
std::vector<ActionDescription>& actions) {
auto pdbs = plan.get(COLLECTIONS);
auto cdbs = current.get(COLLECTIONS);
for (auto const& pdb : VPackObjectIterator(pdbs)) {
auto const& dbname = pdb.key.copyString();
if (local.hasKey(dbname) && cdbs.hasKey(dbname)) {
for (auto const& pcol : VPackObjectIterator(pdb.value)) {
auto const& colname = pcol.key.copyString();
if (cdbs.get(dbname).hasKey(colname)) {
for (auto const& pshrd : VPackObjectIterator(pcol.value.get(SHARDS))) {
auto const& shname = pshrd.key.copyString();
// shard does not exist locally so nothing we can do at this point
if (!local.hasKey(std::vector<std::string>{dbname, shname})) {
continue;
}
// current stuff is created by the leader this one here will just
// bring followers in sync so just continue here
auto cpath = std::vector<std::string>{dbname, colname, shname};
if (!cdbs.hasKey(cpath)) {
LOG_TOPIC("402a4", DEBUG, Logger::MAINTENANCE)
<< "Shard " << shname
<< " not in current yet. Rescheduling maintenance.";
continue;
}
// Plan's servers
auto ppath = std::vector<std::string>{dbname, colname, SHARDS, shname};
if (!pdbs.hasKey(ppath)) {
LOG_TOPIC("e1136", ERR, Logger::MAINTENANCE)
<< "Shard " << shname << " does not have servers substructure in 'Plan'";
continue;
}
auto const& pservers = pdbs.get(ppath);
// Current's servers
cpath.push_back(SERVERS);
if (!cdbs.hasKey(cpath)) {
LOG_TOPIC("1d596", ERR, Logger::MAINTENANCE)
<< "Shard " << shname
<< " does not have servers substructure in 'Current'";
continue;
}
auto const& cservers = cdbs.get(cpath);
// we are not planned to be a follower
if (indexOf(pservers, serverId) <= 0) {
continue;
}
// if we are considered to be in sync there is nothing to do
if (indexOf(cservers, serverId) > 0) {
continue;
}
auto const leader = pservers[0].copyString();
actions.emplace_back(ActionDescription(
{{NAME, "SynchronizeShard"},
{DATABASE, dbname},
{COLLECTION, colname},
{SHARD, shname},
{THE_LEADER, leader},
{SHARD_VERSION, std::to_string(feature.shardVersion(shname))}}));
}
}
}
}
}
return Result();
}
/// @brief Phase two: See, what we can report to the agency
arangodb::Result arangodb::maintenance::phaseTwo(VPackSlice const& plan,
VPackSlice const& cur,
VPackSlice const& local,
std::string const& serverId,
MaintenanceFeature& feature,
VPackBuilder& report) {
MaintenanceFeature::errors_t allErrors;
feature.copyAllErrors(allErrors);
arangodb::Result result;
report.add(VPackValue(PHASE_TWO));
{
VPackObjectBuilder p2(&report);
// agency transactions
report.add(VPackValue("agency"));
{
VPackObjectBuilder agency(&report);
// Update Current
try {
result = reportInCurrent(plan, cur, local, allErrors, serverId, report);
} catch (std::exception const& e) {
LOG_TOPIC("c9a75", ERR, Logger::MAINTENANCE)
<< "Error reporting in current: " << e.what() << ". " << __FILE__
<< ":" << __LINE__;
}
}
// maintenace actions
report.add(VPackValue("actions"));
{
VPackObjectBuilder agency(&report);
try {
std::vector<ActionDescription> actions;
result = syncReplicatedShardsWithLeaders(plan, cur, local, serverId, feature, actions);
for (auto const& action : actions) {
feature.addAction(std::make_shared<ActionDescription>(action), false);
}
} catch (std::exception const& e) {
LOG_TOPIC("7e286", ERR, Logger::MAINTENANCE) << "Error scheduling shards: " << e.what()
<< ". " << __FILE__ << ":" << __LINE__;
}
}
}
report.add(VPackValue("Current"));
{
VPackObjectBuilder p(&report);
report.add("Version", cur.get("Version"));
}
return result;
}
| 38.336229
| 113
| 0.579807
|
amwolff
|
f54a21d6cf733c2229387a7584a654b6fb496d5d
| 201
|
cpp
|
C++
|
predavanje3/#include/bad_include/program.cpp
|
Miillky/objektno_orijentirano_programiranje
|
b41fe690c25a73acd09aff5606524b9e43f0b38a
|
[
"MIT"
] | null | null | null |
predavanje3/#include/bad_include/program.cpp
|
Miillky/objektno_orijentirano_programiranje
|
b41fe690c25a73acd09aff5606524b9e43f0b38a
|
[
"MIT"
] | null | null | null |
predavanje3/#include/bad_include/program.cpp
|
Miillky/objektno_orijentirano_programiranje
|
b41fe690c25a73acd09aff5606524b9e43f0b38a
|
[
"MIT"
] | null | null | null |
// Ne smije se definirati fukcije cin kao ovjde ako koristimo includove, proučit detaljnije...
#include "funkcije.hpp"
void cin(){
cout << "ja sam cin";
}
int main(){
cin();
funkcija();
}
| 18.272727
| 94
| 0.646766
|
Miillky
|
f54c86c8bea61e129adc93a5988ce8588af4b1b8
| 2,659
|
cpp
|
C++
|
nvidia-dla-blocks/hw/cmod/nvdla_clibs/NvdlaDataFormatConvertor.cpp
|
minisparrow/freedom
|
b31723a2cf3d1f245f9de2dcfedde4df2180cc6f
|
[
"Apache-2.0"
] | null | null | null |
nvidia-dla-blocks/hw/cmod/nvdla_clibs/NvdlaDataFormatConvertor.cpp
|
minisparrow/freedom
|
b31723a2cf3d1f245f9de2dcfedde4df2180cc6f
|
[
"Apache-2.0"
] | null | null | null |
nvidia-dla-blocks/hw/cmod/nvdla_clibs/NvdlaDataFormatConvertor.cpp
|
minisparrow/freedom
|
b31723a2cf3d1f245f9de2dcfedde4df2180cc6f
|
[
"Apache-2.0"
] | 1
|
2020-07-16T11:20:40.000Z
|
2020-07-16T11:20:40.000Z
|
// ================================================================
// NVDLA Open Source Project
//
// Copyright(c) 2016 - 2017 NVIDIA Corporation. Licensed under the
// NVDLA Open Hardware License; Check "LICENSE" which comes with
// this distribution for more information.
// ================================================================
// File Name: NvdlaDataFormatConvertor.cpp
#include <inttypes.h>
#include <typeinfo>
#include "NvdlaDataFormatConvertor.h"
#include "log.h"
#define DATA_TYPE_IS_INT 0
#define DATA_TYPE_IS_FP 1
using namespace std;
NvdlaDataFormatConvertor::NvdlaDataFormatConvertor(uint8_t data_type, uint32_t offset, uint32_t scaling_factor, uint8_t truncation_lsb, uint8_t truncation_bit_width) {
cslDebug((70, "NvdlaDataFormatConvertor::NvdlaDataFormatConvertor: Enter constructor.\n"));
set_data_type(data_type);
set_offset(offset);
set_scaling_factor(scaling_factor);
set_truncation_lsb(truncation_lsb);
set_truncation_bit_width(truncation_bit_width);
}
void NvdlaDataFormatConvertor::set_data_type (uint8_t data_type){
data_type_ = data_type;
cslDebug((70, "NvdlaDataFormatConvertor::set_data_type: data type is %d\n", uint16_t(data_type_)));
}
void NvdlaDataFormatConvertor::set_offset (uint32_t &offset){
offset_float_ = *reinterpret_cast <float*> (&offset);
offset_int_ = int64_t(*reinterpret_cast <int32_t*> (&offset));
cslDebug((70, "NvdlaDataFormatConvertor::set_offset: offset float is %f\n", offset_float_));
cslDebug((70, "NvdlaDataFormatConvertor::set_offset: offset integer is %ld\n", offset_int_));
}
void NvdlaDataFormatConvertor::set_scaling_factor (uint32_t &scaling_factor){
scaling_factor_float_ = *reinterpret_cast <float*> (&scaling_factor);
scaling_factor_int_ = int64_t(*reinterpret_cast <int32_t*> (&scaling_factor));
cslDebug((70, "NvdlaDataFormatConvertor::set_scaling_factor: scalling float is %f\n", scaling_factor_float_));
cslDebug((70, "NvdlaDataFormatConvertor::set_scaling_factor: scalling integer is %ld\n", scaling_factor_int_));
}
void NvdlaDataFormatConvertor::set_truncation_lsb (uint8_t truncation_lsb){
truncation_lsb_ = truncation_lsb;
cslDebug((70, "NvdlaDataFormatConvertor::set_truncation_lsb: truncation lsb is %d\n", uint16_t(truncation_lsb_)));
}
void NvdlaDataFormatConvertor::set_truncation_bit_width (uint8_t truncation_bit_width){
truncation_bit_width_ = truncation_bit_width;
cslDebug((70, "NvdlaDataFormatConvertor::set_truncation_bit_width: truncation bit width is %d\n", uint16_t(truncation_bit_width_)));
}
| 45.844828
| 180
| 0.7217
|
minisparrow
|
f54d8cf911287f139e83cf5e3948bce812e904ca
| 4,876
|
cpp
|
C++
|
message.cpp
|
zhaoxy2850/TSDNSServer
|
ed84611238e744f8458a9cac7622fd6b1407297c
|
[
"MIT"
] | 2
|
2017-10-22T15:24:06.000Z
|
2018-10-01T09:36:01.000Z
|
message.cpp
|
zhaoxy2850/TSDNSServer
|
ed84611238e744f8458a9cac7622fd6b1407297c
|
[
"MIT"
] | 1
|
2019-12-25T06:13:32.000Z
|
2019-12-25T06:13:32.000Z
|
message.cpp
|
zhaoxy2850/TSDNSServer
|
ed84611238e744f8458a9cac7622fd6b1407297c
|
[
"MIT"
] | 3
|
2017-02-28T07:09:38.000Z
|
2020-08-15T09:10:40.000Z
|
//
// message.cpp
// TSDNSServer
//
// Created by zhaoxy on 14-5-11.
// Copyright (c) 2014年 tsinghua. All rights reserved.
//
#include "message.h"
using namespace dns;
using namespace std;
//encode an address seperated by '.' like 'www.google.com'
//to address seperated by substring length like '3www6google3com'
void encode_address(char *addr, char *&buff) {
string address(addr);
int pos, current = 0;
while ((pos = (int)address.find('.')) != string::npos) {
address.erase(0, pos+1);
*buff++ = pos;
memcpy(buff, addr+current, pos);
buff += pos;
current += pos+1;
}
*buff++ = address.size();
memcpy(buff, addr+current, address.size());
buff += address.size();
*buff++ = 0;
}
//encode the message to the buffer
void Message::encode_header(char *&buff) {
MHeader header = {0};
header.hId = m_id;
header.hFlags += ((m_qr?1:0)<<15);
header.hFlags += (m_opcode<<11);
header.hFlags += (m_aa<<10);
header.hFlags += (m_tc<<9);
header.hFlags += (m_rd<<8);
header.hFlags += (m_ra<<7);
header.hFlags += m_rcode;
header.queryCount = m_qdCount;
header.answCount = m_anCount;
header.authCount = m_nsCount;
header.addiCount = m_arCount;
header.hId = htons(header.hId);
header.hFlags = htons(header.hFlags);
header.queryCount = htons(header.queryCount);
header.answCount = htons(header.answCount);
header.authCount = htons(header.authCount);
header.addiCount = htons(header.addiCount);
memcpy(buff, &header, sizeof(MHeader));
//offset
buff += sizeof(MHeader);
}
//encode the questions of message to the buffer
void Message::encode_questions(char *&buff) {
//encode each question
for (int i=0; i<m_qdCount; i++) {
MQuestion question = m_questions[i];
encode_address(question.qName, buff);
uint16_t nQType = htons(question.qType);
memcpy(buff, &nQType, sizeof(uint16_t));
buff+=sizeof(uint16_t);
uint16_t nQClass = htons(question.qClass);
memcpy(buff, &nQClass, sizeof(uint16_t));
buff+=sizeof(uint16_t);
}
}
//encode the answers of the message to the buffer
void Message::encode_answers(char *&buff) {
//encode each answer
for (int i=0; i<m_anCount; i++) {
MResource resource = m_answers[i];
encode_address(resource.rName, buff);
uint16_t nRType = htons(resource.rType);
memcpy(buff, &nRType, sizeof(uint16_t));
buff+=sizeof(uint16_t);
uint16_t nRClass = htons(resource.rClass);
memcpy(buff, &nRClass, sizeof(uint16_t));
buff+=sizeof(uint16_t);
uint32_t nTTL = htonl(resource.rTTL);
memcpy(buff, &nTTL, sizeof(uint32_t));
buff+=sizeof(uint32_t);
uint16_t nRDLen = htons(resource.rdLength);
memcpy(buff, &nRDLen, sizeof(uint16_t));
buff+=sizeof(uint16_t);
if (MT_A == resource.rType) {
memcpy(buff, resource.rData, sizeof(uint32_t));
buff+=sizeof(uint32_t);
}
}
}
//decode the message header from the buffer
void Message::decode_header(const char *&buff) {
MHeader header;
memcpy(&header, buff, sizeof(MHeader));
//network order to host order
header.hId = ntohs(header.hId);
header.hFlags = ntohs(header.hFlags);
header.queryCount = ntohs(header.queryCount);
header.answCount = ntohs(header.answCount);
header.authCount = ntohs(header.authCount);
header.addiCount = ntohs(header.addiCount);
//id
m_id = header.hId;
//flags
m_qr = header.hFlags&QR_MASK;
m_opcode = header.hFlags&OPCODE_MASK;
m_aa = header.hFlags&AA_MASK;
m_tc = header.hFlags&TC_MASK;
m_rd = header.hFlags&RD_MASK;
m_ra = header.hFlags&RA_MASK;
m_rcode = header.hFlags&RCODE_MASK;
//count
m_qdCount = header.queryCount;
m_anCount = header.answCount;
m_nsCount = header.authCount;
m_arCount = header.addiCount;
//offset
buff+= sizeof(MHeader);
}
//decode the questions of the message from the buffer
void Message::decode_questions(const char *&buff) {
//reset
m_questions.clear();
//decode each question
for (int i=0; i<m_qdCount; i++) {
MQuestion question = {0};
//name
while (1) {
uint len = *buff++;
if (len==0) break;
if (strlen(question.qName)!=0) strcat(question.qName, ".");
memcpy(question.qName+strlen(question.qName), buff, len);
buff+=len;
}
//type
question.qType = ntohs(*((uint16_t *)buff));
buff+=sizeof(uint16_t);
//class
question.qClass = ntohs(*((uint16_t *)buff));
buff+=sizeof(uint16_t);
//add to list
m_questions.push_back(question);
}
}
| 30.098765
| 71
| 0.612797
|
zhaoxy2850
|
f54e08ef99fa2907926ec3287c946a53e9f323ab
| 2,064
|
cpp
|
C++
|
Examples/CPP/ConvertingProjectData/UsingSvgOptions.cpp
|
aspose-tasks/Aspose.Tasks-for-C
|
acb3e2b75685f65cbe34dd739c7eae0dfc285aa1
|
[
"MIT"
] | 1
|
2022-03-16T14:31:36.000Z
|
2022-03-16T14:31:36.000Z
|
Examples/CPP/ConvertingProjectData/UsingSvgOptions.cpp
|
aspose-tasks/Aspose.Tasks-for-C
|
acb3e2b75685f65cbe34dd739c7eae0dfc285aa1
|
[
"MIT"
] | null | null | null |
Examples/CPP/ConvertingProjectData/UsingSvgOptions.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 "ConvertingProjectData/UsingSvgOptions.h"
#include <visualization/Enums/Timescale.h>
#include <system/type_info.h>
#include <system/string.h>
#include <system/shared_ptr.h>
#include <system/reflection/method_base.h>
#include <system/object.h>
#include <saving/Svg/SvgOptions.h>
#include <saving/SaveOptions.h>
#include <Project.h>
#include "RunExamples.h"
using namespace Aspose::Tasks::Saving;
using namespace Aspose::Tasks::Visualization;
namespace Aspose {
namespace Tasks {
namespace Examples {
namespace CPP {
namespace ConvertingProjectData {
RTTI_INFO_IMPL_HASH(2335436377u, ::Aspose::Tasks::Examples::CPP::ConvertingProjectData::UsingSvgOptions, ThisTypeBaseTypesInfo);
void UsingSvgOptions::Run()
{
// The path to the documents directory.
System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
// ExStart:UseSvgOptions
// Read the input Project file
System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"CreateProject2.mpp");
System::SharedPtr<SaveOptions> saveOptions = System::MakeObject<SvgOptions>();
saveOptions->set_FitContent(true);
saveOptions->set_Timescale(Aspose::Tasks::Visualization::Timescale::ThirdsOfMonths);
project->Save(dataDir + u"UseSvgOptions_out.svg", saveOptions);
// ExEnd:UseSvgOptions
}
} // namespace ConvertingProjectData
} // namespace CPP
} // namespace Examples
} // namespace Tasks
} // namespace Aspose
| 36.210526
| 164
| 0.76938
|
aspose-tasks
|
f551eaeccc9ec4926aa1f71116fc41295669373e
| 34,595
|
cpp
|
C++
|
src/qt/qtwebkit/Source/JavaScriptCore/runtime/Structure.cpp
|
viewdy/phantomjs
|
eddb0db1d253fd0c546060a4555554c8ee08c13c
|
[
"BSD-3-Clause"
] | 1
|
2015-05-27T13:52:20.000Z
|
2015-05-27T13:52:20.000Z
|
src/qt/qtwebkit/Source/JavaScriptCore/runtime/Structure.cpp
|
mrampersad/phantomjs
|
dca6f77a36699eb4e1c46f7600cca618f01b0ac3
|
[
"BSD-3-Clause"
] | null | null | null |
src/qt/qtwebkit/Source/JavaScriptCore/runtime/Structure.cpp
|
mrampersad/phantomjs
|
dca6f77a36699eb4e1c46f7600cca618f01b0ac3
|
[
"BSD-3-Clause"
] | 1
|
2017-03-19T13:03:23.000Z
|
2017-03-19T13:03:23.000Z
|
/*
* Copyright (C) 2008, 2009, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "Structure.h"
#include "CodeBlock.h"
#include "JSObject.h"
#include "JSPropertyNameIterator.h"
#include "Lookup.h"
#include "PropertyNameArray.h"
#include "StructureChain.h"
#include "StructureRareDataInlines.h"
#include <wtf/RefCountedLeakCounter.h>
#include <wtf/RefPtr.h>
#include <wtf/Threading.h>
#define DUMP_STRUCTURE_ID_STATISTICS 0
#ifndef NDEBUG
#define DO_PROPERTYMAP_CONSTENCY_CHECK 0
#else
#define DO_PROPERTYMAP_CONSTENCY_CHECK 0
#endif
using namespace std;
using namespace WTF;
#if DUMP_PROPERTYMAP_STATS
int numProbes;
int numCollisions;
int numRehashes;
int numRemoves;
#endif
namespace JSC {
#if DUMP_STRUCTURE_ID_STATISTICS
static HashSet<Structure*>& liveStructureSet = *(new HashSet<Structure*>);
#endif
bool StructureTransitionTable::contains(StringImpl* rep, unsigned attributes) const
{
if (isUsingSingleSlot()) {
Structure* transition = singleTransition();
return transition && transition->m_nameInPrevious == rep && transition->m_attributesInPrevious == attributes;
}
return map()->get(make_pair(rep, attributes));
}
inline Structure* StructureTransitionTable::get(StringImpl* rep, unsigned attributes) const
{
if (isUsingSingleSlot()) {
Structure* transition = singleTransition();
return (transition && transition->m_nameInPrevious == rep && transition->m_attributesInPrevious == attributes) ? transition : 0;
}
return map()->get(make_pair(rep, attributes));
}
inline void StructureTransitionTable::add(VM& vm, Structure* structure)
{
if (isUsingSingleSlot()) {
Structure* existingTransition = singleTransition();
// This handles the first transition being added.
if (!existingTransition) {
setSingleTransition(vm, structure);
return;
}
// This handles the second transition being added
// (or the first transition being despecified!)
setMap(new TransitionMap());
add(vm, existingTransition);
}
// Add the structure to the map.
// Newer versions of the STL have an std::make_pair function that takes rvalue references.
// When either of the parameters are bitfields, the C++ compiler will try to bind them as lvalues, which is invalid. To work around this, use unary "+" to make the parameter an rvalue.
// See https://bugs.webkit.org/show_bug.cgi?id=59261 for more details
map()->set(make_pair(structure->m_nameInPrevious, +structure->m_attributesInPrevious), structure);
}
void Structure::dumpStatistics()
{
#if DUMP_STRUCTURE_ID_STATISTICS
unsigned numberLeaf = 0;
unsigned numberUsingSingleSlot = 0;
unsigned numberSingletons = 0;
unsigned numberWithPropertyMaps = 0;
unsigned totalPropertyMapsSize = 0;
HashSet<Structure*>::const_iterator end = liveStructureSet.end();
for (HashSet<Structure*>::const_iterator it = liveStructureSet.begin(); it != end; ++it) {
Structure* structure = *it;
switch (structure->m_transitionTable.size()) {
case 0:
++numberLeaf;
if (!structure->previousID())
++numberSingletons;
break;
case 1:
++numberUsingSingleSlot;
break;
}
if (structure->propertyTable()) {
++numberWithPropertyMaps;
totalPropertyMapsSize += structure->propertyTable()->sizeInMemory();
}
}
dataLogF("Number of live Structures: %d\n", liveStructureSet.size());
dataLogF("Number of Structures using the single item optimization for transition map: %d\n", numberUsingSingleSlot);
dataLogF("Number of Structures that are leaf nodes: %d\n", numberLeaf);
dataLogF("Number of Structures that singletons: %d\n", numberSingletons);
dataLogF("Number of Structures with PropertyMaps: %d\n", numberWithPropertyMaps);
dataLogF("Size of a single Structures: %d\n", static_cast<unsigned>(sizeof(Structure)));
dataLogF("Size of sum of all property maps: %d\n", totalPropertyMapsSize);
dataLogF("Size of average of all property maps: %f\n", static_cast<double>(totalPropertyMapsSize) / static_cast<double>(liveStructureSet.size()));
#else
dataLogF("Dumping Structure statistics is not enabled.\n");
#endif
}
Structure::Structure(VM& vm, JSGlobalObject* globalObject, JSValue prototype, const TypeInfo& typeInfo, const ClassInfo* classInfo, IndexingType indexingType, unsigned inlineCapacity)
: JSCell(vm, vm.structureStructure.get())
, m_globalObject(vm, this, globalObject, WriteBarrier<JSGlobalObject>::MayBeNull)
, m_prototype(vm, this, prototype)
, m_classInfo(classInfo)
, m_transitionWatchpointSet(InitializedWatching)
, m_offset(invalidOffset)
, m_typeInfo(typeInfo)
, m_indexingType(indexingType)
, m_inlineCapacity(inlineCapacity)
, m_dictionaryKind(NoneDictionaryKind)
, m_isPinnedPropertyTable(false)
, m_hasGetterSetterProperties(false)
, m_hasReadOnlyOrGetterSetterPropertiesExcludingProto(false)
, m_hasNonEnumerableProperties(false)
, m_attributesInPrevious(0)
, m_specificFunctionThrashCount(0)
, m_preventExtensions(false)
, m_didTransition(false)
, m_staticFunctionReified(false)
{
ASSERT(inlineCapacity <= JSFinalObject::maxInlineCapacity());
ASSERT(static_cast<PropertyOffset>(inlineCapacity) < firstOutOfLineOffset);
ASSERT(!typeInfo.structureHasRareData());
}
const ClassInfo Structure::s_info = { "Structure", 0, 0, 0, CREATE_METHOD_TABLE(Structure) };
Structure::Structure(VM& vm)
: JSCell(CreatingEarlyCell)
, m_prototype(vm, this, jsNull())
, m_classInfo(&s_info)
, m_transitionWatchpointSet(InitializedWatching)
, m_offset(invalidOffset)
, m_typeInfo(CompoundType, OverridesVisitChildren)
, m_indexingType(0)
, m_inlineCapacity(0)
, m_dictionaryKind(NoneDictionaryKind)
, m_isPinnedPropertyTable(false)
, m_hasGetterSetterProperties(false)
, m_hasReadOnlyOrGetterSetterPropertiesExcludingProto(false)
, m_hasNonEnumerableProperties(false)
, m_attributesInPrevious(0)
, m_specificFunctionThrashCount(0)
, m_preventExtensions(false)
, m_didTransition(false)
, m_staticFunctionReified(false)
{
}
Structure::Structure(VM& vm, const Structure* previous)
: JSCell(vm, vm.structureStructure.get())
, m_prototype(vm, this, previous->storedPrototype())
, m_classInfo(previous->m_classInfo)
, m_transitionWatchpointSet(InitializedWatching)
, m_offset(invalidOffset)
, m_typeInfo(previous->typeInfo().type(), previous->typeInfo().flags() & ~StructureHasRareData)
, m_indexingType(previous->indexingTypeIncludingHistory())
, m_inlineCapacity(previous->m_inlineCapacity)
, m_dictionaryKind(previous->m_dictionaryKind)
, m_isPinnedPropertyTable(false)
, m_hasGetterSetterProperties(previous->m_hasGetterSetterProperties)
, m_hasReadOnlyOrGetterSetterPropertiesExcludingProto(previous->m_hasReadOnlyOrGetterSetterPropertiesExcludingProto)
, m_hasNonEnumerableProperties(previous->m_hasNonEnumerableProperties)
, m_attributesInPrevious(0)
, m_specificFunctionThrashCount(previous->m_specificFunctionThrashCount)
, m_preventExtensions(previous->m_preventExtensions)
, m_didTransition(true)
, m_staticFunctionReified(previous->m_staticFunctionReified)
{
if (previous->typeInfo().structureHasRareData() && previous->rareData()->needsCloning())
cloneRareDataFrom(vm, previous);
else if (previous->previousID())
m_previousOrRareData.set(vm, this, previous->previousID());
previous->notifyTransitionFromThisStructure();
if (previous->m_globalObject)
m_globalObject.set(vm, this, previous->m_globalObject.get());
}
void Structure::destroy(JSCell* cell)
{
static_cast<Structure*>(cell)->Structure::~Structure();
}
void Structure::materializePropertyMap(VM& vm)
{
ASSERT(structure()->classInfo() == &s_info);
ASSERT(!propertyTable());
Vector<Structure*, 8> structures;
structures.append(this);
Structure* structure = this;
// Search for the last Structure with a property table.
while ((structure = structure->previousID())) {
if (structure->m_isPinnedPropertyTable) {
ASSERT(structure->propertyTable());
ASSERT(!structure->previousID());
propertyTable().set(vm, this, structure->propertyTable()->copy(vm, 0, numberOfSlotsForLastOffset(m_offset, m_inlineCapacity)));
break;
}
structures.append(structure);
}
if (!propertyTable())
createPropertyMap(vm, numberOfSlotsForLastOffset(m_offset, m_inlineCapacity));
for (ptrdiff_t i = structures.size() - 1; i >= 0; --i) {
structure = structures[i];
if (!structure->m_nameInPrevious)
continue;
PropertyMapEntry entry(vm, this, structure->m_nameInPrevious.get(), structure->m_offset, structure->m_attributesInPrevious, structure->m_specificValueInPrevious.get());
propertyTable()->add(entry, m_offset, PropertyTable::PropertyOffsetMustNotChange);
}
checkOffsetConsistency();
}
inline size_t nextOutOfLineStorageCapacity(size_t currentCapacity)
{
if (!currentCapacity)
return initialOutOfLineCapacity;
return currentCapacity * outOfLineGrowthFactor;
}
size_t Structure::suggestedNewOutOfLineStorageCapacity()
{
return nextOutOfLineStorageCapacity(outOfLineCapacity());
}
void Structure::despecifyDictionaryFunction(VM& vm, PropertyName propertyName)
{
StringImpl* rep = propertyName.uid();
materializePropertyMapIfNecessary(vm);
ASSERT(isDictionary());
ASSERT(propertyTable());
PropertyMapEntry* entry = propertyTable()->find(rep).first;
ASSERT(entry);
entry->specificValue.clear();
}
Structure* Structure::addPropertyTransitionToExistingStructure(Structure* structure, PropertyName propertyName, unsigned attributes, JSCell* specificValue, PropertyOffset& offset)
{
ASSERT(!structure->isDictionary());
ASSERT(structure->isObject());
if (Structure* existingTransition = structure->m_transitionTable.get(propertyName.uid(), attributes)) {
JSCell* specificValueInPrevious = existingTransition->m_specificValueInPrevious.get();
if (specificValueInPrevious && specificValueInPrevious != specificValue)
return 0;
validateOffset(existingTransition->m_offset, existingTransition->inlineCapacity());
offset = existingTransition->m_offset;
return existingTransition;
}
return 0;
}
bool Structure::anyObjectInChainMayInterceptIndexedAccesses() const
{
for (const Structure* current = this; ;) {
if (current->mayInterceptIndexedAccesses())
return true;
JSValue prototype = current->storedPrototype();
if (prototype.isNull())
return false;
current = asObject(prototype)->structure();
}
}
bool Structure::needsSlowPutIndexing() const
{
return anyObjectInChainMayInterceptIndexedAccesses()
|| globalObject()->isHavingABadTime();
}
NonPropertyTransition Structure::suggestedArrayStorageTransition() const
{
if (needsSlowPutIndexing())
return AllocateSlowPutArrayStorage;
return AllocateArrayStorage;
}
Structure* Structure::addPropertyTransition(VM& vm, Structure* structure, PropertyName propertyName, unsigned attributes, JSCell* specificValue, PropertyOffset& offset)
{
// If we have a specific function, we may have got to this point if there is
// already a transition with the correct property name and attributes, but
// specialized to a different function. In this case we just want to give up
// and despecialize the transition.
// In this case we clear the value of specificFunction which will result
// in us adding a non-specific transition, and any subsequent lookup in
// Structure::addPropertyTransitionToExistingStructure will just use that.
if (specificValue && structure->m_transitionTable.contains(propertyName.uid(), attributes))
specificValue = 0;
ASSERT(!structure->isDictionary());
ASSERT(structure->isObject());
ASSERT(!Structure::addPropertyTransitionToExistingStructure(structure, propertyName, attributes, specificValue, offset));
if (structure->m_specificFunctionThrashCount == maxSpecificFunctionThrashCount)
specificValue = 0;
if (structure->transitionCount() > s_maxTransitionLength) {
Structure* transition = toCacheableDictionaryTransition(vm, structure);
ASSERT(structure != transition);
offset = transition->putSpecificValue(vm, propertyName, attributes, specificValue);
return transition;
}
Structure* transition = create(vm, structure);
transition->m_cachedPrototypeChain.setMayBeNull(vm, transition, structure->m_cachedPrototypeChain.get());
transition->setPreviousID(vm, transition, structure);
transition->m_nameInPrevious = propertyName.uid();
transition->m_attributesInPrevious = attributes;
transition->m_specificValueInPrevious.setMayBeNull(vm, transition, specificValue);
transition->propertyTable().set(vm, transition, structure->takePropertyTableOrCloneIfPinned(vm, transition));
transition->m_offset = structure->m_offset;
offset = transition->putSpecificValue(vm, propertyName, attributes, specificValue);
checkOffset(transition->m_offset, transition->inlineCapacity());
structure->m_transitionTable.add(vm, transition);
transition->checkOffsetConsistency();
structure->checkOffsetConsistency();
return transition;
}
Structure* Structure::removePropertyTransition(VM& vm, Structure* structure, PropertyName propertyName, PropertyOffset& offset)
{
ASSERT(!structure->isUncacheableDictionary());
Structure* transition = toUncacheableDictionaryTransition(vm, structure);
offset = transition->remove(propertyName);
transition->checkOffsetConsistency();
return transition;
}
Structure* Structure::changePrototypeTransition(VM& vm, Structure* structure, JSValue prototype)
{
Structure* transition = create(vm, structure);
transition->m_prototype.set(vm, transition, prototype);
structure->materializePropertyMapIfNecessary(vm);
transition->propertyTable().set(vm, transition, structure->copyPropertyTableForPinning(vm, transition));
transition->m_offset = structure->m_offset;
transition->pin();
transition->checkOffsetConsistency();
return transition;
}
Structure* Structure::despecifyFunctionTransition(VM& vm, Structure* structure, PropertyName replaceFunction)
{
ASSERT(structure->m_specificFunctionThrashCount < maxSpecificFunctionThrashCount);
Structure* transition = create(vm, structure);
++transition->m_specificFunctionThrashCount;
structure->materializePropertyMapIfNecessary(vm);
transition->propertyTable().set(vm, transition, structure->copyPropertyTableForPinning(vm, transition));
transition->m_offset = structure->m_offset;
transition->pin();
if (transition->m_specificFunctionThrashCount == maxSpecificFunctionThrashCount)
transition->despecifyAllFunctions(vm);
else {
bool removed = transition->despecifyFunction(vm, replaceFunction);
ASSERT_UNUSED(removed, removed);
}
transition->checkOffsetConsistency();
return transition;
}
Structure* Structure::attributeChangeTransition(VM& vm, Structure* structure, PropertyName propertyName, unsigned attributes)
{
if (!structure->isUncacheableDictionary()) {
Structure* transition = create(vm, structure);
structure->materializePropertyMapIfNecessary(vm);
transition->propertyTable().set(vm, transition, structure->copyPropertyTableForPinning(vm, transition));
transition->m_offset = structure->m_offset;
transition->pin();
structure = transition;
}
ASSERT(structure->propertyTable());
PropertyMapEntry* entry = structure->propertyTable()->find(propertyName.uid()).first;
ASSERT(entry);
entry->attributes = attributes;
structure->checkOffsetConsistency();
return structure;
}
Structure* Structure::toDictionaryTransition(VM& vm, Structure* structure, DictionaryKind kind)
{
ASSERT(!structure->isUncacheableDictionary());
Structure* transition = create(vm, structure);
structure->materializePropertyMapIfNecessary(vm);
transition->propertyTable().set(vm, transition, structure->copyPropertyTableForPinning(vm, transition));
transition->m_offset = structure->m_offset;
transition->m_dictionaryKind = kind;
transition->pin();
transition->checkOffsetConsistency();
return transition;
}
Structure* Structure::toCacheableDictionaryTransition(VM& vm, Structure* structure)
{
return toDictionaryTransition(vm, structure, CachedDictionaryKind);
}
Structure* Structure::toUncacheableDictionaryTransition(VM& vm, Structure* structure)
{
return toDictionaryTransition(vm, structure, UncachedDictionaryKind);
}
// In future we may want to cache this transition.
Structure* Structure::sealTransition(VM& vm, Structure* structure)
{
Structure* transition = preventExtensionsTransition(vm, structure);
if (transition->propertyTable()) {
PropertyTable::iterator end = transition->propertyTable()->end();
for (PropertyTable::iterator iter = transition->propertyTable()->begin(); iter != end; ++iter)
iter->attributes |= DontDelete;
}
transition->checkOffsetConsistency();
return transition;
}
// In future we may want to cache this transition.
Structure* Structure::freezeTransition(VM& vm, Structure* structure)
{
Structure* transition = preventExtensionsTransition(vm, structure);
if (transition->propertyTable()) {
PropertyTable::iterator iter = transition->propertyTable()->begin();
PropertyTable::iterator end = transition->propertyTable()->end();
if (iter != end)
transition->m_hasReadOnlyOrGetterSetterPropertiesExcludingProto = true;
for (; iter != end; ++iter)
iter->attributes |= iter->attributes & Accessor ? DontDelete : (DontDelete | ReadOnly);
}
transition->checkOffsetConsistency();
return transition;
}
// In future we may want to cache this transition.
Structure* Structure::preventExtensionsTransition(VM& vm, Structure* structure)
{
Structure* transition = create(vm, structure);
// Don't set m_offset, as one can not transition to this.
structure->materializePropertyMapIfNecessary(vm);
transition->propertyTable().set(vm, transition, structure->copyPropertyTableForPinning(vm, transition));
transition->m_offset = structure->m_offset;
transition->m_preventExtensions = true;
transition->pin();
transition->checkOffsetConsistency();
return transition;
}
PropertyTable* Structure::takePropertyTableOrCloneIfPinned(VM& vm, Structure* owner)
{
materializePropertyMapIfNecessaryForPinning(vm);
if (m_isPinnedPropertyTable)
return propertyTable()->copy(vm, owner, propertyTable()->size() + 1);
PropertyTable* takenPropertyTable = propertyTable().get();
propertyTable().clear();
return takenPropertyTable;
}
Structure* Structure::nonPropertyTransition(VM& vm, Structure* structure, NonPropertyTransition transitionKind)
{
unsigned attributes = toAttributes(transitionKind);
IndexingType indexingType = newIndexingType(structure->indexingTypeIncludingHistory(), transitionKind);
if (JSGlobalObject* globalObject = structure->m_globalObject.get()) {
if (globalObject->isOriginalArrayStructure(structure)) {
Structure* result = globalObject->originalArrayStructureForIndexingType(indexingType);
if (result->indexingTypeIncludingHistory() == indexingType) {
structure->notifyTransitionFromThisStructure();
return result;
}
}
}
if (Structure* existingTransition = structure->m_transitionTable.get(0, attributes)) {
ASSERT(existingTransition->m_attributesInPrevious == attributes);
ASSERT(existingTransition->indexingTypeIncludingHistory() == indexingType);
return existingTransition;
}
Structure* transition = create(vm, structure);
transition->setPreviousID(vm, transition, structure);
transition->m_attributesInPrevious = attributes;
transition->m_indexingType = indexingType;
transition->propertyTable().set(vm, transition, structure->takePropertyTableOrCloneIfPinned(vm, transition));
transition->m_offset = structure->m_offset;
checkOffset(transition->m_offset, transition->inlineCapacity());
structure->m_transitionTable.add(vm, transition);
transition->checkOffsetConsistency();
return transition;
}
// In future we may want to cache this property.
bool Structure::isSealed(VM& vm)
{
if (isExtensible())
return false;
materializePropertyMapIfNecessary(vm);
if (!propertyTable())
return true;
PropertyTable::iterator end = propertyTable()->end();
for (PropertyTable::iterator iter = propertyTable()->begin(); iter != end; ++iter) {
if ((iter->attributes & DontDelete) != DontDelete)
return false;
}
return true;
}
// In future we may want to cache this property.
bool Structure::isFrozen(VM& vm)
{
if (isExtensible())
return false;
materializePropertyMapIfNecessary(vm);
if (!propertyTable())
return true;
PropertyTable::iterator end = propertyTable()->end();
for (PropertyTable::iterator iter = propertyTable()->begin(); iter != end; ++iter) {
if (!(iter->attributes & DontDelete))
return false;
if (!(iter->attributes & (ReadOnly | Accessor)))
return false;
}
return true;
}
Structure* Structure::flattenDictionaryStructure(VM& vm, JSObject* object)
{
checkOffsetConsistency();
ASSERT(isDictionary());
if (isUncacheableDictionary()) {
ASSERT(propertyTable());
size_t propertyCount = propertyTable()->size();
// Holds our values compacted by insertion order.
Vector<JSValue> values(propertyCount);
// Copies out our values from their hashed locations, compacting property table offsets as we go.
unsigned i = 0;
PropertyTable::iterator end = propertyTable()->end();
m_offset = invalidOffset;
for (PropertyTable::iterator iter = propertyTable()->begin(); iter != end; ++iter, ++i) {
values[i] = object->getDirect(iter->offset);
m_offset = iter->offset = offsetForPropertyNumber(i, m_inlineCapacity);
}
// Copies in our values to their compacted locations.
for (unsigned i = 0; i < propertyCount; i++)
object->putDirect(vm, offsetForPropertyNumber(i, m_inlineCapacity), values[i]);
propertyTable()->clearDeletedOffsets();
checkOffsetConsistency();
}
m_dictionaryKind = NoneDictionaryKind;
return this;
}
PropertyOffset Structure::addPropertyWithoutTransition(VM& vm, PropertyName propertyName, unsigned attributes, JSCell* specificValue)
{
ASSERT(!enumerationCache());
if (m_specificFunctionThrashCount == maxSpecificFunctionThrashCount)
specificValue = 0;
materializePropertyMapIfNecessaryForPinning(vm);
pin();
return putSpecificValue(vm, propertyName, attributes, specificValue);
}
PropertyOffset Structure::removePropertyWithoutTransition(VM& vm, PropertyName propertyName)
{
ASSERT(isUncacheableDictionary());
ASSERT(!enumerationCache());
materializePropertyMapIfNecessaryForPinning(vm);
pin();
return remove(propertyName);
}
void Structure::pin()
{
ASSERT(propertyTable());
m_isPinnedPropertyTable = true;
clearPreviousID();
m_nameInPrevious.clear();
}
void Structure::allocateRareData(VM& vm)
{
ASSERT(!typeInfo().structureHasRareData());
StructureRareData* rareData = StructureRareData::create(vm, previous());
m_typeInfo = TypeInfo(typeInfo().type(), typeInfo().flags() | StructureHasRareData);
m_previousOrRareData.set(vm, this, rareData);
}
void Structure::cloneRareDataFrom(VM& vm, const Structure* other)
{
ASSERT(other->typeInfo().structureHasRareData());
StructureRareData* newRareData = StructureRareData::clone(vm, other->rareData());
m_typeInfo = TypeInfo(typeInfo().type(), typeInfo().flags() | StructureHasRareData);
m_previousOrRareData.set(vm, this, newRareData);
}
#if DUMP_PROPERTYMAP_STATS
struct PropertyMapStatisticsExitLogger {
~PropertyMapStatisticsExitLogger();
};
static PropertyMapStatisticsExitLogger logger;
PropertyMapStatisticsExitLogger::~PropertyMapStatisticsExitLogger()
{
dataLogF("\nJSC::PropertyMap statistics\n\n");
dataLogF("%d probes\n", numProbes);
dataLogF("%d collisions (%.1f%%)\n", numCollisions, 100.0 * numCollisions / numProbes);
dataLogF("%d rehashes\n", numRehashes);
dataLogF("%d removes\n", numRemoves);
}
#endif
#if !DO_PROPERTYMAP_CONSTENCY_CHECK
inline void Structure::checkConsistency()
{
checkOffsetConsistency();
}
#endif
PropertyTable* Structure::copyPropertyTable(VM& vm, Structure* owner)
{
if (!propertyTable())
return 0;
return PropertyTable::clone(vm, owner, *propertyTable().get());
}
PropertyTable* Structure::copyPropertyTableForPinning(VM& vm, Structure* owner)
{
if (propertyTable())
return PropertyTable::clone(vm, owner, *propertyTable().get());
return PropertyTable::create(vm, numberOfSlotsForLastOffset(m_offset, m_inlineCapacity));
}
PropertyOffset Structure::get(VM& vm, PropertyName propertyName, unsigned& attributes, JSCell*& specificValue)
{
ASSERT(structure()->classInfo() == &s_info);
materializePropertyMapIfNecessary(vm);
if (!propertyTable())
return invalidOffset;
PropertyMapEntry* entry = propertyTable()->find(propertyName.uid()).first;
if (!entry)
return invalidOffset;
attributes = entry->attributes;
specificValue = entry->specificValue.get();
return entry->offset;
}
bool Structure::despecifyFunction(VM& vm, PropertyName propertyName)
{
materializePropertyMapIfNecessary(vm);
if (!propertyTable())
return false;
PropertyMapEntry* entry = propertyTable()->find(propertyName.uid()).first;
if (!entry)
return false;
ASSERT(entry->specificValue);
entry->specificValue.clear();
return true;
}
void Structure::despecifyAllFunctions(VM& vm)
{
materializePropertyMapIfNecessary(vm);
if (!propertyTable())
return;
PropertyTable::iterator end = propertyTable()->end();
for (PropertyTable::iterator iter = propertyTable()->begin(); iter != end; ++iter)
iter->specificValue.clear();
}
PropertyOffset Structure::putSpecificValue(VM& vm, PropertyName propertyName, unsigned attributes, JSCell* specificValue)
{
ASSERT(!JSC::isValidOffset(get(vm, propertyName)));
checkConsistency();
if (attributes & DontEnum)
m_hasNonEnumerableProperties = true;
StringImpl* rep = propertyName.uid();
if (!propertyTable())
createPropertyMap(vm);
PropertyOffset newOffset = propertyTable()->nextOffset(m_inlineCapacity);
propertyTable()->add(PropertyMapEntry(vm, this, rep, newOffset, attributes, specificValue), m_offset, PropertyTable::PropertyOffsetMayChange);
checkConsistency();
return newOffset;
}
PropertyOffset Structure::remove(PropertyName propertyName)
{
checkConsistency();
StringImpl* rep = propertyName.uid();
if (!propertyTable())
return invalidOffset;
PropertyTable::find_iterator position = propertyTable()->find(rep);
if (!position.first)
return invalidOffset;
PropertyOffset offset = position.first->offset;
propertyTable()->remove(position);
propertyTable()->addDeletedOffset(offset);
checkConsistency();
return offset;
}
void Structure::createPropertyMap(VM& vm, unsigned capacity)
{
ASSERT(!propertyTable());
checkConsistency();
propertyTable().set(vm, this, PropertyTable::create(vm, capacity));
}
void Structure::getPropertyNamesFromStructure(VM& vm, PropertyNameArray& propertyNames, EnumerationMode mode)
{
materializePropertyMapIfNecessary(vm);
if (!propertyTable())
return;
bool knownUnique = !propertyNames.size();
PropertyTable::iterator end = propertyTable()->end();
for (PropertyTable::iterator iter = propertyTable()->begin(); iter != end; ++iter) {
ASSERT(m_hasNonEnumerableProperties || !(iter->attributes & DontEnum));
if (iter->key->isIdentifier() && (!(iter->attributes & DontEnum) || mode == IncludeDontEnumProperties)) {
if (knownUnique)
propertyNames.addKnownUnique(iter->key);
else
propertyNames.add(iter->key);
}
}
}
JSValue Structure::prototypeForLookup(CodeBlock* codeBlock) const
{
return prototypeForLookup(codeBlock->globalObject());
}
void Structure::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
Structure* thisObject = jsCast<Structure*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
JSCell::visitChildren(thisObject, visitor);
visitor.append(&thisObject->m_globalObject);
if (!thisObject->isObject())
thisObject->m_cachedPrototypeChain.clear();
else {
visitor.append(&thisObject->m_prototype);
visitor.append(&thisObject->m_cachedPrototypeChain);
}
visitor.append(&thisObject->m_previousOrRareData);
visitor.append(&thisObject->m_specificValueInPrevious);
if (thisObject->m_isPinnedPropertyTable) {
ASSERT(thisObject->m_propertyTableUnsafe);
visitor.append(&thisObject->m_propertyTableUnsafe);
} else if (thisObject->m_propertyTableUnsafe)
thisObject->m_propertyTableUnsafe.clear();
}
bool Structure::prototypeChainMayInterceptStoreTo(VM& vm, PropertyName propertyName)
{
unsigned i = propertyName.asIndex();
if (i != PropertyName::NotAnIndex)
return anyObjectInChainMayInterceptIndexedAccesses();
for (Structure* current = this; ;) {
JSValue prototype = current->storedPrototype();
if (prototype.isNull())
return false;
current = prototype.asCell()->structure();
unsigned attributes;
JSCell* specificValue;
PropertyOffset offset = current->get(vm, propertyName, attributes, specificValue);
if (!JSC::isValidOffset(offset))
continue;
if (attributes & (ReadOnly | Accessor))
return true;
return false;
}
}
#if DO_PROPERTYMAP_CONSTENCY_CHECK
void PropertyTable::checkConsistency()
{
checkOffsetConsistency();
ASSERT(m_indexSize >= PropertyTable::MinimumTableSize);
ASSERT(m_indexMask);
ASSERT(m_indexSize == m_indexMask + 1);
ASSERT(!(m_indexSize & m_indexMask));
ASSERT(m_keyCount <= m_indexSize / 2);
ASSERT(m_keyCount + m_deletedCount <= m_indexSize / 2);
ASSERT(m_deletedCount <= m_indexSize / 4);
unsigned indexCount = 0;
unsigned deletedIndexCount = 0;
for (unsigned a = 0; a != m_indexSize; ++a) {
unsigned entryIndex = m_index[a];
if (entryIndex == PropertyTable::EmptyEntryIndex)
continue;
if (entryIndex == deletedEntryIndex()) {
++deletedIndexCount;
continue;
}
ASSERT(entryIndex < deletedEntryIndex());
ASSERT(entryIndex - 1 <= usedCount());
++indexCount;
for (unsigned b = a + 1; b != m_indexSize; ++b)
ASSERT(m_index[b] != entryIndex);
}
ASSERT(indexCount == m_keyCount);
ASSERT(deletedIndexCount == m_deletedCount);
ASSERT(!table()[deletedEntryIndex() - 1].key);
unsigned nonEmptyEntryCount = 0;
for (unsigned c = 0; c < usedCount(); ++c) {
StringImpl* rep = table()[c].key;
if (rep == PROPERTY_MAP_DELETED_ENTRY_KEY)
continue;
++nonEmptyEntryCount;
unsigned i = rep->existingHash();
unsigned k = 0;
unsigned entryIndex;
while (1) {
entryIndex = m_index[i & m_indexMask];
ASSERT(entryIndex != PropertyTable::EmptyEntryIndex);
if (rep == table()[entryIndex - 1].key)
break;
if (k == 0)
k = 1 | doubleHash(rep->existingHash());
i += k;
}
ASSERT(entryIndex == c + 1);
}
ASSERT(nonEmptyEntryCount == m_keyCount);
}
void Structure::checkConsistency()
{
if (!propertyTable())
return;
if (!m_hasNonEnumerableProperties) {
PropertyTable::iterator end = propertyTable()->end();
for (PropertyTable::iterator iter = propertyTable()->begin(); iter != end; ++iter) {
ASSERT(!(iter->attributes & DontEnum));
}
}
propertyTable()->checkConsistency();
}
#endif // DO_PROPERTYMAP_CONSTENCY_CHECK
} // namespace JSC
| 34.838872
| 188
| 0.706836
|
viewdy
|
f554b66a7e4617d91daf7917eeac37f219dcee22
| 8,342
|
cpp
|
C++
|
plugins/probe/3rd/poisson4/factor.cpp
|
azuki-monster/megamol
|
f5d75ae5630f9a71a7fbf81624bfd4f6b253c655
|
[
"BSD-3-Clause"
] | 49
|
2017-08-23T13:24:24.000Z
|
2022-03-16T09:10:58.000Z
|
plugins/probe/3rd/poisson4/factor.cpp
|
azuki-monster/megamol
|
f5d75ae5630f9a71a7fbf81624bfd4f6b253c655
|
[
"BSD-3-Clause"
] | 200
|
2018-07-20T15:18:26.000Z
|
2022-03-31T11:01:44.000Z
|
plugins/probe/3rd/poisson4/factor.cpp
|
azuki-monster/megamol
|
f5d75ae5630f9a71a7fbf81624bfd4f6b253c655
|
[
"BSD-3-Clause"
] | 31
|
2017-07-31T16:19:29.000Z
|
2022-02-14T23:41:03.000Z
|
/*
Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
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 Johns Hopkins University nor the names of its contributors
may be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
*/
//////////////////////
// Polynomial Roots //
//////////////////////
#include <math.h>
#include "poisson4/factor.h"
namespace pcl
{
namespace poisson
{
int Factor(double a1,double a0,double roots[1][2],double EPS){
if(fabs(a1)<=EPS){return 0;}
roots[0][0]=-a0/a1;
roots[0][1]=0;
return 1;
}
int Factor(double a2,double a1,double a0,double roots[2][2],double EPS){
double d;
if(fabs(a2)<=EPS){return Factor(a1,a0,roots,EPS);}
d=a1*a1-4*a0*a2;
a1/=(2*a2);
if(d<0){
d=sqrt(-d)/(2*a2);
roots[0][0]=roots[1][0]=-a1;
roots[0][1]=-d;
roots[1][1]= d;
}
else{
d=sqrt(d)/(2*a2);
roots[0][1]=roots[1][1]=0;
roots[0][0]=-a1-d;
roots[1][0]=-a1+d;
}
return 2;
}
// Solution taken from: http://mathworld.wolfram.com/CubicFormula.html
// and http://www.csit.fsu.edu/~burkardt/f_src/subpak/subpak.f90
int Factor(double a3,double a2,double a1,double a0,double roots[3][2],double EPS){
double q,r,r2,q3;
if(fabs(a3)<=EPS){return Factor(a2,a1,a0,roots,EPS);}
a2/=a3;
a1/=a3;
a0/=a3;
q=-(3*a1-a2*a2)/9;
r=-(9*a2*a1-27*a0-2*a2*a2*a2)/54;
r2=r*r;
q3=q*q*q;
if(r2<q3){
double sqrQ=sqrt(q);
double theta = acos ( r / (sqrQ*q) );
double cTheta=cos(theta/3)*sqrQ;
double sTheta=sin(theta/3)*sqrQ*SQRT_3/2;
roots[0][1]=roots[1][1]=roots[2][1]=0;
roots[0][0]=-2*cTheta;
roots[1][0]=-2*(-cTheta*0.5-sTheta);
roots[2][0]=-2*(-cTheta*0.5+sTheta);
}
else{
double s1,s2,sqr=sqrt(r2-q3);
double t;
t=-r+sqr;
if(t<0){s1=-pow(-t,1.0/3);}
else{s1=pow(t,1.0/3);}
t=-r-sqr;
if(t<0){s2=-pow(-t,1.0/3);}
else{s2=pow(t,1.0/3);}
roots[0][1]=0;
roots[0][0]=s1+s2;
s1/=2;
s2/=2;
roots[1][0]= roots[2][0]=-s1-s2;
roots[1][1]= SQRT_3*(s1-s2);
roots[2][1]=-roots[1][1];
}
roots[0][0]-=a2/3;
roots[1][0]-=a2/3;
roots[2][0]-=a2/3;
return 3;
}
double ArcTan2(double y,double x){
/* This first case should never happen */
if(y==0 && x==0){return 0;}
if(x==0){
if(y>0){return PI/2.0;}
else{return -PI/2.0;}
}
if(x>=0){return atan(y/x);}
else{
if(y>=0){return atan(y/x)+PI;}
else{return atan(y/x)-PI;}
}
}
double Angle(const double in[2]){
if((in[0]*in[0]+in[1]*in[1])==0.0){return 0;}
else{return ArcTan2(in[1],in[0]);}
}
void Sqrt(const double in[2],double out[2]){
double r=sqrt(sqrt(in[0]*in[0]+in[1]*in[1]));
double a=Angle(in)*0.5;
out[0]=r*cos(a);
out[1]=r*sin(a);
}
void Add(const double in1[2],const double in2[2],double out[2]){
out[0]=in1[0]+in2[0];
out[1]=in1[1]+in2[1];
}
void Subtract(const double in1[2],const double in2[2],double out[2]){
out[0]=in1[0]-in2[0];
out[1]=in1[1]-in2[1];
}
void Multiply(const double in1[2],const double in2[2],double out[2]){
out[0]=in1[0]*in2[0]-in1[1]*in2[1];
out[1]=in1[0]*in2[1]+in1[1]*in2[0];
}
void Divide(const double in1[2],const double in2[2],double out[2]){
double temp[2];
double l=in2[0]*in2[0]+in2[1]*in2[1];
temp[0]= in2[0]/l;
temp[1]=-in2[1]/l;
Multiply(in1,temp,out);
}
// Solution taken from: http://mathworld.wolfram.com/QuarticEquation.html
// and http://www.csit.fsu.edu/~burkardt/f_src/subpak/subpak.f90
int Factor(double a4,double a3,double a2,double a1,double a0,double roots[4][2],double EPS){
double R[2],D[2],E[2],R2[2];
if(fabs(a4)<EPS){return Factor(a3,a2,a1,a0,roots,EPS);}
a3/=a4;
a2/=a4;
a1/=a4;
a0/=a4;
Factor(1.0,-a2,a3*a1-4.0*a0,-a3*a3*a0+4.0*a2*a0-a1*a1,roots,EPS);
R2[0]=a3*a3/4.0-a2+roots[0][0];
R2[1]=0;
Sqrt(R2,R);
if(fabs(R[0])>10e-8){
double temp1[2],temp2[2];
double p1[2],p2[2];
p1[0]=a3*a3*0.75-2.0*a2-R2[0];
p1[1]=0;
temp2[0]=((4.0*a3*a2-8.0*a1-a3*a3*a3)/4.0);
temp2[1]=0;
Divide(temp2,R,p2);
Add (p1,p2,temp1);
Subtract(p1,p2,temp2);
Sqrt(temp1,D);
Sqrt(temp2,E);
}
else{
R[0]=R[1]=0;
double temp1[2],temp2[2];
temp1[0]=roots[0][0]*roots[0][0]-4.0*a0;
temp1[1]=0;
Sqrt(temp1,temp2);
temp1[0]=a3*a3*0.75-2.0*a2+2.0*temp2[0];
temp1[1]= 2.0*temp2[1];
Sqrt(temp1,D);
temp1[0]=a3*a3*0.75-2.0*a2-2.0*temp2[0];
temp1[1]= -2.0*temp2[1];
Sqrt(temp1,E);
}
roots[0][0]=-a3/4.0+R[0]/2.0+D[0]/2.0;
roots[0][1]= R[1]/2.0+D[1]/2.0;
roots[1][0]=-a3/4.0+R[0]/2.0-D[0]/2.0;
roots[1][1]= R[1]/2.0-D[1]/2.0;
roots[2][0]=-a3/4.0-R[0]/2.0+E[0]/2.0;
roots[2][1]= -R[1]/2.0+E[1]/2.0;
roots[3][0]=-a3/4.0-R[0]/2.0-E[0]/2.0;
roots[3][1]= -R[1]/2.0-E[1]/2.0;
return 4;
}
int Solve(const double* eqns,const double* values,double* solutions,int dim){
int i,j,eIndex;
double v,m;
int *index=new int[dim];
int *set=new int[dim];
double* myEqns=new double[dim*dim];
double* myValues=new double[dim];
for(i=0;i<dim*dim;i++){myEqns[i]=eqns[i];}
for(i=0;i<dim;i++){
myValues[i]=values[i];
set[i]=0;
}
for(i=0;i<dim;i++){
// Find the largest equation that has a non-zero entry in the i-th index
m=-1;
eIndex=-1;
for(j=0;j<dim;j++){
if(set[j]){continue;}
if(myEqns[j*dim+i]!=0 && fabs(myEqns[j*dim+i])>m){
m=fabs(myEqns[j*dim+i]);
eIndex=j;
}
}
if(eIndex==-1){
delete[] index;
delete[] myValues;
delete[] myEqns;
delete[] set;
return 0;
}
// The position in which the solution for the i-th variable can be found
index[i]=eIndex;
set[eIndex]=1;
// Normalize the equation
v=myEqns[eIndex*dim+i];
for(j=0;j<dim;j++){myEqns[eIndex*dim+j]/=v;}
myValues[eIndex]/=v;
// Subtract it off from everything else
for(j=0;j<dim;j++){
if(j==eIndex){continue;}
double vv=myEqns[j*dim+i];
for(int k=0;k<dim;k++){myEqns[j*dim+k]-=myEqns[eIndex*dim+k]*vv;}
myValues[j]-=myValues[eIndex]*vv;
}
}
for(i=0;i<dim;i++){solutions[i]=myValues[index[i]];}
delete[] index;
delete[] myValues;
delete[] myEqns;
delete[] set;
return 1;
}
}
}
| 30.445255
| 96
| 0.546392
|
azuki-monster
|
f556eefccc7e4962d1c08d5030e175f9cae682c2
| 14,687
|
cpp
|
C++
|
test/planner/planner_test.cpp
|
Nov11/15-721
|
b52c173d4be6838faa86b69959c0c341748f3e58
|
[
"Apache-2.0"
] | 2
|
2021-03-29T01:29:18.000Z
|
2022-02-27T11:22:15.000Z
|
test/planner/planner_test.cpp
|
lym953/15721-p3
|
c5ba8004c6f0f10472aa004303c04be1c860ade9
|
[
"Apache-2.0"
] | null | null | null |
test/planner/planner_test.cpp
|
lym953/15721-p3
|
c5ba8004c6f0f10472aa004303c04be1c860ade9
|
[
"Apache-2.0"
] | null | null | null |
//===----------------------------------------------------------------------===//
//
// Peloton
//
// planner_test.cpp
//
// Identification: test/planner/planner_test.cpp
//
// Copyright (c) 2015-17, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#include "catalog/catalog.h"
#include "common/harness.h"
#include "concurrency/transaction_manager_factory.h"
#include "executor/plan_executor.h"
#include "expression/comparison_expression.h"
#include "expression/operator_expression.h"
#include "expression/parameter_value_expression.h"
#include "expression/tuple_value_expression.h"
#include "expression/expression_util.h"
#include "parser/statements.h"
#include "parser/postgresparser.h"
#include "planner/create_plan.h"
#include "planner/delete_plan.h"
#include "planner/drop_plan.h"
#include "planner/attribute_info.h"
#include "planner/plan_util.h"
#include "planner/project_info.h"
#include "planner/seq_scan_plan.h"
#include "planner/update_plan.h"
namespace peloton {
namespace test {
//===--------------------------------------------------------------------===//
// Planner Test
//===--------------------------------------------------------------------===//
class PlannerTest : public PelotonTest {};
TEST_F(PlannerTest, CreateDatabasePlanTest) {
auto& peloton_parser = parser::PostgresParser::GetInstance();
auto parse_tree_list = peloton_parser.BuildParseTree("CREATE DATABASE pelotondb;");
// There should be only one statement in the statement list
EXPECT_EQ(1, parse_tree_list->GetNumStatements());
auto &parse_tree = parse_tree_list->GetStatements().at(0);
std::unique_ptr<planner::CreatePlan> create_DB_plan(
new planner::CreatePlan((parser::CreateStatement *)parse_tree.get())
);
EXPECT_STREQ("pelotondb", create_DB_plan->GetDatabaseName().c_str());
EXPECT_EQ(CreateType::DB, create_DB_plan->GetCreateType());
}
TEST_F(PlannerTest, DropDatabasePlanTest) {
auto& peloton_parser = parser::PostgresParser::GetInstance();
auto parse_tree_list = peloton_parser.BuildParseTree("DROP DATABASE pelotondb;");
// There should be only one statement in the statement list
EXPECT_EQ(1, parse_tree_list->GetNumStatements());
auto &parse_tree = parse_tree_list->GetStatements().at(0);
std::unique_ptr<planner::DropPlan> drop_DB_plan(
new planner::DropPlan((parser::DropStatement *)parse_tree.get())
);
EXPECT_STREQ("pelotondb", drop_DB_plan->GetDatabaseName().c_str());
EXPECT_EQ(DropType::DB, drop_DB_plan->GetDropType());
}
TEST_F(PlannerTest, DeletePlanTestParameter) {
// Bootstrapping peloton
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
auto txn = txn_manager.BeginTransaction();
catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn);
txn_manager.CommitTransaction(txn);
// Create table
txn = txn_manager.BeginTransaction();
auto id_column = catalog::Column(
type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER),
"id", true);
auto name_column = catalog::Column(type::TypeId::VARCHAR, 32, "name", true);
std::unique_ptr<catalog::Schema> table_schema(
new catalog::Schema({id_column, name_column}));
catalog::Catalog::GetInstance()->CreateTable(
DEFAULT_DB_NAME, "department_table", std::move(table_schema), txn);
txn_manager.CommitTransaction(txn);
// DELETE FROM department_table WHERE id = $0
// id = $0
txn = txn_manager.BeginTransaction();
auto *parameter_expr = new expression::ParameterValueExpression(0);
auto *tuple_expr =
new expression::TupleValueExpression(type::TypeId::INTEGER, 0, 0);
auto *scan_expr = new expression::ComparisonExpression(
ExpressionType::COMPARE_EQUAL, tuple_expr, parameter_expr);
auto target_table = catalog::Catalog::GetInstance()->GetTableWithName(
DEFAULT_DB_NAME, "department_table", txn);
// Create delete plan
std::unique_ptr<planner::DeletePlan> delete_plan(
new planner::DeletePlan(target_table));
// Create sequential scan plan
LOG_TRACE("Creating a sequential scan plan");
std::unique_ptr<planner::SeqScanPlan> seq_scan_node(
new planner::SeqScanPlan(target_table, scan_expr, {}));
LOG_INFO("Sequential scan plan created");
// Add seq scan plan
delete_plan->AddChild(std::move(seq_scan_node));
LOG_INFO("Plan created:\n%s",
planner::PlanUtil::GetInfo(delete_plan.get()).c_str());
std::vector<type::Value> values;
// id = 15
LOG_INFO("Binding values");
values.push_back(type::ValueFactory::GetIntegerValue(15).Copy());
// bind values to parameters in plan
delete_plan->SetParameterValues(&values);
// free the database just created
catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn);
txn_manager.CommitTransaction(txn);
}
TEST_F(PlannerTest, UpdatePlanTestParameter) {
// Bootstrapping peloton
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
auto txn = txn_manager.BeginTransaction();
catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn);
txn_manager.CommitTransaction(txn);
// Create table
txn = txn_manager.BeginTransaction();
auto id_column = catalog::Column(
type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER),
"id", true);
auto name_column = catalog::Column(type::TypeId::VARCHAR, 32, "name", true);
std::unique_ptr<catalog::Schema> table_schema(
new catalog::Schema({id_column, name_column}));
catalog::Catalog::GetInstance()->CreateTable(
DEFAULT_DB_NAME, "department_table", std::move(table_schema), txn);
txn_manager.CommitTransaction(txn);
// UPDATE department_table SET name = $0 WHERE id = $1
txn = txn_manager.BeginTransaction();
auto table_name = std::string("department_table");
auto database_name = DEFAULT_DB_NAME;
auto target_table = catalog::Catalog::GetInstance()->GetTableWithName(
database_name, table_name, txn);
auto schema = target_table->GetSchema();
TargetList tlist;
DirectMapList dmlist;
oid_t col_id;
std::vector<oid_t> column_ids;
col_id = schema->GetColumnID(std::string("name"));
column_ids.push_back(col_id);
auto *update_expr = new expression::ParameterValueExpression(0);
planner::DerivedAttribute attribute(update_expr);
attribute.attribute_info.type = update_expr->ResultType();
attribute.attribute_info.name = std::string("name");
tlist.emplace_back(col_id, attribute);
auto *parameter_expr = new expression::ParameterValueExpression(1);
auto *tuple_expr =
new expression::TupleValueExpression(type::TypeId::INTEGER, 0, 0);
auto *where_expr = new expression::ComparisonExpression(
ExpressionType::COMPARE_EQUAL, tuple_expr, parameter_expr);
auto &schema_columns = schema->GetColumns();
for (uint i = 0; i < schema_columns.size(); i++) {
bool is_in_target_list = false;
for (auto col_id : column_ids) {
if (schema_columns[i].column_name == schema_columns[col_id].column_name) {
is_in_target_list = true;
break;
}
}
if (is_in_target_list == false)
dmlist.emplace_back(i, std::pair<oid_t, oid_t>(0, i));
}
column_ids.clear();
for (uint i = 0; i < schema_columns.size(); i++) {
column_ids.emplace_back(i);
}
std::unique_ptr<const planner::ProjectInfo> project_info(
new planner::ProjectInfo(std::move(tlist), std::move(dmlist)));
std::unique_ptr<planner::UpdatePlan> update_plan(
new planner::UpdatePlan(target_table, std::move(project_info)));
std::unique_ptr<planner::SeqScanPlan> seq_scan_node(
new planner::SeqScanPlan(target_table, where_expr, column_ids));
update_plan->AddChild(std::move(seq_scan_node));
LOG_INFO("Plan created:\n%s", update_plan->GetInfo().c_str());
std::vector<type::Value> values;
// name = CS, id = 1
LOG_INFO("Binding values");
values.push_back(type::ValueFactory::GetVarcharValue("CS").Copy());
values.push_back(type::ValueFactory::GetIntegerValue(1).Copy());
// bind values to parameters in plan
update_plan->SetParameterValues(&values);
txn_manager.CommitTransaction(txn);
// free the database just created
txn = txn_manager.BeginTransaction();
catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn);
txn_manager.CommitTransaction(txn);
}
TEST_F(PlannerTest, InsertPlanTestParameter) {
// Bootstrapping peloton
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
auto txn = txn_manager.BeginTransaction();
catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn);
txn_manager.CommitTransaction(txn);
// Create table
txn = txn_manager.BeginTransaction();
auto id_column = catalog::Column(
type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER),
"id", true);
auto name_column = catalog::Column(type::TypeId::VARCHAR, 32, "name", true);
std::unique_ptr<catalog::Schema> table_schema(
new catalog::Schema({id_column, name_column}));
auto ret = catalog::Catalog::GetInstance()->CreateTable(
DEFAULT_DB_NAME, "department_table", std::move(table_schema), txn);
if (ret != ResultType::SUCCESS) LOG_TRACE("create table failed");
txn_manager.CommitTransaction(txn);
// INSERT INTO department_table VALUES ($0, $1)
txn = txn_manager.BeginTransaction();
std::unique_ptr<parser::InsertStatement> insert_statement(
new parser::InsertStatement(peloton::InsertType::VALUES));
std::string name = "department_table";
auto table_ref = new parser::TableRef(TableReferenceType::NAME);
table_ref->table_info_ .reset(new parser::TableInfo());
table_ref->table_info_->table_name = name;
insert_statement->table_ref_.reset(table_ref);
// Value val =
// type::ValueFactory::GetNullValue(); // The value is not important
// at this point
insert_statement->insert_values.push_back(
std::vector<std::unique_ptr<peloton::expression::AbstractExpression>>());
auto& parameter_exprs = insert_statement->insert_values[0];
auto parameter_expr_1 = new expression::ParameterValueExpression(0);
auto parameter_expr_2 = new expression::ParameterValueExpression(1);
parameter_exprs.push_back(std::unique_ptr<expression::AbstractExpression>(parameter_expr_1));
parameter_exprs.push_back(std::unique_ptr<expression::AbstractExpression>(parameter_expr_2));
auto target_table = catalog::Catalog::GetInstance()->GetTableWithName(
DEFAULT_DB_NAME, "department_table", txn);
std::unique_ptr<planner::InsertPlan> insert_plan(new planner::InsertPlan(
target_table, &insert_statement->columns,
&insert_statement->insert_values));
LOG_INFO("Plan created:\n%s", insert_plan->GetInfo().c_str());
// VALUES(1, "CS")
LOG_INFO("Binding values");
std::vector<type::Value> values;
values.push_back(type::ValueFactory::GetIntegerValue(1).Copy());
values.push_back(type::ValueFactory::GetVarcharValue(
(std::string) "CS",
TestingHarness::GetInstance().GetTestingPool()).Copy());
LOG_INFO("Value 1: %s", values.at(0).GetInfo().c_str());
LOG_INFO("Value 2: %s", values.at(1).GetInfo().c_str());
// bind values to parameters in plan
insert_plan->SetParameterValues(&values);
txn_manager.CommitTransaction(txn);
// free the database just created
txn = txn_manager.BeginTransaction();
catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn);
txn_manager.CommitTransaction(txn);
}
TEST_F(PlannerTest, InsertPlanTestParameterColumns) {
// Bootstrapping peloton
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
auto txn = txn_manager.BeginTransaction();
catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn);
txn_manager.CommitTransaction(txn);
// Create table
txn = txn_manager.BeginTransaction();
auto id_column = catalog::Column(
type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER),
"id", true);
auto name_column = catalog::Column(type::TypeId::VARCHAR, 32, "name", true);
std::unique_ptr<catalog::Schema> table_schema(
new catalog::Schema({id_column, name_column}));
catalog::Catalog::GetInstance()->CreateTable(
DEFAULT_DB_NAME, "department_table", std::move(table_schema), txn);
txn_manager.CommitTransaction(txn);
// INSERT INTO department_table VALUES (1, $1)
txn = txn_manager.BeginTransaction();
std::unique_ptr<parser::InsertStatement> insert_statement(
new parser::InsertStatement(peloton::InsertType::VALUES));
std::string name = "department_table";
auto table_ref = new parser::TableRef(TableReferenceType::NAME);
table_ref->table_info_.reset(new parser::TableInfo());
table_ref->table_info_->table_name = name;
std::string id_col = "id", name_col = "name";
insert_statement->table_ref_.reset(table_ref);
insert_statement->columns.push_back(id_col);
insert_statement->columns.push_back(name_col);
// Value val =
// type::ValueFactory::GetNullValue(); // The value is not important
// at this point
auto constant_expr_1 = new expression::ConstantValueExpression(
type::ValueFactory::GetIntegerValue(1));
auto parameter_expr_2 = new expression::ParameterValueExpression(1);
insert_statement->insert_values.push_back(
std::vector<std::unique_ptr<expression::AbstractExpression>>());
auto& exprs = insert_statement->insert_values[0];
exprs.push_back(std::unique_ptr<expression::AbstractExpression>(constant_expr_1));
exprs.push_back(std::unique_ptr<expression::AbstractExpression>(parameter_expr_2));
auto target_table = catalog::Catalog::GetInstance()->GetTableWithName(
DEFAULT_DB_NAME, "department_table", txn);
std::unique_ptr<planner::InsertPlan> insert_plan(new planner::InsertPlan(
target_table, &insert_statement->columns,
&insert_statement->insert_values));
LOG_INFO("Plan created:\n%s", insert_plan->GetInfo().c_str());
// VALUES(1, "CS")
LOG_INFO("Binding values");
std::vector<type::Value> values;
values.push_back(type::ValueFactory::GetVarcharValue(
(std::string) "CS",
TestingHarness::GetInstance().GetTestingPool()).Copy());
LOG_INFO("Value 1: %s", values.at(0).GetInfo().c_str());
// bind values to parameters in plan
insert_plan->SetParameterValues(&values);
txn_manager.CommitTransaction(txn);
// free the database just created
txn = txn_manager.BeginTransaction();
catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn);
txn_manager.CommitTransaction(txn);
}
} // namespace test
} // namespace peloton
| 39.270053
| 95
| 0.716348
|
Nov11
|
f5574313f17211eb9b87dd20071d9b004c846309
| 52
|
cpp
|
C++
|
app/src/data/gobaldata.cpp
|
black-sheep-dev/harbour-webcontrol
|
4feecae04ac07fed106d21abc002b1623fb6b767
|
[
"MIT"
] | 2
|
2021-10-06T12:53:12.000Z
|
2021-10-12T09:07:26.000Z
|
app/src/data/gobaldata.cpp
|
black-sheep-dev/harbour-webcontrol
|
4feecae04ac07fed106d21abc002b1623fb6b767
|
[
"MIT"
] | 3
|
2020-11-08T16:10:33.000Z
|
2021-09-26T06:02:44.000Z
|
app/src/data/gobaldata.cpp
|
black-sheep-dev/harbour-webcontrol
|
4feecae04ac07fed106d21abc002b1623fb6b767
|
[
"MIT"
] | 1
|
2020-11-08T14:54:25.000Z
|
2020-11-08T14:54:25.000Z
|
#include "gobaldata.h"
DataManager* g_dataManager;
| 13
| 27
| 0.788462
|
black-sheep-dev
|
f557b3eb8f32b41ff574f844e4f8ac1217528baf
| 9,924
|
cpp
|
C++
|
inviwo/modules/crystalvisualization/processors/structuremesh.cpp
|
adamskor/ENVISIoN
|
95cf5e74411807e21909f1a0d47b52fd6318a855
|
[
"BSD-2-Clause"
] | 6
|
2017-07-09T21:50:40.000Z
|
2019-02-25T17:21:43.000Z
|
inviwo/modules/crystalvisualization/processors/structuremesh.cpp
|
adamskor/ENVISIoN
|
95cf5e74411807e21909f1a0d47b52fd6318a855
|
[
"BSD-2-Clause"
] | 23
|
2019-05-28T20:50:21.000Z
|
2022-03-25T18:51:31.000Z
|
inviwo/modules/crystalvisualization/processors/structuremesh.cpp
|
adamskor/ENVISIoN
|
95cf5e74411807e21909f1a0d47b52fd6318a855
|
[
"BSD-2-Clause"
] | 9
|
2018-03-20T12:26:05.000Z
|
2021-03-04T10:12:32.000Z
|
/*********************************************************************************
*
* Copyright (c) 2017-2018 Josef Adamsson, Denise Härnström, Anders Rehult,
* Andreas Kempe
*
* Inviwo - Interactive Visualization Workshop
*
* Copyright (c) 2017 Inviwo Foundation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*********************************************************************************/
/*
* Alterations to this file by Anders Rehult, Andreas Kempe and Abdullatif Ismail
*
* To the extent possible under law, the person who associated CC0
* with the alterations to this file has waived all copyright and
* related or neighboring rights to the alterations made to this file.
*
* You should have received a copy of the CC0 legalcode along with
* this work. If not, see
* <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
#include <modules/crystalvisualization/processors/structuremesh.h>
#include <inviwo/core/datastructures/geometry/basicmesh.h>
#include <inviwo/core/interaction/events/pickingevent.h>
#include <inviwo/core/interaction/events/mouseevent.h>
#include <inviwo/core/datastructures/buffer/bufferramprecision.h>
#include <inviwo/core/datastructures/buffer/buffer.h>
namespace inviwo {
// The Class Identifier has to be globally unique. Use a reverse DNS naming scheme
const ProcessorInfo StructureMesh::processorInfo_{
"envision.StructureMesh", // Class identifier
"Structure Mesh", // Display name
"Crystal", // Category
CodeState::Experimental, // Code state
Tags::None, // Tags
};
const ProcessorInfo StructureMesh::getProcessorInfo() const {
return processorInfo_;
}
StructureMesh::StructureMesh()
: Processor()
, structure_("coordinates")
, mesh_("mesh")
, scalingFactor_("scalingFactor", "Scaling factor", 1.f)
, basis_("basis", "Basis", glm::mat3x3())
, fullMesh_("fullMesh", "Full mesh", false)
, animation_("animation", "Animation", false)
, timestep_("timestep", "Time step", false)
, enablePicking_("enablePicking", "Enable Picking", false)
, spherePicking_(this, 0, [&](PickingEvent* p) { handlePicking(p); })
, pickedIndex_("pickedIndex", "Picked atom") {
addPort(structure_);
addPort(mesh_);
addProperty(scalingFactor_);
addProperty(basis_);
addProperty(fullMesh_);
addProperty(animation_);
addProperty(timestep_);
addProperty(enablePicking_);
addProperty(pickedIndex_);
pickedIndex_.setReadOnly(true);
structure_.onChange([&](){
const auto data = structure_.getVectorData();
for(size_t i = colors_.size(); i < data.size(); ++i) {
colors_.push_back(std::make_unique<FloatVec4Property>("color" + toString(i), "Color " + toString(i),
vec4(1.0f, 1.0f, 1.0f, 1.0f), vec4(0.0f), vec4(1.0f), vec4(0.01f),
InvalidationLevel::InvalidOutput, PropertySemantics::Color));
addProperty(colors_.back().get(), false);
radii_.push_back(std::make_unique<FloatProperty>("radius"+ toString(i), "Atom Radius"+ toString(i), 1.0f));
addProperty(radii_.back().get(), false);
num_.push_back(std::make_unique<IntProperty>("atoms" + toString(i), "Atoms" + toString(i), 0));
addProperty(num_.back().get(), false);
}
int numSpheres = 0;
for (const auto &strucs : structure_)
numSpheres += strucs->size();
spherePicking_.resize(numSpheres);
});
}
void StructureMesh::process() {
if (fullMesh_.get()) {
auto mesh = std::make_shared<SphereMesh>();
mesh_.setData(mesh);
size_t ind = 0;
for (const auto &strucs : structure_) {
for (long long j = 0; j < static_cast<long long>(strucs->size()); ++j) {
auto center = scalingFactor_.get() * basis_.get() * strucs->at(j) - 0.5f * (basis_.get()[0] + basis_.get()[1] + basis_.get()[2]);
mesh->addVertex(center, radii_[ind]->get(), colors_[ind]->get());
}
++ind;
}
} else {
if (structure_.isChanged() || animation_.isModified() || std::any_of(num_.begin(), num_.end(),
[](const std::unique_ptr<IntProperty>& property) {
return property->isModified();
}) || enablePicking_.isModified()) {
int numSpheres = 0;
size_t pInd = 0;
for (const auto &strucs : structure_) {
if (animation_.get()) {
numSpheres += num_[pInd]->get();
++pInd;
}
else {
numSpheres += strucs->size();
}
}
vertexRAM_ = std::make_shared<BufferRAMPrecision<vec3>>(numSpheres);
colorRAM_ = std::make_shared<BufferRAMPrecision<vec4>>(numSpheres);
radiiRAM_ = std::make_shared<BufferRAMPrecision<float>>(numSpheres);
auto mesh = std::make_shared<Mesh>(DrawType::Points, ConnectivityType::None);
mesh->addBuffer(Mesh::BufferInfo(BufferType::PositionAttrib),
std::make_shared<Buffer<vec3>>(vertexRAM_));
mesh->addBuffer(Mesh::BufferInfo(BufferType::ColorAttrib),
std::make_shared<Buffer<vec4>>(colorRAM_));
mesh->addBuffer(Mesh::BufferInfo(BufferType::NumberOfBufferTypes, 5),
std::make_shared<Buffer<float>>(radiiRAM_));
mesh_.setData(mesh);
if (enablePicking_.get()) {
auto pickingRAM = std::make_shared<BufferRAMPrecision<uint32_t>>(numSpheres);
auto& data = pickingRAM->getDataContainer();
// fill in picking IDs
std::iota(data.begin(), data.end(), static_cast<uint32_t>(spherePicking_.getPickingId(0)));
mesh->addBuffer(Mesh::BufferInfo(BufferType::NumberOfBufferTypes, 4),
std::make_shared<Buffer<uint32_t>>(pickingRAM));
}
}
auto& vertices = vertexRAM_->getDataContainer();
auto& colors = colorRAM_->getDataContainer();
auto& radii = radiiRAM_->getDataContainer();
size_t portInd = 0;
size_t sphereInd = 0;
for (const auto &strucs : structure_) {
long long j_start, j_stop;
j_start = 0;
j_stop = static_cast<long long>(strucs->size());
if (animation_.get()) {
j_start = num_[portInd]->get() * timestep_.get();
j_stop = num_[portInd]->get() * (timestep_.get() + 1);
}
for (long long j = j_start; j < j_stop ; ++j) {
auto center = scalingFactor_.get() * basis_.get() * strucs->at(j); //- 0.5f * (basis_.get()[0] + basis_.get()[1] + basis_.get()[2]);
vertices[sphereInd] = center;
colors[sphereInd] = colors_[portInd]->get();
radii[sphereInd] = radii_[portInd]->get();
++sphereInd;
}
++portInd;
}
if (enablePicking_.get()) {
//Set alpha-layer of any picked atom
size_t idx = pickedIndex_.get();
if (idx < sphereInd) {
colors[idx].w = 0.5;
}
}
//colorRAM_->getOwner()->invalidateAllOther(colorRAM_.get());
//vertexRAM_->getOwner()->invalidateAllOther(vertexRAM_.get());
//radiiRAM_->getOwner()->invalidateAllOther(radiiRAM_.get());
invalidate(InvalidationLevel::InvalidOutput);
}
}
void StructureMesh::handlePicking(PickingEvent* p) {
if (enablePicking_.get()) {
if (p->getState() == PickingState::Updated &&
p->getEvent()->hash() == MouseEvent::chash()) {
auto me = p->getEventAs<MouseEvent>();
if ((me->buttonState() & MouseButton::Left) && me->state() != MouseState::Move) {
size_t currentlyPicked = pickedIndex_.get();
size_t picked = p->getPickedId();
// A different atom has been selected, change the
// colours to mach the selection.
if (picked != currentlyPicked) {
auto& color = colorRAM_->getDataContainer();
color[currentlyPicked].w = 1;
color[picked].w = 0.5;
pickedIndex_.set(picked);
////colorRAM_->getOwner()->invalidateAllOther(colorRAM_.get());
invalidate(InvalidationLevel::InvalidOutput);
}
p->markAsUsed();
}
}
}
}
} // namespace
| 42.050847
| 148
| 0.598851
|
adamskor
|
f557cf3c0769ebc7ff424e11d87ed2f5d6b593aa
| 1,227
|
cc
|
C++
|
longest-increasing-subsequence.cc
|
ArCan314/leetcode
|
8e22790dc2f34f5cf2892741ff4e5d492bb6d0dd
|
[
"MIT"
] | null | null | null |
longest-increasing-subsequence.cc
|
ArCan314/leetcode
|
8e22790dc2f34f5cf2892741ff4e5d492bb6d0dd
|
[
"MIT"
] | null | null | null |
longest-increasing-subsequence.cc
|
ArCan314/leetcode
|
8e22790dc2f34f5cf2892741ff4e5d492bb6d0dd
|
[
"MIT"
] | null | null | null |
#include <vector>
#include <algorithm>
class Solution
{
public:
int lengthOfLIS(std::vector<int> &nums)
{
return lengthOfLISDpOpt(nums);
}
int lengthOfLISDp(std::vector<int> &nums)
{
std::vector<int> dp(nums.size(), 1);
for (int i = 0; i < nums.size(); i++)
for (int j = 0; j < i; j++)
if (nums[i] < nums[j])
dp[i] = std::max(dp[i], dp[j] + 1);
return *std::max_element(nums.begin(), nums.end());
}
int lengthOfLISDpOpt(std::vector<int> &nums)
{
std::vector<int> dp;
dp.push_back(nums[0]);
for (int i = 1; i < nums.size(); i++)
{
if (nums[i] > dp.back())
dp.push_back(nums[i]);
else if (nums[i] < dp.back())
{
int left = 0, right = dp.size() - 1;
while (left < right)
{
int mid = (left + right) / 2;
if (dp[mid] < nums[i])
left = mid + 1;
else
right = mid;
}
dp[left] = nums[i];
}
}
return dp.size();
}
};
| 25.040816
| 59
| 0.396088
|
ArCan314
|
f5590ff0c6e2900d5904703e7bdb9814ac67de33
| 5,914
|
cc
|
C++
|
orttraining/orttraining/training_ops/cuda/tensor/gather_elements_grad.cc
|
lchang20/onnxruntime
|
97b8f6f394ae02c73ed775f456fd85639c91ced1
|
[
"MIT"
] | 6,036
|
2019-05-07T06:03:57.000Z
|
2022-03-31T17:59:54.000Z
|
orttraining/orttraining/training_ops/cuda/tensor/gather_elements_grad.cc
|
lchang20/onnxruntime
|
97b8f6f394ae02c73ed775f456fd85639c91ced1
|
[
"MIT"
] | 5,730
|
2019-05-06T23:04:55.000Z
|
2022-03-31T23:55:56.000Z
|
orttraining/orttraining/training_ops/cuda/tensor/gather_elements_grad.cc
|
lchang20/onnxruntime
|
97b8f6f394ae02c73ed775f456fd85639c91ced1
|
[
"MIT"
] | 1,566
|
2019-05-07T01:30:07.000Z
|
2022-03-31T17:06:50.000Z
|
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "orttraining/training_ops/cuda/tensor/gather_elements_grad.h"
#include "orttraining/training_ops/cuda/tensor/gather_elements_grad_impl.h"
#include "core/providers/cpu/tensor/utils.h"
#include "core/providers/common.h"
namespace onnxruntime {
namespace cuda {
ONNX_OPERATOR_KERNEL_EX(
GatherElementsGrad,
kMSDomain,
1,
kCudaExecutionProvider,
(*KernelDefBuilder::Create())
.InputMemoryType(OrtMemTypeCPUInput, 1) // 'GatherElements' data shape needs to be on CPU
.TypeConstraint("T", DataTypeImpl::AllIEEEFloatTensorTypes())
.TypeConstraint("I", DataTypeImpl::GetTensorType<int64_t>())
.TypeConstraint("Tind", std::vector<MLDataType>{DataTypeImpl::GetTensorType<int32_t>(),
DataTypeImpl::GetTensorType<int64_t>()}),
GatherElementsGrad);
template <typename T>
struct GatherElementsGrad::ComputeImpl {
Status operator()(cudaStream_t stream,
const Tensor* dY,
const Tensor* indices_tensor,
Tensor* dX,
const int rank,
TArray<int64_t>& buffer_output_dims,
TArray<int64_t>& buffer_input_strides,
const int64_t indices_size,
TArray<int64_t>& buffer_indices_dims,
TArray<fast_divmod>& fdm_indices_strides,
const int axis) const {
T* output_data = dX->template MutableData<T>();
const T* update_data = dY->template Data<T>();
typedef typename ToCudaType<T>::MappedType CudaT;
MLDataType Tin_type = indices_tensor->DataType();
if (utils::IsPrimitiveDataType<int32_t>(Tin_type)) {
const int32_t* indices_data = indices_tensor->template Data<int32_t>();
return GatherElementsGradImpl(
stream,
rank,
buffer_output_dims,
buffer_input_strides,
indices_data,
indices_size,
buffer_indices_dims,
fdm_indices_strides,
reinterpret_cast<const CudaT*>(update_data),
axis,
reinterpret_cast<CudaT*>(output_data));
} else if (utils::IsPrimitiveDataType<int64_t>(Tin_type)) {
const int64_t* indices_data = indices_tensor->template Data<int64_t>();
return GatherElementsGradImpl(
stream,
rank,
buffer_output_dims,
buffer_input_strides,
indices_data,
indices_size,
buffer_indices_dims,
fdm_indices_strides,
reinterpret_cast<const CudaT*>(update_data),
axis,
reinterpret_cast<CudaT*>(output_data));
}
return ORT_MAKE_STATUS(ONNXRUNTIME, NOT_IMPLEMENTED, "Type for Tin is not supported yet in ScatterElements.");
}
};
Status GatherElementsGrad::ComputeInternal(OpKernelContext* context) const {
const auto* dY = context->Input<Tensor>(0);
const Tensor* shape = context->Input<Tensor>(1);
const TensorShape data_shape(shape->template Data<int64_t>(), shape->Shape().Size());
const int axis = static_cast<int>(HandleNegativeAxis(axis_, data_shape.NumDimensions()));
const auto* indices_tensor = context->Input<Tensor>(2);
const auto& indices_dims = indices_tensor->Shape().GetDims();
const int64_t indices_size = indices_tensor->Shape().Size();
const auto& dY_dims = dY->Shape().GetDims();
if (indices_dims.size() != dY_dims.size()) {
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT,
"Indices and dY must have the same rank");
}
for (size_t i = 0; i < indices_dims.size(); ++i) {
if (indices_dims[i] != dY_dims[i]) {
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "Indices vs dY dimensions differs at position=", i,
" ", indices_dims[i], " vs ", dY_dims[i]);
}
}
// According to the spec the rank of ind/upd shall be the same as output(data)
// and we also want to make sure that the dimensions of the of the ind/upd do not
// exceed that of the output
const auto& output_dims = data_shape.GetDims();
if (output_dims.size() != indices_dims.size()) {
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "Indices must have the same rank as Output. Indices rank=",
indices_dims.size(), ". Output rank=", output_dims.size());
}
for (size_t i = 0; i < output_dims.size(); ++i) {
// For all axes except the axis of interest, make sure that the corresponding 'indices' shape
// value is within bounds of the corresponding 'data' shape.
if (static_cast<int64_t>(i) != axis_ && output_dims[i] < indices_dims[i]) {
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "Indices dim=", indices_dims[i], " at pos=", i,
" is greater than Output dim=", output_dims[i]);
}
}
int rank = static_cast<int>(output_dims.size());
Tensor* dX = context->Output(0, data_shape);
CUDA_RETURN_IF_ERROR(cudaMemsetAsync(dX->MutableDataRaw(), 0, dX->SizeInBytes(), Stream()));
TArray<int64_t> buffer_output_dims(output_dims);
TensorPitches input_strides(output_dims);
TArray<int64_t> buffer_input_strides(input_strides);
TArray<int64_t> buffer_indices_dims(indices_dims);
TArray<fast_divmod> fdm_indices_strides(rank);
TensorPitches indices_strides(indices_dims);
for (auto i = 0; i < rank; i++) {
fdm_indices_strides[i] = fast_divmod(static_cast<int>(indices_strides[i]));
}
utils::MLTypeCallDispatcher<MLFloat16, float, double> t_disp(dY->GetElementType());
return t_disp.InvokeRet<Status, ComputeImpl>(
Stream(), dY, indices_tensor, dX, rank,
buffer_output_dims, buffer_input_strides, indices_size,
buffer_indices_dims, fdm_indices_strides, axis);
}
} // namespace cuda
} // namespace onnxruntime
| 41.356643
| 117
| 0.664694
|
lchang20
|
f5591aae36e45b4c6d59fb2cb0ef9773ba8b351c
| 1,871
|
cpp
|
C++
|
basic/mobile_io/02f_feedback_background_mobile_io.cpp
|
HebiRobotics/hebi-cpp-examples
|
db01c9b957b3c97885d452d8b72f9919ba6c48c4
|
[
"Apache-2.0"
] | 7
|
2018-03-31T06:52:08.000Z
|
2022-02-24T21:27:09.000Z
|
basic/mobile_io/02f_feedback_background_mobile_io.cpp
|
HebiRobotics/hebi-cpp-examples
|
db01c9b957b3c97885d452d8b72f9919ba6c48c4
|
[
"Apache-2.0"
] | 34
|
2018-06-03T17:28:08.000Z
|
2021-05-29T01:15:25.000Z
|
basic/mobile_io/02f_feedback_background_mobile_io.cpp
|
HebiRobotics/hebi-cpp-examples
|
db01c9b957b3c97885d452d8b72f9919ba6c48c4
|
[
"Apache-2.0"
] | 9
|
2018-02-08T22:50:58.000Z
|
2021-03-30T08:07:35.000Z
|
/*
* Get feedback from a mobile io module and plot it live
*
* For more information, go to http://docs.hebi.us/tools.html#cpp-api
*
* HEBI Robotics
* August 2019
*/
#include <chrono>
#include <iostream>
#include <thread>
#include "lookup.hpp"
#include "group_feedback.hpp"
#include "util/plot_functions.h"
namespace plt = matplotlibcpp;
using namespace hebi;
int main() {
// Find your module on the network
Lookup lookup;
std::string family_name("HEBI");
std::string module_name("Mobile IO");
auto group = lookup.getGroupFromNames({family_name}, {module_name});
// Confirm the module is found before preceding
if (!group) {
std::cout << "Group not found!" << std::endl;
return -1;
}
// Set the feedback frequency.
// This is by default "100"; setting this to 5 here allows the console output
// to be more reasonable.
group -> setFeedbackFrequencyHz(5);
// Add a callback to react to feedback received on a background thread
// Note: We use a C++11 "lambda function" here to pass in a function pointer,
// but you can also pass in a C-style function pointer with the signature:
// void func(const hebi::GroupFeedback& group_fbk);
std::vector<double> y;
group->addFeedbackHandler([&y](const GroupFeedback& group_fbk)
{
auto gyro = group_fbk.getGyro();
y = {gyro(0,0), gyro(0,1), gyro(0,2)};
// Plot the feedback
std::vector<std::string> x_labels = {"X", "Y", "Z"};
std::vector<double> x_ticks = {0.0, 1.0, 2.0};
plt::clf();
plt::ylim(-3.14, 3.14);
plt::xticks(x_ticks, x_labels);
plt::xlabel("Axis");
plt::ylabel("Angular Velocity (rad/s)");
plt::bar(y);
plt::pause(0.01);
});
// Wait 10 seconds, and then stop and clear threads
std::this_thread::sleep_for(std::chrono::milliseconds(10000));
group -> clearFeedbackHandlers();
return 0;
}
| 26.728571
| 79
| 0.660075
|
HebiRobotics
|
f55a4792607360637b43c251f017136708be5bb5
| 1,554
|
cpp
|
C++
|
ThreadArray.cpp
|
esc0rtd3w/GTAV_PS3_NativeCall
|
32324900e8cdc2f35355c0b54d0b6a5dc9883586
|
[
"Apache-2.0"
] | 4
|
2016-03-11T00:54:09.000Z
|
2021-09-08T23:19:36.000Z
|
ThreadArray.cpp
|
balika011/GTAV_PS3_NativeCall
|
32324900e8cdc2f35355c0b54d0b6a5dc9883586
|
[
"Apache-2.0"
] | null | null | null |
ThreadArray.cpp
|
balika011/GTAV_PS3_NativeCall
|
32324900e8cdc2f35355c0b54d0b6a5dc9883586
|
[
"Apache-2.0"
] | 2
|
2017-08-20T08:46:36.000Z
|
2019-02-03T13:11:28.000Z
|
#include "main.h"
#define THREAD_ARRAY_ADDR 0x01E5FE80
#define THREAD_COUNT_ADDR 0x01E5FE84
#define threadArray ((struct sysArray<scrThread>*)THREAD_ARRAY_ADDR);
#define threadCount (*(int*)(THREAD_COUNT_ADDR));
scrThread* ThreadArray::GetThreadByName(char* name)
{
scrThread* ret = 0;
int i = 0;
while(i < threadArray->uCount && ret == 0 && threadArray->pData != 0)
{
if(threadArray->pData[i]->m_iThreadID)
if(strcmp(threadArray->pData[i]->m_szScriptName, name) == 0)
ret = threadArray->pData[i];
++i;
}
return ret;
}
scrThread* ThreadArray::GetThreadByHash(unsigned int hash)
{
scrThread* ret = 0;
int i = 0;
while(i < threadArray->uCount && ret == 0 && threadArray->pData != 0)
{
if(threadArray->pData[i]->m_iThreadID)
if(threadArray->pData[i]->m_iThreadHash == hash)
ret = threadArray->pData[i];
++i;
}
return ret;
}
void ThreadArray::DbgShowAllThread()
{
int i = 0;
while(i < threadArray->uCount)
{
if(threadArray->pData[i]->m_iThreadID)
printf("Id %d: Thread id %d - %s\n", i, threadArray->pData[i]->m_iThreadID, threadArray->pData[i]->m_szScriptName);
++i;
}
printf("Count %d\n", threadArray->uCount);
}
scrThread* ThreadArray::NewThread(char* name)
{
int i = 0;
while(i < threadArray->uCount && threadArray->pData[i]->m_iThreadID != 0)
++i;
// we failed to find a free slot
if(i == threadArray->uCount)
return 0;
scrThread* newThread = new scrThread(name);
threadArray->pData[i] = newThread;
newThread->m_iThreadID = ++threadCount;
newThread->reset();
return newThread;
}
| 21.887324
| 118
| 0.67825
|
esc0rtd3w
|
f55a51784c168b3437ae9308188579183fd093d7
| 1,486
|
cpp
|
C++
|
src/engine/actor.cpp
|
0916dhkim/SimplePlatformer
|
f00a985c9f754139759fedbff6a24bd7665030f9
|
[
"Apache-2.0"
] | null | null | null |
src/engine/actor.cpp
|
0916dhkim/SimplePlatformer
|
f00a985c9f754139759fedbff6a24bd7665030f9
|
[
"Apache-2.0"
] | null | null | null |
src/engine/actor.cpp
|
0916dhkim/SimplePlatformer
|
f00a985c9f754139759fedbff6a24bd7665030f9
|
[
"Apache-2.0"
] | null | null | null |
#include <engine/actor.hpp>
Actor::Actor(std::uint_fast64_t id) : id(id), layer(0) {}
void Actor::SetBody(std::unique_ptr<PhysicalBody> &&physical_body) { this->body = std::move(physical_body); }
void Actor::SetRenderer(std::unique_ptr<Renderer> &&renderer) { this->renderer = std::move(renderer); }
void Actor::SetPosition(const b2Vec2 &position) {
transform.SetPosition(position);
if (body != nullptr) {
body->SetPosition(position);
}
}
void Actor::SetPosition(float x, float y) {
transform.SetPosition(x, y);
if (body != nullptr) {
body->SetPosition(b2Vec2(x, y));
}
}
void Actor::SetRotation(float rotation) {
transform.SetRotation(rotation);
if (body != nullptr) {
body->SetRotation(rotation);
}
}
Transform &Actor::GetTransform() { return transform; }
std::set<std::string> Actor::GetTags() const {
// Copy tags set and return.
return std::set<std::string>(tags);
}
void Actor::AddTag(const std::string &tag) { tags.insert(tag); }
void Actor::RemoveTag(const std::string &tag) { tags.erase(tag); }
bool Actor::HasTag(const std::string &tag) const {
auto t = tags.find(tag);
if (t == tags.end()) {
// No match
return false;
}
return true;
}
void Actor::Render(const Camera &camera) const {
if (renderer != nullptr) {
renderer->Render(camera);
}
}
void Actor::UpdateActorTransform() {
if (body != nullptr) {
transform.SetPosition(body->GetPosition());
transform.SetRotation(body->GetRotation());
}
}
| 24.360656
| 109
| 0.66891
|
0916dhkim
|
f560f0b6eacdab2a247d5cf25f7b6408d6a3b0c5
| 2,797
|
cpp
|
C++
|
middleware/src/generator/mesh/cube_shape.cpp
|
TerraGraphics/TerraEngine
|
874165a22ab7dd3774a6cfdeb023485a552d9860
|
[
"Apache-2.0"
] | 5
|
2019-12-24T21:43:13.000Z
|
2020-06-16T03:44:16.000Z
|
middleware/src/generator/mesh/cube_shape.cpp
|
TerraGraphics/TerraEngine
|
874165a22ab7dd3774a6cfdeb023485a552d9860
|
[
"Apache-2.0"
] | null | null | null |
middleware/src/generator/mesh/cube_shape.cpp
|
TerraGraphics/TerraEngine
|
874165a22ab7dd3774a6cfdeb023485a552d9860
|
[
"Apache-2.0"
] | 1
|
2020-03-30T00:17:27.000Z
|
2020-03-30T00:17:27.000Z
|
#include "middleware/generator/mesh/cube_shape.h"
#include <memory>
#include <utility>
#include <type_traits>
#include "core/common/exception.h"
static auto MakeGenerator(const dg::float3 sizes, const dg::uint3 segments) {
float offset = sizes.z * 0.5f;
dg::float2 size = {sizes.x, sizes.y};
dg::uint2 sg = {segments.x, segments.y};
math::Axis2 axes = {math::Axis::X, math::Axis::Y};
auto p0 = PlaneShape(axes, math::Direction::POS_Z, size, sg);
p0.SetCenter({0, 0, offset});
auto p1 = PlaneShape(axes, math::Direction::NEG_Z, size, sg);
p1.SetCenter({0, 0, -offset});
offset = sizes.x * 0.5f;
size = {sizes.y, sizes.z};
sg = {segments.y, segments.z};
axes = {math::Axis::Y, math::Axis::Z};
auto p2 = PlaneShape(axes, math::Direction::POS_X, size, sg);
p2.SetCenter({offset, 0, 0});
auto p3 = PlaneShape(axes, math::Direction::NEG_X, size, sg);
p3.SetCenter({-offset, 0, 0});
offset = sizes.y * 0.5f;
size = {sizes.z, sizes.x};
sg = {segments.z, segments.x};
axes = {math::Axis::Z, math::Axis::X};
auto p4 = PlaneShape(axes, math::Direction::POS_Y, size, sg);
p4.SetCenter({0, offset, 0});
auto p5 = PlaneShape(axes, math::Direction::NEG_Y, size, sg);
p5.SetCenter({0, -offset, 0});
return MergeShape<PlaneShape, PlaneShape, PlaneShape, PlaneShape, PlaneShape, PlaneShape>(
std::move(p0),
std::move(p1),
std::move(p2),
std::move(p3),
std::move(p4),
std::move(p5));
}
CubeShape::CubeShape(const dg::float3 sizes, const dg::uint3 segments)
: Shape("CubeShape", {math::Axis::X, math::Axis::Y, math::Axis::Z})
, m_generator(MakeGenerator(sizes, segments)) {
if (segments.x < 1) {
throw EngineError("minimum value for segments.x in CubeShape is 1");
}
if (segments.y < 1) {
throw EngineError("minimum value for segments.y in CubeShape is 1");
}
if (segments.z < 1) {
throw EngineError("minimum value for segments.z in CubeShape is 1");
}
if (sizes.x < 0) {
throw EngineError("minimum value for sizes.x in CubeShape is greater than 0");
}
if (sizes.y < 0) {
throw EngineError("minimum value for sizes.y in CubeShape is greater than 0");
}
if (sizes.z < 0) {
throw EngineError("minimum value for sizes.z in CubeShape is greater than 0");
}
SetGenerator(&m_generator);
}
CubeShape::CubeShape(CubeShape&& other) noexcept
: Shape(std::move(other))
, m_generator(std::move(other.m_generator)) {
SetGenerator(&m_generator);
}
CubeShape& CubeShape::operator=(CubeShape&& other) noexcept {
Shape::operator=(std::move(other));
m_generator = std::move(other.m_generator);
SetGenerator(&m_generator);
return *this;
}
| 32.523256
| 94
| 0.626385
|
TerraGraphics
|
f56128b2033187724c7d23af81c68307e0e3f51c
| 857
|
cpp
|
C++
|
foobar2000/SDK/main_thread_callback.cpp
|
ttsping/foo_fix
|
4a0b950ccb8c10c912a9abeeffdd85e777463309
|
[
"Info-ZIP"
] | 294
|
2017-11-20T17:42:08.000Z
|
2022-03-31T04:15:13.000Z
|
foobar2000/SDK/main_thread_callback.cpp
|
ttsping/foo_fix
|
4a0b950ccb8c10c912a9abeeffdd85e777463309
|
[
"Info-ZIP"
] | 108
|
2021-04-08T10:57:27.000Z
|
2022-03-27T08:02:15.000Z
|
foobar2000/SDK/main_thread_callback.cpp
|
ttsping/foo_fix
|
4a0b950ccb8c10c912a9abeeffdd85e777463309
|
[
"Info-ZIP"
] | 14
|
2018-03-10T12:47:03.000Z
|
2021-11-11T09:00:08.000Z
|
#include "foobar2000.h"
void main_thread_callback::callback_enqueue() {
main_thread_callback_manager::get()->add_callback(this);
}
void main_thread_callback_add(main_thread_callback::ptr ptr) {
main_thread_callback_manager::get()->add_callback(ptr);
}
namespace {
typedef std::function<void ()> func_t;
class mtcallback_func : public main_thread_callback {
public:
mtcallback_func(func_t const & f) : m_f(f) {}
void callback_run() {
m_f();
}
private:
func_t m_f;
};
}
void fb2k::inMainThread( std::function<void () > f ) {
main_thread_callback_add( new service_impl_t<mtcallback_func>(f));
}
void fb2k::inMainThread2( std::function<void () > f ) {
if ( core_api::is_main_thread() ) {
f();
} else {
inMainThread(f);
}
}
| 22.552632
| 71
| 0.62077
|
ttsping
|
f5612a9a9cbccb0feb246b085e3e1225df11c4db
| 4,839
|
cpp
|
C++
|
source/pawgui.cpp
|
pawbyte/pawgui
|
24e77f4ce40bd0e91f5f5edc27cc87ff5783d0ab
|
[
"MIT"
] | 2
|
2020-03-09T14:29:42.000Z
|
2021-02-06T05:07:39.000Z
|
source/pawgui.cpp
|
pawbyte/pawgui
|
24e77f4ce40bd0e91f5f5edc27cc87ff5783d0ab
|
[
"MIT"
] | null | null | null |
source/pawgui.cpp
|
pawbyte/pawgui
|
24e77f4ce40bd0e91f5f5edc27cc87ff5783d0ab
|
[
"MIT"
] | null | null | null |
/*
pawgui.cpp
This file is part of:
PawByte Ambitious Working GUI(PAWGUI)
https://www.pawbyte.com/pawgui
Copyright (c) 2014-2020 Nathan Hurde, Chase Lee.
Copyright (c) 2014-2020 PawByte LLC.
Copyright (c) 2014-2020 PawByte Ambitious Working GUI(PAWGUI) contributors ( Contributors Page )
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.
-PawByte Ambitious Working GUI(PAWGUI) <https://www.pawbyte.com/pawgui>
*/
#include "pawgui.h"
namespace pawgui
{
bool init_gui( std::string mono_font_location, int font_min_size )
{
//gpe::cursor_main_controller->cursor_create_from_image( gpe::app_directory_name + "resources/gfx/iconpacks/fontawesome/asterisk.png" );
rsm_gui = new gpe::asset_manager( gpe::rph->get_default_render_package(), "pawgui");
if( load_default_fonts( mono_font_location, font_min_size) )
{
gpe::error_log->report("IDE properly added all PawGUI Fonts... \n");
popup_font_size_width = 12;
popup_font_size_height = 12;
if( font_popup!=NULL)
{
font_popup->get_metrics("A",&popup_font_size_width,&popup_font_size_height);
}
}
else
{
gpe::error_log->report("Unable to load PawGUI Fonts!\n");
return false;
}
main_settings = new gui_settings();
main_overlay_system = new overlay_system();
main_loader_display = new loader_display();
main_search_controller = new search_controller();
if( main_settings!=NULL && main_overlay_system!=NULL && main_search_controller!=NULL )
{
main_context_menu = new popup_menu_option(" ",-1,false,false,true);
main_context_menu->isTopOfMenu = true;
texture_color_picker_gradient = rsm_gui->texture_add_filename( gpe::app_directory_name+"resources/gfx/textures/color_picker_gradient.png" );
std::string colorPickerFilename = gpe::app_directory_name+"resources/gfx/textures/color_picker_gradient.png";
checkmark_texture = rsm_gui->texture_add_filename( gpe::app_directory_name+"resources/gfx/iconpacks/fontawesome/chevron-down.png");
dropdown_arrow_texture = rsm_gui->texture_add_filename( gpe::app_directory_name+"resources/gfx/iconpacks/fontawesome/angle-down.png");
eyedropper_texture = rsm_gui->texture_add_filename( gpe::app_directory_name+"resources/gfx/iconpacks/fontawesome/eyedropper.png");
main_scrollbar_arrow = rsm_gui->animation_add("guiScrollArrowDown", gpe::app_directory_name+"resources/gfx/iconpacks/fontawesome/caret-down.png",1,true,0,0,false);
return true;
}
return false;
}
bool quit_gui()
{
gpe::error_log->report("Deleting PAWGUI ....");
texture_color_picker_gradient = NULL;
if( main_overlay_system !=NULL)
{
delete main_overlay_system;
main_overlay_system = NULL;
}
if( main_loader_display !=NULL)
{
delete main_loader_display;
main_loader_display = NULL;
}
if( main_search_controller !=NULL)
{
delete main_search_controller;
main_search_controller = NULL;
}
if( main_settings !=NULL)
{
delete main_settings;
main_settings = NULL;
}
gpe::error_log->report("Deleting mini-code-highlighter....");
if( main_syntax_highlighter!=NULL)
{
delete main_syntax_highlighter;
main_syntax_highlighter = NULL;
}
if( rsm_gui!=NULL )
{
delete rsm_gui;
rsm_gui = NULL;
}
return true;
}
}
| 39.991736
| 176
| 0.65902
|
pawbyte
|
f56253d59fc5c13df8a30aea81798adeb68e743f
| 5,242
|
cpp
|
C++
|
dbms/src/Interpreters/tests/hash_map2.cpp
|
rudneff/ClickHouse
|
3cb59b92bccbeb888d136f7c6e14b622382c0434
|
[
"Apache-2.0"
] | 3
|
2016-12-30T14:19:47.000Z
|
2021-11-13T06:58:32.000Z
|
dbms/src/Interpreters/tests/hash_map2.cpp
|
rudneff/ClickHouse
|
3cb59b92bccbeb888d136f7c6e14b622382c0434
|
[
"Apache-2.0"
] | 1
|
2017-01-13T21:29:36.000Z
|
2017-01-16T18:29:08.000Z
|
dbms/src/Interpreters/tests/hash_map2.cpp
|
jbfavre/clickhouse-debian
|
3806e3370decb40066f15627a3bca4063b992bfb
|
[
"Apache-2.0"
] | 1
|
2021-02-07T16:00:54.000Z
|
2021-02-07T16:00:54.000Z
|
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <sparsehash/dense_hash_map>
#include <sparsehash/sparse_hash_map>
#include <DB/Common/Stopwatch.h>
//#define DBMS_HASH_MAP_COUNT_COLLISIONS
#define DBMS_HASH_MAP_DEBUG_RESIZES
#include <DB/Core/Types.h>
#include <DB/IO/ReadBufferFromFile.h>
#include <DB/IO/CompressedReadBuffer.h>
#include <DB/Common/HashTable/HashMap.h>
using Key = UInt64;
using Value = UInt64;
struct CellWithoutZeroWithSavedHash : public HashMapCell<Key, Value, DefaultHash<Key> >
{
// size_t saved_hash;
static constexpr bool need_zero_value_storage = false;
CellWithoutZeroWithSavedHash() : HashMapCell() {}
CellWithoutZeroWithSavedHash(const Key & key_, const State & state) : HashMapCell(key_, state) {}
CellWithoutZeroWithSavedHash(const value_type & value_, const State & state) : HashMapCell(value_, state) {}
/* bool keyEquals(const Key & key_) const { return value.first == key_; }
bool keyEquals(const CellWithoutZeroWithSavedHash & other) const { return saved_hash == other.saved_hash && value.first == other.value.first; }
void setHash(size_t hash_value) { saved_hash = hash_value; }
size_t getHash(const DefaultHash<Key> & hash) const { return saved_hash; }*/
};
struct Grower : public HashTableGrower<>
{
/// Состояние этой структуры достаточно, чтобы получить размер буфера хэш-таблицы.
/// Определяет начальный размер хэш-таблицы.
static const size_t initial_size_degree = 16;
Grower() { size_degree = initial_size_degree; }
// size_t max_fill = (1 << initial_size_degree) * 0.9;
/// Размер хэш-таблицы в ячейках.
size_t bufSize() const { return 1 << size_degree; }
size_t maxFill() const { return 1 << (size_degree - 1); }
// size_t maxFill() const { return max_fill; }
size_t mask() const { return bufSize() - 1; }
/// Из значения хэш-функции получить номер ячейки в хэш-таблице.
size_t place(size_t x) const { return x & mask(); }
/// Следующая ячейка в цепочке разрешения коллизий.
size_t next(size_t pos) const { ++pos; return pos & mask(); }
/// Является ли хэш-таблица достаточно заполненной. Нужно увеличить размер хэш-таблицы, или удалить из неё что-нибудь ненужное.
bool overflow(size_t elems) const { return elems > maxFill(); }
/// Увеличить размер хэш-таблицы.
void increaseSize()
{
size_degree += size_degree >= 23 ? 1 : 2;
// max_fill = (1 << size_degree) * 0.9;
}
/// Установить размер буфера по количеству элементов хэш-таблицы. Используется при десериализации хэш-таблицы.
void set(size_t num_elems)
{
throw Poco::Exception(__PRETTY_FUNCTION__);
}
};
int main(int argc, char ** argv)
{
size_t n = atoi(argv[1]);
size_t m = atoi(argv[2]);
std::vector<Key> data(n);
std::cerr << "sizeof(Key) = " << sizeof(Key) << ", sizeof(Value) = " << sizeof(Value) << std::endl;
{
Stopwatch watch;
DB::ReadBufferFromFileDescriptor in1(STDIN_FILENO);
DB::CompressedReadBuffer in2(in1);
in2.readStrict(reinterpret_cast<char*>(&data[0]), sizeof(data[0]) * n);
watch.stop();
std::cerr << std::fixed << std::setprecision(2)
<< "Vector. Size: " << n
<< ", elapsed: " << watch.elapsedSeconds()
<< " (" << n / watch.elapsedSeconds() << " elem/sec.)"
<< std::endl;
}
if (m == 1)
{
Stopwatch watch;
// using Map = HashMap<Key, Value>;
/// Из-за WithoutZero быстрее на 0.7% (для не влезающей в L3-кэш) - 2.3% (для влезающей в L3-кэш).
using Map = HashMapTable<Key, CellWithoutZeroWithSavedHash, DefaultHash<Key>, Grower>;
Map map;
Map::iterator it;
bool inserted;
for (size_t i = 0; i < n; ++i)
{
map.emplace(data[i], it, inserted);
if (inserted)
it->second = 0;
++it->second;
}
watch.stop();
std::cerr << std::fixed << std::setprecision(2)
<< "HashMap. Size: " << map.size()
<< ", elapsed: " << watch.elapsedSeconds()
<< " (" << n / watch.elapsedSeconds() << " elem/sec.)"
#ifdef DBMS_HASH_MAP_COUNT_COLLISIONS
<< ", collisions: " << map.getCollisions()
#endif
<< std::endl;
}
if (m == 2)
{
Stopwatch watch;
std::unordered_map<Key, Value, DefaultHash<Key> > map;
for (size_t i = 0; i < n; ++i)
++map[data[i]];
watch.stop();
std::cerr << std::fixed << std::setprecision(2)
<< "std::unordered_map. Size: " << map.size()
<< ", elapsed: " << watch.elapsedSeconds()
<< " (" << n / watch.elapsedSeconds() << " elem/sec.)"
<< std::endl;
}
if (m == 3)
{
Stopwatch watch;
google::dense_hash_map<Key, Value, DefaultHash<Key> > map;
map.set_empty_key(-1ULL);
for (size_t i = 0; i < n; ++i)
++map[data[i]];
watch.stop();
std::cerr << std::fixed << std::setprecision(2)
<< "google::dense_hash_map. Size: " << map.size()
<< ", elapsed: " << watch.elapsedSeconds()
<< " (" << n / watch.elapsedSeconds() << " elem/sec.)"
<< std::endl;
}
if (m == 4)
{
Stopwatch watch;
google::sparse_hash_map<Key, Value, DefaultHash<Key> > map;
for (size_t i = 0; i < n; ++i)
++map[data[i]];
watch.stop();
std::cerr << std::fixed << std::setprecision(2)
<< "google::sparse_hash_map. Size: " << map.size()
<< ", elapsed: " << watch.elapsedSeconds()
<< " (" << n / watch.elapsedSeconds() << " elem/sec.)"
<< std::endl;
}
return 0;
}
| 27.589474
| 144
| 0.652804
|
rudneff
|
f563a4bf59faf71e966c828d6b867c36dbb7ce80
| 1,249
|
cc
|
C++
|
src/core/analysis/dictionary_node_creator.cc
|
wrightak/jumanpp
|
49784bac7ee9562f1839aa12c780b019a1cb0e03
|
[
"Apache-2.0"
] | 300
|
2016-10-19T02:20:39.000Z
|
2022-02-23T19:58:04.000Z
|
src/core/analysis/dictionary_node_creator.cc
|
wrightak/jumanpp
|
49784bac7ee9562f1839aa12c780b019a1cb0e03
|
[
"Apache-2.0"
] | 130
|
2016-10-17T07:57:14.000Z
|
2022-03-20T17:37:13.000Z
|
src/core/analysis/dictionary_node_creator.cc
|
wrightak/jumanpp
|
49784bac7ee9562f1839aa12c780b019a1cb0e03
|
[
"Apache-2.0"
] | 36
|
2016-10-19T11:47:05.000Z
|
2022-01-25T09:36:12.000Z
|
//
// Created by Arseny Tolmachev on 2017/02/23.
//
#include "dictionary_node_creator.h"
namespace jumanpp {
namespace core {
namespace analysis {
bool DictionaryNodeCreator::spawnNodes(const AnalysisInput& input,
LatticeBuilder* lattice) {
auto& points = input.codepoints();
LatticePosition totalPoints = (LatticePosition)points.size();
for (LatticePosition begin = 0; begin < totalPoints; ++begin) {
auto trav = entries_.traversal();
using dic::TraverseStatus;
for (LatticePosition position = begin; position < totalPoints; ++position) {
auto& cp = points[position];
TraverseStatus status = trav.step(cp.bytes);
if (status == TraverseStatus::Ok) {
LatticePosition end = position + LatticePosition(1);
auto dicEntries = trav.entries();
while (dicEntries.readOnePtr()) {
lattice->appendSeed(dicEntries.currentPtr(), begin, end);
}
} else if (status == TraverseStatus::NoNode) {
break;
}
}
}
return true;
}
DictionaryNodeCreator::DictionaryNodeCreator(
const dic::DictionaryEntries& entries_)
: entries_(entries_) {}
} // namespace analysis
} // namespace core
} // namespace jumanpp
| 26.574468
| 80
| 0.653323
|
wrightak
|
f5642cb7c14deaa7da323181761683888433836b
| 575,048
|
cpp
|
C++
|
cisco-ios-xe/ydk/models/cisco_ios_xe/fragmented/Cisco_IOS_XE_native_216.cpp
|
CiscoDevNet/ydk-cpp
|
ef7d75970f2ef1154100e0f7b0a2ee823609b481
|
[
"ECL-2.0",
"Apache-2.0"
] | 17
|
2016-12-02T05:45:49.000Z
|
2022-02-10T19:32:54.000Z
|
cisco-ios-xe/ydk/models/cisco_ios_xe/fragmented/Cisco_IOS_XE_native_216.cpp
|
CiscoDevNet/ydk-cpp
|
ef7d75970f2ef1154100e0f7b0a2ee823609b481
|
[
"ECL-2.0",
"Apache-2.0"
] | 2
|
2017-03-27T15:22:38.000Z
|
2019-11-05T08:30:16.000Z
|
cisco-ios-xe/ydk/models/cisco_ios_xe/fragmented/Cisco_IOS_XE_native_216.cpp
|
CiscoDevNet/ydk-cpp
|
ef7d75970f2ef1154100e0f7b0a2ee823609b481
|
[
"ECL-2.0",
"Apache-2.0"
] | 11
|
2016-12-02T05:45:52.000Z
|
2019-11-07T08:28:17.000Z
|
#include <sstream>
#include <iostream>
#include <ydk/entity_util.hpp>
#include "bundle_info.hpp"
#include "generated_entity_lookup.hpp"
#include "Cisco_IOS_XE_native_216.hpp"
using namespace ydk;
namespace cisco_ios_xe {
namespace Cisco_IOS_XE_native {
Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::TrafficShare()
:
balanced{YType::empty, "balanced"}
,
min(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::Min>())
{
min->parent = this;
yang_name = "traffic-share"; yang_parent_name = "af-ip-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::~TrafficShare()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::has_data() const
{
if (is_presence_container) return true;
return balanced.is_set
|| (min != nullptr && min->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(balanced.yfilter)
|| (min != nullptr && min->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "traffic-share";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (balanced.is_set || is_set(balanced.yfilter)) leaf_name_data.push_back(balanced.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "min")
{
if(min == nullptr)
{
min = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::Min>();
}
return min;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(min != nullptr)
{
_children["min"] = min;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "balanced")
{
balanced = value;
balanced.value_namespace = name_space;
balanced.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "balanced")
{
balanced.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "min" || name == "balanced")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::Min::Min()
:
across_interfaces{YType::empty, "across-interfaces"}
{
yang_name = "min"; yang_parent_name = "traffic-share"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::Min::~Min()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::Min::has_data() const
{
if (is_presence_container) return true;
return across_interfaces.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::Min::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(across_interfaces.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::Min::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "min";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::Min::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (across_interfaces.is_set || is_set(across_interfaces.yfilter)) leaf_name_data.push_back(across_interfaces.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::Min::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::Min::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::Min::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "across-interfaces")
{
across_interfaces = value;
across_interfaces.value_namespace = name_space;
across_interfaces.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::Min::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "across-interfaces")
{
across_interfaces.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::TrafficShare::Min::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "across-interfaces")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Topology()
:
base(nullptr) // presence node
{
yang_name = "topology"; yang_parent_name = "af-ip-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::~Topology()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::has_data() const
{
if (is_presence_container) return true;
return (base != nullptr && base->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::has_operation() const
{
return is_set(yfilter)
|| (base != nullptr && base->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "topology";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "base")
{
if(base == nullptr)
{
base = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base>();
}
return base;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(base != nullptr)
{
_children["base"] = base;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "base")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Base()
:
distance(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance>())
, distribute_list(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList>())
, redistribute(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute>())
, summary_metric(this, {"ipv4_addr_slash_prefix_len"})
{
distance->parent = this;
distribute_list->parent = this;
redistribute->parent = this;
yang_name = "base"; yang_parent_name = "topology"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::~Base()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<summary_metric.len(); index++)
{
if(summary_metric[index]->has_data())
return true;
}
return (distance != nullptr && distance->has_data())
|| (distribute_list != nullptr && distribute_list->has_data())
|| (redistribute != nullptr && redistribute->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::has_operation() const
{
for (std::size_t index=0; index<summary_metric.len(); index++)
{
if(summary_metric[index]->has_operation())
return true;
}
return is_set(yfilter)
|| (distance != nullptr && distance->has_operation())
|| (distribute_list != nullptr && distribute_list->has_operation())
|| (redistribute != nullptr && redistribute->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "base";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "distance")
{
if(distance == nullptr)
{
distance = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance>();
}
return distance;
}
if(child_yang_name == "distribute-list")
{
if(distribute_list == nullptr)
{
distribute_list = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList>();
}
return distribute_list;
}
if(child_yang_name == "redistribute")
{
if(redistribute == nullptr)
{
redistribute = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute>();
}
return redistribute;
}
if(child_yang_name == "summary-metric")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric>();
ent_->parent = this;
summary_metric.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(distance != nullptr)
{
_children["distance"] = distance;
}
if(distribute_list != nullptr)
{
_children["distribute-list"] = distribute_list;
}
if(redistribute != nullptr)
{
_children["redistribute"] = redistribute;
}
count_ = 0;
for (auto ent_ : summary_metric.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "distance" || name == "distribute-list" || name == "redistribute" || name == "summary-metric")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Distance()
:
eigrp(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_>())
{
eigrp->parent = this;
yang_name = "distance"; yang_parent_name = "base"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::~Distance()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::has_data() const
{
if (is_presence_container) return true;
return (eigrp != nullptr && eigrp->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::has_operation() const
{
return is_set(yfilter)
|| (eigrp != nullptr && eigrp->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "distance";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "eigrp")
{
if(eigrp == nullptr)
{
eigrp = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_>();
}
return eigrp;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(eigrp != nullptr)
{
_children["eigrp"] = eigrp;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "eigrp")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::Eigrp_()
:
distance_list(this, {"internal_route"})
{
yang_name = "eigrp"; yang_parent_name = "distance"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::~Eigrp_()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<distance_list.len(); index++)
{
if(distance_list[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::has_operation() const
{
for (std::size_t index=0; index<distance_list.len(); index++)
{
if(distance_list[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "eigrp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "distance-list")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::DistanceList>();
ent_->parent = this;
distance_list.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : distance_list.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "distance-list")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::DistanceList::DistanceList()
:
internal_route{YType::uint8, "internal-route"},
external_route{YType::uint8, "external-route"}
{
yang_name = "distance-list"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::DistanceList::~DistanceList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::DistanceList::has_data() const
{
if (is_presence_container) return true;
return internal_route.is_set
|| external_route.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::DistanceList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(internal_route.yfilter)
|| ydk::is_set(external_route.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::DistanceList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "distance-list";
ADD_KEY_TOKEN(internal_route, "internal-route");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::DistanceList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (internal_route.is_set || is_set(internal_route.yfilter)) leaf_name_data.push_back(internal_route.get_name_leafdata());
if (external_route.is_set || is_set(external_route.yfilter)) leaf_name_data.push_back(external_route.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::DistanceList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::DistanceList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::DistanceList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "internal-route")
{
internal_route = value;
internal_route.value_namespace = name_space;
internal_route.value_namespace_prefix = name_space_prefix;
}
if(value_path == "external-route")
{
external_route = value;
external_route.value_namespace = name_space;
external_route.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::DistanceList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "internal-route")
{
internal_route.yfilter = yfilter;
}
if(value_path == "external-route")
{
external_route.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Distance::Eigrp_::DistanceList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "internal-route" || name == "external-route")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::DistributeList()
:
prefix_list(this, {"prefix_list"})
, route_map(this, {"name"})
{
yang_name = "distribute-list"; yang_parent_name = "base"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::~DistributeList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<prefix_list.len(); index++)
{
if(prefix_list[index]->has_data())
return true;
}
for (std::size_t index=0; index<route_map.len(); index++)
{
if(route_map[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::has_operation() const
{
for (std::size_t index=0; index<prefix_list.len(); index++)
{
if(prefix_list[index]->has_operation())
return true;
}
for (std::size_t index=0; index<route_map.len(); index++)
{
if(route_map[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "distribute-list";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "prefix-list")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::PrefixList>();
ent_->parent = this;
prefix_list.append(ent_);
return ent_;
}
if(child_yang_name == "route-map")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::RouteMap>();
ent_->parent = this;
route_map.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : prefix_list.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : route_map.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "prefix-list" || name == "route-map")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::PrefixList::PrefixList()
:
prefix_list{YType::str, "prefix-list"},
gateway{YType::empty, "gateway"},
in{YType::empty, "in"},
out{YType::empty, "out"}
{
yang_name = "prefix-list"; yang_parent_name = "distribute-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::PrefixList::~PrefixList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::PrefixList::has_data() const
{
if (is_presence_container) return true;
return prefix_list.is_set
|| gateway.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::PrefixList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(prefix_list.yfilter)
|| ydk::is_set(gateway.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::PrefixList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "prefix-list";
ADD_KEY_TOKEN(prefix_list, "prefix-list");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::PrefixList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (prefix_list.is_set || is_set(prefix_list.yfilter)) leaf_name_data.push_back(prefix_list.get_name_leafdata());
if (gateway.is_set || is_set(gateway.yfilter)) leaf_name_data.push_back(gateway.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::PrefixList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::PrefixList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::PrefixList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "prefix-list")
{
prefix_list = value;
prefix_list.value_namespace = name_space;
prefix_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "gateway")
{
gateway = value;
gateway.value_namespace = name_space;
gateway.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::PrefixList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
if(value_path == "gateway")
{
gateway.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::PrefixList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "prefix-list" || name == "gateway" || name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::RouteMap::RouteMap()
:
name{YType::str, "name"},
in{YType::str, "in"},
out{YType::str, "out"}
{
yang_name = "route-map"; yang_parent_name = "distribute-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::RouteMap::~RouteMap()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::RouteMap::has_data() const
{
if (is_presence_container) return true;
return name.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::RouteMap::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(name.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::RouteMap::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "route-map";
ADD_KEY_TOKEN(name, "name");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::RouteMap::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (name.is_set || is_set(name.yfilter)) leaf_name_data.push_back(name.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::RouteMap::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::RouteMap::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::RouteMap::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "name")
{
name = value;
name.value_namespace = name_space;
name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::RouteMap::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "name")
{
name.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::DistributeList::RouteMap::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "name" || name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Redistribute()
:
connected{YType::empty, "connected"}
,
eigrp(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_>())
, ospf(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf>())
, static_(nullptr) // presence node
{
eigrp->parent = this;
ospf->parent = this;
yang_name = "redistribute"; yang_parent_name = "base"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::~Redistribute()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::has_data() const
{
if (is_presence_container) return true;
return connected.is_set
|| (eigrp != nullptr && eigrp->has_data())
|| (ospf != nullptr && ospf->has_data())
|| (static_ != nullptr && static_->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(connected.yfilter)
|| (eigrp != nullptr && eigrp->has_operation())
|| (ospf != nullptr && ospf->has_operation())
|| (static_ != nullptr && static_->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "redistribute";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (connected.is_set || is_set(connected.yfilter)) leaf_name_data.push_back(connected.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "eigrp")
{
if(eigrp == nullptr)
{
eigrp = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_>();
}
return eigrp;
}
if(child_yang_name == "ospf")
{
if(ospf == nullptr)
{
ospf = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf>();
}
return ospf;
}
if(child_yang_name == "static")
{
if(static_ == nullptr)
{
static_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Static>();
}
return static_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(eigrp != nullptr)
{
_children["eigrp"] = eigrp;
}
if(ospf != nullptr)
{
_children["ospf"] = ospf;
}
if(static_ != nullptr)
{
_children["static"] = static_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "connected")
{
connected = value;
connected.value_namespace = name_space;
connected.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "connected")
{
connected.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "eigrp" || name == "ospf" || name == "static" || name == "connected")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::Eigrp_()
:
as_list(this, {"autonomous_system"})
{
yang_name = "eigrp"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::~Eigrp_()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<as_list.len(); index++)
{
if(as_list[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::has_operation() const
{
for (std::size_t index=0; index<as_list.len(); index++)
{
if(as_list[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "eigrp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "as-list")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::AsList>();
ent_->parent = this;
as_list.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : as_list.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "as-list")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::AsList::AsList()
:
autonomous_system{YType::uint16, "autonomous-system"}
{
yang_name = "as-list"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::AsList::~AsList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::AsList::has_data() const
{
if (is_presence_container) return true;
return autonomous_system.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::AsList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(autonomous_system.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::AsList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "as-list";
ADD_KEY_TOKEN(autonomous_system, "autonomous-system");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::AsList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (autonomous_system.is_set || is_set(autonomous_system.yfilter)) leaf_name_data.push_back(autonomous_system.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::AsList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::AsList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::AsList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "autonomous-system")
{
autonomous_system = value;
autonomous_system.value_namespace = name_space;
autonomous_system.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::AsList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "autonomous-system")
{
autonomous_system.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Eigrp_::AsList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "autonomous-system")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::Ospf()
:
pid_list(this, {"process_id"})
{
yang_name = "ospf"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::~Ospf()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<pid_list.len(); index++)
{
if(pid_list[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::has_operation() const
{
for (std::size_t index=0; index<pid_list.len(); index++)
{
if(pid_list[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ospf";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "pid-list")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::PidList>();
ent_->parent = this;
pid_list.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : pid_list.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "pid-list")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::PidList::PidList()
:
process_id{YType::uint16, "process-id"}
{
yang_name = "pid-list"; yang_parent_name = "ospf"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::PidList::~PidList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::PidList::has_data() const
{
if (is_presence_container) return true;
return process_id.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::PidList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(process_id.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::PidList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "pid-list";
ADD_KEY_TOKEN(process_id, "process-id");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::PidList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (process_id.is_set || is_set(process_id.yfilter)) leaf_name_data.push_back(process_id.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::PidList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::PidList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::PidList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "process-id")
{
process_id = value;
process_id.value_namespace = name_space;
process_id.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::PidList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "process-id")
{
process_id.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Ospf::PidList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "process-id")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Static::Static()
{
yang_name = "static"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Static::~Static()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Static::has_data() const
{
if (is_presence_container) return true;
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Static::has_operation() const
{
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Static::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "static";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Static::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Static::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Static::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Static::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Static::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::Redistribute::Static::has_leaf_or_child_of_name(const std::string & name) const
{
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::SummaryMetric()
:
ipv4_addr_slash_prefix_len{YType::str, "ipv4-addr-slash-prefix-len"},
distance{YType::uint8, "distance"}
,
metric(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::Metric>())
{
metric->parent = this;
yang_name = "summary-metric"; yang_parent_name = "base"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::~SummaryMetric()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::has_data() const
{
if (is_presence_container) return true;
return ipv4_addr_slash_prefix_len.is_set
|| distance.is_set
|| (metric != nullptr && metric->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ipv4_addr_slash_prefix_len.yfilter)
|| ydk::is_set(distance.yfilter)
|| (metric != nullptr && metric->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "summary-metric";
ADD_KEY_TOKEN(ipv4_addr_slash_prefix_len, "ipv4-addr-slash-prefix-len");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ipv4_addr_slash_prefix_len.is_set || is_set(ipv4_addr_slash_prefix_len.yfilter)) leaf_name_data.push_back(ipv4_addr_slash_prefix_len.get_name_leafdata());
if (distance.is_set || is_set(distance.yfilter)) leaf_name_data.push_back(distance.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "metric")
{
if(metric == nullptr)
{
metric = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::Metric>();
}
return metric;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(metric != nullptr)
{
_children["metric"] = metric;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ipv4-addr-slash-prefix-len")
{
ipv4_addr_slash_prefix_len = value;
ipv4_addr_slash_prefix_len.value_namespace = name_space;
ipv4_addr_slash_prefix_len.value_namespace_prefix = name_space_prefix;
}
if(value_path == "distance")
{
distance = value;
distance.value_namespace = name_space;
distance.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ipv4-addr-slash-prefix-len")
{
ipv4_addr_slash_prefix_len.yfilter = yfilter;
}
if(value_path == "distance")
{
distance.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "metric" || name == "ipv4-addr-slash-prefix-len" || name == "distance")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::Metric::Metric()
:
bandwidth_metric{YType::uint32, "bandwidth-metric"},
delay_metric{YType::uint32, "delay-metric"},
reliability_metric{YType::uint8, "reliability-metric"},
effective_bandwidth_metric{YType::uint8, "effective-bandwidth-metric"},
mtu{YType::uint16, "mtu"}
{
yang_name = "metric"; yang_parent_name = "summary-metric"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::Metric::~Metric()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::Metric::has_data() const
{
if (is_presence_container) return true;
return bandwidth_metric.is_set
|| delay_metric.is_set
|| reliability_metric.is_set
|| effective_bandwidth_metric.is_set
|| mtu.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::Metric::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(bandwidth_metric.yfilter)
|| ydk::is_set(delay_metric.yfilter)
|| ydk::is_set(reliability_metric.yfilter)
|| ydk::is_set(effective_bandwidth_metric.yfilter)
|| ydk::is_set(mtu.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::Metric::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "metric";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::Metric::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (bandwidth_metric.is_set || is_set(bandwidth_metric.yfilter)) leaf_name_data.push_back(bandwidth_metric.get_name_leafdata());
if (delay_metric.is_set || is_set(delay_metric.yfilter)) leaf_name_data.push_back(delay_metric.get_name_leafdata());
if (reliability_metric.is_set || is_set(reliability_metric.yfilter)) leaf_name_data.push_back(reliability_metric.get_name_leafdata());
if (effective_bandwidth_metric.is_set || is_set(effective_bandwidth_metric.yfilter)) leaf_name_data.push_back(effective_bandwidth_metric.get_name_leafdata());
if (mtu.is_set || is_set(mtu.yfilter)) leaf_name_data.push_back(mtu.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::Metric::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::Metric::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::Metric::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "bandwidth-metric")
{
bandwidth_metric = value;
bandwidth_metric.value_namespace = name_space;
bandwidth_metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "delay-metric")
{
delay_metric = value;
delay_metric.value_namespace = name_space;
delay_metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "reliability-metric")
{
reliability_metric = value;
reliability_metric.value_namespace = name_space;
reliability_metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "effective-bandwidth-metric")
{
effective_bandwidth_metric = value;
effective_bandwidth_metric.value_namespace = name_space;
effective_bandwidth_metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "mtu")
{
mtu = value;
mtu.value_namespace = name_space;
mtu.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::Metric::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "bandwidth-metric")
{
bandwidth_metric.yfilter = yfilter;
}
if(value_path == "delay-metric")
{
delay_metric.yfilter = yfilter;
}
if(value_path == "reliability-metric")
{
reliability_metric.yfilter = yfilter;
}
if(value_path == "effective-bandwidth-metric")
{
effective_bandwidth_metric.yfilter = yfilter;
}
if(value_path == "mtu")
{
mtu.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpList::Topology::Base::SummaryMetric::Metric::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "bandwidth-metric" || name == "delay-metric" || name == "reliability-metric" || name == "effective-bandwidth-metric" || name == "mtu")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfIpVrfList()
:
vrf{YType::str, "vrf"},
unicast_multicast{YType::enumeration, "unicast-multicast"},
autonomous_system{YType::uint16, "autonomous-system"},
auto_summary{YType::empty, "auto-summary"},
maximum_paths{YType::uint8, "maximum-paths"},
nsf{YType::empty, "nsf"},
shutdown{YType::empty, "shutdown"},
variance{YType::uint8, "variance"}
,
af_interface(this, {"name"})
, set_as_in_submode(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::SetAsInSubmode>())
, bfd(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd>())
, default_information(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation>())
, default_metric(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric>())
, distance(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance>())
, distribute_list(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList>())
, eigrp(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_>())
, metric(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Metric>())
, neighbor(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor>())
, network(this, {"number"})
, offset_list(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList>())
, redistribute(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute>())
, summary_metric(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric>())
, timers(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers>())
, traffic_share(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare>())
, topology(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology>())
{
set_as_in_submode->parent = this;
bfd->parent = this;
default_information->parent = this;
default_metric->parent = this;
distance->parent = this;
distribute_list->parent = this;
eigrp->parent = this;
metric->parent = this;
neighbor->parent = this;
offset_list->parent = this;
redistribute->parent = this;
summary_metric->parent = this;
timers->parent = this;
traffic_share->parent = this;
topology->parent = this;
yang_name = "af-ip-vrf-list"; yang_parent_name = "address-family"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::~AfIpVrfList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<af_interface.len(); index++)
{
if(af_interface[index]->has_data())
return true;
}
for (std::size_t index=0; index<network.len(); index++)
{
if(network[index]->has_data())
return true;
}
return vrf.is_set
|| unicast_multicast.is_set
|| autonomous_system.is_set
|| auto_summary.is_set
|| maximum_paths.is_set
|| nsf.is_set
|| shutdown.is_set
|| variance.is_set
|| (set_as_in_submode != nullptr && set_as_in_submode->has_data())
|| (bfd != nullptr && bfd->has_data())
|| (default_information != nullptr && default_information->has_data())
|| (default_metric != nullptr && default_metric->has_data())
|| (distance != nullptr && distance->has_data())
|| (distribute_list != nullptr && distribute_list->has_data())
|| (eigrp != nullptr && eigrp->has_data())
|| (metric != nullptr && metric->has_data())
|| (neighbor != nullptr && neighbor->has_data())
|| (offset_list != nullptr && offset_list->has_data())
|| (redistribute != nullptr && redistribute->has_data())
|| (summary_metric != nullptr && summary_metric->has_data())
|| (timers != nullptr && timers->has_data())
|| (traffic_share != nullptr && traffic_share->has_data())
|| (topology != nullptr && topology->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::has_operation() const
{
for (std::size_t index=0; index<af_interface.len(); index++)
{
if(af_interface[index]->has_operation())
return true;
}
for (std::size_t index=0; index<network.len(); index++)
{
if(network[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(vrf.yfilter)
|| ydk::is_set(unicast_multicast.yfilter)
|| ydk::is_set(autonomous_system.yfilter)
|| ydk::is_set(auto_summary.yfilter)
|| ydk::is_set(maximum_paths.yfilter)
|| ydk::is_set(nsf.yfilter)
|| ydk::is_set(shutdown.yfilter)
|| ydk::is_set(variance.yfilter)
|| (set_as_in_submode != nullptr && set_as_in_submode->has_operation())
|| (bfd != nullptr && bfd->has_operation())
|| (default_information != nullptr && default_information->has_operation())
|| (default_metric != nullptr && default_metric->has_operation())
|| (distance != nullptr && distance->has_operation())
|| (distribute_list != nullptr && distribute_list->has_operation())
|| (eigrp != nullptr && eigrp->has_operation())
|| (metric != nullptr && metric->has_operation())
|| (neighbor != nullptr && neighbor->has_operation())
|| (offset_list != nullptr && offset_list->has_operation())
|| (redistribute != nullptr && redistribute->has_operation())
|| (summary_metric != nullptr && summary_metric->has_operation())
|| (timers != nullptr && timers->has_operation())
|| (traffic_share != nullptr && traffic_share->has_operation())
|| (topology != nullptr && topology->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "af-ip-vrf-list";
ADD_KEY_TOKEN(vrf, "vrf");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (vrf.is_set || is_set(vrf.yfilter)) leaf_name_data.push_back(vrf.get_name_leafdata());
if (unicast_multicast.is_set || is_set(unicast_multicast.yfilter)) leaf_name_data.push_back(unicast_multicast.get_name_leafdata());
if (autonomous_system.is_set || is_set(autonomous_system.yfilter)) leaf_name_data.push_back(autonomous_system.get_name_leafdata());
if (auto_summary.is_set || is_set(auto_summary.yfilter)) leaf_name_data.push_back(auto_summary.get_name_leafdata());
if (maximum_paths.is_set || is_set(maximum_paths.yfilter)) leaf_name_data.push_back(maximum_paths.get_name_leafdata());
if (nsf.is_set || is_set(nsf.yfilter)) leaf_name_data.push_back(nsf.get_name_leafdata());
if (shutdown.is_set || is_set(shutdown.yfilter)) leaf_name_data.push_back(shutdown.get_name_leafdata());
if (variance.is_set || is_set(variance.yfilter)) leaf_name_data.push_back(variance.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "af-interface")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface>();
ent_->parent = this;
af_interface.append(ent_);
return ent_;
}
if(child_yang_name == "set-as-in-submode")
{
if(set_as_in_submode == nullptr)
{
set_as_in_submode = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::SetAsInSubmode>();
}
return set_as_in_submode;
}
if(child_yang_name == "bfd")
{
if(bfd == nullptr)
{
bfd = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd>();
}
return bfd;
}
if(child_yang_name == "default-information")
{
if(default_information == nullptr)
{
default_information = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation>();
}
return default_information;
}
if(child_yang_name == "default-metric")
{
if(default_metric == nullptr)
{
default_metric = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric>();
}
return default_metric;
}
if(child_yang_name == "distance")
{
if(distance == nullptr)
{
distance = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance>();
}
return distance;
}
if(child_yang_name == "distribute-list")
{
if(distribute_list == nullptr)
{
distribute_list = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList>();
}
return distribute_list;
}
if(child_yang_name == "eigrp")
{
if(eigrp == nullptr)
{
eigrp = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_>();
}
return eigrp;
}
if(child_yang_name == "metric")
{
if(metric == nullptr)
{
metric = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Metric>();
}
return metric;
}
if(child_yang_name == "neighbor")
{
if(neighbor == nullptr)
{
neighbor = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor>();
}
return neighbor;
}
if(child_yang_name == "network")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Network>();
ent_->parent = this;
network.append(ent_);
return ent_;
}
if(child_yang_name == "offset-list")
{
if(offset_list == nullptr)
{
offset_list = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList>();
}
return offset_list;
}
if(child_yang_name == "redistribute")
{
if(redistribute == nullptr)
{
redistribute = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute>();
}
return redistribute;
}
if(child_yang_name == "summary-metric")
{
if(summary_metric == nullptr)
{
summary_metric = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric>();
}
return summary_metric;
}
if(child_yang_name == "timers")
{
if(timers == nullptr)
{
timers = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers>();
}
return timers;
}
if(child_yang_name == "traffic-share")
{
if(traffic_share == nullptr)
{
traffic_share = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare>();
}
return traffic_share;
}
if(child_yang_name == "topology")
{
if(topology == nullptr)
{
topology = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology>();
}
return topology;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : af_interface.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
if(set_as_in_submode != nullptr)
{
_children["set-as-in-submode"] = set_as_in_submode;
}
if(bfd != nullptr)
{
_children["bfd"] = bfd;
}
if(default_information != nullptr)
{
_children["default-information"] = default_information;
}
if(default_metric != nullptr)
{
_children["default-metric"] = default_metric;
}
if(distance != nullptr)
{
_children["distance"] = distance;
}
if(distribute_list != nullptr)
{
_children["distribute-list"] = distribute_list;
}
if(eigrp != nullptr)
{
_children["eigrp"] = eigrp;
}
if(metric != nullptr)
{
_children["metric"] = metric;
}
if(neighbor != nullptr)
{
_children["neighbor"] = neighbor;
}
count_ = 0;
for (auto ent_ : network.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
if(offset_list != nullptr)
{
_children["offset-list"] = offset_list;
}
if(redistribute != nullptr)
{
_children["redistribute"] = redistribute;
}
if(summary_metric != nullptr)
{
_children["summary-metric"] = summary_metric;
}
if(timers != nullptr)
{
_children["timers"] = timers;
}
if(traffic_share != nullptr)
{
_children["traffic-share"] = traffic_share;
}
if(topology != nullptr)
{
_children["topology"] = topology;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "vrf")
{
vrf = value;
vrf.value_namespace = name_space;
vrf.value_namespace_prefix = name_space_prefix;
}
if(value_path == "unicast-multicast")
{
unicast_multicast = value;
unicast_multicast.value_namespace = name_space;
unicast_multicast.value_namespace_prefix = name_space_prefix;
}
if(value_path == "autonomous-system")
{
autonomous_system = value;
autonomous_system.value_namespace = name_space;
autonomous_system.value_namespace_prefix = name_space_prefix;
}
if(value_path == "auto-summary")
{
auto_summary = value;
auto_summary.value_namespace = name_space;
auto_summary.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;
}
if(value_path == "nsf")
{
nsf = value;
nsf.value_namespace = name_space;
nsf.value_namespace_prefix = name_space_prefix;
}
if(value_path == "shutdown")
{
shutdown = value;
shutdown.value_namespace = name_space;
shutdown.value_namespace_prefix = name_space_prefix;
}
if(value_path == "variance")
{
variance = value;
variance.value_namespace = name_space;
variance.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "vrf")
{
vrf.yfilter = yfilter;
}
if(value_path == "unicast-multicast")
{
unicast_multicast.yfilter = yfilter;
}
if(value_path == "autonomous-system")
{
autonomous_system.yfilter = yfilter;
}
if(value_path == "auto-summary")
{
auto_summary.yfilter = yfilter;
}
if(value_path == "maximum-paths")
{
maximum_paths.yfilter = yfilter;
}
if(value_path == "nsf")
{
nsf.yfilter = yfilter;
}
if(value_path == "shutdown")
{
shutdown.yfilter = yfilter;
}
if(value_path == "variance")
{
variance.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "af-interface" || name == "set-as-in-submode" || name == "bfd" || name == "default-information" || name == "default-metric" || name == "distance" || name == "distribute-list" || name == "eigrp" || name == "metric" || name == "neighbor" || name == "network" || name == "offset-list" || name == "redistribute" || name == "summary-metric" || name == "timers" || name == "traffic-share" || name == "topology" || name == "vrf" || name == "unicast-multicast" || name == "autonomous-system" || name == "auto-summary" || name == "maximum-paths" || name == "nsf" || name == "shutdown" || name == "variance")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::AfInterface()
:
name{YType::str, "name"},
bandwidth_percent{YType::uint32, "bandwidth-percent"},
hello_interval{YType::uint16, "hello-interval"},
hold_time{YType::uint16, "hold-time"},
passive_interface{YType::boolean, "passive-interface"},
split_horizon{YType::boolean, "split-horizon"}
,
stub_site(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::StubSite>())
, authentication(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication>())
, summary_address(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::SummaryAddress>())
{
stub_site->parent = this;
authentication->parent = this;
summary_address->parent = this;
yang_name = "af-interface"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::~AfInterface()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::has_data() const
{
if (is_presence_container) return true;
return name.is_set
|| bandwidth_percent.is_set
|| hello_interval.is_set
|| hold_time.is_set
|| passive_interface.is_set
|| split_horizon.is_set
|| (stub_site != nullptr && stub_site->has_data())
|| (authentication != nullptr && authentication->has_data())
|| (summary_address != nullptr && summary_address->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(name.yfilter)
|| ydk::is_set(bandwidth_percent.yfilter)
|| ydk::is_set(hello_interval.yfilter)
|| ydk::is_set(hold_time.yfilter)
|| ydk::is_set(passive_interface.yfilter)
|| ydk::is_set(split_horizon.yfilter)
|| (stub_site != nullptr && stub_site->has_operation())
|| (authentication != nullptr && authentication->has_operation())
|| (summary_address != nullptr && summary_address->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "af-interface";
ADD_KEY_TOKEN(name, "name");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (name.is_set || is_set(name.yfilter)) leaf_name_data.push_back(name.get_name_leafdata());
if (bandwidth_percent.is_set || is_set(bandwidth_percent.yfilter)) leaf_name_data.push_back(bandwidth_percent.get_name_leafdata());
if (hello_interval.is_set || is_set(hello_interval.yfilter)) leaf_name_data.push_back(hello_interval.get_name_leafdata());
if (hold_time.is_set || is_set(hold_time.yfilter)) leaf_name_data.push_back(hold_time.get_name_leafdata());
if (passive_interface.is_set || is_set(passive_interface.yfilter)) leaf_name_data.push_back(passive_interface.get_name_leafdata());
if (split_horizon.is_set || is_set(split_horizon.yfilter)) leaf_name_data.push_back(split_horizon.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "stub-site")
{
if(stub_site == nullptr)
{
stub_site = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::StubSite>();
}
return stub_site;
}
if(child_yang_name == "authentication")
{
if(authentication == nullptr)
{
authentication = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication>();
}
return authentication;
}
if(child_yang_name == "summary-address")
{
if(summary_address == nullptr)
{
summary_address = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::SummaryAddress>();
}
return summary_address;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(stub_site != nullptr)
{
_children["stub-site"] = stub_site;
}
if(authentication != nullptr)
{
_children["authentication"] = authentication;
}
if(summary_address != nullptr)
{
_children["summary-address"] = summary_address;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "name")
{
name = value;
name.value_namespace = name_space;
name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "bandwidth-percent")
{
bandwidth_percent = value;
bandwidth_percent.value_namespace = name_space;
bandwidth_percent.value_namespace_prefix = name_space_prefix;
}
if(value_path == "hello-interval")
{
hello_interval = value;
hello_interval.value_namespace = name_space;
hello_interval.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 == "passive-interface")
{
passive_interface = value;
passive_interface.value_namespace = name_space;
passive_interface.value_namespace_prefix = name_space_prefix;
}
if(value_path == "split-horizon")
{
split_horizon = value;
split_horizon.value_namespace = name_space;
split_horizon.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "name")
{
name.yfilter = yfilter;
}
if(value_path == "bandwidth-percent")
{
bandwidth_percent.yfilter = yfilter;
}
if(value_path == "hello-interval")
{
hello_interval.yfilter = yfilter;
}
if(value_path == "hold-time")
{
hold_time.yfilter = yfilter;
}
if(value_path == "passive-interface")
{
passive_interface.yfilter = yfilter;
}
if(value_path == "split-horizon")
{
split_horizon.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "stub-site" || name == "authentication" || name == "summary-address" || name == "name" || name == "bandwidth-percent" || name == "hello-interval" || name == "hold-time" || name == "passive-interface" || name == "split-horizon")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::StubSite::StubSite()
:
wan_interface{YType::empty, "wan-interface"}
{
yang_name = "stub-site"; yang_parent_name = "af-interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::StubSite::~StubSite()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::StubSite::has_data() const
{
if (is_presence_container) return true;
return wan_interface.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::StubSite::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(wan_interface.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::StubSite::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "stub-site";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::StubSite::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (wan_interface.is_set || is_set(wan_interface.yfilter)) leaf_name_data.push_back(wan_interface.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::StubSite::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::StubSite::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::StubSite::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "wan-interface")
{
wan_interface = value;
wan_interface.value_namespace = name_space;
wan_interface.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::StubSite::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "wan-interface")
{
wan_interface.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::StubSite::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "wan-interface")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Authentication()
:
key_chain{YType::str, "key-chain"}
,
mode(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode>())
{
mode->parent = this;
yang_name = "authentication"; yang_parent_name = "af-interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::~Authentication()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::has_data() const
{
if (is_presence_container) return true;
return key_chain.is_set
|| (mode != nullptr && mode->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(key_chain.yfilter)
|| (mode != nullptr && mode->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "authentication";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (key_chain.is_set || is_set(key_chain.yfilter)) leaf_name_data.push_back(key_chain.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "mode")
{
if(mode == nullptr)
{
mode = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode>();
}
return mode;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(mode != nullptr)
{
_children["mode"] = mode;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "key-chain")
{
key_chain = value;
key_chain.value_namespace = name_space;
key_chain.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "key-chain")
{
key_chain.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "mode" || name == "key-chain")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::Mode()
:
md5{YType::empty, "md5"}
,
hmac_sha_256(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::HmacSha256>())
{
hmac_sha_256->parent = this;
yang_name = "mode"; yang_parent_name = "authentication"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::~Mode()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::has_data() const
{
if (is_presence_container) return true;
return md5.is_set
|| (hmac_sha_256 != nullptr && hmac_sha_256->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(md5.yfilter)
|| (hmac_sha_256 != nullptr && hmac_sha_256->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "mode";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (md5.is_set || is_set(md5.yfilter)) leaf_name_data.push_back(md5.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "hmac-sha-256")
{
if(hmac_sha_256 == nullptr)
{
hmac_sha_256 = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::HmacSha256>();
}
return hmac_sha_256;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(hmac_sha_256 != nullptr)
{
_children["hmac-sha-256"] = hmac_sha_256;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "md5")
{
md5 = value;
md5.value_namespace = name_space;
md5.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "md5")
{
md5.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "hmac-sha-256" || name == "md5")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::HmacSha256::HmacSha256()
:
auth_type{YType::uint8, "auth-type"},
auth_key{YType::str, "auth-key"}
{
yang_name = "hmac-sha-256"; yang_parent_name = "mode"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::HmacSha256::~HmacSha256()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::HmacSha256::has_data() const
{
if (is_presence_container) return true;
return auth_type.is_set
|| auth_key.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::HmacSha256::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(auth_type.yfilter)
|| ydk::is_set(auth_key.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::HmacSha256::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "hmac-sha-256";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::HmacSha256::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (auth_type.is_set || is_set(auth_type.yfilter)) leaf_name_data.push_back(auth_type.get_name_leafdata());
if (auth_key.is_set || is_set(auth_key.yfilter)) leaf_name_data.push_back(auth_key.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::HmacSha256::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::HmacSha256::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::HmacSha256::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "auth-type")
{
auth_type = value;
auth_type.value_namespace = name_space;
auth_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "auth-key")
{
auth_key = value;
auth_key.value_namespace = name_space;
auth_key.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::HmacSha256::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "auth-type")
{
auth_type.yfilter = yfilter;
}
if(value_path == "auth-key")
{
auth_key.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::Authentication::Mode::HmacSha256::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "auth-type" || name == "auth-key")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::SummaryAddress::SummaryAddress()
:
address{YType::str, "address"},
mask{YType::str, "mask"}
{
yang_name = "summary-address"; yang_parent_name = "af-interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::SummaryAddress::~SummaryAddress()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::SummaryAddress::has_data() const
{
if (is_presence_container) return true;
return address.is_set
|| mask.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::SummaryAddress::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(address.yfilter)
|| ydk::is_set(mask.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::SummaryAddress::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "summary-address";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::SummaryAddress::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata());
if (mask.is_set || is_set(mask.yfilter)) leaf_name_data.push_back(mask.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::SummaryAddress::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::SummaryAddress::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::SummaryAddress::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address = value;
address.value_namespace = name_space;
address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "mask")
{
mask = value;
mask.value_namespace = name_space;
mask.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::SummaryAddress::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
if(value_path == "mask")
{
mask.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::AfInterface::SummaryAddress::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "mask")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::SetAsInSubmode::SetAsInSubmode()
:
autonomous_system{YType::uint16, "autonomous-system"}
{
yang_name = "set-as-in-submode"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::SetAsInSubmode::~SetAsInSubmode()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::SetAsInSubmode::has_data() const
{
if (is_presence_container) return true;
return autonomous_system.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::SetAsInSubmode::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(autonomous_system.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::SetAsInSubmode::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "set-as-in-submode";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::SetAsInSubmode::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (autonomous_system.is_set || is_set(autonomous_system.yfilter)) leaf_name_data.push_back(autonomous_system.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::SetAsInSubmode::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::SetAsInSubmode::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::SetAsInSubmode::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "autonomous-system")
{
autonomous_system = value;
autonomous_system.value_namespace = name_space;
autonomous_system.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::SetAsInSubmode::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "autonomous-system")
{
autonomous_system.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::SetAsInSubmode::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "autonomous-system")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Bfd()
:
all_interfaces{YType::empty, "all-interfaces"}
,
interface(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface>())
{
interface->parent = this;
yang_name = "bfd"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::~Bfd()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::has_data() const
{
if (is_presence_container) return true;
return all_interfaces.is_set
|| (interface != nullptr && interface->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(all_interfaces.yfilter)
|| (interface != nullptr && interface->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "bfd";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (all_interfaces.is_set || is_set(all_interfaces.yfilter)) leaf_name_data.push_back(all_interfaces.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "interface")
{
if(interface == nullptr)
{
interface = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface>();
}
return interface;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(interface != nullptr)
{
_children["interface"] = interface;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "all-interfaces")
{
all_interfaces = value;
all_interfaces.value_namespace = name_space;
all_interfaces.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "all-interfaces")
{
all_interfaces.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "interface" || name == "all-interfaces")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::Interface()
:
appnav_compress{YType::uint16, "AppNav-Compress"},
appnav_uncompress{YType::uint16, "AppNav-UnCompress"},
atm{YType::str, "ATM"},
atm_acr{YType::str, "ATM-ACR"},
bdi{YType::str, "BDI"},
cem{YType::str, "CEM"},
cem_acr{YType::uint8, "CEM-ACR"},
embedded_service_engine{YType::str, "Embedded-Service-Engine"},
ethernet{YType::str, "Ethernet"},
fastethernet{YType::str, "FastEthernet"},
gigabitethernet{YType::str, "GigabitEthernet"},
fivegigabitethernet{YType::str, "FiveGigabitEthernet"},
twentyfivegige{YType::str, "TwentyFiveGigE"},
twogigabitethernet{YType::str, "TwoGigabitEthernet"},
fortygigabitethernet{YType::str, "FortyGigabitEthernet"},
hundredgige{YType::str, "HundredGigE"},
lisp{YType::str, "LISP"},
loopback{YType::uint32, "Loopback"},
multilink{YType::uint16, "Multilink"},
nve{YType::uint16, "nve"},
overlay{YType::uint16, "overlay"},
port_channel{YType::uint32, "Port-channel"},
pseudowire{YType::uint32, "pseudowire"},
sm{YType::str, "SM"},
cellular{YType::str, "Cellular"},
serial{YType::str, "Serial"},
tengigabitethernet{YType::str, "TenGigabitEthernet"},
tunnel{YType::uint32, "Tunnel"},
virtual_template{YType::uint16, "Virtual-Template"},
vlan{YType::uint16, "Vlan"},
virtualportgroup{YType::uint16, "VirtualPortGroup"},
vasileft{YType::uint16, "vasileft"},
vasiright{YType::uint16, "vasiright"}
,
atm_subinterface(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMSubinterface>())
, atm_acrsubinterface(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMACRsubinterface>())
, lisp_subinterface(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::LISPSubinterface>())
, port_channel_subinterface(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::PortChannelSubinterface>())
{
atm_subinterface->parent = this;
atm_acrsubinterface->parent = this;
lisp_subinterface->parent = this;
port_channel_subinterface->parent = this;
yang_name = "interface"; yang_parent_name = "bfd"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::~Interface()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::has_data() const
{
if (is_presence_container) return true;
return appnav_compress.is_set
|| appnav_uncompress.is_set
|| atm.is_set
|| atm_acr.is_set
|| bdi.is_set
|| cem.is_set
|| cem_acr.is_set
|| embedded_service_engine.is_set
|| ethernet.is_set
|| fastethernet.is_set
|| gigabitethernet.is_set
|| fivegigabitethernet.is_set
|| twentyfivegige.is_set
|| twogigabitethernet.is_set
|| fortygigabitethernet.is_set
|| hundredgige.is_set
|| lisp.is_set
|| loopback.is_set
|| multilink.is_set
|| nve.is_set
|| overlay.is_set
|| port_channel.is_set
|| pseudowire.is_set
|| sm.is_set
|| cellular.is_set
|| serial.is_set
|| tengigabitethernet.is_set
|| tunnel.is_set
|| virtual_template.is_set
|| vlan.is_set
|| virtualportgroup.is_set
|| vasileft.is_set
|| vasiright.is_set
|| (atm_subinterface != nullptr && atm_subinterface->has_data())
|| (atm_acrsubinterface != nullptr && atm_acrsubinterface->has_data())
|| (lisp_subinterface != nullptr && lisp_subinterface->has_data())
|| (port_channel_subinterface != nullptr && port_channel_subinterface->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(appnav_compress.yfilter)
|| ydk::is_set(appnav_uncompress.yfilter)
|| ydk::is_set(atm.yfilter)
|| ydk::is_set(atm_acr.yfilter)
|| ydk::is_set(bdi.yfilter)
|| ydk::is_set(cem.yfilter)
|| ydk::is_set(cem_acr.yfilter)
|| ydk::is_set(embedded_service_engine.yfilter)
|| ydk::is_set(ethernet.yfilter)
|| ydk::is_set(fastethernet.yfilter)
|| ydk::is_set(gigabitethernet.yfilter)
|| ydk::is_set(fivegigabitethernet.yfilter)
|| ydk::is_set(twentyfivegige.yfilter)
|| ydk::is_set(twogigabitethernet.yfilter)
|| ydk::is_set(fortygigabitethernet.yfilter)
|| ydk::is_set(hundredgige.yfilter)
|| ydk::is_set(lisp.yfilter)
|| ydk::is_set(loopback.yfilter)
|| ydk::is_set(multilink.yfilter)
|| ydk::is_set(nve.yfilter)
|| ydk::is_set(overlay.yfilter)
|| ydk::is_set(port_channel.yfilter)
|| ydk::is_set(pseudowire.yfilter)
|| ydk::is_set(sm.yfilter)
|| ydk::is_set(cellular.yfilter)
|| ydk::is_set(serial.yfilter)
|| ydk::is_set(tengigabitethernet.yfilter)
|| ydk::is_set(tunnel.yfilter)
|| ydk::is_set(virtual_template.yfilter)
|| ydk::is_set(vlan.yfilter)
|| ydk::is_set(virtualportgroup.yfilter)
|| ydk::is_set(vasileft.yfilter)
|| ydk::is_set(vasiright.yfilter)
|| (atm_subinterface != nullptr && atm_subinterface->has_operation())
|| (atm_acrsubinterface != nullptr && atm_acrsubinterface->has_operation())
|| (lisp_subinterface != nullptr && lisp_subinterface->has_operation())
|| (port_channel_subinterface != nullptr && port_channel_subinterface->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "interface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (appnav_compress.is_set || is_set(appnav_compress.yfilter)) leaf_name_data.push_back(appnav_compress.get_name_leafdata());
if (appnav_uncompress.is_set || is_set(appnav_uncompress.yfilter)) leaf_name_data.push_back(appnav_uncompress.get_name_leafdata());
if (atm.is_set || is_set(atm.yfilter)) leaf_name_data.push_back(atm.get_name_leafdata());
if (atm_acr.is_set || is_set(atm_acr.yfilter)) leaf_name_data.push_back(atm_acr.get_name_leafdata());
if (bdi.is_set || is_set(bdi.yfilter)) leaf_name_data.push_back(bdi.get_name_leafdata());
if (cem.is_set || is_set(cem.yfilter)) leaf_name_data.push_back(cem.get_name_leafdata());
if (cem_acr.is_set || is_set(cem_acr.yfilter)) leaf_name_data.push_back(cem_acr.get_name_leafdata());
if (embedded_service_engine.is_set || is_set(embedded_service_engine.yfilter)) leaf_name_data.push_back(embedded_service_engine.get_name_leafdata());
if (ethernet.is_set || is_set(ethernet.yfilter)) leaf_name_data.push_back(ethernet.get_name_leafdata());
if (fastethernet.is_set || is_set(fastethernet.yfilter)) leaf_name_data.push_back(fastethernet.get_name_leafdata());
if (gigabitethernet.is_set || is_set(gigabitethernet.yfilter)) leaf_name_data.push_back(gigabitethernet.get_name_leafdata());
if (fivegigabitethernet.is_set || is_set(fivegigabitethernet.yfilter)) leaf_name_data.push_back(fivegigabitethernet.get_name_leafdata());
if (twentyfivegige.is_set || is_set(twentyfivegige.yfilter)) leaf_name_data.push_back(twentyfivegige.get_name_leafdata());
if (twogigabitethernet.is_set || is_set(twogigabitethernet.yfilter)) leaf_name_data.push_back(twogigabitethernet.get_name_leafdata());
if (fortygigabitethernet.is_set || is_set(fortygigabitethernet.yfilter)) leaf_name_data.push_back(fortygigabitethernet.get_name_leafdata());
if (hundredgige.is_set || is_set(hundredgige.yfilter)) leaf_name_data.push_back(hundredgige.get_name_leafdata());
if (lisp.is_set || is_set(lisp.yfilter)) leaf_name_data.push_back(lisp.get_name_leafdata());
if (loopback.is_set || is_set(loopback.yfilter)) leaf_name_data.push_back(loopback.get_name_leafdata());
if (multilink.is_set || is_set(multilink.yfilter)) leaf_name_data.push_back(multilink.get_name_leafdata());
if (nve.is_set || is_set(nve.yfilter)) leaf_name_data.push_back(nve.get_name_leafdata());
if (overlay.is_set || is_set(overlay.yfilter)) leaf_name_data.push_back(overlay.get_name_leafdata());
if (port_channel.is_set || is_set(port_channel.yfilter)) leaf_name_data.push_back(port_channel.get_name_leafdata());
if (pseudowire.is_set || is_set(pseudowire.yfilter)) leaf_name_data.push_back(pseudowire.get_name_leafdata());
if (sm.is_set || is_set(sm.yfilter)) leaf_name_data.push_back(sm.get_name_leafdata());
if (cellular.is_set || is_set(cellular.yfilter)) leaf_name_data.push_back(cellular.get_name_leafdata());
if (serial.is_set || is_set(serial.yfilter)) leaf_name_data.push_back(serial.get_name_leafdata());
if (tengigabitethernet.is_set || is_set(tengigabitethernet.yfilter)) leaf_name_data.push_back(tengigabitethernet.get_name_leafdata());
if (tunnel.is_set || is_set(tunnel.yfilter)) leaf_name_data.push_back(tunnel.get_name_leafdata());
if (virtual_template.is_set || is_set(virtual_template.yfilter)) leaf_name_data.push_back(virtual_template.get_name_leafdata());
if (vlan.is_set || is_set(vlan.yfilter)) leaf_name_data.push_back(vlan.get_name_leafdata());
if (virtualportgroup.is_set || is_set(virtualportgroup.yfilter)) leaf_name_data.push_back(virtualportgroup.get_name_leafdata());
if (vasileft.is_set || is_set(vasileft.yfilter)) leaf_name_data.push_back(vasileft.get_name_leafdata());
if (vasiright.is_set || is_set(vasiright.yfilter)) leaf_name_data.push_back(vasiright.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ATM-subinterface")
{
if(atm_subinterface == nullptr)
{
atm_subinterface = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMSubinterface>();
}
return atm_subinterface;
}
if(child_yang_name == "ATM-ACRsubinterface")
{
if(atm_acrsubinterface == nullptr)
{
atm_acrsubinterface = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMACRsubinterface>();
}
return atm_acrsubinterface;
}
if(child_yang_name == "LISP-subinterface")
{
if(lisp_subinterface == nullptr)
{
lisp_subinterface = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::LISPSubinterface>();
}
return lisp_subinterface;
}
if(child_yang_name == "Port-channel-subinterface")
{
if(port_channel_subinterface == nullptr)
{
port_channel_subinterface = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::PortChannelSubinterface>();
}
return port_channel_subinterface;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(atm_subinterface != nullptr)
{
_children["ATM-subinterface"] = atm_subinterface;
}
if(atm_acrsubinterface != nullptr)
{
_children["ATM-ACRsubinterface"] = atm_acrsubinterface;
}
if(lisp_subinterface != nullptr)
{
_children["LISP-subinterface"] = lisp_subinterface;
}
if(port_channel_subinterface != nullptr)
{
_children["Port-channel-subinterface"] = port_channel_subinterface;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "AppNav-Compress")
{
appnav_compress = value;
appnav_compress.value_namespace = name_space;
appnav_compress.value_namespace_prefix = name_space_prefix;
}
if(value_path == "AppNav-UnCompress")
{
appnav_uncompress = value;
appnav_uncompress.value_namespace = name_space;
appnav_uncompress.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ATM")
{
atm = value;
atm.value_namespace = name_space;
atm.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ATM-ACR")
{
atm_acr = value;
atm_acr.value_namespace = name_space;
atm_acr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "BDI")
{
bdi = value;
bdi.value_namespace = name_space;
bdi.value_namespace_prefix = name_space_prefix;
}
if(value_path == "CEM")
{
cem = value;
cem.value_namespace = name_space;
cem.value_namespace_prefix = name_space_prefix;
}
if(value_path == "CEM-ACR")
{
cem_acr = value;
cem_acr.value_namespace = name_space;
cem_acr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Embedded-Service-Engine")
{
embedded_service_engine = value;
embedded_service_engine.value_namespace = name_space;
embedded_service_engine.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Ethernet")
{
ethernet = value;
ethernet.value_namespace = name_space;
ethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FastEthernet")
{
fastethernet = value;
fastethernet.value_namespace = name_space;
fastethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "GigabitEthernet")
{
gigabitethernet = value;
gigabitethernet.value_namespace = name_space;
gigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FiveGigabitEthernet")
{
fivegigabitethernet = value;
fivegigabitethernet.value_namespace = name_space;
fivegigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TwentyFiveGigE")
{
twentyfivegige = value;
twentyfivegige.value_namespace = name_space;
twentyfivegige.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TwoGigabitEthernet")
{
twogigabitethernet = value;
twogigabitethernet.value_namespace = name_space;
twogigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FortyGigabitEthernet")
{
fortygigabitethernet = value;
fortygigabitethernet.value_namespace = name_space;
fortygigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "HundredGigE")
{
hundredgige = value;
hundredgige.value_namespace = name_space;
hundredgige.value_namespace_prefix = name_space_prefix;
}
if(value_path == "LISP")
{
lisp = value;
lisp.value_namespace = name_space;
lisp.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Loopback")
{
loopback = value;
loopback.value_namespace = name_space;
loopback.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Multilink")
{
multilink = value;
multilink.value_namespace = name_space;
multilink.value_namespace_prefix = name_space_prefix;
}
if(value_path == "nve")
{
nve = value;
nve.value_namespace = name_space;
nve.value_namespace_prefix = name_space_prefix;
}
if(value_path == "overlay")
{
overlay = value;
overlay.value_namespace = name_space;
overlay.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Port-channel")
{
port_channel = value;
port_channel.value_namespace = name_space;
port_channel.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pseudowire")
{
pseudowire = value;
pseudowire.value_namespace = name_space;
pseudowire.value_namespace_prefix = name_space_prefix;
}
if(value_path == "SM")
{
sm = value;
sm.value_namespace = name_space;
sm.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Cellular")
{
cellular = value;
cellular.value_namespace = name_space;
cellular.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Serial")
{
serial = value;
serial.value_namespace = name_space;
serial.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TenGigabitEthernet")
{
tengigabitethernet = value;
tengigabitethernet.value_namespace = name_space;
tengigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Tunnel")
{
tunnel = value;
tunnel.value_namespace = name_space;
tunnel.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Virtual-Template")
{
virtual_template = value;
virtual_template.value_namespace = name_space;
virtual_template.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Vlan")
{
vlan = value;
vlan.value_namespace = name_space;
vlan.value_namespace_prefix = name_space_prefix;
}
if(value_path == "VirtualPortGroup")
{
virtualportgroup = value;
virtualportgroup.value_namespace = name_space;
virtualportgroup.value_namespace_prefix = name_space_prefix;
}
if(value_path == "vasileft")
{
vasileft = value;
vasileft.value_namespace = name_space;
vasileft.value_namespace_prefix = name_space_prefix;
}
if(value_path == "vasiright")
{
vasiright = value;
vasiright.value_namespace = name_space;
vasiright.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "AppNav-Compress")
{
appnav_compress.yfilter = yfilter;
}
if(value_path == "AppNav-UnCompress")
{
appnav_uncompress.yfilter = yfilter;
}
if(value_path == "ATM")
{
atm.yfilter = yfilter;
}
if(value_path == "ATM-ACR")
{
atm_acr.yfilter = yfilter;
}
if(value_path == "BDI")
{
bdi.yfilter = yfilter;
}
if(value_path == "CEM")
{
cem.yfilter = yfilter;
}
if(value_path == "CEM-ACR")
{
cem_acr.yfilter = yfilter;
}
if(value_path == "Embedded-Service-Engine")
{
embedded_service_engine.yfilter = yfilter;
}
if(value_path == "Ethernet")
{
ethernet.yfilter = yfilter;
}
if(value_path == "FastEthernet")
{
fastethernet.yfilter = yfilter;
}
if(value_path == "GigabitEthernet")
{
gigabitethernet.yfilter = yfilter;
}
if(value_path == "FiveGigabitEthernet")
{
fivegigabitethernet.yfilter = yfilter;
}
if(value_path == "TwentyFiveGigE")
{
twentyfivegige.yfilter = yfilter;
}
if(value_path == "TwoGigabitEthernet")
{
twogigabitethernet.yfilter = yfilter;
}
if(value_path == "FortyGigabitEthernet")
{
fortygigabitethernet.yfilter = yfilter;
}
if(value_path == "HundredGigE")
{
hundredgige.yfilter = yfilter;
}
if(value_path == "LISP")
{
lisp.yfilter = yfilter;
}
if(value_path == "Loopback")
{
loopback.yfilter = yfilter;
}
if(value_path == "Multilink")
{
multilink.yfilter = yfilter;
}
if(value_path == "nve")
{
nve.yfilter = yfilter;
}
if(value_path == "overlay")
{
overlay.yfilter = yfilter;
}
if(value_path == "Port-channel")
{
port_channel.yfilter = yfilter;
}
if(value_path == "pseudowire")
{
pseudowire.yfilter = yfilter;
}
if(value_path == "SM")
{
sm.yfilter = yfilter;
}
if(value_path == "Cellular")
{
cellular.yfilter = yfilter;
}
if(value_path == "Serial")
{
serial.yfilter = yfilter;
}
if(value_path == "TenGigabitEthernet")
{
tengigabitethernet.yfilter = yfilter;
}
if(value_path == "Tunnel")
{
tunnel.yfilter = yfilter;
}
if(value_path == "Virtual-Template")
{
virtual_template.yfilter = yfilter;
}
if(value_path == "Vlan")
{
vlan.yfilter = yfilter;
}
if(value_path == "VirtualPortGroup")
{
virtualportgroup.yfilter = yfilter;
}
if(value_path == "vasileft")
{
vasileft.yfilter = yfilter;
}
if(value_path == "vasiright")
{
vasiright.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM-subinterface" || name == "ATM-ACRsubinterface" || name == "LISP-subinterface" || name == "Port-channel-subinterface" || name == "AppNav-Compress" || name == "AppNav-UnCompress" || name == "ATM" || name == "ATM-ACR" || name == "BDI" || name == "CEM" || name == "CEM-ACR" || name == "Embedded-Service-Engine" || name == "Ethernet" || name == "FastEthernet" || name == "GigabitEthernet" || name == "FiveGigabitEthernet" || name == "TwentyFiveGigE" || name == "TwoGigabitEthernet" || name == "FortyGigabitEthernet" || name == "HundredGigE" || name == "LISP" || name == "Loopback" || name == "Multilink" || name == "nve" || name == "overlay" || name == "Port-channel" || name == "pseudowire" || name == "SM" || name == "Cellular" || name == "Serial" || name == "TenGigabitEthernet" || name == "Tunnel" || name == "Virtual-Template" || name == "Vlan" || name == "VirtualPortGroup" || name == "vasileft" || name == "vasiright")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMSubinterface::ATMSubinterface()
:
atm{YType::str, "ATM"}
{
yang_name = "ATM-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMSubinterface::~ATMSubinterface()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMSubinterface::has_data() const
{
if (is_presence_container) return true;
return atm.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(atm.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ATM-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (atm.is_set || is_set(atm.yfilter)) leaf_name_data.push_back(atm.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ATM")
{
atm = value;
atm.value_namespace = name_space;
atm.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ATM")
{
atm.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMACRsubinterface::ATMACRsubinterface()
:
atm_acr{YType::str, "ATM-ACR"}
{
yang_name = "ATM-ACRsubinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMACRsubinterface::~ATMACRsubinterface()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMACRsubinterface::has_data() const
{
if (is_presence_container) return true;
return atm_acr.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMACRsubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(atm_acr.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMACRsubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ATM-ACRsubinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMACRsubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (atm_acr.is_set || is_set(atm_acr.yfilter)) leaf_name_data.push_back(atm_acr.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMACRsubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMACRsubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMACRsubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ATM-ACR")
{
atm_acr = value;
atm_acr.value_namespace = name_space;
atm_acr.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMACRsubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ATM-ACR")
{
atm_acr.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::ATMACRsubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM-ACR")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::LISPSubinterface::LISPSubinterface()
:
lisp{YType::str, "LISP"}
{
yang_name = "LISP-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::LISPSubinterface::~LISPSubinterface()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::LISPSubinterface::has_data() const
{
if (is_presence_container) return true;
return lisp.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::LISPSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lisp.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::LISPSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "LISP-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::LISPSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lisp.is_set || is_set(lisp.yfilter)) leaf_name_data.push_back(lisp.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::LISPSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::LISPSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::LISPSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "LISP")
{
lisp = value;
lisp.value_namespace = name_space;
lisp.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::LISPSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "LISP")
{
lisp.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::LISPSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "LISP")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::PortChannelSubinterface::PortChannelSubinterface()
:
port_channel{YType::str, "Port-channel"}
{
yang_name = "Port-channel-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::PortChannelSubinterface::~PortChannelSubinterface()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::PortChannelSubinterface::has_data() const
{
if (is_presence_container) return true;
return port_channel.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::PortChannelSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(port_channel.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::PortChannelSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "Port-channel-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::PortChannelSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (port_channel.is_set || is_set(port_channel.yfilter)) leaf_name_data.push_back(port_channel.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::PortChannelSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::PortChannelSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::PortChannelSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "Port-channel")
{
port_channel = value;
port_channel.value_namespace = name_space;
port_channel.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::PortChannelSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "Port-channel")
{
port_channel.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Bfd::Interface::PortChannelSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "Port-channel")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::DefaultInformation()
:
in(nullptr) // presence node
, out(nullptr) // presence node
{
yang_name = "default-information"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::~DefaultInformation()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::has_data() const
{
if (is_presence_container) return true;
return (in != nullptr && in->has_data())
|| (out != nullptr && out->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::has_operation() const
{
return is_set(yfilter)
|| (in != nullptr && in->has_operation())
|| (out != nullptr && out->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "default-information";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "in")
{
if(in == nullptr)
{
in = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::In>();
}
return in;
}
if(child_yang_name == "out")
{
if(out == nullptr)
{
out = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::Out>();
}
return out;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(in != nullptr)
{
_children["in"] = in;
}
if(out != nullptr)
{
_children["out"] = out;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::In::In()
:
sa_num{YType::uint16, "sa-num"},
sa_name{YType::str, "sa-name"}
{
yang_name = "in"; yang_parent_name = "default-information"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::In::~In()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::In::has_data() const
{
if (is_presence_container) return true;
return sa_num.is_set
|| sa_name.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::In::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(sa_num.yfilter)
|| ydk::is_set(sa_name.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::In::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "in";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::In::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (sa_num.is_set || is_set(sa_num.yfilter)) leaf_name_data.push_back(sa_num.get_name_leafdata());
if (sa_name.is_set || is_set(sa_name.yfilter)) leaf_name_data.push_back(sa_name.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::In::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::In::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::In::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "sa-num")
{
sa_num = value;
sa_num.value_namespace = name_space;
sa_num.value_namespace_prefix = name_space_prefix;
}
if(value_path == "sa-name")
{
sa_name = value;
sa_name.value_namespace = name_space;
sa_name.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::In::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "sa-num")
{
sa_num.yfilter = yfilter;
}
if(value_path == "sa-name")
{
sa_name.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::In::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "sa-num" || name == "sa-name")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::Out::Out()
:
sa_out_num{YType::uint16, "sa-out-num"},
sa_out_name{YType::str, "sa-out-name"}
{
yang_name = "out"; yang_parent_name = "default-information"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::Out::~Out()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::Out::has_data() const
{
if (is_presence_container) return true;
return sa_out_num.is_set
|| sa_out_name.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::Out::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(sa_out_num.yfilter)
|| ydk::is_set(sa_out_name.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::Out::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "out";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::Out::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (sa_out_num.is_set || is_set(sa_out_num.yfilter)) leaf_name_data.push_back(sa_out_num.get_name_leafdata());
if (sa_out_name.is_set || is_set(sa_out_name.yfilter)) leaf_name_data.push_back(sa_out_name.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::Out::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::Out::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::Out::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "sa-out-num")
{
sa_out_num = value;
sa_out_num.value_namespace = name_space;
sa_out_num.value_namespace_prefix = name_space_prefix;
}
if(value_path == "sa-out-name")
{
sa_out_name = value;
sa_out_name.value_namespace = name_space;
sa_out_name.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::Out::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "sa-out-num")
{
sa_out_num.yfilter = yfilter;
}
if(value_path == "sa-out-name")
{
sa_out_name.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultInformation::Out::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "sa-out-num" || name == "sa-out-name")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DefaultMetric()
:
dm_rdr(this, {"dm_rdr"})
{
yang_name = "default-metric"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::~DefaultMetric()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<dm_rdr.len(); index++)
{
if(dm_rdr[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::has_operation() const
{
for (std::size_t index=0; index<dm_rdr.len(); index++)
{
if(dm_rdr[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "default-metric";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "dm-rdr")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr>();
ent_->parent = this;
dm_rdr.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : dm_rdr.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dm-rdr")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::DmRdr()
:
dm_rdr{YType::uint32, "dm-rdr"}
,
dm_rdr0(this, {"dm_rdr0"})
{
yang_name = "dm-rdr"; yang_parent_name = "default-metric"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::~DmRdr()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<dm_rdr0.len(); index++)
{
if(dm_rdr0[index]->has_data())
return true;
}
return dm_rdr.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::has_operation() const
{
for (std::size_t index=0; index<dm_rdr0.len(); index++)
{
if(dm_rdr0[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(dm_rdr.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "dm-rdr";
ADD_KEY_TOKEN(dm_rdr, "dm-rdr");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (dm_rdr.is_set || is_set(dm_rdr.yfilter)) leaf_name_data.push_back(dm_rdr.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "dm-rdr0")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::DmRdr0>();
ent_->parent = this;
dm_rdr0.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : dm_rdr0.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "dm-rdr")
{
dm_rdr = value;
dm_rdr.value_namespace = name_space;
dm_rdr.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "dm-rdr")
{
dm_rdr.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dm-rdr0" || name == "dm-rdr")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::DmRdr0::DmRdr0()
:
dm_rdr0{YType::uint32, "dm-rdr0"},
dm_rdr_pct{YType::uint8, "dm-rdr-pct"}
{
yang_name = "dm-rdr0"; yang_parent_name = "dm-rdr"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::DmRdr0::~DmRdr0()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::DmRdr0::has_data() const
{
if (is_presence_container) return true;
return dm_rdr0.is_set
|| dm_rdr_pct.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::DmRdr0::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(dm_rdr0.yfilter)
|| ydk::is_set(dm_rdr_pct.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::DmRdr0::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "dm-rdr0";
ADD_KEY_TOKEN(dm_rdr0, "dm-rdr0");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::DmRdr0::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (dm_rdr0.is_set || is_set(dm_rdr0.yfilter)) leaf_name_data.push_back(dm_rdr0.get_name_leafdata());
if (dm_rdr_pct.is_set || is_set(dm_rdr_pct.yfilter)) leaf_name_data.push_back(dm_rdr_pct.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::DmRdr0::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::DmRdr0::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::DmRdr0::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "dm-rdr0")
{
dm_rdr0 = value;
dm_rdr0.value_namespace = name_space;
dm_rdr0.value_namespace_prefix = name_space_prefix;
}
if(value_path == "dm-rdr-pct")
{
dm_rdr_pct = value;
dm_rdr_pct.value_namespace = name_space;
dm_rdr_pct.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::DmRdr0::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "dm-rdr0")
{
dm_rdr0.yfilter = yfilter;
}
if(value_path == "dm-rdr-pct")
{
dm_rdr_pct.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DefaultMetric::DmRdr::DmRdr0::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dm-rdr0" || name == "dm-rdr-pct")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Distance()
:
rad_dis(this, {"rad_dis"})
, eigrp(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_>())
{
eigrp->parent = this;
yang_name = "distance"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::~Distance()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<rad_dis.len(); index++)
{
if(rad_dis[index]->has_data())
return true;
}
return (eigrp != nullptr && eigrp->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::has_operation() const
{
for (std::size_t index=0; index<rad_dis.len(); index++)
{
if(rad_dis[index]->has_operation())
return true;
}
return is_set(yfilter)
|| (eigrp != nullptr && eigrp->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "distance";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "rad-dis")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis>();
ent_->parent = this;
rad_dis.append(ent_);
return ent_;
}
if(child_yang_name == "eigrp")
{
if(eigrp == nullptr)
{
eigrp = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_>();
}
return eigrp;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : rad_dis.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
if(eigrp != nullptr)
{
_children["eigrp"] = eigrp;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "rad-dis" || name == "eigrp")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::RadDis()
:
rad_dis{YType::uint8, "rad-dis"}
,
ipv4(this, {"ipv4"})
{
yang_name = "rad-dis"; yang_parent_name = "distance"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::~RadDis()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<ipv4.len(); index++)
{
if(ipv4[index]->has_data())
return true;
}
return rad_dis.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::has_operation() const
{
for (std::size_t index=0; index<ipv4.len(); index++)
{
if(ipv4[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(rad_dis.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "rad-dis";
ADD_KEY_TOKEN(rad_dis, "rad-dis");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (rad_dis.is_set || is_set(rad_dis.yfilter)) leaf_name_data.push_back(rad_dis.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ipv4")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::Ipv4>();
ent_->parent = this;
ipv4.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : ipv4.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "rad-dis")
{
rad_dis = value;
rad_dis.value_namespace = name_space;
rad_dis.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "rad-dis")
{
rad_dis.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4" || name == "rad-dis")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::Ipv4::Ipv4()
:
ipv4{YType::str, "ipv4"},
ipv40{YType::str, "ipv40"}
{
yang_name = "ipv4"; yang_parent_name = "rad-dis"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::Ipv4::~Ipv4()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::Ipv4::has_data() const
{
if (is_presence_container) return true;
return ipv4.is_set
|| ipv40.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::Ipv4::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ipv4.yfilter)
|| ydk::is_set(ipv40.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::Ipv4::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv4";
ADD_KEY_TOKEN(ipv4, "ipv4");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::Ipv4::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ipv4.is_set || is_set(ipv4.yfilter)) leaf_name_data.push_back(ipv4.get_name_leafdata());
if (ipv40.is_set || is_set(ipv40.yfilter)) leaf_name_data.push_back(ipv40.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::Ipv4::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::Ipv4::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::Ipv4::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ipv4")
{
ipv4 = value;
ipv4.value_namespace = name_space;
ipv4.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ipv40")
{
ipv40 = value;
ipv40.value_namespace = name_space;
ipv40.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::Ipv4::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ipv4")
{
ipv4.yfilter = yfilter;
}
if(value_path == "ipv40")
{
ipv40.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::RadDis::Ipv4::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4" || name == "ipv40")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::Eigrp_()
:
di_rt(this, {"di_rt"})
{
yang_name = "eigrp"; yang_parent_name = "distance"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::~Eigrp_()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<di_rt.len(); index++)
{
if(di_rt[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::has_operation() const
{
for (std::size_t index=0; index<di_rt.len(); index++)
{
if(di_rt[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "eigrp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "di-rt")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::DiRt>();
ent_->parent = this;
di_rt.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : di_rt.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "di-rt")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::DiRt::DiRt()
:
di_rt{YType::uint8, "di-rt"},
di_rt0{YType::uint8, "di-rt0"}
{
yang_name = "di-rt"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::DiRt::~DiRt()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::DiRt::has_data() const
{
if (is_presence_container) return true;
return di_rt.is_set
|| di_rt0.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::DiRt::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(di_rt.yfilter)
|| ydk::is_set(di_rt0.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::DiRt::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "di-rt";
ADD_KEY_TOKEN(di_rt, "di-rt");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::DiRt::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (di_rt.is_set || is_set(di_rt.yfilter)) leaf_name_data.push_back(di_rt.get_name_leafdata());
if (di_rt0.is_set || is_set(di_rt0.yfilter)) leaf_name_data.push_back(di_rt0.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::DiRt::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::DiRt::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::DiRt::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "di-rt")
{
di_rt = value;
di_rt.value_namespace = name_space;
di_rt.value_namespace_prefix = name_space_prefix;
}
if(value_path == "di-rt0")
{
di_rt0 = value;
di_rt0.value_namespace = name_space;
di_rt0.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::DiRt::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "di-rt")
{
di_rt.yfilter = yfilter;
}
if(value_path == "di-rt0")
{
di_rt0.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Distance::Eigrp_::DiRt::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "di-rt" || name == "di-rt0")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::DistributeList()
:
eig_filt(this, {"eig_filt"})
, gateway(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway>())
, prefix(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix>())
, route_map(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap>())
{
gateway->parent = this;
prefix->parent = this;
route_map->parent = this;
yang_name = "distribute-list"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::~DistributeList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<eig_filt.len(); index++)
{
if(eig_filt[index]->has_data())
return true;
}
return (gateway != nullptr && gateway->has_data())
|| (prefix != nullptr && prefix->has_data())
|| (route_map != nullptr && route_map->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::has_operation() const
{
for (std::size_t index=0; index<eig_filt.len(); index++)
{
if(eig_filt[index]->has_operation())
return true;
}
return is_set(yfilter)
|| (gateway != nullptr && gateway->has_operation())
|| (prefix != nullptr && prefix->has_operation())
|| (route_map != nullptr && route_map->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "distribute-list";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "eig-filt")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt>();
ent_->parent = this;
eig_filt.append(ent_);
return ent_;
}
if(child_yang_name == "gateway")
{
if(gateway == nullptr)
{
gateway = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway>();
}
return gateway;
}
if(child_yang_name == "prefix")
{
if(prefix == nullptr)
{
prefix = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix>();
}
return prefix;
}
if(child_yang_name == "route-map")
{
if(route_map == nullptr)
{
route_map = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap>();
}
return route_map;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : eig_filt.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
if(gateway != nullptr)
{
_children["gateway"] = gateway;
}
if(prefix != nullptr)
{
_children["prefix"] = prefix;
}
if(route_map != nullptr)
{
_children["route-map"] = route_map;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "eig-filt" || name == "gateway" || name == "prefix" || name == "route-map")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::EigFilt()
:
eig_filt{YType::str, "eig-filt"}
,
in(nullptr) // presence node
, out(nullptr) // presence node
{
yang_name = "eig-filt"; yang_parent_name = "distribute-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::~EigFilt()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::has_data() const
{
if (is_presence_container) return true;
return eig_filt.is_set
|| (in != nullptr && in->has_data())
|| (out != nullptr && out->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(eig_filt.yfilter)
|| (in != nullptr && in->has_operation())
|| (out != nullptr && out->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "eig-filt";
ADD_KEY_TOKEN(eig_filt, "eig-filt");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (eig_filt.is_set || is_set(eig_filt.yfilter)) leaf_name_data.push_back(eig_filt.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "in")
{
if(in == nullptr)
{
in = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::In>();
}
return in;
}
if(child_yang_name == "out")
{
if(out == nullptr)
{
out = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::Out>();
}
return out;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(in != nullptr)
{
_children["in"] = in;
}
if(out != nullptr)
{
_children["out"] = out;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "eig-filt")
{
eig_filt = value;
eig_filt.value_namespace = name_space;
eig_filt.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "eig-filt")
{
eig_filt.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "in" || name == "out" || name == "eig-filt")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::In::In()
:
interface_name{YType::str, "interface_name"}
{
yang_name = "in"; yang_parent_name = "eig-filt"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::In::~In()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::In::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : interface_name.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::In::has_operation() const
{
for (auto const & leaf : interface_name.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(interface_name.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::In::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "in";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::In::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto interface_name_name_datas = interface_name.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), interface_name_name_datas.begin(), interface_name_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::In::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::In::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::In::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "interface_name")
{
interface_name.append(value);
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::In::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "interface_name")
{
interface_name.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::In::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "interface_name")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::Out::Out()
:
interface_name{YType::str, "interface_name"}
{
yang_name = "out"; yang_parent_name = "eig-filt"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::Out::~Out()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::Out::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : interface_name.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::Out::has_operation() const
{
for (auto const & leaf : interface_name.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(interface_name.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::Out::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "out";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::Out::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto interface_name_name_datas = interface_name.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), interface_name_name_datas.begin(), interface_name_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::Out::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::Out::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::Out::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "interface_name")
{
interface_name.append(value);
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::Out::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "interface_name")
{
interface_name.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::EigFilt::Out::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "interface_name")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::Gateway()
:
gw_list(this, {"gw_list"})
{
yang_name = "gateway"; yang_parent_name = "distribute-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::~Gateway()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<gw_list.len(); index++)
{
if(gw_list[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::has_operation() const
{
for (std::size_t index=0; index<gw_list.len(); index++)
{
if(gw_list[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "gateway";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "gw-list")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::GwList>();
ent_->parent = this;
gw_list.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : gw_list.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "gw-list")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::GwList::GwList()
:
gw_list{YType::str, "gw-list"},
in{YType::empty, "in"},
out{YType::empty, "out"}
{
yang_name = "gw-list"; yang_parent_name = "gateway"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::GwList::~GwList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::GwList::has_data() const
{
if (is_presence_container) return true;
return gw_list.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::GwList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(gw_list.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::GwList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "gw-list";
ADD_KEY_TOKEN(gw_list, "gw-list");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::GwList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (gw_list.is_set || is_set(gw_list.yfilter)) leaf_name_data.push_back(gw_list.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::GwList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::GwList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::GwList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "gw-list")
{
gw_list = value;
gw_list.value_namespace = name_space;
gw_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::GwList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "gw-list")
{
gw_list.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Gateway::GwList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "gw-list" || name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::Prefix()
:
pl_name(this, {"pl_name"})
{
yang_name = "prefix"; yang_parent_name = "distribute-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::~Prefix()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<pl_name.len(); index++)
{
if(pl_name[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::has_operation() const
{
for (std::size_t index=0; index<pl_name.len(); index++)
{
if(pl_name[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "prefix";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "pl-name")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::PlName>();
ent_->parent = this;
pl_name.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : pl_name.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "pl-name")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::PlName::PlName()
:
pl_name{YType::str, "pl-name"},
gateway{YType::empty, "gateway"},
in{YType::empty, "in"},
out{YType::empty, "out"}
{
yang_name = "pl-name"; yang_parent_name = "prefix"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::PlName::~PlName()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::PlName::has_data() const
{
if (is_presence_container) return true;
return pl_name.is_set
|| gateway.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::PlName::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(pl_name.yfilter)
|| ydk::is_set(gateway.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::PlName::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "pl-name";
ADD_KEY_TOKEN(pl_name, "pl-name");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::PlName::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (pl_name.is_set || is_set(pl_name.yfilter)) leaf_name_data.push_back(pl_name.get_name_leafdata());
if (gateway.is_set || is_set(gateway.yfilter)) leaf_name_data.push_back(gateway.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::PlName::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::PlName::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::PlName::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "pl-name")
{
pl_name = value;
pl_name.value_namespace = name_space;
pl_name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "gateway")
{
gateway = value;
gateway.value_namespace = name_space;
gateway.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::PlName::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "pl-name")
{
pl_name.yfilter = yfilter;
}
if(value_path == "gateway")
{
gateway.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::Prefix::PlName::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "pl-name" || name == "gateway" || name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::RouteMap()
:
rmap_name(this, {"rmap_name"})
{
yang_name = "route-map"; yang_parent_name = "distribute-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::~RouteMap()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<rmap_name.len(); index++)
{
if(rmap_name[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::has_operation() const
{
for (std::size_t index=0; index<rmap_name.len(); index++)
{
if(rmap_name[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "route-map";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "rmap-name")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::RmapName>();
ent_->parent = this;
rmap_name.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : rmap_name.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "rmap-name")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::RmapName::RmapName()
:
rmap_name{YType::str, "rmap-name"},
in{YType::empty, "in"},
out{YType::empty, "out"}
{
yang_name = "rmap-name"; yang_parent_name = "route-map"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::RmapName::~RmapName()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::RmapName::has_data() const
{
if (is_presence_container) return true;
return rmap_name.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::RmapName::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(rmap_name.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::RmapName::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "rmap-name";
ADD_KEY_TOKEN(rmap_name, "rmap-name");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::RmapName::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (rmap_name.is_set || is_set(rmap_name.yfilter)) leaf_name_data.push_back(rmap_name.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::RmapName::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::RmapName::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::RmapName::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "rmap-name")
{
rmap_name = value;
rmap_name.value_namespace = name_space;
rmap_name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::RmapName::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "rmap-name")
{
rmap_name.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::DistributeList::RouteMap::RmapName::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "rmap-name" || name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::Eigrp_()
:
router_id{YType::str, "router-id"},
stub_site{YType::str, "stub-site"}
,
stub(nullptr) // presence node
{
yang_name = "eigrp"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::~Eigrp_()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::has_data() const
{
if (is_presence_container) return true;
return router_id.is_set
|| stub_site.is_set
|| (stub != nullptr && stub->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(router_id.yfilter)
|| ydk::is_set(stub_site.yfilter)
|| (stub != nullptr && stub->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "eigrp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (router_id.is_set || is_set(router_id.yfilter)) leaf_name_data.push_back(router_id.get_name_leafdata());
if (stub_site.is_set || is_set(stub_site.yfilter)) leaf_name_data.push_back(stub_site.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "stub")
{
if(stub == nullptr)
{
stub = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::Stub>();
}
return stub;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(stub != nullptr)
{
_children["stub"] = stub;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "router-id")
{
router_id = value;
router_id.value_namespace = name_space;
router_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "stub-site")
{
stub_site = value;
stub_site.value_namespace = name_space;
stub_site.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "router-id")
{
router_id.yfilter = yfilter;
}
if(value_path == "stub-site")
{
stub_site.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "stub" || name == "router-id" || name == "stub-site")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::Stub::Stub()
:
connected{YType::empty, "connected"},
summary{YType::empty, "summary"},
redistributed{YType::empty, "redistributed"},
leak_map{YType::str, "leak-map"},
receive_only{YType::empty, "receive-only"},
static_{YType::empty, "static"}
{
yang_name = "stub"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::Stub::~Stub()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::Stub::has_data() const
{
if (is_presence_container) return true;
return connected.is_set
|| summary.is_set
|| redistributed.is_set
|| leak_map.is_set
|| receive_only.is_set
|| static_.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::Stub::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(connected.yfilter)
|| ydk::is_set(summary.yfilter)
|| ydk::is_set(redistributed.yfilter)
|| ydk::is_set(leak_map.yfilter)
|| ydk::is_set(receive_only.yfilter)
|| ydk::is_set(static_.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::Stub::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "stub";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::Stub::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (connected.is_set || is_set(connected.yfilter)) leaf_name_data.push_back(connected.get_name_leafdata());
if (summary.is_set || is_set(summary.yfilter)) leaf_name_data.push_back(summary.get_name_leafdata());
if (redistributed.is_set || is_set(redistributed.yfilter)) leaf_name_data.push_back(redistributed.get_name_leafdata());
if (leak_map.is_set || is_set(leak_map.yfilter)) leaf_name_data.push_back(leak_map.get_name_leafdata());
if (receive_only.is_set || is_set(receive_only.yfilter)) leaf_name_data.push_back(receive_only.get_name_leafdata());
if (static_.is_set || is_set(static_.yfilter)) leaf_name_data.push_back(static_.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::Stub::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::Stub::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::Stub::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "connected")
{
connected = value;
connected.value_namespace = name_space;
connected.value_namespace_prefix = name_space_prefix;
}
if(value_path == "summary")
{
summary = value;
summary.value_namespace = name_space;
summary.value_namespace_prefix = name_space_prefix;
}
if(value_path == "redistributed")
{
redistributed = value;
redistributed.value_namespace = name_space;
redistributed.value_namespace_prefix = name_space_prefix;
}
if(value_path == "leak-map")
{
leak_map = value;
leak_map.value_namespace = name_space;
leak_map.value_namespace_prefix = name_space_prefix;
}
if(value_path == "receive-only")
{
receive_only = value;
receive_only.value_namespace = name_space;
receive_only.value_namespace_prefix = name_space_prefix;
}
if(value_path == "static")
{
static_ = value;
static_.value_namespace = name_space;
static_.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::Stub::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "connected")
{
connected.yfilter = yfilter;
}
if(value_path == "summary")
{
summary.yfilter = yfilter;
}
if(value_path == "redistributed")
{
redistributed.yfilter = yfilter;
}
if(value_path == "leak-map")
{
leak_map.yfilter = yfilter;
}
if(value_path == "receive-only")
{
receive_only.yfilter = yfilter;
}
if(value_path == "static")
{
static_.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Eigrp_::Stub::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "connected" || name == "summary" || name == "redistributed" || name == "leak-map" || name == "receive-only" || name == "static")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Metric::Metric()
:
maximum_hops{YType::uint8, "maximum-hops"},
weights{YType::uint8, "weights"}
{
yang_name = "metric"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Metric::~Metric()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Metric::has_data() const
{
if (is_presence_container) return true;
return maximum_hops.is_set
|| weights.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Metric::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(maximum_hops.yfilter)
|| ydk::is_set(weights.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Metric::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "metric";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Metric::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (maximum_hops.is_set || is_set(maximum_hops.yfilter)) leaf_name_data.push_back(maximum_hops.get_name_leafdata());
if (weights.is_set || is_set(weights.yfilter)) leaf_name_data.push_back(weights.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Metric::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Metric::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Metric::set_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-hops")
{
maximum_hops = value;
maximum_hops.value_namespace = name_space;
maximum_hops.value_namespace_prefix = name_space_prefix;
}
if(value_path == "weights")
{
weights = value;
weights.value_namespace = name_space;
weights.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Metric::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "maximum-hops")
{
maximum_hops.yfilter = yfilter;
}
if(value_path == "weights")
{
weights.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Metric::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "maximum-hops" || name == "weights")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Neighbor()
:
ipv4(this, {"ipv4"})
{
yang_name = "neighbor"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::~Neighbor()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<ipv4.len(); index++)
{
if(ipv4[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::has_operation() const
{
for (std::size_t index=0; index<ipv4.len(); index++)
{
if(ipv4[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "neighbor";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ipv4")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4>();
ent_->parent = this;
ipv4.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : ipv4.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Ipv4()
:
ipv4{YType::str, "ipv4"}
,
interface(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface>())
{
interface->parent = this;
yang_name = "ipv4"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::~Ipv4()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::has_data() const
{
if (is_presence_container) return true;
return ipv4.is_set
|| (interface != nullptr && interface->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ipv4.yfilter)
|| (interface != nullptr && interface->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv4";
ADD_KEY_TOKEN(ipv4, "ipv4");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ipv4.is_set || is_set(ipv4.yfilter)) leaf_name_data.push_back(ipv4.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "interface")
{
if(interface == nullptr)
{
interface = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface>();
}
return interface;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(interface != nullptr)
{
_children["interface"] = interface;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ipv4")
{
ipv4 = value;
ipv4.value_namespace = name_space;
ipv4.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ipv4")
{
ipv4.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "interface" || name == "ipv4")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::Interface()
:
appnav_compress{YType::uint16, "AppNav-Compress"},
appnav_uncompress{YType::uint16, "AppNav-UnCompress"},
atm{YType::str, "ATM"},
atm_acr{YType::str, "ATM-ACR"},
bdi{YType::str, "BDI"},
cem{YType::str, "CEM"},
cem_acr{YType::uint8, "CEM-ACR"},
embedded_service_engine{YType::str, "Embedded-Service-Engine"},
ethernet{YType::str, "Ethernet"},
fastethernet{YType::str, "FastEthernet"},
gigabitethernet{YType::str, "GigabitEthernet"},
fivegigabitethernet{YType::str, "FiveGigabitEthernet"},
twentyfivegige{YType::str, "TwentyFiveGigE"},
twogigabitethernet{YType::str, "TwoGigabitEthernet"},
fortygigabitethernet{YType::str, "FortyGigabitEthernet"},
hundredgige{YType::str, "HundredGigE"},
lisp{YType::str, "LISP"},
loopback{YType::uint32, "Loopback"},
multilink{YType::uint16, "Multilink"},
nve{YType::uint16, "nve"},
overlay{YType::uint16, "overlay"},
port_channel{YType::uint32, "Port-channel"},
pseudowire{YType::uint32, "pseudowire"},
sm{YType::str, "SM"},
cellular{YType::str, "Cellular"},
serial{YType::str, "Serial"},
tengigabitethernet{YType::str, "TenGigabitEthernet"},
tunnel{YType::uint32, "Tunnel"},
virtual_template{YType::uint16, "Virtual-Template"},
vlan{YType::uint16, "Vlan"},
virtualportgroup{YType::uint16, "VirtualPortGroup"},
vasileft{YType::uint16, "vasileft"},
vasiright{YType::uint16, "vasiright"}
,
atm_subinterface(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMSubinterface>())
, atm_acrsubinterface(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMACRsubinterface>())
, lisp_subinterface(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::LISPSubinterface>())
, port_channel_subinterface(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::PortChannelSubinterface>())
{
atm_subinterface->parent = this;
atm_acrsubinterface->parent = this;
lisp_subinterface->parent = this;
port_channel_subinterface->parent = this;
yang_name = "interface"; yang_parent_name = "ipv4"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::~Interface()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::has_data() const
{
if (is_presence_container) return true;
return appnav_compress.is_set
|| appnav_uncompress.is_set
|| atm.is_set
|| atm_acr.is_set
|| bdi.is_set
|| cem.is_set
|| cem_acr.is_set
|| embedded_service_engine.is_set
|| ethernet.is_set
|| fastethernet.is_set
|| gigabitethernet.is_set
|| fivegigabitethernet.is_set
|| twentyfivegige.is_set
|| twogigabitethernet.is_set
|| fortygigabitethernet.is_set
|| hundredgige.is_set
|| lisp.is_set
|| loopback.is_set
|| multilink.is_set
|| nve.is_set
|| overlay.is_set
|| port_channel.is_set
|| pseudowire.is_set
|| sm.is_set
|| cellular.is_set
|| serial.is_set
|| tengigabitethernet.is_set
|| tunnel.is_set
|| virtual_template.is_set
|| vlan.is_set
|| virtualportgroup.is_set
|| vasileft.is_set
|| vasiright.is_set
|| (atm_subinterface != nullptr && atm_subinterface->has_data())
|| (atm_acrsubinterface != nullptr && atm_acrsubinterface->has_data())
|| (lisp_subinterface != nullptr && lisp_subinterface->has_data())
|| (port_channel_subinterface != nullptr && port_channel_subinterface->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(appnav_compress.yfilter)
|| ydk::is_set(appnav_uncompress.yfilter)
|| ydk::is_set(atm.yfilter)
|| ydk::is_set(atm_acr.yfilter)
|| ydk::is_set(bdi.yfilter)
|| ydk::is_set(cem.yfilter)
|| ydk::is_set(cem_acr.yfilter)
|| ydk::is_set(embedded_service_engine.yfilter)
|| ydk::is_set(ethernet.yfilter)
|| ydk::is_set(fastethernet.yfilter)
|| ydk::is_set(gigabitethernet.yfilter)
|| ydk::is_set(fivegigabitethernet.yfilter)
|| ydk::is_set(twentyfivegige.yfilter)
|| ydk::is_set(twogigabitethernet.yfilter)
|| ydk::is_set(fortygigabitethernet.yfilter)
|| ydk::is_set(hundredgige.yfilter)
|| ydk::is_set(lisp.yfilter)
|| ydk::is_set(loopback.yfilter)
|| ydk::is_set(multilink.yfilter)
|| ydk::is_set(nve.yfilter)
|| ydk::is_set(overlay.yfilter)
|| ydk::is_set(port_channel.yfilter)
|| ydk::is_set(pseudowire.yfilter)
|| ydk::is_set(sm.yfilter)
|| ydk::is_set(cellular.yfilter)
|| ydk::is_set(serial.yfilter)
|| ydk::is_set(tengigabitethernet.yfilter)
|| ydk::is_set(tunnel.yfilter)
|| ydk::is_set(virtual_template.yfilter)
|| ydk::is_set(vlan.yfilter)
|| ydk::is_set(virtualportgroup.yfilter)
|| ydk::is_set(vasileft.yfilter)
|| ydk::is_set(vasiright.yfilter)
|| (atm_subinterface != nullptr && atm_subinterface->has_operation())
|| (atm_acrsubinterface != nullptr && atm_acrsubinterface->has_operation())
|| (lisp_subinterface != nullptr && lisp_subinterface->has_operation())
|| (port_channel_subinterface != nullptr && port_channel_subinterface->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "interface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (appnav_compress.is_set || is_set(appnav_compress.yfilter)) leaf_name_data.push_back(appnav_compress.get_name_leafdata());
if (appnav_uncompress.is_set || is_set(appnav_uncompress.yfilter)) leaf_name_data.push_back(appnav_uncompress.get_name_leafdata());
if (atm.is_set || is_set(atm.yfilter)) leaf_name_data.push_back(atm.get_name_leafdata());
if (atm_acr.is_set || is_set(atm_acr.yfilter)) leaf_name_data.push_back(atm_acr.get_name_leafdata());
if (bdi.is_set || is_set(bdi.yfilter)) leaf_name_data.push_back(bdi.get_name_leafdata());
if (cem.is_set || is_set(cem.yfilter)) leaf_name_data.push_back(cem.get_name_leafdata());
if (cem_acr.is_set || is_set(cem_acr.yfilter)) leaf_name_data.push_back(cem_acr.get_name_leafdata());
if (embedded_service_engine.is_set || is_set(embedded_service_engine.yfilter)) leaf_name_data.push_back(embedded_service_engine.get_name_leafdata());
if (ethernet.is_set || is_set(ethernet.yfilter)) leaf_name_data.push_back(ethernet.get_name_leafdata());
if (fastethernet.is_set || is_set(fastethernet.yfilter)) leaf_name_data.push_back(fastethernet.get_name_leafdata());
if (gigabitethernet.is_set || is_set(gigabitethernet.yfilter)) leaf_name_data.push_back(gigabitethernet.get_name_leafdata());
if (fivegigabitethernet.is_set || is_set(fivegigabitethernet.yfilter)) leaf_name_data.push_back(fivegigabitethernet.get_name_leafdata());
if (twentyfivegige.is_set || is_set(twentyfivegige.yfilter)) leaf_name_data.push_back(twentyfivegige.get_name_leafdata());
if (twogigabitethernet.is_set || is_set(twogigabitethernet.yfilter)) leaf_name_data.push_back(twogigabitethernet.get_name_leafdata());
if (fortygigabitethernet.is_set || is_set(fortygigabitethernet.yfilter)) leaf_name_data.push_back(fortygigabitethernet.get_name_leafdata());
if (hundredgige.is_set || is_set(hundredgige.yfilter)) leaf_name_data.push_back(hundredgige.get_name_leafdata());
if (lisp.is_set || is_set(lisp.yfilter)) leaf_name_data.push_back(lisp.get_name_leafdata());
if (loopback.is_set || is_set(loopback.yfilter)) leaf_name_data.push_back(loopback.get_name_leafdata());
if (multilink.is_set || is_set(multilink.yfilter)) leaf_name_data.push_back(multilink.get_name_leafdata());
if (nve.is_set || is_set(nve.yfilter)) leaf_name_data.push_back(nve.get_name_leafdata());
if (overlay.is_set || is_set(overlay.yfilter)) leaf_name_data.push_back(overlay.get_name_leafdata());
if (port_channel.is_set || is_set(port_channel.yfilter)) leaf_name_data.push_back(port_channel.get_name_leafdata());
if (pseudowire.is_set || is_set(pseudowire.yfilter)) leaf_name_data.push_back(pseudowire.get_name_leafdata());
if (sm.is_set || is_set(sm.yfilter)) leaf_name_data.push_back(sm.get_name_leafdata());
if (cellular.is_set || is_set(cellular.yfilter)) leaf_name_data.push_back(cellular.get_name_leafdata());
if (serial.is_set || is_set(serial.yfilter)) leaf_name_data.push_back(serial.get_name_leafdata());
if (tengigabitethernet.is_set || is_set(tengigabitethernet.yfilter)) leaf_name_data.push_back(tengigabitethernet.get_name_leafdata());
if (tunnel.is_set || is_set(tunnel.yfilter)) leaf_name_data.push_back(tunnel.get_name_leafdata());
if (virtual_template.is_set || is_set(virtual_template.yfilter)) leaf_name_data.push_back(virtual_template.get_name_leafdata());
if (vlan.is_set || is_set(vlan.yfilter)) leaf_name_data.push_back(vlan.get_name_leafdata());
if (virtualportgroup.is_set || is_set(virtualportgroup.yfilter)) leaf_name_data.push_back(virtualportgroup.get_name_leafdata());
if (vasileft.is_set || is_set(vasileft.yfilter)) leaf_name_data.push_back(vasileft.get_name_leafdata());
if (vasiright.is_set || is_set(vasiright.yfilter)) leaf_name_data.push_back(vasiright.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ATM-subinterface")
{
if(atm_subinterface == nullptr)
{
atm_subinterface = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMSubinterface>();
}
return atm_subinterface;
}
if(child_yang_name == "ATM-ACRsubinterface")
{
if(atm_acrsubinterface == nullptr)
{
atm_acrsubinterface = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMACRsubinterface>();
}
return atm_acrsubinterface;
}
if(child_yang_name == "LISP-subinterface")
{
if(lisp_subinterface == nullptr)
{
lisp_subinterface = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::LISPSubinterface>();
}
return lisp_subinterface;
}
if(child_yang_name == "Port-channel-subinterface")
{
if(port_channel_subinterface == nullptr)
{
port_channel_subinterface = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::PortChannelSubinterface>();
}
return port_channel_subinterface;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(atm_subinterface != nullptr)
{
_children["ATM-subinterface"] = atm_subinterface;
}
if(atm_acrsubinterface != nullptr)
{
_children["ATM-ACRsubinterface"] = atm_acrsubinterface;
}
if(lisp_subinterface != nullptr)
{
_children["LISP-subinterface"] = lisp_subinterface;
}
if(port_channel_subinterface != nullptr)
{
_children["Port-channel-subinterface"] = port_channel_subinterface;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "AppNav-Compress")
{
appnav_compress = value;
appnav_compress.value_namespace = name_space;
appnav_compress.value_namespace_prefix = name_space_prefix;
}
if(value_path == "AppNav-UnCompress")
{
appnav_uncompress = value;
appnav_uncompress.value_namespace = name_space;
appnav_uncompress.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ATM")
{
atm = value;
atm.value_namespace = name_space;
atm.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ATM-ACR")
{
atm_acr = value;
atm_acr.value_namespace = name_space;
atm_acr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "BDI")
{
bdi = value;
bdi.value_namespace = name_space;
bdi.value_namespace_prefix = name_space_prefix;
}
if(value_path == "CEM")
{
cem = value;
cem.value_namespace = name_space;
cem.value_namespace_prefix = name_space_prefix;
}
if(value_path == "CEM-ACR")
{
cem_acr = value;
cem_acr.value_namespace = name_space;
cem_acr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Embedded-Service-Engine")
{
embedded_service_engine = value;
embedded_service_engine.value_namespace = name_space;
embedded_service_engine.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Ethernet")
{
ethernet = value;
ethernet.value_namespace = name_space;
ethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FastEthernet")
{
fastethernet = value;
fastethernet.value_namespace = name_space;
fastethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "GigabitEthernet")
{
gigabitethernet = value;
gigabitethernet.value_namespace = name_space;
gigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FiveGigabitEthernet")
{
fivegigabitethernet = value;
fivegigabitethernet.value_namespace = name_space;
fivegigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TwentyFiveGigE")
{
twentyfivegige = value;
twentyfivegige.value_namespace = name_space;
twentyfivegige.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TwoGigabitEthernet")
{
twogigabitethernet = value;
twogigabitethernet.value_namespace = name_space;
twogigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FortyGigabitEthernet")
{
fortygigabitethernet = value;
fortygigabitethernet.value_namespace = name_space;
fortygigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "HundredGigE")
{
hundredgige = value;
hundredgige.value_namespace = name_space;
hundredgige.value_namespace_prefix = name_space_prefix;
}
if(value_path == "LISP")
{
lisp = value;
lisp.value_namespace = name_space;
lisp.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Loopback")
{
loopback = value;
loopback.value_namespace = name_space;
loopback.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Multilink")
{
multilink = value;
multilink.value_namespace = name_space;
multilink.value_namespace_prefix = name_space_prefix;
}
if(value_path == "nve")
{
nve = value;
nve.value_namespace = name_space;
nve.value_namespace_prefix = name_space_prefix;
}
if(value_path == "overlay")
{
overlay = value;
overlay.value_namespace = name_space;
overlay.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Port-channel")
{
port_channel = value;
port_channel.value_namespace = name_space;
port_channel.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pseudowire")
{
pseudowire = value;
pseudowire.value_namespace = name_space;
pseudowire.value_namespace_prefix = name_space_prefix;
}
if(value_path == "SM")
{
sm = value;
sm.value_namespace = name_space;
sm.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Cellular")
{
cellular = value;
cellular.value_namespace = name_space;
cellular.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Serial")
{
serial = value;
serial.value_namespace = name_space;
serial.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TenGigabitEthernet")
{
tengigabitethernet = value;
tengigabitethernet.value_namespace = name_space;
tengigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Tunnel")
{
tunnel = value;
tunnel.value_namespace = name_space;
tunnel.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Virtual-Template")
{
virtual_template = value;
virtual_template.value_namespace = name_space;
virtual_template.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Vlan")
{
vlan = value;
vlan.value_namespace = name_space;
vlan.value_namespace_prefix = name_space_prefix;
}
if(value_path == "VirtualPortGroup")
{
virtualportgroup = value;
virtualportgroup.value_namespace = name_space;
virtualportgroup.value_namespace_prefix = name_space_prefix;
}
if(value_path == "vasileft")
{
vasileft = value;
vasileft.value_namespace = name_space;
vasileft.value_namespace_prefix = name_space_prefix;
}
if(value_path == "vasiright")
{
vasiright = value;
vasiright.value_namespace = name_space;
vasiright.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "AppNav-Compress")
{
appnav_compress.yfilter = yfilter;
}
if(value_path == "AppNav-UnCompress")
{
appnav_uncompress.yfilter = yfilter;
}
if(value_path == "ATM")
{
atm.yfilter = yfilter;
}
if(value_path == "ATM-ACR")
{
atm_acr.yfilter = yfilter;
}
if(value_path == "BDI")
{
bdi.yfilter = yfilter;
}
if(value_path == "CEM")
{
cem.yfilter = yfilter;
}
if(value_path == "CEM-ACR")
{
cem_acr.yfilter = yfilter;
}
if(value_path == "Embedded-Service-Engine")
{
embedded_service_engine.yfilter = yfilter;
}
if(value_path == "Ethernet")
{
ethernet.yfilter = yfilter;
}
if(value_path == "FastEthernet")
{
fastethernet.yfilter = yfilter;
}
if(value_path == "GigabitEthernet")
{
gigabitethernet.yfilter = yfilter;
}
if(value_path == "FiveGigabitEthernet")
{
fivegigabitethernet.yfilter = yfilter;
}
if(value_path == "TwentyFiveGigE")
{
twentyfivegige.yfilter = yfilter;
}
if(value_path == "TwoGigabitEthernet")
{
twogigabitethernet.yfilter = yfilter;
}
if(value_path == "FortyGigabitEthernet")
{
fortygigabitethernet.yfilter = yfilter;
}
if(value_path == "HundredGigE")
{
hundredgige.yfilter = yfilter;
}
if(value_path == "LISP")
{
lisp.yfilter = yfilter;
}
if(value_path == "Loopback")
{
loopback.yfilter = yfilter;
}
if(value_path == "Multilink")
{
multilink.yfilter = yfilter;
}
if(value_path == "nve")
{
nve.yfilter = yfilter;
}
if(value_path == "overlay")
{
overlay.yfilter = yfilter;
}
if(value_path == "Port-channel")
{
port_channel.yfilter = yfilter;
}
if(value_path == "pseudowire")
{
pseudowire.yfilter = yfilter;
}
if(value_path == "SM")
{
sm.yfilter = yfilter;
}
if(value_path == "Cellular")
{
cellular.yfilter = yfilter;
}
if(value_path == "Serial")
{
serial.yfilter = yfilter;
}
if(value_path == "TenGigabitEthernet")
{
tengigabitethernet.yfilter = yfilter;
}
if(value_path == "Tunnel")
{
tunnel.yfilter = yfilter;
}
if(value_path == "Virtual-Template")
{
virtual_template.yfilter = yfilter;
}
if(value_path == "Vlan")
{
vlan.yfilter = yfilter;
}
if(value_path == "VirtualPortGroup")
{
virtualportgroup.yfilter = yfilter;
}
if(value_path == "vasileft")
{
vasileft.yfilter = yfilter;
}
if(value_path == "vasiright")
{
vasiright.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM-subinterface" || name == "ATM-ACRsubinterface" || name == "LISP-subinterface" || name == "Port-channel-subinterface" || name == "AppNav-Compress" || name == "AppNav-UnCompress" || name == "ATM" || name == "ATM-ACR" || name == "BDI" || name == "CEM" || name == "CEM-ACR" || name == "Embedded-Service-Engine" || name == "Ethernet" || name == "FastEthernet" || name == "GigabitEthernet" || name == "FiveGigabitEthernet" || name == "TwentyFiveGigE" || name == "TwoGigabitEthernet" || name == "FortyGigabitEthernet" || name == "HundredGigE" || name == "LISP" || name == "Loopback" || name == "Multilink" || name == "nve" || name == "overlay" || name == "Port-channel" || name == "pseudowire" || name == "SM" || name == "Cellular" || name == "Serial" || name == "TenGigabitEthernet" || name == "Tunnel" || name == "Virtual-Template" || name == "Vlan" || name == "VirtualPortGroup" || name == "vasileft" || name == "vasiright")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMSubinterface::ATMSubinterface()
:
atm{YType::str, "ATM"}
{
yang_name = "ATM-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMSubinterface::~ATMSubinterface()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMSubinterface::has_data() const
{
if (is_presence_container) return true;
return atm.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(atm.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ATM-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (atm.is_set || is_set(atm.yfilter)) leaf_name_data.push_back(atm.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ATM")
{
atm = value;
atm.value_namespace = name_space;
atm.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ATM")
{
atm.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMACRsubinterface::ATMACRsubinterface()
:
atm_acr{YType::str, "ATM-ACR"}
{
yang_name = "ATM-ACRsubinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMACRsubinterface::~ATMACRsubinterface()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMACRsubinterface::has_data() const
{
if (is_presence_container) return true;
return atm_acr.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMACRsubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(atm_acr.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMACRsubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ATM-ACRsubinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMACRsubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (atm_acr.is_set || is_set(atm_acr.yfilter)) leaf_name_data.push_back(atm_acr.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMACRsubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMACRsubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMACRsubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ATM-ACR")
{
atm_acr = value;
atm_acr.value_namespace = name_space;
atm_acr.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMACRsubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ATM-ACR")
{
atm_acr.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::ATMACRsubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM-ACR")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::LISPSubinterface::LISPSubinterface()
:
lisp{YType::str, "LISP"}
{
yang_name = "LISP-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::LISPSubinterface::~LISPSubinterface()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::LISPSubinterface::has_data() const
{
if (is_presence_container) return true;
return lisp.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::LISPSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lisp.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::LISPSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "LISP-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::LISPSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lisp.is_set || is_set(lisp.yfilter)) leaf_name_data.push_back(lisp.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::LISPSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::LISPSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::LISPSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "LISP")
{
lisp = value;
lisp.value_namespace = name_space;
lisp.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::LISPSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "LISP")
{
lisp.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::LISPSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "LISP")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::PortChannelSubinterface::PortChannelSubinterface()
:
port_channel{YType::str, "Port-channel"}
{
yang_name = "Port-channel-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::PortChannelSubinterface::~PortChannelSubinterface()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::PortChannelSubinterface::has_data() const
{
if (is_presence_container) return true;
return port_channel.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::PortChannelSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(port_channel.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::PortChannelSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "Port-channel-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::PortChannelSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (port_channel.is_set || is_set(port_channel.yfilter)) leaf_name_data.push_back(port_channel.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::PortChannelSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::PortChannelSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::PortChannelSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "Port-channel")
{
port_channel = value;
port_channel.value_namespace = name_space;
port_channel.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::PortChannelSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "Port-channel")
{
port_channel.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Neighbor::Ipv4::Interface::PortChannelSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "Port-channel")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Network::Network()
:
number{YType::str, "number"},
wild_card{YType::str, "wild-card"}
{
yang_name = "network"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Network::~Network()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Network::has_data() const
{
if (is_presence_container) return true;
return number.is_set
|| wild_card.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Network::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(number.yfilter)
|| ydk::is_set(wild_card.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Network::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "network";
ADD_KEY_TOKEN(number, "number");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Network::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (number.is_set || is_set(number.yfilter)) leaf_name_data.push_back(number.get_name_leafdata());
if (wild_card.is_set || is_set(wild_card.yfilter)) leaf_name_data.push_back(wild_card.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Network::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Network::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Network::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "number")
{
number = value;
number.value_namespace = name_space;
number.value_namespace_prefix = name_space_prefix;
}
if(value_path == "wild-card")
{
wild_card = value;
wild_card.value_namespace = name_space;
wild_card.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Network::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "number")
{
number.yfilter = yfilter;
}
if(value_path == "wild-card")
{
wild_card.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Network::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "number" || name == "wild-card")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::OffsetList()
:
nsr_list(this, {"nsr_list"})
, ol_acl(this, {"ol_acl"})
{
yang_name = "offset-list"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::~OffsetList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<nsr_list.len(); index++)
{
if(nsr_list[index]->has_data())
return true;
}
for (std::size_t index=0; index<ol_acl.len(); index++)
{
if(ol_acl[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::has_operation() const
{
for (std::size_t index=0; index<nsr_list.len(); index++)
{
if(nsr_list[index]->has_operation())
return true;
}
for (std::size_t index=0; index<ol_acl.len(); index++)
{
if(ol_acl[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "offset-list";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "nsr-list")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::NsrList>();
ent_->parent = this;
nsr_list.append(ent_);
return ent_;
}
if(child_yang_name == "ol-acl")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::OlAcl>();
ent_->parent = this;
ol_acl.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : nsr_list.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : ol_acl.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "nsr-list" || name == "ol-acl")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::NsrList::NsrList()
:
nsr_list{YType::uint16, "nsr-list"},
in{YType::empty, "in"},
out{YType::empty, "out"}
{
yang_name = "nsr-list"; yang_parent_name = "offset-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::NsrList::~NsrList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::NsrList::has_data() const
{
if (is_presence_container) return true;
return nsr_list.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::NsrList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(nsr_list.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::NsrList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "nsr-list";
ADD_KEY_TOKEN(nsr_list, "nsr-list");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::NsrList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (nsr_list.is_set || is_set(nsr_list.yfilter)) leaf_name_data.push_back(nsr_list.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::NsrList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::NsrList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::NsrList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "nsr-list")
{
nsr_list = value;
nsr_list.value_namespace = name_space;
nsr_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::NsrList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "nsr-list")
{
nsr_list.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::NsrList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "nsr-list" || name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::OlAcl::OlAcl()
:
ol_acl{YType::str, "ol-acl"},
in{YType::empty, "in"},
out{YType::empty, "out"}
{
yang_name = "ol-acl"; yang_parent_name = "offset-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::OlAcl::~OlAcl()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::OlAcl::has_data() const
{
if (is_presence_container) return true;
return ol_acl.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::OlAcl::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ol_acl.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::OlAcl::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ol-acl";
ADD_KEY_TOKEN(ol_acl, "ol-acl");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::OlAcl::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ol_acl.is_set || is_set(ol_acl.yfilter)) leaf_name_data.push_back(ol_acl.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::OlAcl::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::OlAcl::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::OlAcl::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ol-acl")
{
ol_acl = value;
ol_acl.value_namespace = name_space;
ol_acl.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::OlAcl::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ol-acl")
{
ol_acl.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::OffsetList::OlAcl::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ol-acl" || name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Redistribute()
:
eigrp{YType::uint16, "eigrp"},
ospf{YType::uint16, "ospf"}
,
bgp(this, {"rdr_as"})
, connected(nullptr) // presence node
, isis(nullptr) // presence node
, lisp(nullptr) // presence node
, mobile(nullptr) // presence node
, odr(nullptr) // presence node
, rip(nullptr) // presence node
, static_(nullptr) // presence node
, vrf(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Vrf>())
{
vrf->parent = this;
yang_name = "redistribute"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::~Redistribute()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<bgp.len(); index++)
{
if(bgp[index]->has_data())
return true;
}
return eigrp.is_set
|| ospf.is_set
|| (connected != nullptr && connected->has_data())
|| (isis != nullptr && isis->has_data())
|| (lisp != nullptr && lisp->has_data())
|| (mobile != nullptr && mobile->has_data())
|| (odr != nullptr && odr->has_data())
|| (rip != nullptr && rip->has_data())
|| (static_ != nullptr && static_->has_data())
|| (vrf != nullptr && vrf->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::has_operation() const
{
for (std::size_t index=0; index<bgp.len(); index++)
{
if(bgp[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(eigrp.yfilter)
|| ydk::is_set(ospf.yfilter)
|| (connected != nullptr && connected->has_operation())
|| (isis != nullptr && isis->has_operation())
|| (lisp != nullptr && lisp->has_operation())
|| (mobile != nullptr && mobile->has_operation())
|| (odr != nullptr && odr->has_operation())
|| (rip != nullptr && rip->has_operation())
|| (static_ != nullptr && static_->has_operation())
|| (vrf != nullptr && vrf->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "redistribute";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (eigrp.is_set || is_set(eigrp.yfilter)) leaf_name_data.push_back(eigrp.get_name_leafdata());
if (ospf.is_set || is_set(ospf.yfilter)) leaf_name_data.push_back(ospf.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "bgp")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp>();
ent_->parent = this;
bgp.append(ent_);
return ent_;
}
if(child_yang_name == "connected")
{
if(connected == nullptr)
{
connected = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Connected>();
}
return connected;
}
if(child_yang_name == "isis")
{
if(isis == nullptr)
{
isis = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Isis>();
}
return isis;
}
if(child_yang_name == "lisp")
{
if(lisp == nullptr)
{
lisp = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Lisp>();
}
return lisp;
}
if(child_yang_name == "mobile")
{
if(mobile == nullptr)
{
mobile = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Mobile>();
}
return mobile;
}
if(child_yang_name == "odr")
{
if(odr == nullptr)
{
odr = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Odr>();
}
return odr;
}
if(child_yang_name == "rip")
{
if(rip == nullptr)
{
rip = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Rip>();
}
return rip;
}
if(child_yang_name == "static")
{
if(static_ == nullptr)
{
static_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Static>();
}
return static_;
}
if(child_yang_name == "vrf")
{
if(vrf == nullptr)
{
vrf = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Vrf>();
}
return vrf;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : bgp.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
if(connected != nullptr)
{
_children["connected"] = connected;
}
if(isis != nullptr)
{
_children["isis"] = isis;
}
if(lisp != nullptr)
{
_children["lisp"] = lisp;
}
if(mobile != nullptr)
{
_children["mobile"] = mobile;
}
if(odr != nullptr)
{
_children["odr"] = odr;
}
if(rip != nullptr)
{
_children["rip"] = rip;
}
if(static_ != nullptr)
{
_children["static"] = static_;
}
if(vrf != nullptr)
{
_children["vrf"] = vrf;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "eigrp")
{
eigrp = value;
eigrp.value_namespace = name_space;
eigrp.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ospf")
{
ospf = value;
ospf.value_namespace = name_space;
ospf.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "eigrp")
{
eigrp.yfilter = yfilter;
}
if(value_path == "ospf")
{
ospf.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "bgp" || name == "connected" || name == "isis" || name == "lisp" || name == "mobile" || name == "odr" || name == "rip" || name == "static" || name == "vrf" || name == "eigrp" || name == "ospf")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Bgp()
:
rdr_as{YType::str, "rdr-as"},
route_map{YType::str, "route-map"},
rd_lesser_1_period_0_xx_period_yy_greater_{YType::empty, "rd-LESSER_1_PERIOD_0-XX_PERIOD_YY_GREATER_"}
,
metric(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Metric>())
{
metric->parent = this;
yang_name = "bgp"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::~Bgp()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::has_data() const
{
if (is_presence_container) return true;
return rdr_as.is_set
|| route_map.is_set
|| rd_lesser_1_period_0_xx_period_yy_greater_.is_set
|| (metric != nullptr && metric->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(rdr_as.yfilter)
|| ydk::is_set(route_map.yfilter)
|| ydk::is_set(rd_lesser_1_period_0_xx_period_yy_greater_.yfilter)
|| (metric != nullptr && metric->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "bgp";
ADD_KEY_TOKEN(rdr_as, "rdr-as");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (rdr_as.is_set || is_set(rdr_as.yfilter)) leaf_name_data.push_back(rdr_as.get_name_leafdata());
if (route_map.is_set || is_set(route_map.yfilter)) leaf_name_data.push_back(route_map.get_name_leafdata());
if (rd_lesser_1_period_0_xx_period_yy_greater_.is_set || is_set(rd_lesser_1_period_0_xx_period_yy_greater_.yfilter)) leaf_name_data.push_back(rd_lesser_1_period_0_xx_period_yy_greater_.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "metric")
{
if(metric == nullptr)
{
metric = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Metric>();
}
return metric;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(metric != nullptr)
{
_children["metric"] = metric;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "rdr-as")
{
rdr_as = value;
rdr_as.value_namespace = name_space;
rdr_as.value_namespace_prefix = name_space_prefix;
}
if(value_path == "route-map")
{
route_map = value;
route_map.value_namespace = name_space;
route_map.value_namespace_prefix = name_space_prefix;
}
if(value_path == "rd-LESSER_1_PERIOD_0-XX_PERIOD_YY_GREATER_")
{
rd_lesser_1_period_0_xx_period_yy_greater_ = value;
rd_lesser_1_period_0_xx_period_yy_greater_.value_namespace = name_space;
rd_lesser_1_period_0_xx_period_yy_greater_.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "rdr-as")
{
rdr_as.yfilter = yfilter;
}
if(value_path == "route-map")
{
route_map.yfilter = yfilter;
}
if(value_path == "rd-LESSER_1_PERIOD_0-XX_PERIOD_YY_GREATER_")
{
rd_lesser_1_period_0_xx_period_yy_greater_.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "metric" || name == "rdr-as" || name == "route-map" || name == "rd-LESSER_1_PERIOD_0-XX_PERIOD_YY_GREATER_")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Metric::Metric()
:
bandwith{YType::uint32, "bandwith"},
delay{YType::uint32, "delay"},
reliability{YType::uint8, "reliability"},
effective{YType::uint8, "Effective"},
mtu{YType::uint16, "mtu"}
{
yang_name = "metric"; yang_parent_name = "bgp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Metric::~Metric()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Metric::has_data() const
{
if (is_presence_container) return true;
return bandwith.is_set
|| delay.is_set
|| reliability.is_set
|| effective.is_set
|| mtu.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Metric::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(bandwith.yfilter)
|| ydk::is_set(delay.yfilter)
|| ydk::is_set(reliability.yfilter)
|| ydk::is_set(effective.yfilter)
|| ydk::is_set(mtu.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Metric::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "metric";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Metric::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (bandwith.is_set || is_set(bandwith.yfilter)) leaf_name_data.push_back(bandwith.get_name_leafdata());
if (delay.is_set || is_set(delay.yfilter)) leaf_name_data.push_back(delay.get_name_leafdata());
if (reliability.is_set || is_set(reliability.yfilter)) leaf_name_data.push_back(reliability.get_name_leafdata());
if (effective.is_set || is_set(effective.yfilter)) leaf_name_data.push_back(effective.get_name_leafdata());
if (mtu.is_set || is_set(mtu.yfilter)) leaf_name_data.push_back(mtu.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Metric::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Metric::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Metric::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "bandwith")
{
bandwith = value;
bandwith.value_namespace = name_space;
bandwith.value_namespace_prefix = name_space_prefix;
}
if(value_path == "delay")
{
delay = value;
delay.value_namespace = name_space;
delay.value_namespace_prefix = name_space_prefix;
}
if(value_path == "reliability")
{
reliability = value;
reliability.value_namespace = name_space;
reliability.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Effective")
{
effective = value;
effective.value_namespace = name_space;
effective.value_namespace_prefix = name_space_prefix;
}
if(value_path == "mtu")
{
mtu = value;
mtu.value_namespace = name_space;
mtu.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Metric::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "bandwith")
{
bandwith.yfilter = yfilter;
}
if(value_path == "delay")
{
delay.yfilter = yfilter;
}
if(value_path == "reliability")
{
reliability.yfilter = yfilter;
}
if(value_path == "Effective")
{
effective.yfilter = yfilter;
}
if(value_path == "mtu")
{
mtu.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Bgp::Metric::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "bandwith" || name == "delay" || name == "reliability" || name == "Effective" || name == "mtu")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Connected::Connected()
:
metric{YType::empty, "metric"},
route_map{YType::empty, "route-map"}
{
yang_name = "connected"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Connected::~Connected()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Connected::has_data() const
{
if (is_presence_container) return true;
return metric.is_set
|| route_map.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Connected::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(metric.yfilter)
|| ydk::is_set(route_map.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Connected::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "connected";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Connected::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (metric.is_set || is_set(metric.yfilter)) leaf_name_data.push_back(metric.get_name_leafdata());
if (route_map.is_set || is_set(route_map.yfilter)) leaf_name_data.push_back(route_map.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Connected::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Connected::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Connected::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "metric")
{
metric = value;
metric.value_namespace = name_space;
metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "route-map")
{
route_map = value;
route_map.value_namespace = name_space;
route_map.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Connected::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "metric")
{
metric.yfilter = yfilter;
}
if(value_path == "route-map")
{
route_map.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Connected::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "metric" || name == "route-map")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Isis::Isis()
:
is_tag{YType::str, "is-tag"},
level_1{YType::empty, "level-1"},
level_1_2{YType::empty, "level-1-2"},
level_2{YType::empty, "level-2"},
metric{YType::empty, "metric"},
route_map{YType::empty, "route-map"}
{
yang_name = "isis"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Isis::~Isis()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Isis::has_data() const
{
if (is_presence_container) return true;
return is_tag.is_set
|| level_1.is_set
|| level_1_2.is_set
|| level_2.is_set
|| metric.is_set
|| route_map.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Isis::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(is_tag.yfilter)
|| ydk::is_set(level_1.yfilter)
|| ydk::is_set(level_1_2.yfilter)
|| ydk::is_set(level_2.yfilter)
|| ydk::is_set(metric.yfilter)
|| ydk::is_set(route_map.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Isis::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "isis";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Isis::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (is_tag.is_set || is_set(is_tag.yfilter)) leaf_name_data.push_back(is_tag.get_name_leafdata());
if (level_1.is_set || is_set(level_1.yfilter)) leaf_name_data.push_back(level_1.get_name_leafdata());
if (level_1_2.is_set || is_set(level_1_2.yfilter)) leaf_name_data.push_back(level_1_2.get_name_leafdata());
if (level_2.is_set || is_set(level_2.yfilter)) leaf_name_data.push_back(level_2.get_name_leafdata());
if (metric.is_set || is_set(metric.yfilter)) leaf_name_data.push_back(metric.get_name_leafdata());
if (route_map.is_set || is_set(route_map.yfilter)) leaf_name_data.push_back(route_map.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Isis::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Isis::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Isis::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "is-tag")
{
is_tag = value;
is_tag.value_namespace = name_space;
is_tag.value_namespace_prefix = name_space_prefix;
}
if(value_path == "level-1")
{
level_1 = value;
level_1.value_namespace = name_space;
level_1.value_namespace_prefix = name_space_prefix;
}
if(value_path == "level-1-2")
{
level_1_2 = value;
level_1_2.value_namespace = name_space;
level_1_2.value_namespace_prefix = name_space_prefix;
}
if(value_path == "level-2")
{
level_2 = value;
level_2.value_namespace = name_space;
level_2.value_namespace_prefix = name_space_prefix;
}
if(value_path == "metric")
{
metric = value;
metric.value_namespace = name_space;
metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "route-map")
{
route_map = value;
route_map.value_namespace = name_space;
route_map.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Isis::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "is-tag")
{
is_tag.yfilter = yfilter;
}
if(value_path == "level-1")
{
level_1.yfilter = yfilter;
}
if(value_path == "level-1-2")
{
level_1_2.yfilter = yfilter;
}
if(value_path == "level-2")
{
level_2.yfilter = yfilter;
}
if(value_path == "metric")
{
metric.yfilter = yfilter;
}
if(value_path == "route-map")
{
route_map.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Isis::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "is-tag" || name == "level-1" || name == "level-1-2" || name == "level-2" || name == "metric" || name == "route-map")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Lisp::Lisp()
:
metric{YType::empty, "metric"},
route_map{YType::empty, "route-map"}
{
yang_name = "lisp"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Lisp::~Lisp()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Lisp::has_data() const
{
if (is_presence_container) return true;
return metric.is_set
|| route_map.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Lisp::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(metric.yfilter)
|| ydk::is_set(route_map.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Lisp::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "lisp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Lisp::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (metric.is_set || is_set(metric.yfilter)) leaf_name_data.push_back(metric.get_name_leafdata());
if (route_map.is_set || is_set(route_map.yfilter)) leaf_name_data.push_back(route_map.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Lisp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Lisp::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Lisp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "metric")
{
metric = value;
metric.value_namespace = name_space;
metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "route-map")
{
route_map = value;
route_map.value_namespace = name_space;
route_map.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Lisp::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "metric")
{
metric.yfilter = yfilter;
}
if(value_path == "route-map")
{
route_map.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Lisp::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "metric" || name == "route-map")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Mobile::Mobile()
:
metric{YType::empty, "metric"},
route_map{YType::empty, "route-map"}
{
yang_name = "mobile"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Mobile::~Mobile()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Mobile::has_data() const
{
if (is_presence_container) return true;
return metric.is_set
|| route_map.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Mobile::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(metric.yfilter)
|| ydk::is_set(route_map.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Mobile::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "mobile";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Mobile::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (metric.is_set || is_set(metric.yfilter)) leaf_name_data.push_back(metric.get_name_leafdata());
if (route_map.is_set || is_set(route_map.yfilter)) leaf_name_data.push_back(route_map.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Mobile::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Mobile::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Mobile::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "metric")
{
metric = value;
metric.value_namespace = name_space;
metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "route-map")
{
route_map = value;
route_map.value_namespace = name_space;
route_map.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Mobile::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "metric")
{
metric.yfilter = yfilter;
}
if(value_path == "route-map")
{
route_map.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Mobile::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "metric" || name == "route-map")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Odr::Odr()
:
metric{YType::empty, "metric"},
route_map{YType::empty, "route-map"}
{
yang_name = "odr"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Odr::~Odr()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Odr::has_data() const
{
if (is_presence_container) return true;
return metric.is_set
|| route_map.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Odr::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(metric.yfilter)
|| ydk::is_set(route_map.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Odr::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "odr";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Odr::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (metric.is_set || is_set(metric.yfilter)) leaf_name_data.push_back(metric.get_name_leafdata());
if (route_map.is_set || is_set(route_map.yfilter)) leaf_name_data.push_back(route_map.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Odr::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Odr::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Odr::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "metric")
{
metric = value;
metric.value_namespace = name_space;
metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "route-map")
{
route_map = value;
route_map.value_namespace = name_space;
route_map.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Odr::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "metric")
{
metric.yfilter = yfilter;
}
if(value_path == "route-map")
{
route_map.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Odr::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "metric" || name == "route-map")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Rip::Rip()
:
metric{YType::empty, "metric"},
route_map{YType::empty, "route-map"}
{
yang_name = "rip"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Rip::~Rip()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Rip::has_data() const
{
if (is_presence_container) return true;
return metric.is_set
|| route_map.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Rip::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(metric.yfilter)
|| ydk::is_set(route_map.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Rip::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "rip";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Rip::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (metric.is_set || is_set(metric.yfilter)) leaf_name_data.push_back(metric.get_name_leafdata());
if (route_map.is_set || is_set(route_map.yfilter)) leaf_name_data.push_back(route_map.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Rip::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Rip::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Rip::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "metric")
{
metric = value;
metric.value_namespace = name_space;
metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "route-map")
{
route_map = value;
route_map.value_namespace = name_space;
route_map.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Rip::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "metric")
{
metric.yfilter = yfilter;
}
if(value_path == "route-map")
{
route_map.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Rip::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "metric" || name == "route-map")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Static::Static()
:
metric{YType::empty, "metric"},
route_map{YType::empty, "route-map"}
{
yang_name = "static"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Static::~Static()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Static::has_data() const
{
if (is_presence_container) return true;
return metric.is_set
|| route_map.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Static::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(metric.yfilter)
|| ydk::is_set(route_map.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Static::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "static";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Static::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (metric.is_set || is_set(metric.yfilter)) leaf_name_data.push_back(metric.get_name_leafdata());
if (route_map.is_set || is_set(route_map.yfilter)) leaf_name_data.push_back(route_map.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Static::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Static::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Static::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "metric")
{
metric = value;
metric.value_namespace = name_space;
metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "route-map")
{
route_map = value;
route_map.value_namespace = name_space;
route_map.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Static::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "metric")
{
metric.yfilter = yfilter;
}
if(value_path == "route-map")
{
route_map.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Static::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "metric" || name == "route-map")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Vrf::Vrf()
:
name{YType::str, "name"},
global{YType::empty, "global"}
{
yang_name = "vrf"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Vrf::~Vrf()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Vrf::has_data() const
{
if (is_presence_container) return true;
return name.is_set
|| global.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Vrf::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(name.yfilter)
|| ydk::is_set(global.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Vrf::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "vrf";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Vrf::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (name.is_set || is_set(name.yfilter)) leaf_name_data.push_back(name.get_name_leafdata());
if (global.is_set || is_set(global.yfilter)) leaf_name_data.push_back(global.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Vrf::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Vrf::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Vrf::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "name")
{
name = value;
name.value_namespace = name_space;
name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "global")
{
global = value;
global.value_namespace = name_space;
global.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Vrf::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "name")
{
name.yfilter = yfilter;
}
if(value_path == "global")
{
global.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Redistribute::Vrf::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "name" || name == "global")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::SummaryMetric()
:
a_period_b_period_c_period_d_slash_nn{YType::empty, "A_PERIOD_B_PERIOD_C_PERIOD_D_SLASH_nn"}
,
ipv4(this, {"ipv4"})
{
yang_name = "summary-metric"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::~SummaryMetric()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<ipv4.len(); index++)
{
if(ipv4[index]->has_data())
return true;
}
return a_period_b_period_c_period_d_slash_nn.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::has_operation() const
{
for (std::size_t index=0; index<ipv4.len(); index++)
{
if(ipv4[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(a_period_b_period_c_period_d_slash_nn.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "summary-metric";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (a_period_b_period_c_period_d_slash_nn.is_set || is_set(a_period_b_period_c_period_d_slash_nn.yfilter)) leaf_name_data.push_back(a_period_b_period_c_period_d_slash_nn.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ipv4")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::Ipv4>();
ent_->parent = this;
ipv4.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : ipv4.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "A_PERIOD_B_PERIOD_C_PERIOD_D_SLASH_nn")
{
a_period_b_period_c_period_d_slash_nn = value;
a_period_b_period_c_period_d_slash_nn.value_namespace = name_space;
a_period_b_period_c_period_d_slash_nn.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "A_PERIOD_B_PERIOD_C_PERIOD_D_SLASH_nn")
{
a_period_b_period_c_period_d_slash_nn.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4" || name == "A_PERIOD_B_PERIOD_C_PERIOD_D_SLASH_nn")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::Ipv4::Ipv4()
:
ipv4{YType::str, "ipv4"},
mask{YType::str, "mask"}
{
yang_name = "ipv4"; yang_parent_name = "summary-metric"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::Ipv4::~Ipv4()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::Ipv4::has_data() const
{
if (is_presence_container) return true;
return ipv4.is_set
|| mask.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::Ipv4::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ipv4.yfilter)
|| ydk::is_set(mask.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::Ipv4::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv4";
ADD_KEY_TOKEN(ipv4, "ipv4");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::Ipv4::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ipv4.is_set || is_set(ipv4.yfilter)) leaf_name_data.push_back(ipv4.get_name_leafdata());
if (mask.is_set || is_set(mask.yfilter)) leaf_name_data.push_back(mask.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::Ipv4::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::Ipv4::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::Ipv4::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ipv4")
{
ipv4 = value;
ipv4.value_namespace = name_space;
ipv4.value_namespace_prefix = name_space_prefix;
}
if(value_path == "mask")
{
mask = value;
mask.value_namespace = name_space;
mask.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::Ipv4::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ipv4")
{
ipv4.yfilter = yfilter;
}
if(value_path == "mask")
{
mask.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::SummaryMetric::Ipv4::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4" || name == "mask")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Timers()
:
active_time(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::ActiveTime>())
, graceful_restart(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::GracefulRestart>())
, nsf(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Nsf>())
{
active_time->parent = this;
graceful_restart->parent = this;
nsf->parent = this;
yang_name = "timers"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::~Timers()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::has_data() const
{
if (is_presence_container) return true;
return (active_time != nullptr && active_time->has_data())
|| (graceful_restart != nullptr && graceful_restart->has_data())
|| (nsf != nullptr && nsf->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::has_operation() const
{
return is_set(yfilter)
|| (active_time != nullptr && active_time->has_operation())
|| (graceful_restart != nullptr && graceful_restart->has_operation())
|| (nsf != nullptr && nsf->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "timers";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::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> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "active-time")
{
if(active_time == nullptr)
{
active_time = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::ActiveTime>();
}
return active_time;
}
if(child_yang_name == "graceful-restart")
{
if(graceful_restart == nullptr)
{
graceful_restart = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::GracefulRestart>();
}
return graceful_restart;
}
if(child_yang_name == "nsf")
{
if(nsf == nullptr)
{
nsf = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Nsf>();
}
return nsf;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(active_time != nullptr)
{
_children["active-time"] = active_time;
}
if(graceful_restart != nullptr)
{
_children["graceful-restart"] = graceful_restart;
}
if(nsf != nullptr)
{
_children["nsf"] = nsf;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "active-time" || name == "graceful-restart" || name == "nsf")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::ActiveTime::ActiveTime()
:
atimer{YType::uint16, "atimer"},
disabled{YType::empty, "disabled"}
{
yang_name = "active-time"; yang_parent_name = "timers"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::ActiveTime::~ActiveTime()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::ActiveTime::has_data() const
{
if (is_presence_container) return true;
return atimer.is_set
|| disabled.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::ActiveTime::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(atimer.yfilter)
|| ydk::is_set(disabled.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::ActiveTime::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "active-time";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::ActiveTime::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (atimer.is_set || is_set(atimer.yfilter)) leaf_name_data.push_back(atimer.get_name_leafdata());
if (disabled.is_set || is_set(disabled.yfilter)) leaf_name_data.push_back(disabled.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::ActiveTime::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::ActiveTime::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::ActiveTime::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "atimer")
{
atimer = value;
atimer.value_namespace = name_space;
atimer.value_namespace_prefix = name_space_prefix;
}
if(value_path == "disabled")
{
disabled = value;
disabled.value_namespace = name_space;
disabled.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::ActiveTime::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "atimer")
{
atimer.yfilter = yfilter;
}
if(value_path == "disabled")
{
disabled.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::ActiveTime::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "atimer" || name == "disabled")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::GracefulRestart::GracefulRestart()
:
purge_time{YType::empty, "purge-time"}
{
yang_name = "graceful-restart"; yang_parent_name = "timers"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::GracefulRestart::~GracefulRestart()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::GracefulRestart::has_data() const
{
if (is_presence_container) return true;
return purge_time.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::GracefulRestart::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(purge_time.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::GracefulRestart::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "graceful-restart";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::GracefulRestart::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (purge_time.is_set || is_set(purge_time.yfilter)) leaf_name_data.push_back(purge_time.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::GracefulRestart::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::GracefulRestart::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::GracefulRestart::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "purge-time")
{
purge_time = value;
purge_time.value_namespace = name_space;
purge_time.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::GracefulRestart::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "purge-time")
{
purge_time.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::GracefulRestart::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "purge-time")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Nsf::Nsf()
:
converge{YType::empty, "converge"},
signal{YType::empty, "signal"}
{
yang_name = "nsf"; yang_parent_name = "timers"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Nsf::~Nsf()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Nsf::has_data() const
{
if (is_presence_container) return true;
return converge.is_set
|| signal.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Nsf::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(converge.yfilter)
|| ydk::is_set(signal.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Nsf::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "nsf";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Nsf::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (converge.is_set || is_set(converge.yfilter)) leaf_name_data.push_back(converge.get_name_leafdata());
if (signal.is_set || is_set(signal.yfilter)) leaf_name_data.push_back(signal.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Nsf::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Nsf::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Nsf::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "converge")
{
converge = value;
converge.value_namespace = name_space;
converge.value_namespace_prefix = name_space_prefix;
}
if(value_path == "signal")
{
signal = value;
signal.value_namespace = name_space;
signal.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Nsf::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "converge")
{
converge.yfilter = yfilter;
}
if(value_path == "signal")
{
signal.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Timers::Nsf::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "converge" || name == "signal")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::TrafficShare()
:
balanced{YType::empty, "balanced"}
,
min(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::Min>())
{
min->parent = this;
yang_name = "traffic-share"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::~TrafficShare()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::has_data() const
{
if (is_presence_container) return true;
return balanced.is_set
|| (min != nullptr && min->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(balanced.yfilter)
|| (min != nullptr && min->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "traffic-share";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (balanced.is_set || is_set(balanced.yfilter)) leaf_name_data.push_back(balanced.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "min")
{
if(min == nullptr)
{
min = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::Min>();
}
return min;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(min != nullptr)
{
_children["min"] = min;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "balanced")
{
balanced = value;
balanced.value_namespace = name_space;
balanced.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "balanced")
{
balanced.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "min" || name == "balanced")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::Min::Min()
:
across_interfaces{YType::empty, "across-interfaces"}
{
yang_name = "min"; yang_parent_name = "traffic-share"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::Min::~Min()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::Min::has_data() const
{
if (is_presence_container) return true;
return across_interfaces.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::Min::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(across_interfaces.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::Min::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "min";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::Min::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (across_interfaces.is_set || is_set(across_interfaces.yfilter)) leaf_name_data.push_back(across_interfaces.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::Min::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::Min::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::Min::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "across-interfaces")
{
across_interfaces = value;
across_interfaces.value_namespace = name_space;
across_interfaces.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::Min::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "across-interfaces")
{
across_interfaces.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::TrafficShare::Min::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "across-interfaces")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Topology()
:
base(nullptr) // presence node
{
yang_name = "topology"; yang_parent_name = "af-ip-vrf-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::~Topology()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::has_data() const
{
if (is_presence_container) return true;
return (base != nullptr && base->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::has_operation() const
{
return is_set(yfilter)
|| (base != nullptr && base->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "topology";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "base")
{
if(base == nullptr)
{
base = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base>();
}
return base;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(base != nullptr)
{
_children["base"] = base;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "base")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Base()
:
distance(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance>())
, distribute_list(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList>())
, redistribute(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute>())
, summary_metric(this, {"ipv4_addr_slash_prefix_len"})
{
distance->parent = this;
distribute_list->parent = this;
redistribute->parent = this;
yang_name = "base"; yang_parent_name = "topology"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::~Base()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<summary_metric.len(); index++)
{
if(summary_metric[index]->has_data())
return true;
}
return (distance != nullptr && distance->has_data())
|| (distribute_list != nullptr && distribute_list->has_data())
|| (redistribute != nullptr && redistribute->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::has_operation() const
{
for (std::size_t index=0; index<summary_metric.len(); index++)
{
if(summary_metric[index]->has_operation())
return true;
}
return is_set(yfilter)
|| (distance != nullptr && distance->has_operation())
|| (distribute_list != nullptr && distribute_list->has_operation())
|| (redistribute != nullptr && redistribute->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "base";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "distance")
{
if(distance == nullptr)
{
distance = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance>();
}
return distance;
}
if(child_yang_name == "distribute-list")
{
if(distribute_list == nullptr)
{
distribute_list = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList>();
}
return distribute_list;
}
if(child_yang_name == "redistribute")
{
if(redistribute == nullptr)
{
redistribute = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute>();
}
return redistribute;
}
if(child_yang_name == "summary-metric")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric>();
ent_->parent = this;
summary_metric.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(distance != nullptr)
{
_children["distance"] = distance;
}
if(distribute_list != nullptr)
{
_children["distribute-list"] = distribute_list;
}
if(redistribute != nullptr)
{
_children["redistribute"] = redistribute;
}
count_ = 0;
for (auto ent_ : summary_metric.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "distance" || name == "distribute-list" || name == "redistribute" || name == "summary-metric")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Distance()
:
eigrp(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_>())
{
eigrp->parent = this;
yang_name = "distance"; yang_parent_name = "base"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::~Distance()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::has_data() const
{
if (is_presence_container) return true;
return (eigrp != nullptr && eigrp->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::has_operation() const
{
return is_set(yfilter)
|| (eigrp != nullptr && eigrp->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "distance";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "eigrp")
{
if(eigrp == nullptr)
{
eigrp = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_>();
}
return eigrp;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(eigrp != nullptr)
{
_children["eigrp"] = eigrp;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "eigrp")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::Eigrp_()
:
distance_list(this, {"internal_route"})
{
yang_name = "eigrp"; yang_parent_name = "distance"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::~Eigrp_()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<distance_list.len(); index++)
{
if(distance_list[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::has_operation() const
{
for (std::size_t index=0; index<distance_list.len(); index++)
{
if(distance_list[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "eigrp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "distance-list")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::DistanceList>();
ent_->parent = this;
distance_list.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : distance_list.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "distance-list")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::DistanceList::DistanceList()
:
internal_route{YType::uint8, "internal-route"},
external_route{YType::uint8, "external-route"}
{
yang_name = "distance-list"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::DistanceList::~DistanceList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::DistanceList::has_data() const
{
if (is_presence_container) return true;
return internal_route.is_set
|| external_route.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::DistanceList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(internal_route.yfilter)
|| ydk::is_set(external_route.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::DistanceList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "distance-list";
ADD_KEY_TOKEN(internal_route, "internal-route");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::DistanceList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (internal_route.is_set || is_set(internal_route.yfilter)) leaf_name_data.push_back(internal_route.get_name_leafdata());
if (external_route.is_set || is_set(external_route.yfilter)) leaf_name_data.push_back(external_route.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::DistanceList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::DistanceList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::DistanceList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "internal-route")
{
internal_route = value;
internal_route.value_namespace = name_space;
internal_route.value_namespace_prefix = name_space_prefix;
}
if(value_path == "external-route")
{
external_route = value;
external_route.value_namespace = name_space;
external_route.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::DistanceList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "internal-route")
{
internal_route.yfilter = yfilter;
}
if(value_path == "external-route")
{
external_route.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Distance::Eigrp_::DistanceList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "internal-route" || name == "external-route")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::DistributeList()
:
prefix_list(this, {"prefix_list"})
, route_map(this, {"name"})
{
yang_name = "distribute-list"; yang_parent_name = "base"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::~DistributeList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<prefix_list.len(); index++)
{
if(prefix_list[index]->has_data())
return true;
}
for (std::size_t index=0; index<route_map.len(); index++)
{
if(route_map[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::has_operation() const
{
for (std::size_t index=0; index<prefix_list.len(); index++)
{
if(prefix_list[index]->has_operation())
return true;
}
for (std::size_t index=0; index<route_map.len(); index++)
{
if(route_map[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "distribute-list";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "prefix-list")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::PrefixList>();
ent_->parent = this;
prefix_list.append(ent_);
return ent_;
}
if(child_yang_name == "route-map")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::RouteMap>();
ent_->parent = this;
route_map.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : prefix_list.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : route_map.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "prefix-list" || name == "route-map")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::PrefixList::PrefixList()
:
prefix_list{YType::str, "prefix-list"},
gateway{YType::empty, "gateway"},
in{YType::empty, "in"},
out{YType::empty, "out"}
{
yang_name = "prefix-list"; yang_parent_name = "distribute-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::PrefixList::~PrefixList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::PrefixList::has_data() const
{
if (is_presence_container) return true;
return prefix_list.is_set
|| gateway.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::PrefixList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(prefix_list.yfilter)
|| ydk::is_set(gateway.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::PrefixList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "prefix-list";
ADD_KEY_TOKEN(prefix_list, "prefix-list");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::PrefixList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (prefix_list.is_set || is_set(prefix_list.yfilter)) leaf_name_data.push_back(prefix_list.get_name_leafdata());
if (gateway.is_set || is_set(gateway.yfilter)) leaf_name_data.push_back(gateway.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::PrefixList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::PrefixList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::PrefixList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "prefix-list")
{
prefix_list = value;
prefix_list.value_namespace = name_space;
prefix_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "gateway")
{
gateway = value;
gateway.value_namespace = name_space;
gateway.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::PrefixList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
if(value_path == "gateway")
{
gateway.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::PrefixList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "prefix-list" || name == "gateway" || name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::RouteMap::RouteMap()
:
name{YType::str, "name"},
in{YType::str, "in"},
out{YType::str, "out"}
{
yang_name = "route-map"; yang_parent_name = "distribute-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::RouteMap::~RouteMap()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::RouteMap::has_data() const
{
if (is_presence_container) return true;
return name.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::RouteMap::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(name.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::RouteMap::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "route-map";
ADD_KEY_TOKEN(name, "name");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::RouteMap::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (name.is_set || is_set(name.yfilter)) leaf_name_data.push_back(name.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::RouteMap::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::RouteMap::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::RouteMap::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "name")
{
name = value;
name.value_namespace = name_space;
name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::RouteMap::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "name")
{
name.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::DistributeList::RouteMap::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "name" || name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Redistribute()
:
connected{YType::empty, "connected"}
,
eigrp(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_>())
, ospf(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf>())
, static_(nullptr) // presence node
{
eigrp->parent = this;
ospf->parent = this;
yang_name = "redistribute"; yang_parent_name = "base"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::~Redistribute()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::has_data() const
{
if (is_presence_container) return true;
return connected.is_set
|| (eigrp != nullptr && eigrp->has_data())
|| (ospf != nullptr && ospf->has_data())
|| (static_ != nullptr && static_->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(connected.yfilter)
|| (eigrp != nullptr && eigrp->has_operation())
|| (ospf != nullptr && ospf->has_operation())
|| (static_ != nullptr && static_->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "redistribute";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (connected.is_set || is_set(connected.yfilter)) leaf_name_data.push_back(connected.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "eigrp")
{
if(eigrp == nullptr)
{
eigrp = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_>();
}
return eigrp;
}
if(child_yang_name == "ospf")
{
if(ospf == nullptr)
{
ospf = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf>();
}
return ospf;
}
if(child_yang_name == "static")
{
if(static_ == nullptr)
{
static_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Static>();
}
return static_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(eigrp != nullptr)
{
_children["eigrp"] = eigrp;
}
if(ospf != nullptr)
{
_children["ospf"] = ospf;
}
if(static_ != nullptr)
{
_children["static"] = static_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "connected")
{
connected = value;
connected.value_namespace = name_space;
connected.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "connected")
{
connected.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "eigrp" || name == "ospf" || name == "static" || name == "connected")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::Eigrp_()
:
as_list(this, {"autonomous_system"})
{
yang_name = "eigrp"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::~Eigrp_()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<as_list.len(); index++)
{
if(as_list[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::has_operation() const
{
for (std::size_t index=0; index<as_list.len(); index++)
{
if(as_list[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "eigrp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "as-list")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::AsList>();
ent_->parent = this;
as_list.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : as_list.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "as-list")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::AsList::AsList()
:
autonomous_system{YType::uint16, "autonomous-system"}
{
yang_name = "as-list"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::AsList::~AsList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::AsList::has_data() const
{
if (is_presence_container) return true;
return autonomous_system.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::AsList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(autonomous_system.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::AsList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "as-list";
ADD_KEY_TOKEN(autonomous_system, "autonomous-system");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::AsList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (autonomous_system.is_set || is_set(autonomous_system.yfilter)) leaf_name_data.push_back(autonomous_system.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::AsList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::AsList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::AsList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "autonomous-system")
{
autonomous_system = value;
autonomous_system.value_namespace = name_space;
autonomous_system.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::AsList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "autonomous-system")
{
autonomous_system.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Eigrp_::AsList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "autonomous-system")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::Ospf()
:
pid_list(this, {"process_id"})
{
yang_name = "ospf"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::~Ospf()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<pid_list.len(); index++)
{
if(pid_list[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::has_operation() const
{
for (std::size_t index=0; index<pid_list.len(); index++)
{
if(pid_list[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ospf";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "pid-list")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::PidList>();
ent_->parent = this;
pid_list.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : pid_list.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "pid-list")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::PidList::PidList()
:
process_id{YType::uint16, "process-id"}
{
yang_name = "pid-list"; yang_parent_name = "ospf"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::PidList::~PidList()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::PidList::has_data() const
{
if (is_presence_container) return true;
return process_id.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::PidList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(process_id.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::PidList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "pid-list";
ADD_KEY_TOKEN(process_id, "process-id");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::PidList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (process_id.is_set || is_set(process_id.yfilter)) leaf_name_data.push_back(process_id.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::PidList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::PidList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::PidList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "process-id")
{
process_id = value;
process_id.value_namespace = name_space;
process_id.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::PidList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "process-id")
{
process_id.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Ospf::PidList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "process-id")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Static::Static()
{
yang_name = "static"; yang_parent_name = "redistribute"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Static::~Static()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Static::has_data() const
{
if (is_presence_container) return true;
return false;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Static::has_operation() const
{
return is_set(yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Static::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "static";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Static::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Static::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Static::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Static::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Static::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::Redistribute::Static::has_leaf_or_child_of_name(const std::string & name) const
{
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::SummaryMetric()
:
ipv4_addr_slash_prefix_len{YType::str, "ipv4-addr-slash-prefix-len"},
distance{YType::uint8, "distance"}
,
metric(std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::Metric>())
{
metric->parent = this;
yang_name = "summary-metric"; yang_parent_name = "base"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::~SummaryMetric()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::has_data() const
{
if (is_presence_container) return true;
return ipv4_addr_slash_prefix_len.is_set
|| distance.is_set
|| (metric != nullptr && metric->has_data());
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ipv4_addr_slash_prefix_len.yfilter)
|| ydk::is_set(distance.yfilter)
|| (metric != nullptr && metric->has_operation());
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "summary-metric";
ADD_KEY_TOKEN(ipv4_addr_slash_prefix_len, "ipv4-addr-slash-prefix-len");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ipv4_addr_slash_prefix_len.is_set || is_set(ipv4_addr_slash_prefix_len.yfilter)) leaf_name_data.push_back(ipv4_addr_slash_prefix_len.get_name_leafdata());
if (distance.is_set || is_set(distance.yfilter)) leaf_name_data.push_back(distance.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "metric")
{
if(metric == nullptr)
{
metric = std::make_shared<Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::Metric>();
}
return metric;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(metric != nullptr)
{
_children["metric"] = metric;
}
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ipv4-addr-slash-prefix-len")
{
ipv4_addr_slash_prefix_len = value;
ipv4_addr_slash_prefix_len.value_namespace = name_space;
ipv4_addr_slash_prefix_len.value_namespace_prefix = name_space_prefix;
}
if(value_path == "distance")
{
distance = value;
distance.value_namespace = name_space;
distance.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ipv4-addr-slash-prefix-len")
{
ipv4_addr_slash_prefix_len.yfilter = yfilter;
}
if(value_path == "distance")
{
distance.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "metric" || name == "ipv4-addr-slash-prefix-len" || name == "distance")
return true;
return false;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::Metric::Metric()
:
bandwidth_metric{YType::uint32, "bandwidth-metric"},
delay_metric{YType::uint32, "delay-metric"},
reliability_metric{YType::uint8, "reliability-metric"},
effective_bandwidth_metric{YType::uint8, "effective-bandwidth-metric"},
mtu{YType::uint16, "mtu"}
{
yang_name = "metric"; yang_parent_name = "summary-metric"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::Metric::~Metric()
{
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::Metric::has_data() const
{
if (is_presence_container) return true;
return bandwidth_metric.is_set
|| delay_metric.is_set
|| reliability_metric.is_set
|| effective_bandwidth_metric.is_set
|| mtu.is_set;
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::Metric::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(bandwidth_metric.yfilter)
|| ydk::is_set(delay_metric.yfilter)
|| ydk::is_set(reliability_metric.yfilter)
|| ydk::is_set(effective_bandwidth_metric.yfilter)
|| ydk::is_set(mtu.yfilter);
}
std::string Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::Metric::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "metric";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::Metric::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (bandwidth_metric.is_set || is_set(bandwidth_metric.yfilter)) leaf_name_data.push_back(bandwidth_metric.get_name_leafdata());
if (delay_metric.is_set || is_set(delay_metric.yfilter)) leaf_name_data.push_back(delay_metric.get_name_leafdata());
if (reliability_metric.is_set || is_set(reliability_metric.yfilter)) leaf_name_data.push_back(reliability_metric.get_name_leafdata());
if (effective_bandwidth_metric.is_set || is_set(effective_bandwidth_metric.yfilter)) leaf_name_data.push_back(effective_bandwidth_metric.get_name_leafdata());
if (mtu.is_set || is_set(mtu.yfilter)) leaf_name_data.push_back(mtu.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::Metric::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::Metric::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::Metric::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "bandwidth-metric")
{
bandwidth_metric = value;
bandwidth_metric.value_namespace = name_space;
bandwidth_metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "delay-metric")
{
delay_metric = value;
delay_metric.value_namespace = name_space;
delay_metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "reliability-metric")
{
reliability_metric = value;
reliability_metric.value_namespace = name_space;
reliability_metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "effective-bandwidth-metric")
{
effective_bandwidth_metric = value;
effective_bandwidth_metric.value_namespace = name_space;
effective_bandwidth_metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "mtu")
{
mtu = value;
mtu.value_namespace = name_space;
mtu.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::Metric::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "bandwidth-metric")
{
bandwidth_metric.yfilter = yfilter;
}
if(value_path == "delay-metric")
{
delay_metric.yfilter = yfilter;
}
if(value_path == "reliability-metric")
{
reliability_metric.yfilter = yfilter;
}
if(value_path == "effective-bandwidth-metric")
{
effective_bandwidth_metric.yfilter = yfilter;
}
if(value_path == "mtu")
{
mtu.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AddressFamily::AfIpVrfList::Topology::Base::SummaryMetric::Metric::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "bandwidth-metric" || name == "delay-metric" || name == "reliability-metric" || name == "effective-bandwidth-metric" || name == "mtu")
return true;
return false;
}
Native::Router::Eigrp::AfInterface::AfInterface()
:
name{YType::str, "name"},
bandwidth_percent{YType::uint32, "bandwidth-percent"},
hello_interval{YType::uint16, "hello-interval"},
hold_time{YType::uint16, "hold-time"},
passive_interface{YType::boolean, "passive-interface"},
split_horizon{YType::boolean, "split-horizon"}
,
stub_site(std::make_shared<Native::Router::Eigrp::AfInterface::StubSite>())
, authentication(std::make_shared<Native::Router::Eigrp::AfInterface::Authentication>())
, summary_address(std::make_shared<Native::Router::Eigrp::AfInterface::SummaryAddress>())
{
stub_site->parent = this;
authentication->parent = this;
summary_address->parent = this;
yang_name = "af-interface"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AfInterface::~AfInterface()
{
}
bool Native::Router::Eigrp::AfInterface::has_data() const
{
if (is_presence_container) return true;
return name.is_set
|| bandwidth_percent.is_set
|| hello_interval.is_set
|| hold_time.is_set
|| passive_interface.is_set
|| split_horizon.is_set
|| (stub_site != nullptr && stub_site->has_data())
|| (authentication != nullptr && authentication->has_data())
|| (summary_address != nullptr && summary_address->has_data());
}
bool Native::Router::Eigrp::AfInterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(name.yfilter)
|| ydk::is_set(bandwidth_percent.yfilter)
|| ydk::is_set(hello_interval.yfilter)
|| ydk::is_set(hold_time.yfilter)
|| ydk::is_set(passive_interface.yfilter)
|| ydk::is_set(split_horizon.yfilter)
|| (stub_site != nullptr && stub_site->has_operation())
|| (authentication != nullptr && authentication->has_operation())
|| (summary_address != nullptr && summary_address->has_operation());
}
std::string Native::Router::Eigrp::AfInterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "af-interface";
ADD_KEY_TOKEN(name, "name");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AfInterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (name.is_set || is_set(name.yfilter)) leaf_name_data.push_back(name.get_name_leafdata());
if (bandwidth_percent.is_set || is_set(bandwidth_percent.yfilter)) leaf_name_data.push_back(bandwidth_percent.get_name_leafdata());
if (hello_interval.is_set || is_set(hello_interval.yfilter)) leaf_name_data.push_back(hello_interval.get_name_leafdata());
if (hold_time.is_set || is_set(hold_time.yfilter)) leaf_name_data.push_back(hold_time.get_name_leafdata());
if (passive_interface.is_set || is_set(passive_interface.yfilter)) leaf_name_data.push_back(passive_interface.get_name_leafdata());
if (split_horizon.is_set || is_set(split_horizon.yfilter)) leaf_name_data.push_back(split_horizon.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AfInterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "stub-site")
{
if(stub_site == nullptr)
{
stub_site = std::make_shared<Native::Router::Eigrp::AfInterface::StubSite>();
}
return stub_site;
}
if(child_yang_name == "authentication")
{
if(authentication == nullptr)
{
authentication = std::make_shared<Native::Router::Eigrp::AfInterface::Authentication>();
}
return authentication;
}
if(child_yang_name == "summary-address")
{
if(summary_address == nullptr)
{
summary_address = std::make_shared<Native::Router::Eigrp::AfInterface::SummaryAddress>();
}
return summary_address;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AfInterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(stub_site != nullptr)
{
_children["stub-site"] = stub_site;
}
if(authentication != nullptr)
{
_children["authentication"] = authentication;
}
if(summary_address != nullptr)
{
_children["summary-address"] = summary_address;
}
return _children;
}
void Native::Router::Eigrp::AfInterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "name")
{
name = value;
name.value_namespace = name_space;
name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "bandwidth-percent")
{
bandwidth_percent = value;
bandwidth_percent.value_namespace = name_space;
bandwidth_percent.value_namespace_prefix = name_space_prefix;
}
if(value_path == "hello-interval")
{
hello_interval = value;
hello_interval.value_namespace = name_space;
hello_interval.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 == "passive-interface")
{
passive_interface = value;
passive_interface.value_namespace = name_space;
passive_interface.value_namespace_prefix = name_space_prefix;
}
if(value_path == "split-horizon")
{
split_horizon = value;
split_horizon.value_namespace = name_space;
split_horizon.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AfInterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "name")
{
name.yfilter = yfilter;
}
if(value_path == "bandwidth-percent")
{
bandwidth_percent.yfilter = yfilter;
}
if(value_path == "hello-interval")
{
hello_interval.yfilter = yfilter;
}
if(value_path == "hold-time")
{
hold_time.yfilter = yfilter;
}
if(value_path == "passive-interface")
{
passive_interface.yfilter = yfilter;
}
if(value_path == "split-horizon")
{
split_horizon.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AfInterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "stub-site" || name == "authentication" || name == "summary-address" || name == "name" || name == "bandwidth-percent" || name == "hello-interval" || name == "hold-time" || name == "passive-interface" || name == "split-horizon")
return true;
return false;
}
Native::Router::Eigrp::AfInterface::StubSite::StubSite()
:
wan_interface{YType::empty, "wan-interface"}
{
yang_name = "stub-site"; yang_parent_name = "af-interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AfInterface::StubSite::~StubSite()
{
}
bool Native::Router::Eigrp::AfInterface::StubSite::has_data() const
{
if (is_presence_container) return true;
return wan_interface.is_set;
}
bool Native::Router::Eigrp::AfInterface::StubSite::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(wan_interface.yfilter);
}
std::string Native::Router::Eigrp::AfInterface::StubSite::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "stub-site";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AfInterface::StubSite::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (wan_interface.is_set || is_set(wan_interface.yfilter)) leaf_name_data.push_back(wan_interface.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AfInterface::StubSite::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AfInterface::StubSite::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AfInterface::StubSite::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "wan-interface")
{
wan_interface = value;
wan_interface.value_namespace = name_space;
wan_interface.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AfInterface::StubSite::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "wan-interface")
{
wan_interface.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AfInterface::StubSite::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "wan-interface")
return true;
return false;
}
Native::Router::Eigrp::AfInterface::Authentication::Authentication()
:
key_chain{YType::str, "key-chain"}
,
mode(std::make_shared<Native::Router::Eigrp::AfInterface::Authentication::Mode>())
{
mode->parent = this;
yang_name = "authentication"; yang_parent_name = "af-interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AfInterface::Authentication::~Authentication()
{
}
bool Native::Router::Eigrp::AfInterface::Authentication::has_data() const
{
if (is_presence_container) return true;
return key_chain.is_set
|| (mode != nullptr && mode->has_data());
}
bool Native::Router::Eigrp::AfInterface::Authentication::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(key_chain.yfilter)
|| (mode != nullptr && mode->has_operation());
}
std::string Native::Router::Eigrp::AfInterface::Authentication::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "authentication";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AfInterface::Authentication::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (key_chain.is_set || is_set(key_chain.yfilter)) leaf_name_data.push_back(key_chain.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AfInterface::Authentication::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "mode")
{
if(mode == nullptr)
{
mode = std::make_shared<Native::Router::Eigrp::AfInterface::Authentication::Mode>();
}
return mode;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AfInterface::Authentication::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(mode != nullptr)
{
_children["mode"] = mode;
}
return _children;
}
void Native::Router::Eigrp::AfInterface::Authentication::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "key-chain")
{
key_chain = value;
key_chain.value_namespace = name_space;
key_chain.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AfInterface::Authentication::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "key-chain")
{
key_chain.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AfInterface::Authentication::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "mode" || name == "key-chain")
return true;
return false;
}
Native::Router::Eigrp::AfInterface::Authentication::Mode::Mode()
:
md5{YType::empty, "md5"}
,
hmac_sha_256(std::make_shared<Native::Router::Eigrp::AfInterface::Authentication::Mode::HmacSha256>())
{
hmac_sha_256->parent = this;
yang_name = "mode"; yang_parent_name = "authentication"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AfInterface::Authentication::Mode::~Mode()
{
}
bool Native::Router::Eigrp::AfInterface::Authentication::Mode::has_data() const
{
if (is_presence_container) return true;
return md5.is_set
|| (hmac_sha_256 != nullptr && hmac_sha_256->has_data());
}
bool Native::Router::Eigrp::AfInterface::Authentication::Mode::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(md5.yfilter)
|| (hmac_sha_256 != nullptr && hmac_sha_256->has_operation());
}
std::string Native::Router::Eigrp::AfInterface::Authentication::Mode::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "mode";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AfInterface::Authentication::Mode::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (md5.is_set || is_set(md5.yfilter)) leaf_name_data.push_back(md5.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AfInterface::Authentication::Mode::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "hmac-sha-256")
{
if(hmac_sha_256 == nullptr)
{
hmac_sha_256 = std::make_shared<Native::Router::Eigrp::AfInterface::Authentication::Mode::HmacSha256>();
}
return hmac_sha_256;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AfInterface::Authentication::Mode::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(hmac_sha_256 != nullptr)
{
_children["hmac-sha-256"] = hmac_sha_256;
}
return _children;
}
void Native::Router::Eigrp::AfInterface::Authentication::Mode::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "md5")
{
md5 = value;
md5.value_namespace = name_space;
md5.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AfInterface::Authentication::Mode::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "md5")
{
md5.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AfInterface::Authentication::Mode::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "hmac-sha-256" || name == "md5")
return true;
return false;
}
Native::Router::Eigrp::AfInterface::Authentication::Mode::HmacSha256::HmacSha256()
:
auth_type{YType::uint8, "auth-type"},
auth_key{YType::str, "auth-key"}
{
yang_name = "hmac-sha-256"; yang_parent_name = "mode"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AfInterface::Authentication::Mode::HmacSha256::~HmacSha256()
{
}
bool Native::Router::Eigrp::AfInterface::Authentication::Mode::HmacSha256::has_data() const
{
if (is_presence_container) return true;
return auth_type.is_set
|| auth_key.is_set;
}
bool Native::Router::Eigrp::AfInterface::Authentication::Mode::HmacSha256::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(auth_type.yfilter)
|| ydk::is_set(auth_key.yfilter);
}
std::string Native::Router::Eigrp::AfInterface::Authentication::Mode::HmacSha256::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "hmac-sha-256";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AfInterface::Authentication::Mode::HmacSha256::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (auth_type.is_set || is_set(auth_type.yfilter)) leaf_name_data.push_back(auth_type.get_name_leafdata());
if (auth_key.is_set || is_set(auth_key.yfilter)) leaf_name_data.push_back(auth_key.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AfInterface::Authentication::Mode::HmacSha256::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AfInterface::Authentication::Mode::HmacSha256::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AfInterface::Authentication::Mode::HmacSha256::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "auth-type")
{
auth_type = value;
auth_type.value_namespace = name_space;
auth_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "auth-key")
{
auth_key = value;
auth_key.value_namespace = name_space;
auth_key.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AfInterface::Authentication::Mode::HmacSha256::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "auth-type")
{
auth_type.yfilter = yfilter;
}
if(value_path == "auth-key")
{
auth_key.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AfInterface::Authentication::Mode::HmacSha256::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "auth-type" || name == "auth-key")
return true;
return false;
}
Native::Router::Eigrp::AfInterface::SummaryAddress::SummaryAddress()
:
address{YType::str, "address"},
mask{YType::str, "mask"}
{
yang_name = "summary-address"; yang_parent_name = "af-interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::AfInterface::SummaryAddress::~SummaryAddress()
{
}
bool Native::Router::Eigrp::AfInterface::SummaryAddress::has_data() const
{
if (is_presence_container) return true;
return address.is_set
|| mask.is_set;
}
bool Native::Router::Eigrp::AfInterface::SummaryAddress::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(address.yfilter)
|| ydk::is_set(mask.yfilter);
}
std::string Native::Router::Eigrp::AfInterface::SummaryAddress::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "summary-address";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::AfInterface::SummaryAddress::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata());
if (mask.is_set || is_set(mask.yfilter)) leaf_name_data.push_back(mask.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::AfInterface::SummaryAddress::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::AfInterface::SummaryAddress::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::AfInterface::SummaryAddress::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address = value;
address.value_namespace = name_space;
address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "mask")
{
mask = value;
mask.value_namespace = name_space;
mask.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::AfInterface::SummaryAddress::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
if(value_path == "mask")
{
mask.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::AfInterface::SummaryAddress::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "mask")
return true;
return false;
}
Native::Router::Eigrp::SetAsInSubmode::SetAsInSubmode()
:
autonomous_system{YType::uint16, "autonomous-system"}
{
yang_name = "set-as-in-submode"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::SetAsInSubmode::~SetAsInSubmode()
{
}
bool Native::Router::Eigrp::SetAsInSubmode::has_data() const
{
if (is_presence_container) return true;
return autonomous_system.is_set;
}
bool Native::Router::Eigrp::SetAsInSubmode::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(autonomous_system.yfilter);
}
std::string Native::Router::Eigrp::SetAsInSubmode::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "set-as-in-submode";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::SetAsInSubmode::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (autonomous_system.is_set || is_set(autonomous_system.yfilter)) leaf_name_data.push_back(autonomous_system.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::SetAsInSubmode::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::SetAsInSubmode::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::SetAsInSubmode::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "autonomous-system")
{
autonomous_system = value;
autonomous_system.value_namespace = name_space;
autonomous_system.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::SetAsInSubmode::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "autonomous-system")
{
autonomous_system.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::SetAsInSubmode::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "autonomous-system")
return true;
return false;
}
Native::Router::Eigrp::Bfd::Bfd()
:
all_interfaces{YType::empty, "all-interfaces"}
,
interface(std::make_shared<Native::Router::Eigrp::Bfd::Interface>())
{
interface->parent = this;
yang_name = "bfd"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Bfd::~Bfd()
{
}
bool Native::Router::Eigrp::Bfd::has_data() const
{
if (is_presence_container) return true;
return all_interfaces.is_set
|| (interface != nullptr && interface->has_data());
}
bool Native::Router::Eigrp::Bfd::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(all_interfaces.yfilter)
|| (interface != nullptr && interface->has_operation());
}
std::string Native::Router::Eigrp::Bfd::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "bfd";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Bfd::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (all_interfaces.is_set || is_set(all_interfaces.yfilter)) leaf_name_data.push_back(all_interfaces.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Bfd::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "interface")
{
if(interface == nullptr)
{
interface = std::make_shared<Native::Router::Eigrp::Bfd::Interface>();
}
return interface;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Bfd::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(interface != nullptr)
{
_children["interface"] = interface;
}
return _children;
}
void Native::Router::Eigrp::Bfd::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "all-interfaces")
{
all_interfaces = value;
all_interfaces.value_namespace = name_space;
all_interfaces.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Bfd::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "all-interfaces")
{
all_interfaces.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Bfd::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "interface" || name == "all-interfaces")
return true;
return false;
}
Native::Router::Eigrp::Bfd::Interface::Interface()
:
appnav_compress{YType::uint16, "AppNav-Compress"},
appnav_uncompress{YType::uint16, "AppNav-UnCompress"},
atm{YType::str, "ATM"},
atm_acr{YType::str, "ATM-ACR"},
bdi{YType::str, "BDI"},
cem{YType::str, "CEM"},
cem_acr{YType::uint8, "CEM-ACR"},
embedded_service_engine{YType::str, "Embedded-Service-Engine"},
ethernet{YType::str, "Ethernet"},
fastethernet{YType::str, "FastEthernet"},
gigabitethernet{YType::str, "GigabitEthernet"},
fivegigabitethernet{YType::str, "FiveGigabitEthernet"},
twentyfivegige{YType::str, "TwentyFiveGigE"},
twogigabitethernet{YType::str, "TwoGigabitEthernet"},
fortygigabitethernet{YType::str, "FortyGigabitEthernet"},
hundredgige{YType::str, "HundredGigE"},
lisp{YType::str, "LISP"},
loopback{YType::uint32, "Loopback"},
multilink{YType::uint16, "Multilink"},
nve{YType::uint16, "nve"},
overlay{YType::uint16, "overlay"},
port_channel{YType::uint32, "Port-channel"},
pseudowire{YType::uint32, "pseudowire"},
sm{YType::str, "SM"},
cellular{YType::str, "Cellular"},
serial{YType::str, "Serial"},
tengigabitethernet{YType::str, "TenGigabitEthernet"},
tunnel{YType::uint32, "Tunnel"},
virtual_template{YType::uint16, "Virtual-Template"},
vlan{YType::uint16, "Vlan"},
virtualportgroup{YType::uint16, "VirtualPortGroup"},
vasileft{YType::uint16, "vasileft"},
vasiright{YType::uint16, "vasiright"}
,
atm_subinterface(std::make_shared<Native::Router::Eigrp::Bfd::Interface::ATMSubinterface>())
, atm_acrsubinterface(std::make_shared<Native::Router::Eigrp::Bfd::Interface::ATMACRsubinterface>())
, lisp_subinterface(std::make_shared<Native::Router::Eigrp::Bfd::Interface::LISPSubinterface>())
, port_channel_subinterface(std::make_shared<Native::Router::Eigrp::Bfd::Interface::PortChannelSubinterface>())
{
atm_subinterface->parent = this;
atm_acrsubinterface->parent = this;
lisp_subinterface->parent = this;
port_channel_subinterface->parent = this;
yang_name = "interface"; yang_parent_name = "bfd"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Bfd::Interface::~Interface()
{
}
bool Native::Router::Eigrp::Bfd::Interface::has_data() const
{
if (is_presence_container) return true;
return appnav_compress.is_set
|| appnav_uncompress.is_set
|| atm.is_set
|| atm_acr.is_set
|| bdi.is_set
|| cem.is_set
|| cem_acr.is_set
|| embedded_service_engine.is_set
|| ethernet.is_set
|| fastethernet.is_set
|| gigabitethernet.is_set
|| fivegigabitethernet.is_set
|| twentyfivegige.is_set
|| twogigabitethernet.is_set
|| fortygigabitethernet.is_set
|| hundredgige.is_set
|| lisp.is_set
|| loopback.is_set
|| multilink.is_set
|| nve.is_set
|| overlay.is_set
|| port_channel.is_set
|| pseudowire.is_set
|| sm.is_set
|| cellular.is_set
|| serial.is_set
|| tengigabitethernet.is_set
|| tunnel.is_set
|| virtual_template.is_set
|| vlan.is_set
|| virtualportgroup.is_set
|| vasileft.is_set
|| vasiright.is_set
|| (atm_subinterface != nullptr && atm_subinterface->has_data())
|| (atm_acrsubinterface != nullptr && atm_acrsubinterface->has_data())
|| (lisp_subinterface != nullptr && lisp_subinterface->has_data())
|| (port_channel_subinterface != nullptr && port_channel_subinterface->has_data());
}
bool Native::Router::Eigrp::Bfd::Interface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(appnav_compress.yfilter)
|| ydk::is_set(appnav_uncompress.yfilter)
|| ydk::is_set(atm.yfilter)
|| ydk::is_set(atm_acr.yfilter)
|| ydk::is_set(bdi.yfilter)
|| ydk::is_set(cem.yfilter)
|| ydk::is_set(cem_acr.yfilter)
|| ydk::is_set(embedded_service_engine.yfilter)
|| ydk::is_set(ethernet.yfilter)
|| ydk::is_set(fastethernet.yfilter)
|| ydk::is_set(gigabitethernet.yfilter)
|| ydk::is_set(fivegigabitethernet.yfilter)
|| ydk::is_set(twentyfivegige.yfilter)
|| ydk::is_set(twogigabitethernet.yfilter)
|| ydk::is_set(fortygigabitethernet.yfilter)
|| ydk::is_set(hundredgige.yfilter)
|| ydk::is_set(lisp.yfilter)
|| ydk::is_set(loopback.yfilter)
|| ydk::is_set(multilink.yfilter)
|| ydk::is_set(nve.yfilter)
|| ydk::is_set(overlay.yfilter)
|| ydk::is_set(port_channel.yfilter)
|| ydk::is_set(pseudowire.yfilter)
|| ydk::is_set(sm.yfilter)
|| ydk::is_set(cellular.yfilter)
|| ydk::is_set(serial.yfilter)
|| ydk::is_set(tengigabitethernet.yfilter)
|| ydk::is_set(tunnel.yfilter)
|| ydk::is_set(virtual_template.yfilter)
|| ydk::is_set(vlan.yfilter)
|| ydk::is_set(virtualportgroup.yfilter)
|| ydk::is_set(vasileft.yfilter)
|| ydk::is_set(vasiright.yfilter)
|| (atm_subinterface != nullptr && atm_subinterface->has_operation())
|| (atm_acrsubinterface != nullptr && atm_acrsubinterface->has_operation())
|| (lisp_subinterface != nullptr && lisp_subinterface->has_operation())
|| (port_channel_subinterface != nullptr && port_channel_subinterface->has_operation());
}
std::string Native::Router::Eigrp::Bfd::Interface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "interface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Bfd::Interface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (appnav_compress.is_set || is_set(appnav_compress.yfilter)) leaf_name_data.push_back(appnav_compress.get_name_leafdata());
if (appnav_uncompress.is_set || is_set(appnav_uncompress.yfilter)) leaf_name_data.push_back(appnav_uncompress.get_name_leafdata());
if (atm.is_set || is_set(atm.yfilter)) leaf_name_data.push_back(atm.get_name_leafdata());
if (atm_acr.is_set || is_set(atm_acr.yfilter)) leaf_name_data.push_back(atm_acr.get_name_leafdata());
if (bdi.is_set || is_set(bdi.yfilter)) leaf_name_data.push_back(bdi.get_name_leafdata());
if (cem.is_set || is_set(cem.yfilter)) leaf_name_data.push_back(cem.get_name_leafdata());
if (cem_acr.is_set || is_set(cem_acr.yfilter)) leaf_name_data.push_back(cem_acr.get_name_leafdata());
if (embedded_service_engine.is_set || is_set(embedded_service_engine.yfilter)) leaf_name_data.push_back(embedded_service_engine.get_name_leafdata());
if (ethernet.is_set || is_set(ethernet.yfilter)) leaf_name_data.push_back(ethernet.get_name_leafdata());
if (fastethernet.is_set || is_set(fastethernet.yfilter)) leaf_name_data.push_back(fastethernet.get_name_leafdata());
if (gigabitethernet.is_set || is_set(gigabitethernet.yfilter)) leaf_name_data.push_back(gigabitethernet.get_name_leafdata());
if (fivegigabitethernet.is_set || is_set(fivegigabitethernet.yfilter)) leaf_name_data.push_back(fivegigabitethernet.get_name_leafdata());
if (twentyfivegige.is_set || is_set(twentyfivegige.yfilter)) leaf_name_data.push_back(twentyfivegige.get_name_leafdata());
if (twogigabitethernet.is_set || is_set(twogigabitethernet.yfilter)) leaf_name_data.push_back(twogigabitethernet.get_name_leafdata());
if (fortygigabitethernet.is_set || is_set(fortygigabitethernet.yfilter)) leaf_name_data.push_back(fortygigabitethernet.get_name_leafdata());
if (hundredgige.is_set || is_set(hundredgige.yfilter)) leaf_name_data.push_back(hundredgige.get_name_leafdata());
if (lisp.is_set || is_set(lisp.yfilter)) leaf_name_data.push_back(lisp.get_name_leafdata());
if (loopback.is_set || is_set(loopback.yfilter)) leaf_name_data.push_back(loopback.get_name_leafdata());
if (multilink.is_set || is_set(multilink.yfilter)) leaf_name_data.push_back(multilink.get_name_leafdata());
if (nve.is_set || is_set(nve.yfilter)) leaf_name_data.push_back(nve.get_name_leafdata());
if (overlay.is_set || is_set(overlay.yfilter)) leaf_name_data.push_back(overlay.get_name_leafdata());
if (port_channel.is_set || is_set(port_channel.yfilter)) leaf_name_data.push_back(port_channel.get_name_leafdata());
if (pseudowire.is_set || is_set(pseudowire.yfilter)) leaf_name_data.push_back(pseudowire.get_name_leafdata());
if (sm.is_set || is_set(sm.yfilter)) leaf_name_data.push_back(sm.get_name_leafdata());
if (cellular.is_set || is_set(cellular.yfilter)) leaf_name_data.push_back(cellular.get_name_leafdata());
if (serial.is_set || is_set(serial.yfilter)) leaf_name_data.push_back(serial.get_name_leafdata());
if (tengigabitethernet.is_set || is_set(tengigabitethernet.yfilter)) leaf_name_data.push_back(tengigabitethernet.get_name_leafdata());
if (tunnel.is_set || is_set(tunnel.yfilter)) leaf_name_data.push_back(tunnel.get_name_leafdata());
if (virtual_template.is_set || is_set(virtual_template.yfilter)) leaf_name_data.push_back(virtual_template.get_name_leafdata());
if (vlan.is_set || is_set(vlan.yfilter)) leaf_name_data.push_back(vlan.get_name_leafdata());
if (virtualportgroup.is_set || is_set(virtualportgroup.yfilter)) leaf_name_data.push_back(virtualportgroup.get_name_leafdata());
if (vasileft.is_set || is_set(vasileft.yfilter)) leaf_name_data.push_back(vasileft.get_name_leafdata());
if (vasiright.is_set || is_set(vasiright.yfilter)) leaf_name_data.push_back(vasiright.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Bfd::Interface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ATM-subinterface")
{
if(atm_subinterface == nullptr)
{
atm_subinterface = std::make_shared<Native::Router::Eigrp::Bfd::Interface::ATMSubinterface>();
}
return atm_subinterface;
}
if(child_yang_name == "ATM-ACRsubinterface")
{
if(atm_acrsubinterface == nullptr)
{
atm_acrsubinterface = std::make_shared<Native::Router::Eigrp::Bfd::Interface::ATMACRsubinterface>();
}
return atm_acrsubinterface;
}
if(child_yang_name == "LISP-subinterface")
{
if(lisp_subinterface == nullptr)
{
lisp_subinterface = std::make_shared<Native::Router::Eigrp::Bfd::Interface::LISPSubinterface>();
}
return lisp_subinterface;
}
if(child_yang_name == "Port-channel-subinterface")
{
if(port_channel_subinterface == nullptr)
{
port_channel_subinterface = std::make_shared<Native::Router::Eigrp::Bfd::Interface::PortChannelSubinterface>();
}
return port_channel_subinterface;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Bfd::Interface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(atm_subinterface != nullptr)
{
_children["ATM-subinterface"] = atm_subinterface;
}
if(atm_acrsubinterface != nullptr)
{
_children["ATM-ACRsubinterface"] = atm_acrsubinterface;
}
if(lisp_subinterface != nullptr)
{
_children["LISP-subinterface"] = lisp_subinterface;
}
if(port_channel_subinterface != nullptr)
{
_children["Port-channel-subinterface"] = port_channel_subinterface;
}
return _children;
}
void Native::Router::Eigrp::Bfd::Interface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "AppNav-Compress")
{
appnav_compress = value;
appnav_compress.value_namespace = name_space;
appnav_compress.value_namespace_prefix = name_space_prefix;
}
if(value_path == "AppNav-UnCompress")
{
appnav_uncompress = value;
appnav_uncompress.value_namespace = name_space;
appnav_uncompress.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ATM")
{
atm = value;
atm.value_namespace = name_space;
atm.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ATM-ACR")
{
atm_acr = value;
atm_acr.value_namespace = name_space;
atm_acr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "BDI")
{
bdi = value;
bdi.value_namespace = name_space;
bdi.value_namespace_prefix = name_space_prefix;
}
if(value_path == "CEM")
{
cem = value;
cem.value_namespace = name_space;
cem.value_namespace_prefix = name_space_prefix;
}
if(value_path == "CEM-ACR")
{
cem_acr = value;
cem_acr.value_namespace = name_space;
cem_acr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Embedded-Service-Engine")
{
embedded_service_engine = value;
embedded_service_engine.value_namespace = name_space;
embedded_service_engine.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Ethernet")
{
ethernet = value;
ethernet.value_namespace = name_space;
ethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FastEthernet")
{
fastethernet = value;
fastethernet.value_namespace = name_space;
fastethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "GigabitEthernet")
{
gigabitethernet = value;
gigabitethernet.value_namespace = name_space;
gigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FiveGigabitEthernet")
{
fivegigabitethernet = value;
fivegigabitethernet.value_namespace = name_space;
fivegigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TwentyFiveGigE")
{
twentyfivegige = value;
twentyfivegige.value_namespace = name_space;
twentyfivegige.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TwoGigabitEthernet")
{
twogigabitethernet = value;
twogigabitethernet.value_namespace = name_space;
twogigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FortyGigabitEthernet")
{
fortygigabitethernet = value;
fortygigabitethernet.value_namespace = name_space;
fortygigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "HundredGigE")
{
hundredgige = value;
hundredgige.value_namespace = name_space;
hundredgige.value_namespace_prefix = name_space_prefix;
}
if(value_path == "LISP")
{
lisp = value;
lisp.value_namespace = name_space;
lisp.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Loopback")
{
loopback = value;
loopback.value_namespace = name_space;
loopback.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Multilink")
{
multilink = value;
multilink.value_namespace = name_space;
multilink.value_namespace_prefix = name_space_prefix;
}
if(value_path == "nve")
{
nve = value;
nve.value_namespace = name_space;
nve.value_namespace_prefix = name_space_prefix;
}
if(value_path == "overlay")
{
overlay = value;
overlay.value_namespace = name_space;
overlay.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Port-channel")
{
port_channel = value;
port_channel.value_namespace = name_space;
port_channel.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pseudowire")
{
pseudowire = value;
pseudowire.value_namespace = name_space;
pseudowire.value_namespace_prefix = name_space_prefix;
}
if(value_path == "SM")
{
sm = value;
sm.value_namespace = name_space;
sm.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Cellular")
{
cellular = value;
cellular.value_namespace = name_space;
cellular.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Serial")
{
serial = value;
serial.value_namespace = name_space;
serial.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TenGigabitEthernet")
{
tengigabitethernet = value;
tengigabitethernet.value_namespace = name_space;
tengigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Tunnel")
{
tunnel = value;
tunnel.value_namespace = name_space;
tunnel.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Virtual-Template")
{
virtual_template = value;
virtual_template.value_namespace = name_space;
virtual_template.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Vlan")
{
vlan = value;
vlan.value_namespace = name_space;
vlan.value_namespace_prefix = name_space_prefix;
}
if(value_path == "VirtualPortGroup")
{
virtualportgroup = value;
virtualportgroup.value_namespace = name_space;
virtualportgroup.value_namespace_prefix = name_space_prefix;
}
if(value_path == "vasileft")
{
vasileft = value;
vasileft.value_namespace = name_space;
vasileft.value_namespace_prefix = name_space_prefix;
}
if(value_path == "vasiright")
{
vasiright = value;
vasiright.value_namespace = name_space;
vasiright.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Bfd::Interface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "AppNav-Compress")
{
appnav_compress.yfilter = yfilter;
}
if(value_path == "AppNav-UnCompress")
{
appnav_uncompress.yfilter = yfilter;
}
if(value_path == "ATM")
{
atm.yfilter = yfilter;
}
if(value_path == "ATM-ACR")
{
atm_acr.yfilter = yfilter;
}
if(value_path == "BDI")
{
bdi.yfilter = yfilter;
}
if(value_path == "CEM")
{
cem.yfilter = yfilter;
}
if(value_path == "CEM-ACR")
{
cem_acr.yfilter = yfilter;
}
if(value_path == "Embedded-Service-Engine")
{
embedded_service_engine.yfilter = yfilter;
}
if(value_path == "Ethernet")
{
ethernet.yfilter = yfilter;
}
if(value_path == "FastEthernet")
{
fastethernet.yfilter = yfilter;
}
if(value_path == "GigabitEthernet")
{
gigabitethernet.yfilter = yfilter;
}
if(value_path == "FiveGigabitEthernet")
{
fivegigabitethernet.yfilter = yfilter;
}
if(value_path == "TwentyFiveGigE")
{
twentyfivegige.yfilter = yfilter;
}
if(value_path == "TwoGigabitEthernet")
{
twogigabitethernet.yfilter = yfilter;
}
if(value_path == "FortyGigabitEthernet")
{
fortygigabitethernet.yfilter = yfilter;
}
if(value_path == "HundredGigE")
{
hundredgige.yfilter = yfilter;
}
if(value_path == "LISP")
{
lisp.yfilter = yfilter;
}
if(value_path == "Loopback")
{
loopback.yfilter = yfilter;
}
if(value_path == "Multilink")
{
multilink.yfilter = yfilter;
}
if(value_path == "nve")
{
nve.yfilter = yfilter;
}
if(value_path == "overlay")
{
overlay.yfilter = yfilter;
}
if(value_path == "Port-channel")
{
port_channel.yfilter = yfilter;
}
if(value_path == "pseudowire")
{
pseudowire.yfilter = yfilter;
}
if(value_path == "SM")
{
sm.yfilter = yfilter;
}
if(value_path == "Cellular")
{
cellular.yfilter = yfilter;
}
if(value_path == "Serial")
{
serial.yfilter = yfilter;
}
if(value_path == "TenGigabitEthernet")
{
tengigabitethernet.yfilter = yfilter;
}
if(value_path == "Tunnel")
{
tunnel.yfilter = yfilter;
}
if(value_path == "Virtual-Template")
{
virtual_template.yfilter = yfilter;
}
if(value_path == "Vlan")
{
vlan.yfilter = yfilter;
}
if(value_path == "VirtualPortGroup")
{
virtualportgroup.yfilter = yfilter;
}
if(value_path == "vasileft")
{
vasileft.yfilter = yfilter;
}
if(value_path == "vasiright")
{
vasiright.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Bfd::Interface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM-subinterface" || name == "ATM-ACRsubinterface" || name == "LISP-subinterface" || name == "Port-channel-subinterface" || name == "AppNav-Compress" || name == "AppNav-UnCompress" || name == "ATM" || name == "ATM-ACR" || name == "BDI" || name == "CEM" || name == "CEM-ACR" || name == "Embedded-Service-Engine" || name == "Ethernet" || name == "FastEthernet" || name == "GigabitEthernet" || name == "FiveGigabitEthernet" || name == "TwentyFiveGigE" || name == "TwoGigabitEthernet" || name == "FortyGigabitEthernet" || name == "HundredGigE" || name == "LISP" || name == "Loopback" || name == "Multilink" || name == "nve" || name == "overlay" || name == "Port-channel" || name == "pseudowire" || name == "SM" || name == "Cellular" || name == "Serial" || name == "TenGigabitEthernet" || name == "Tunnel" || name == "Virtual-Template" || name == "Vlan" || name == "VirtualPortGroup" || name == "vasileft" || name == "vasiright")
return true;
return false;
}
Native::Router::Eigrp::Bfd::Interface::ATMSubinterface::ATMSubinterface()
:
atm{YType::str, "ATM"}
{
yang_name = "ATM-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Bfd::Interface::ATMSubinterface::~ATMSubinterface()
{
}
bool Native::Router::Eigrp::Bfd::Interface::ATMSubinterface::has_data() const
{
if (is_presence_container) return true;
return atm.is_set;
}
bool Native::Router::Eigrp::Bfd::Interface::ATMSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(atm.yfilter);
}
std::string Native::Router::Eigrp::Bfd::Interface::ATMSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ATM-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Bfd::Interface::ATMSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (atm.is_set || is_set(atm.yfilter)) leaf_name_data.push_back(atm.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Bfd::Interface::ATMSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Bfd::Interface::ATMSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::Bfd::Interface::ATMSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ATM")
{
atm = value;
atm.value_namespace = name_space;
atm.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Bfd::Interface::ATMSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ATM")
{
atm.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Bfd::Interface::ATMSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM")
return true;
return false;
}
Native::Router::Eigrp::Bfd::Interface::ATMACRsubinterface::ATMACRsubinterface()
:
atm_acr{YType::str, "ATM-ACR"}
{
yang_name = "ATM-ACRsubinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Bfd::Interface::ATMACRsubinterface::~ATMACRsubinterface()
{
}
bool Native::Router::Eigrp::Bfd::Interface::ATMACRsubinterface::has_data() const
{
if (is_presence_container) return true;
return atm_acr.is_set;
}
bool Native::Router::Eigrp::Bfd::Interface::ATMACRsubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(atm_acr.yfilter);
}
std::string Native::Router::Eigrp::Bfd::Interface::ATMACRsubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ATM-ACRsubinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Bfd::Interface::ATMACRsubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (atm_acr.is_set || is_set(atm_acr.yfilter)) leaf_name_data.push_back(atm_acr.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Bfd::Interface::ATMACRsubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Bfd::Interface::ATMACRsubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::Bfd::Interface::ATMACRsubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ATM-ACR")
{
atm_acr = value;
atm_acr.value_namespace = name_space;
atm_acr.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Bfd::Interface::ATMACRsubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ATM-ACR")
{
atm_acr.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Bfd::Interface::ATMACRsubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM-ACR")
return true;
return false;
}
Native::Router::Eigrp::Bfd::Interface::LISPSubinterface::LISPSubinterface()
:
lisp{YType::str, "LISP"}
{
yang_name = "LISP-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Bfd::Interface::LISPSubinterface::~LISPSubinterface()
{
}
bool Native::Router::Eigrp::Bfd::Interface::LISPSubinterface::has_data() const
{
if (is_presence_container) return true;
return lisp.is_set;
}
bool Native::Router::Eigrp::Bfd::Interface::LISPSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lisp.yfilter);
}
std::string Native::Router::Eigrp::Bfd::Interface::LISPSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "LISP-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Bfd::Interface::LISPSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lisp.is_set || is_set(lisp.yfilter)) leaf_name_data.push_back(lisp.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Bfd::Interface::LISPSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Bfd::Interface::LISPSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::Bfd::Interface::LISPSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "LISP")
{
lisp = value;
lisp.value_namespace = name_space;
lisp.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Bfd::Interface::LISPSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "LISP")
{
lisp.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Bfd::Interface::LISPSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "LISP")
return true;
return false;
}
Native::Router::Eigrp::Bfd::Interface::PortChannelSubinterface::PortChannelSubinterface()
:
port_channel{YType::str, "Port-channel"}
{
yang_name = "Port-channel-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Bfd::Interface::PortChannelSubinterface::~PortChannelSubinterface()
{
}
bool Native::Router::Eigrp::Bfd::Interface::PortChannelSubinterface::has_data() const
{
if (is_presence_container) return true;
return port_channel.is_set;
}
bool Native::Router::Eigrp::Bfd::Interface::PortChannelSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(port_channel.yfilter);
}
std::string Native::Router::Eigrp::Bfd::Interface::PortChannelSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "Port-channel-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Bfd::Interface::PortChannelSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (port_channel.is_set || is_set(port_channel.yfilter)) leaf_name_data.push_back(port_channel.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Bfd::Interface::PortChannelSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Bfd::Interface::PortChannelSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::Bfd::Interface::PortChannelSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "Port-channel")
{
port_channel = value;
port_channel.value_namespace = name_space;
port_channel.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Bfd::Interface::PortChannelSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "Port-channel")
{
port_channel.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Bfd::Interface::PortChannelSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "Port-channel")
return true;
return false;
}
Native::Router::Eigrp::DefaultInformation::DefaultInformation()
:
in(nullptr) // presence node
, out(nullptr) // presence node
{
yang_name = "default-information"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::DefaultInformation::~DefaultInformation()
{
}
bool Native::Router::Eigrp::DefaultInformation::has_data() const
{
if (is_presence_container) return true;
return (in != nullptr && in->has_data())
|| (out != nullptr && out->has_data());
}
bool Native::Router::Eigrp::DefaultInformation::has_operation() const
{
return is_set(yfilter)
|| (in != nullptr && in->has_operation())
|| (out != nullptr && out->has_operation());
}
std::string Native::Router::Eigrp::DefaultInformation::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "default-information";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DefaultInformation::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DefaultInformation::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "in")
{
if(in == nullptr)
{
in = std::make_shared<Native::Router::Eigrp::DefaultInformation::In>();
}
return in;
}
if(child_yang_name == "out")
{
if(out == nullptr)
{
out = std::make_shared<Native::Router::Eigrp::DefaultInformation::Out>();
}
return out;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DefaultInformation::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(in != nullptr)
{
_children["in"] = in;
}
if(out != nullptr)
{
_children["out"] = out;
}
return _children;
}
void Native::Router::Eigrp::DefaultInformation::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::DefaultInformation::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::DefaultInformation::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::DefaultInformation::In::In()
:
sa_num{YType::uint16, "sa-num"},
sa_name{YType::str, "sa-name"}
{
yang_name = "in"; yang_parent_name = "default-information"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::DefaultInformation::In::~In()
{
}
bool Native::Router::Eigrp::DefaultInformation::In::has_data() const
{
if (is_presence_container) return true;
return sa_num.is_set
|| sa_name.is_set;
}
bool Native::Router::Eigrp::DefaultInformation::In::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(sa_num.yfilter)
|| ydk::is_set(sa_name.yfilter);
}
std::string Native::Router::Eigrp::DefaultInformation::In::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "in";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DefaultInformation::In::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (sa_num.is_set || is_set(sa_num.yfilter)) leaf_name_data.push_back(sa_num.get_name_leafdata());
if (sa_name.is_set || is_set(sa_name.yfilter)) leaf_name_data.push_back(sa_name.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DefaultInformation::In::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DefaultInformation::In::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::DefaultInformation::In::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "sa-num")
{
sa_num = value;
sa_num.value_namespace = name_space;
sa_num.value_namespace_prefix = name_space_prefix;
}
if(value_path == "sa-name")
{
sa_name = value;
sa_name.value_namespace = name_space;
sa_name.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::DefaultInformation::In::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "sa-num")
{
sa_num.yfilter = yfilter;
}
if(value_path == "sa-name")
{
sa_name.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::DefaultInformation::In::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "sa-num" || name == "sa-name")
return true;
return false;
}
Native::Router::Eigrp::DefaultInformation::Out::Out()
:
sa_out_num{YType::uint16, "sa-out-num"},
sa_out_name{YType::str, "sa-out-name"}
{
yang_name = "out"; yang_parent_name = "default-information"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::DefaultInformation::Out::~Out()
{
}
bool Native::Router::Eigrp::DefaultInformation::Out::has_data() const
{
if (is_presence_container) return true;
return sa_out_num.is_set
|| sa_out_name.is_set;
}
bool Native::Router::Eigrp::DefaultInformation::Out::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(sa_out_num.yfilter)
|| ydk::is_set(sa_out_name.yfilter);
}
std::string Native::Router::Eigrp::DefaultInformation::Out::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "out";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DefaultInformation::Out::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (sa_out_num.is_set || is_set(sa_out_num.yfilter)) leaf_name_data.push_back(sa_out_num.get_name_leafdata());
if (sa_out_name.is_set || is_set(sa_out_name.yfilter)) leaf_name_data.push_back(sa_out_name.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DefaultInformation::Out::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DefaultInformation::Out::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::DefaultInformation::Out::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "sa-out-num")
{
sa_out_num = value;
sa_out_num.value_namespace = name_space;
sa_out_num.value_namespace_prefix = name_space_prefix;
}
if(value_path == "sa-out-name")
{
sa_out_name = value;
sa_out_name.value_namespace = name_space;
sa_out_name.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::DefaultInformation::Out::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "sa-out-num")
{
sa_out_num.yfilter = yfilter;
}
if(value_path == "sa-out-name")
{
sa_out_name.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::DefaultInformation::Out::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "sa-out-num" || name == "sa-out-name")
return true;
return false;
}
Native::Router::Eigrp::DefaultMetric::DefaultMetric()
:
dm_rdr(this, {"dm_rdr"})
{
yang_name = "default-metric"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::DefaultMetric::~DefaultMetric()
{
}
bool Native::Router::Eigrp::DefaultMetric::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<dm_rdr.len(); index++)
{
if(dm_rdr[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::DefaultMetric::has_operation() const
{
for (std::size_t index=0; index<dm_rdr.len(); index++)
{
if(dm_rdr[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::DefaultMetric::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "default-metric";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DefaultMetric::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DefaultMetric::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "dm-rdr")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::DefaultMetric::DmRdr>();
ent_->parent = this;
dm_rdr.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DefaultMetric::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : dm_rdr.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::DefaultMetric::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::DefaultMetric::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::DefaultMetric::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dm-rdr")
return true;
return false;
}
Native::Router::Eigrp::DefaultMetric::DmRdr::DmRdr()
:
dm_rdr{YType::uint32, "dm-rdr"}
,
dm_rdr0(this, {"dm_rdr0"})
{
yang_name = "dm-rdr"; yang_parent_name = "default-metric"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::DefaultMetric::DmRdr::~DmRdr()
{
}
bool Native::Router::Eigrp::DefaultMetric::DmRdr::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<dm_rdr0.len(); index++)
{
if(dm_rdr0[index]->has_data())
return true;
}
return dm_rdr.is_set;
}
bool Native::Router::Eigrp::DefaultMetric::DmRdr::has_operation() const
{
for (std::size_t index=0; index<dm_rdr0.len(); index++)
{
if(dm_rdr0[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(dm_rdr.yfilter);
}
std::string Native::Router::Eigrp::DefaultMetric::DmRdr::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "dm-rdr";
ADD_KEY_TOKEN(dm_rdr, "dm-rdr");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DefaultMetric::DmRdr::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (dm_rdr.is_set || is_set(dm_rdr.yfilter)) leaf_name_data.push_back(dm_rdr.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DefaultMetric::DmRdr::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "dm-rdr0")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::DefaultMetric::DmRdr::DmRdr0>();
ent_->parent = this;
dm_rdr0.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DefaultMetric::DmRdr::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : dm_rdr0.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::DefaultMetric::DmRdr::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "dm-rdr")
{
dm_rdr = value;
dm_rdr.value_namespace = name_space;
dm_rdr.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::DefaultMetric::DmRdr::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "dm-rdr")
{
dm_rdr.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::DefaultMetric::DmRdr::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dm-rdr0" || name == "dm-rdr")
return true;
return false;
}
Native::Router::Eigrp::DefaultMetric::DmRdr::DmRdr0::DmRdr0()
:
dm_rdr0{YType::uint32, "dm-rdr0"},
dm_rdr_pct{YType::uint8, "dm-rdr-pct"}
{
yang_name = "dm-rdr0"; yang_parent_name = "dm-rdr"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::DefaultMetric::DmRdr::DmRdr0::~DmRdr0()
{
}
bool Native::Router::Eigrp::DefaultMetric::DmRdr::DmRdr0::has_data() const
{
if (is_presence_container) return true;
return dm_rdr0.is_set
|| dm_rdr_pct.is_set;
}
bool Native::Router::Eigrp::DefaultMetric::DmRdr::DmRdr0::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(dm_rdr0.yfilter)
|| ydk::is_set(dm_rdr_pct.yfilter);
}
std::string Native::Router::Eigrp::DefaultMetric::DmRdr::DmRdr0::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "dm-rdr0";
ADD_KEY_TOKEN(dm_rdr0, "dm-rdr0");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DefaultMetric::DmRdr::DmRdr0::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (dm_rdr0.is_set || is_set(dm_rdr0.yfilter)) leaf_name_data.push_back(dm_rdr0.get_name_leafdata());
if (dm_rdr_pct.is_set || is_set(dm_rdr_pct.yfilter)) leaf_name_data.push_back(dm_rdr_pct.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DefaultMetric::DmRdr::DmRdr0::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DefaultMetric::DmRdr::DmRdr0::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::DefaultMetric::DmRdr::DmRdr0::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "dm-rdr0")
{
dm_rdr0 = value;
dm_rdr0.value_namespace = name_space;
dm_rdr0.value_namespace_prefix = name_space_prefix;
}
if(value_path == "dm-rdr-pct")
{
dm_rdr_pct = value;
dm_rdr_pct.value_namespace = name_space;
dm_rdr_pct.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::DefaultMetric::DmRdr::DmRdr0::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "dm-rdr0")
{
dm_rdr0.yfilter = yfilter;
}
if(value_path == "dm-rdr-pct")
{
dm_rdr_pct.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::DefaultMetric::DmRdr::DmRdr0::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dm-rdr0" || name == "dm-rdr-pct")
return true;
return false;
}
Native::Router::Eigrp::Distance::Distance()
:
rad_dis(this, {"rad_dis"})
, eigrp(std::make_shared<Native::Router::Eigrp::Distance::Eigrp_>())
{
eigrp->parent = this;
yang_name = "distance"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Distance::~Distance()
{
}
bool Native::Router::Eigrp::Distance::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<rad_dis.len(); index++)
{
if(rad_dis[index]->has_data())
return true;
}
return (eigrp != nullptr && eigrp->has_data());
}
bool Native::Router::Eigrp::Distance::has_operation() const
{
for (std::size_t index=0; index<rad_dis.len(); index++)
{
if(rad_dis[index]->has_operation())
return true;
}
return is_set(yfilter)
|| (eigrp != nullptr && eigrp->has_operation());
}
std::string Native::Router::Eigrp::Distance::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "distance";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Distance::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Distance::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "rad-dis")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::Distance::RadDis>();
ent_->parent = this;
rad_dis.append(ent_);
return ent_;
}
if(child_yang_name == "eigrp")
{
if(eigrp == nullptr)
{
eigrp = std::make_shared<Native::Router::Eigrp::Distance::Eigrp_>();
}
return eigrp;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Distance::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : rad_dis.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
if(eigrp != nullptr)
{
_children["eigrp"] = eigrp;
}
return _children;
}
void Native::Router::Eigrp::Distance::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::Distance::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::Distance::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "rad-dis" || name == "eigrp")
return true;
return false;
}
Native::Router::Eigrp::Distance::RadDis::RadDis()
:
rad_dis{YType::uint8, "rad-dis"}
,
ipv4(this, {"ipv4"})
{
yang_name = "rad-dis"; yang_parent_name = "distance"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Distance::RadDis::~RadDis()
{
}
bool Native::Router::Eigrp::Distance::RadDis::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<ipv4.len(); index++)
{
if(ipv4[index]->has_data())
return true;
}
return rad_dis.is_set;
}
bool Native::Router::Eigrp::Distance::RadDis::has_operation() const
{
for (std::size_t index=0; index<ipv4.len(); index++)
{
if(ipv4[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(rad_dis.yfilter);
}
std::string Native::Router::Eigrp::Distance::RadDis::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "rad-dis";
ADD_KEY_TOKEN(rad_dis, "rad-dis");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Distance::RadDis::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (rad_dis.is_set || is_set(rad_dis.yfilter)) leaf_name_data.push_back(rad_dis.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Distance::RadDis::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ipv4")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::Distance::RadDis::Ipv4>();
ent_->parent = this;
ipv4.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Distance::RadDis::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : ipv4.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::Distance::RadDis::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "rad-dis")
{
rad_dis = value;
rad_dis.value_namespace = name_space;
rad_dis.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Distance::RadDis::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "rad-dis")
{
rad_dis.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Distance::RadDis::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4" || name == "rad-dis")
return true;
return false;
}
Native::Router::Eigrp::Distance::RadDis::Ipv4::Ipv4()
:
ipv4{YType::str, "ipv4"},
ipv40{YType::str, "ipv40"}
{
yang_name = "ipv4"; yang_parent_name = "rad-dis"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Distance::RadDis::Ipv4::~Ipv4()
{
}
bool Native::Router::Eigrp::Distance::RadDis::Ipv4::has_data() const
{
if (is_presence_container) return true;
return ipv4.is_set
|| ipv40.is_set;
}
bool Native::Router::Eigrp::Distance::RadDis::Ipv4::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ipv4.yfilter)
|| ydk::is_set(ipv40.yfilter);
}
std::string Native::Router::Eigrp::Distance::RadDis::Ipv4::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv4";
ADD_KEY_TOKEN(ipv4, "ipv4");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Distance::RadDis::Ipv4::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ipv4.is_set || is_set(ipv4.yfilter)) leaf_name_data.push_back(ipv4.get_name_leafdata());
if (ipv40.is_set || is_set(ipv40.yfilter)) leaf_name_data.push_back(ipv40.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Distance::RadDis::Ipv4::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Distance::RadDis::Ipv4::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::Distance::RadDis::Ipv4::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ipv4")
{
ipv4 = value;
ipv4.value_namespace = name_space;
ipv4.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ipv40")
{
ipv40 = value;
ipv40.value_namespace = name_space;
ipv40.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Distance::RadDis::Ipv4::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ipv4")
{
ipv4.yfilter = yfilter;
}
if(value_path == "ipv40")
{
ipv40.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Distance::RadDis::Ipv4::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4" || name == "ipv40")
return true;
return false;
}
Native::Router::Eigrp::Distance::Eigrp_::Eigrp_()
:
di_rt(this, {"di_rt"})
{
yang_name = "eigrp"; yang_parent_name = "distance"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Distance::Eigrp_::~Eigrp_()
{
}
bool Native::Router::Eigrp::Distance::Eigrp_::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<di_rt.len(); index++)
{
if(di_rt[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::Distance::Eigrp_::has_operation() const
{
for (std::size_t index=0; index<di_rt.len(); index++)
{
if(di_rt[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::Distance::Eigrp_::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "eigrp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Distance::Eigrp_::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Distance::Eigrp_::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "di-rt")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::Distance::Eigrp_::DiRt>();
ent_->parent = this;
di_rt.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Distance::Eigrp_::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : di_rt.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::Distance::Eigrp_::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::Distance::Eigrp_::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::Distance::Eigrp_::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "di-rt")
return true;
return false;
}
Native::Router::Eigrp::Distance::Eigrp_::DiRt::DiRt()
:
di_rt{YType::uint8, "di-rt"},
di_rt0{YType::uint8, "di-rt0"}
{
yang_name = "di-rt"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Distance::Eigrp_::DiRt::~DiRt()
{
}
bool Native::Router::Eigrp::Distance::Eigrp_::DiRt::has_data() const
{
if (is_presence_container) return true;
return di_rt.is_set
|| di_rt0.is_set;
}
bool Native::Router::Eigrp::Distance::Eigrp_::DiRt::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(di_rt.yfilter)
|| ydk::is_set(di_rt0.yfilter);
}
std::string Native::Router::Eigrp::Distance::Eigrp_::DiRt::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "di-rt";
ADD_KEY_TOKEN(di_rt, "di-rt");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Distance::Eigrp_::DiRt::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (di_rt.is_set || is_set(di_rt.yfilter)) leaf_name_data.push_back(di_rt.get_name_leafdata());
if (di_rt0.is_set || is_set(di_rt0.yfilter)) leaf_name_data.push_back(di_rt0.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Distance::Eigrp_::DiRt::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Distance::Eigrp_::DiRt::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::Distance::Eigrp_::DiRt::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "di-rt")
{
di_rt = value;
di_rt.value_namespace = name_space;
di_rt.value_namespace_prefix = name_space_prefix;
}
if(value_path == "di-rt0")
{
di_rt0 = value;
di_rt0.value_namespace = name_space;
di_rt0.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Distance::Eigrp_::DiRt::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "di-rt")
{
di_rt.yfilter = yfilter;
}
if(value_path == "di-rt0")
{
di_rt0.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Distance::Eigrp_::DiRt::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "di-rt" || name == "di-rt0")
return true;
return false;
}
Native::Router::Eigrp::DistributeList::DistributeList()
:
eig_filt(this, {"eig_filt"})
, gateway(std::make_shared<Native::Router::Eigrp::DistributeList::Gateway>())
, prefix(std::make_shared<Native::Router::Eigrp::DistributeList::Prefix>())
, route_map(std::make_shared<Native::Router::Eigrp::DistributeList::RouteMap>())
{
gateway->parent = this;
prefix->parent = this;
route_map->parent = this;
yang_name = "distribute-list"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::DistributeList::~DistributeList()
{
}
bool Native::Router::Eigrp::DistributeList::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<eig_filt.len(); index++)
{
if(eig_filt[index]->has_data())
return true;
}
return (gateway != nullptr && gateway->has_data())
|| (prefix != nullptr && prefix->has_data())
|| (route_map != nullptr && route_map->has_data());
}
bool Native::Router::Eigrp::DistributeList::has_operation() const
{
for (std::size_t index=0; index<eig_filt.len(); index++)
{
if(eig_filt[index]->has_operation())
return true;
}
return is_set(yfilter)
|| (gateway != nullptr && gateway->has_operation())
|| (prefix != nullptr && prefix->has_operation())
|| (route_map != nullptr && route_map->has_operation());
}
std::string Native::Router::Eigrp::DistributeList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "distribute-list";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DistributeList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DistributeList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "eig-filt")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::DistributeList::EigFilt>();
ent_->parent = this;
eig_filt.append(ent_);
return ent_;
}
if(child_yang_name == "gateway")
{
if(gateway == nullptr)
{
gateway = std::make_shared<Native::Router::Eigrp::DistributeList::Gateway>();
}
return gateway;
}
if(child_yang_name == "prefix")
{
if(prefix == nullptr)
{
prefix = std::make_shared<Native::Router::Eigrp::DistributeList::Prefix>();
}
return prefix;
}
if(child_yang_name == "route-map")
{
if(route_map == nullptr)
{
route_map = std::make_shared<Native::Router::Eigrp::DistributeList::RouteMap>();
}
return route_map;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DistributeList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : eig_filt.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
if(gateway != nullptr)
{
_children["gateway"] = gateway;
}
if(prefix != nullptr)
{
_children["prefix"] = prefix;
}
if(route_map != nullptr)
{
_children["route-map"] = route_map;
}
return _children;
}
void Native::Router::Eigrp::DistributeList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::DistributeList::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::DistributeList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "eig-filt" || name == "gateway" || name == "prefix" || name == "route-map")
return true;
return false;
}
Native::Router::Eigrp::DistributeList::EigFilt::EigFilt()
:
eig_filt{YType::str, "eig-filt"}
,
in(nullptr) // presence node
, out(nullptr) // presence node
{
yang_name = "eig-filt"; yang_parent_name = "distribute-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::DistributeList::EigFilt::~EigFilt()
{
}
bool Native::Router::Eigrp::DistributeList::EigFilt::has_data() const
{
if (is_presence_container) return true;
return eig_filt.is_set
|| (in != nullptr && in->has_data())
|| (out != nullptr && out->has_data());
}
bool Native::Router::Eigrp::DistributeList::EigFilt::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(eig_filt.yfilter)
|| (in != nullptr && in->has_operation())
|| (out != nullptr && out->has_operation());
}
std::string Native::Router::Eigrp::DistributeList::EigFilt::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "eig-filt";
ADD_KEY_TOKEN(eig_filt, "eig-filt");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DistributeList::EigFilt::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (eig_filt.is_set || is_set(eig_filt.yfilter)) leaf_name_data.push_back(eig_filt.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DistributeList::EigFilt::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "in")
{
if(in == nullptr)
{
in = std::make_shared<Native::Router::Eigrp::DistributeList::EigFilt::In>();
}
return in;
}
if(child_yang_name == "out")
{
if(out == nullptr)
{
out = std::make_shared<Native::Router::Eigrp::DistributeList::EigFilt::Out>();
}
return out;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DistributeList::EigFilt::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(in != nullptr)
{
_children["in"] = in;
}
if(out != nullptr)
{
_children["out"] = out;
}
return _children;
}
void Native::Router::Eigrp::DistributeList::EigFilt::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "eig-filt")
{
eig_filt = value;
eig_filt.value_namespace = name_space;
eig_filt.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::DistributeList::EigFilt::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "eig-filt")
{
eig_filt.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::DistributeList::EigFilt::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "in" || name == "out" || name == "eig-filt")
return true;
return false;
}
Native::Router::Eigrp::DistributeList::EigFilt::In::In()
:
interface_name{YType::str, "interface_name"}
{
yang_name = "in"; yang_parent_name = "eig-filt"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::DistributeList::EigFilt::In::~In()
{
}
bool Native::Router::Eigrp::DistributeList::EigFilt::In::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : interface_name.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::Router::Eigrp::DistributeList::EigFilt::In::has_operation() const
{
for (auto const & leaf : interface_name.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(interface_name.yfilter);
}
std::string Native::Router::Eigrp::DistributeList::EigFilt::In::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "in";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DistributeList::EigFilt::In::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto interface_name_name_datas = interface_name.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), interface_name_name_datas.begin(), interface_name_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DistributeList::EigFilt::In::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DistributeList::EigFilt::In::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::DistributeList::EigFilt::In::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "interface_name")
{
interface_name.append(value);
}
}
void Native::Router::Eigrp::DistributeList::EigFilt::In::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "interface_name")
{
interface_name.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::DistributeList::EigFilt::In::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "interface_name")
return true;
return false;
}
Native::Router::Eigrp::DistributeList::EigFilt::Out::Out()
:
interface_name{YType::str, "interface_name"}
{
yang_name = "out"; yang_parent_name = "eig-filt"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::DistributeList::EigFilt::Out::~Out()
{
}
bool Native::Router::Eigrp::DistributeList::EigFilt::Out::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : interface_name.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::Router::Eigrp::DistributeList::EigFilt::Out::has_operation() const
{
for (auto const & leaf : interface_name.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(interface_name.yfilter);
}
std::string Native::Router::Eigrp::DistributeList::EigFilt::Out::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "out";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DistributeList::EigFilt::Out::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto interface_name_name_datas = interface_name.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), interface_name_name_datas.begin(), interface_name_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DistributeList::EigFilt::Out::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DistributeList::EigFilt::Out::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::DistributeList::EigFilt::Out::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "interface_name")
{
interface_name.append(value);
}
}
void Native::Router::Eigrp::DistributeList::EigFilt::Out::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "interface_name")
{
interface_name.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::DistributeList::EigFilt::Out::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "interface_name")
return true;
return false;
}
Native::Router::Eigrp::DistributeList::Gateway::Gateway()
:
gw_list(this, {"gw_list"})
{
yang_name = "gateway"; yang_parent_name = "distribute-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::DistributeList::Gateway::~Gateway()
{
}
bool Native::Router::Eigrp::DistributeList::Gateway::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<gw_list.len(); index++)
{
if(gw_list[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::DistributeList::Gateway::has_operation() const
{
for (std::size_t index=0; index<gw_list.len(); index++)
{
if(gw_list[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::DistributeList::Gateway::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "gateway";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DistributeList::Gateway::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DistributeList::Gateway::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "gw-list")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::DistributeList::Gateway::GwList>();
ent_->parent = this;
gw_list.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DistributeList::Gateway::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : gw_list.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::DistributeList::Gateway::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::DistributeList::Gateway::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::DistributeList::Gateway::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "gw-list")
return true;
return false;
}
Native::Router::Eigrp::DistributeList::Gateway::GwList::GwList()
:
gw_list{YType::str, "gw-list"},
in{YType::empty, "in"},
out{YType::empty, "out"}
{
yang_name = "gw-list"; yang_parent_name = "gateway"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::DistributeList::Gateway::GwList::~GwList()
{
}
bool Native::Router::Eigrp::DistributeList::Gateway::GwList::has_data() const
{
if (is_presence_container) return true;
return gw_list.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::DistributeList::Gateway::GwList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(gw_list.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::DistributeList::Gateway::GwList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "gw-list";
ADD_KEY_TOKEN(gw_list, "gw-list");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DistributeList::Gateway::GwList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (gw_list.is_set || is_set(gw_list.yfilter)) leaf_name_data.push_back(gw_list.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DistributeList::Gateway::GwList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DistributeList::Gateway::GwList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::DistributeList::Gateway::GwList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "gw-list")
{
gw_list = value;
gw_list.value_namespace = name_space;
gw_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::DistributeList::Gateway::GwList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "gw-list")
{
gw_list.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::DistributeList::Gateway::GwList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "gw-list" || name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::DistributeList::Prefix::Prefix()
:
pl_name(this, {"pl_name"})
{
yang_name = "prefix"; yang_parent_name = "distribute-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::DistributeList::Prefix::~Prefix()
{
}
bool Native::Router::Eigrp::DistributeList::Prefix::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<pl_name.len(); index++)
{
if(pl_name[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::DistributeList::Prefix::has_operation() const
{
for (std::size_t index=0; index<pl_name.len(); index++)
{
if(pl_name[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::DistributeList::Prefix::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "prefix";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DistributeList::Prefix::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DistributeList::Prefix::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "pl-name")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::DistributeList::Prefix::PlName>();
ent_->parent = this;
pl_name.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DistributeList::Prefix::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : pl_name.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::DistributeList::Prefix::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::DistributeList::Prefix::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::DistributeList::Prefix::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "pl-name")
return true;
return false;
}
Native::Router::Eigrp::DistributeList::Prefix::PlName::PlName()
:
pl_name{YType::str, "pl-name"},
gateway{YType::empty, "gateway"},
in{YType::empty, "in"},
out{YType::empty, "out"}
{
yang_name = "pl-name"; yang_parent_name = "prefix"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::DistributeList::Prefix::PlName::~PlName()
{
}
bool Native::Router::Eigrp::DistributeList::Prefix::PlName::has_data() const
{
if (is_presence_container) return true;
return pl_name.is_set
|| gateway.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::DistributeList::Prefix::PlName::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(pl_name.yfilter)
|| ydk::is_set(gateway.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::DistributeList::Prefix::PlName::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "pl-name";
ADD_KEY_TOKEN(pl_name, "pl-name");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DistributeList::Prefix::PlName::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (pl_name.is_set || is_set(pl_name.yfilter)) leaf_name_data.push_back(pl_name.get_name_leafdata());
if (gateway.is_set || is_set(gateway.yfilter)) leaf_name_data.push_back(gateway.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DistributeList::Prefix::PlName::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DistributeList::Prefix::PlName::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::DistributeList::Prefix::PlName::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "pl-name")
{
pl_name = value;
pl_name.value_namespace = name_space;
pl_name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "gateway")
{
gateway = value;
gateway.value_namespace = name_space;
gateway.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::DistributeList::Prefix::PlName::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "pl-name")
{
pl_name.yfilter = yfilter;
}
if(value_path == "gateway")
{
gateway.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::DistributeList::Prefix::PlName::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "pl-name" || name == "gateway" || name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::DistributeList::RouteMap::RouteMap()
:
rmap_name(this, {"rmap_name"})
{
yang_name = "route-map"; yang_parent_name = "distribute-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::DistributeList::RouteMap::~RouteMap()
{
}
bool Native::Router::Eigrp::DistributeList::RouteMap::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<rmap_name.len(); index++)
{
if(rmap_name[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::DistributeList::RouteMap::has_operation() const
{
for (std::size_t index=0; index<rmap_name.len(); index++)
{
if(rmap_name[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::DistributeList::RouteMap::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "route-map";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DistributeList::RouteMap::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DistributeList::RouteMap::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "rmap-name")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::DistributeList::RouteMap::RmapName>();
ent_->parent = this;
rmap_name.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DistributeList::RouteMap::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : rmap_name.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::DistributeList::RouteMap::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::DistributeList::RouteMap::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::DistributeList::RouteMap::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "rmap-name")
return true;
return false;
}
Native::Router::Eigrp::DistributeList::RouteMap::RmapName::RmapName()
:
rmap_name{YType::str, "rmap-name"},
in{YType::empty, "in"},
out{YType::empty, "out"}
{
yang_name = "rmap-name"; yang_parent_name = "route-map"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::DistributeList::RouteMap::RmapName::~RmapName()
{
}
bool Native::Router::Eigrp::DistributeList::RouteMap::RmapName::has_data() const
{
if (is_presence_container) return true;
return rmap_name.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::DistributeList::RouteMap::RmapName::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(rmap_name.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::DistributeList::RouteMap::RmapName::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "rmap-name";
ADD_KEY_TOKEN(rmap_name, "rmap-name");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::DistributeList::RouteMap::RmapName::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (rmap_name.is_set || is_set(rmap_name.yfilter)) leaf_name_data.push_back(rmap_name.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::DistributeList::RouteMap::RmapName::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::DistributeList::RouteMap::RmapName::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::DistributeList::RouteMap::RmapName::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "rmap-name")
{
rmap_name = value;
rmap_name.value_namespace = name_space;
rmap_name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::DistributeList::RouteMap::RmapName::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "rmap-name")
{
rmap_name.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::DistributeList::RouteMap::RmapName::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "rmap-name" || name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::Eigrp_::Eigrp_()
:
router_id{YType::str, "router-id"},
stub_site{YType::str, "stub-site"}
,
stub(nullptr) // presence node
{
yang_name = "eigrp"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Eigrp_::~Eigrp_()
{
}
bool Native::Router::Eigrp::Eigrp_::has_data() const
{
if (is_presence_container) return true;
return router_id.is_set
|| stub_site.is_set
|| (stub != nullptr && stub->has_data());
}
bool Native::Router::Eigrp::Eigrp_::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(router_id.yfilter)
|| ydk::is_set(stub_site.yfilter)
|| (stub != nullptr && stub->has_operation());
}
std::string Native::Router::Eigrp::Eigrp_::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "eigrp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Eigrp_::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (router_id.is_set || is_set(router_id.yfilter)) leaf_name_data.push_back(router_id.get_name_leafdata());
if (stub_site.is_set || is_set(stub_site.yfilter)) leaf_name_data.push_back(stub_site.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Eigrp_::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "stub")
{
if(stub == nullptr)
{
stub = std::make_shared<Native::Router::Eigrp::Eigrp_::Stub>();
}
return stub;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Eigrp_::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(stub != nullptr)
{
_children["stub"] = stub;
}
return _children;
}
void Native::Router::Eigrp::Eigrp_::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "router-id")
{
router_id = value;
router_id.value_namespace = name_space;
router_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "stub-site")
{
stub_site = value;
stub_site.value_namespace = name_space;
stub_site.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Eigrp_::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "router-id")
{
router_id.yfilter = yfilter;
}
if(value_path == "stub-site")
{
stub_site.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Eigrp_::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "stub" || name == "router-id" || name == "stub-site")
return true;
return false;
}
Native::Router::Eigrp::Eigrp_::Stub::Stub()
:
connected{YType::empty, "connected"},
summary{YType::empty, "summary"},
redistributed{YType::empty, "redistributed"},
leak_map{YType::str, "leak-map"},
receive_only{YType::empty, "receive-only"},
static_{YType::empty, "static"}
{
yang_name = "stub"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::Router::Eigrp::Eigrp_::Stub::~Stub()
{
}
bool Native::Router::Eigrp::Eigrp_::Stub::has_data() const
{
if (is_presence_container) return true;
return connected.is_set
|| summary.is_set
|| redistributed.is_set
|| leak_map.is_set
|| receive_only.is_set
|| static_.is_set;
}
bool Native::Router::Eigrp::Eigrp_::Stub::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(connected.yfilter)
|| ydk::is_set(summary.yfilter)
|| ydk::is_set(redistributed.yfilter)
|| ydk::is_set(leak_map.yfilter)
|| ydk::is_set(receive_only.yfilter)
|| ydk::is_set(static_.yfilter);
}
std::string Native::Router::Eigrp::Eigrp_::Stub::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "stub";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Eigrp_::Stub::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (connected.is_set || is_set(connected.yfilter)) leaf_name_data.push_back(connected.get_name_leafdata());
if (summary.is_set || is_set(summary.yfilter)) leaf_name_data.push_back(summary.get_name_leafdata());
if (redistributed.is_set || is_set(redistributed.yfilter)) leaf_name_data.push_back(redistributed.get_name_leafdata());
if (leak_map.is_set || is_set(leak_map.yfilter)) leaf_name_data.push_back(leak_map.get_name_leafdata());
if (receive_only.is_set || is_set(receive_only.yfilter)) leaf_name_data.push_back(receive_only.get_name_leafdata());
if (static_.is_set || is_set(static_.yfilter)) leaf_name_data.push_back(static_.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Eigrp_::Stub::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Eigrp_::Stub::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::Eigrp_::Stub::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "connected")
{
connected = value;
connected.value_namespace = name_space;
connected.value_namespace_prefix = name_space_prefix;
}
if(value_path == "summary")
{
summary = value;
summary.value_namespace = name_space;
summary.value_namespace_prefix = name_space_prefix;
}
if(value_path == "redistributed")
{
redistributed = value;
redistributed.value_namespace = name_space;
redistributed.value_namespace_prefix = name_space_prefix;
}
if(value_path == "leak-map")
{
leak_map = value;
leak_map.value_namespace = name_space;
leak_map.value_namespace_prefix = name_space_prefix;
}
if(value_path == "receive-only")
{
receive_only = value;
receive_only.value_namespace = name_space;
receive_only.value_namespace_prefix = name_space_prefix;
}
if(value_path == "static")
{
static_ = value;
static_.value_namespace = name_space;
static_.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Eigrp_::Stub::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "connected")
{
connected.yfilter = yfilter;
}
if(value_path == "summary")
{
summary.yfilter = yfilter;
}
if(value_path == "redistributed")
{
redistributed.yfilter = yfilter;
}
if(value_path == "leak-map")
{
leak_map.yfilter = yfilter;
}
if(value_path == "receive-only")
{
receive_only.yfilter = yfilter;
}
if(value_path == "static")
{
static_.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Eigrp_::Stub::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "connected" || name == "summary" || name == "redistributed" || name == "leak-map" || name == "receive-only" || name == "static")
return true;
return false;
}
Native::Router::Eigrp::Metric::Metric()
:
maximum_hops{YType::uint8, "maximum-hops"},
weights{YType::uint8, "weights"}
{
yang_name = "metric"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Metric::~Metric()
{
}
bool Native::Router::Eigrp::Metric::has_data() const
{
if (is_presence_container) return true;
return maximum_hops.is_set
|| weights.is_set;
}
bool Native::Router::Eigrp::Metric::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(maximum_hops.yfilter)
|| ydk::is_set(weights.yfilter);
}
std::string Native::Router::Eigrp::Metric::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "metric";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Metric::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (maximum_hops.is_set || is_set(maximum_hops.yfilter)) leaf_name_data.push_back(maximum_hops.get_name_leafdata());
if (weights.is_set || is_set(weights.yfilter)) leaf_name_data.push_back(weights.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Metric::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Metric::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::Metric::set_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-hops")
{
maximum_hops = value;
maximum_hops.value_namespace = name_space;
maximum_hops.value_namespace_prefix = name_space_prefix;
}
if(value_path == "weights")
{
weights = value;
weights.value_namespace = name_space;
weights.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Metric::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "maximum-hops")
{
maximum_hops.yfilter = yfilter;
}
if(value_path == "weights")
{
weights.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Metric::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "maximum-hops" || name == "weights")
return true;
return false;
}
Native::Router::Eigrp::Neighbor::Neighbor()
:
ipv4(this, {"ipv4"})
{
yang_name = "neighbor"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Neighbor::~Neighbor()
{
}
bool Native::Router::Eigrp::Neighbor::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<ipv4.len(); index++)
{
if(ipv4[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::Neighbor::has_operation() const
{
for (std::size_t index=0; index<ipv4.len(); index++)
{
if(ipv4[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::Neighbor::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "neighbor";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Neighbor::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Neighbor::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ipv4")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::Neighbor::Ipv4>();
ent_->parent = this;
ipv4.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Neighbor::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : ipv4.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::Neighbor::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::Neighbor::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::Neighbor::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4")
return true;
return false;
}
Native::Router::Eigrp::Neighbor::Ipv4::Ipv4()
:
ipv4{YType::str, "ipv4"}
,
interface(std::make_shared<Native::Router::Eigrp::Neighbor::Ipv4::Interface>())
{
interface->parent = this;
yang_name = "ipv4"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Neighbor::Ipv4::~Ipv4()
{
}
bool Native::Router::Eigrp::Neighbor::Ipv4::has_data() const
{
if (is_presence_container) return true;
return ipv4.is_set
|| (interface != nullptr && interface->has_data());
}
bool Native::Router::Eigrp::Neighbor::Ipv4::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ipv4.yfilter)
|| (interface != nullptr && interface->has_operation());
}
std::string Native::Router::Eigrp::Neighbor::Ipv4::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv4";
ADD_KEY_TOKEN(ipv4, "ipv4");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Neighbor::Ipv4::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ipv4.is_set || is_set(ipv4.yfilter)) leaf_name_data.push_back(ipv4.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Neighbor::Ipv4::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "interface")
{
if(interface == nullptr)
{
interface = std::make_shared<Native::Router::Eigrp::Neighbor::Ipv4::Interface>();
}
return interface;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Neighbor::Ipv4::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(interface != nullptr)
{
_children["interface"] = interface;
}
return _children;
}
void Native::Router::Eigrp::Neighbor::Ipv4::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ipv4")
{
ipv4 = value;
ipv4.value_namespace = name_space;
ipv4.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Neighbor::Ipv4::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ipv4")
{
ipv4.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Neighbor::Ipv4::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "interface" || name == "ipv4")
return true;
return false;
}
Native::Router::Eigrp::Neighbor::Ipv4::Interface::Interface()
:
appnav_compress{YType::uint16, "AppNav-Compress"},
appnav_uncompress{YType::uint16, "AppNav-UnCompress"},
atm{YType::str, "ATM"},
atm_acr{YType::str, "ATM-ACR"},
bdi{YType::str, "BDI"},
cem{YType::str, "CEM"},
cem_acr{YType::uint8, "CEM-ACR"},
embedded_service_engine{YType::str, "Embedded-Service-Engine"},
ethernet{YType::str, "Ethernet"},
fastethernet{YType::str, "FastEthernet"},
gigabitethernet{YType::str, "GigabitEthernet"},
fivegigabitethernet{YType::str, "FiveGigabitEthernet"},
twentyfivegige{YType::str, "TwentyFiveGigE"},
twogigabitethernet{YType::str, "TwoGigabitEthernet"},
fortygigabitethernet{YType::str, "FortyGigabitEthernet"},
hundredgige{YType::str, "HundredGigE"},
lisp{YType::str, "LISP"},
loopback{YType::uint32, "Loopback"},
multilink{YType::uint16, "Multilink"},
nve{YType::uint16, "nve"},
overlay{YType::uint16, "overlay"},
port_channel{YType::uint32, "Port-channel"},
pseudowire{YType::uint32, "pseudowire"},
sm{YType::str, "SM"},
cellular{YType::str, "Cellular"},
serial{YType::str, "Serial"},
tengigabitethernet{YType::str, "TenGigabitEthernet"},
tunnel{YType::uint32, "Tunnel"},
virtual_template{YType::uint16, "Virtual-Template"},
vlan{YType::uint16, "Vlan"},
virtualportgroup{YType::uint16, "VirtualPortGroup"},
vasileft{YType::uint16, "vasileft"},
vasiright{YType::uint16, "vasiright"}
,
atm_subinterface(std::make_shared<Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMSubinterface>())
, atm_acrsubinterface(std::make_shared<Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMACRsubinterface>())
, lisp_subinterface(std::make_shared<Native::Router::Eigrp::Neighbor::Ipv4::Interface::LISPSubinterface>())
, port_channel_subinterface(std::make_shared<Native::Router::Eigrp::Neighbor::Ipv4::Interface::PortChannelSubinterface>())
{
atm_subinterface->parent = this;
atm_acrsubinterface->parent = this;
lisp_subinterface->parent = this;
port_channel_subinterface->parent = this;
yang_name = "interface"; yang_parent_name = "ipv4"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Neighbor::Ipv4::Interface::~Interface()
{
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::has_data() const
{
if (is_presence_container) return true;
return appnav_compress.is_set
|| appnav_uncompress.is_set
|| atm.is_set
|| atm_acr.is_set
|| bdi.is_set
|| cem.is_set
|| cem_acr.is_set
|| embedded_service_engine.is_set
|| ethernet.is_set
|| fastethernet.is_set
|| gigabitethernet.is_set
|| fivegigabitethernet.is_set
|| twentyfivegige.is_set
|| twogigabitethernet.is_set
|| fortygigabitethernet.is_set
|| hundredgige.is_set
|| lisp.is_set
|| loopback.is_set
|| multilink.is_set
|| nve.is_set
|| overlay.is_set
|| port_channel.is_set
|| pseudowire.is_set
|| sm.is_set
|| cellular.is_set
|| serial.is_set
|| tengigabitethernet.is_set
|| tunnel.is_set
|| virtual_template.is_set
|| vlan.is_set
|| virtualportgroup.is_set
|| vasileft.is_set
|| vasiright.is_set
|| (atm_subinterface != nullptr && atm_subinterface->has_data())
|| (atm_acrsubinterface != nullptr && atm_acrsubinterface->has_data())
|| (lisp_subinterface != nullptr && lisp_subinterface->has_data())
|| (port_channel_subinterface != nullptr && port_channel_subinterface->has_data());
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(appnav_compress.yfilter)
|| ydk::is_set(appnav_uncompress.yfilter)
|| ydk::is_set(atm.yfilter)
|| ydk::is_set(atm_acr.yfilter)
|| ydk::is_set(bdi.yfilter)
|| ydk::is_set(cem.yfilter)
|| ydk::is_set(cem_acr.yfilter)
|| ydk::is_set(embedded_service_engine.yfilter)
|| ydk::is_set(ethernet.yfilter)
|| ydk::is_set(fastethernet.yfilter)
|| ydk::is_set(gigabitethernet.yfilter)
|| ydk::is_set(fivegigabitethernet.yfilter)
|| ydk::is_set(twentyfivegige.yfilter)
|| ydk::is_set(twogigabitethernet.yfilter)
|| ydk::is_set(fortygigabitethernet.yfilter)
|| ydk::is_set(hundredgige.yfilter)
|| ydk::is_set(lisp.yfilter)
|| ydk::is_set(loopback.yfilter)
|| ydk::is_set(multilink.yfilter)
|| ydk::is_set(nve.yfilter)
|| ydk::is_set(overlay.yfilter)
|| ydk::is_set(port_channel.yfilter)
|| ydk::is_set(pseudowire.yfilter)
|| ydk::is_set(sm.yfilter)
|| ydk::is_set(cellular.yfilter)
|| ydk::is_set(serial.yfilter)
|| ydk::is_set(tengigabitethernet.yfilter)
|| ydk::is_set(tunnel.yfilter)
|| ydk::is_set(virtual_template.yfilter)
|| ydk::is_set(vlan.yfilter)
|| ydk::is_set(virtualportgroup.yfilter)
|| ydk::is_set(vasileft.yfilter)
|| ydk::is_set(vasiright.yfilter)
|| (atm_subinterface != nullptr && atm_subinterface->has_operation())
|| (atm_acrsubinterface != nullptr && atm_acrsubinterface->has_operation())
|| (lisp_subinterface != nullptr && lisp_subinterface->has_operation())
|| (port_channel_subinterface != nullptr && port_channel_subinterface->has_operation());
}
std::string Native::Router::Eigrp::Neighbor::Ipv4::Interface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "interface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Neighbor::Ipv4::Interface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (appnav_compress.is_set || is_set(appnav_compress.yfilter)) leaf_name_data.push_back(appnav_compress.get_name_leafdata());
if (appnav_uncompress.is_set || is_set(appnav_uncompress.yfilter)) leaf_name_data.push_back(appnav_uncompress.get_name_leafdata());
if (atm.is_set || is_set(atm.yfilter)) leaf_name_data.push_back(atm.get_name_leafdata());
if (atm_acr.is_set || is_set(atm_acr.yfilter)) leaf_name_data.push_back(atm_acr.get_name_leafdata());
if (bdi.is_set || is_set(bdi.yfilter)) leaf_name_data.push_back(bdi.get_name_leafdata());
if (cem.is_set || is_set(cem.yfilter)) leaf_name_data.push_back(cem.get_name_leafdata());
if (cem_acr.is_set || is_set(cem_acr.yfilter)) leaf_name_data.push_back(cem_acr.get_name_leafdata());
if (embedded_service_engine.is_set || is_set(embedded_service_engine.yfilter)) leaf_name_data.push_back(embedded_service_engine.get_name_leafdata());
if (ethernet.is_set || is_set(ethernet.yfilter)) leaf_name_data.push_back(ethernet.get_name_leafdata());
if (fastethernet.is_set || is_set(fastethernet.yfilter)) leaf_name_data.push_back(fastethernet.get_name_leafdata());
if (gigabitethernet.is_set || is_set(gigabitethernet.yfilter)) leaf_name_data.push_back(gigabitethernet.get_name_leafdata());
if (fivegigabitethernet.is_set || is_set(fivegigabitethernet.yfilter)) leaf_name_data.push_back(fivegigabitethernet.get_name_leafdata());
if (twentyfivegige.is_set || is_set(twentyfivegige.yfilter)) leaf_name_data.push_back(twentyfivegige.get_name_leafdata());
if (twogigabitethernet.is_set || is_set(twogigabitethernet.yfilter)) leaf_name_data.push_back(twogigabitethernet.get_name_leafdata());
if (fortygigabitethernet.is_set || is_set(fortygigabitethernet.yfilter)) leaf_name_data.push_back(fortygigabitethernet.get_name_leafdata());
if (hundredgige.is_set || is_set(hundredgige.yfilter)) leaf_name_data.push_back(hundredgige.get_name_leafdata());
if (lisp.is_set || is_set(lisp.yfilter)) leaf_name_data.push_back(lisp.get_name_leafdata());
if (loopback.is_set || is_set(loopback.yfilter)) leaf_name_data.push_back(loopback.get_name_leafdata());
if (multilink.is_set || is_set(multilink.yfilter)) leaf_name_data.push_back(multilink.get_name_leafdata());
if (nve.is_set || is_set(nve.yfilter)) leaf_name_data.push_back(nve.get_name_leafdata());
if (overlay.is_set || is_set(overlay.yfilter)) leaf_name_data.push_back(overlay.get_name_leafdata());
if (port_channel.is_set || is_set(port_channel.yfilter)) leaf_name_data.push_back(port_channel.get_name_leafdata());
if (pseudowire.is_set || is_set(pseudowire.yfilter)) leaf_name_data.push_back(pseudowire.get_name_leafdata());
if (sm.is_set || is_set(sm.yfilter)) leaf_name_data.push_back(sm.get_name_leafdata());
if (cellular.is_set || is_set(cellular.yfilter)) leaf_name_data.push_back(cellular.get_name_leafdata());
if (serial.is_set || is_set(serial.yfilter)) leaf_name_data.push_back(serial.get_name_leafdata());
if (tengigabitethernet.is_set || is_set(tengigabitethernet.yfilter)) leaf_name_data.push_back(tengigabitethernet.get_name_leafdata());
if (tunnel.is_set || is_set(tunnel.yfilter)) leaf_name_data.push_back(tunnel.get_name_leafdata());
if (virtual_template.is_set || is_set(virtual_template.yfilter)) leaf_name_data.push_back(virtual_template.get_name_leafdata());
if (vlan.is_set || is_set(vlan.yfilter)) leaf_name_data.push_back(vlan.get_name_leafdata());
if (virtualportgroup.is_set || is_set(virtualportgroup.yfilter)) leaf_name_data.push_back(virtualportgroup.get_name_leafdata());
if (vasileft.is_set || is_set(vasileft.yfilter)) leaf_name_data.push_back(vasileft.get_name_leafdata());
if (vasiright.is_set || is_set(vasiright.yfilter)) leaf_name_data.push_back(vasiright.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Neighbor::Ipv4::Interface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ATM-subinterface")
{
if(atm_subinterface == nullptr)
{
atm_subinterface = std::make_shared<Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMSubinterface>();
}
return atm_subinterface;
}
if(child_yang_name == "ATM-ACRsubinterface")
{
if(atm_acrsubinterface == nullptr)
{
atm_acrsubinterface = std::make_shared<Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMACRsubinterface>();
}
return atm_acrsubinterface;
}
if(child_yang_name == "LISP-subinterface")
{
if(lisp_subinterface == nullptr)
{
lisp_subinterface = std::make_shared<Native::Router::Eigrp::Neighbor::Ipv4::Interface::LISPSubinterface>();
}
return lisp_subinterface;
}
if(child_yang_name == "Port-channel-subinterface")
{
if(port_channel_subinterface == nullptr)
{
port_channel_subinterface = std::make_shared<Native::Router::Eigrp::Neighbor::Ipv4::Interface::PortChannelSubinterface>();
}
return port_channel_subinterface;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Neighbor::Ipv4::Interface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(atm_subinterface != nullptr)
{
_children["ATM-subinterface"] = atm_subinterface;
}
if(atm_acrsubinterface != nullptr)
{
_children["ATM-ACRsubinterface"] = atm_acrsubinterface;
}
if(lisp_subinterface != nullptr)
{
_children["LISP-subinterface"] = lisp_subinterface;
}
if(port_channel_subinterface != nullptr)
{
_children["Port-channel-subinterface"] = port_channel_subinterface;
}
return _children;
}
void Native::Router::Eigrp::Neighbor::Ipv4::Interface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "AppNav-Compress")
{
appnav_compress = value;
appnav_compress.value_namespace = name_space;
appnav_compress.value_namespace_prefix = name_space_prefix;
}
if(value_path == "AppNav-UnCompress")
{
appnav_uncompress = value;
appnav_uncompress.value_namespace = name_space;
appnav_uncompress.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ATM")
{
atm = value;
atm.value_namespace = name_space;
atm.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ATM-ACR")
{
atm_acr = value;
atm_acr.value_namespace = name_space;
atm_acr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "BDI")
{
bdi = value;
bdi.value_namespace = name_space;
bdi.value_namespace_prefix = name_space_prefix;
}
if(value_path == "CEM")
{
cem = value;
cem.value_namespace = name_space;
cem.value_namespace_prefix = name_space_prefix;
}
if(value_path == "CEM-ACR")
{
cem_acr = value;
cem_acr.value_namespace = name_space;
cem_acr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Embedded-Service-Engine")
{
embedded_service_engine = value;
embedded_service_engine.value_namespace = name_space;
embedded_service_engine.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Ethernet")
{
ethernet = value;
ethernet.value_namespace = name_space;
ethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FastEthernet")
{
fastethernet = value;
fastethernet.value_namespace = name_space;
fastethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "GigabitEthernet")
{
gigabitethernet = value;
gigabitethernet.value_namespace = name_space;
gigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FiveGigabitEthernet")
{
fivegigabitethernet = value;
fivegigabitethernet.value_namespace = name_space;
fivegigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TwentyFiveGigE")
{
twentyfivegige = value;
twentyfivegige.value_namespace = name_space;
twentyfivegige.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TwoGigabitEthernet")
{
twogigabitethernet = value;
twogigabitethernet.value_namespace = name_space;
twogigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FortyGigabitEthernet")
{
fortygigabitethernet = value;
fortygigabitethernet.value_namespace = name_space;
fortygigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "HundredGigE")
{
hundredgige = value;
hundredgige.value_namespace = name_space;
hundredgige.value_namespace_prefix = name_space_prefix;
}
if(value_path == "LISP")
{
lisp = value;
lisp.value_namespace = name_space;
lisp.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Loopback")
{
loopback = value;
loopback.value_namespace = name_space;
loopback.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Multilink")
{
multilink = value;
multilink.value_namespace = name_space;
multilink.value_namespace_prefix = name_space_prefix;
}
if(value_path == "nve")
{
nve = value;
nve.value_namespace = name_space;
nve.value_namespace_prefix = name_space_prefix;
}
if(value_path == "overlay")
{
overlay = value;
overlay.value_namespace = name_space;
overlay.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Port-channel")
{
port_channel = value;
port_channel.value_namespace = name_space;
port_channel.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pseudowire")
{
pseudowire = value;
pseudowire.value_namespace = name_space;
pseudowire.value_namespace_prefix = name_space_prefix;
}
if(value_path == "SM")
{
sm = value;
sm.value_namespace = name_space;
sm.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Cellular")
{
cellular = value;
cellular.value_namespace = name_space;
cellular.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Serial")
{
serial = value;
serial.value_namespace = name_space;
serial.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TenGigabitEthernet")
{
tengigabitethernet = value;
tengigabitethernet.value_namespace = name_space;
tengigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Tunnel")
{
tunnel = value;
tunnel.value_namespace = name_space;
tunnel.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Virtual-Template")
{
virtual_template = value;
virtual_template.value_namespace = name_space;
virtual_template.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Vlan")
{
vlan = value;
vlan.value_namespace = name_space;
vlan.value_namespace_prefix = name_space_prefix;
}
if(value_path == "VirtualPortGroup")
{
virtualportgroup = value;
virtualportgroup.value_namespace = name_space;
virtualportgroup.value_namespace_prefix = name_space_prefix;
}
if(value_path == "vasileft")
{
vasileft = value;
vasileft.value_namespace = name_space;
vasileft.value_namespace_prefix = name_space_prefix;
}
if(value_path == "vasiright")
{
vasiright = value;
vasiright.value_namespace = name_space;
vasiright.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Neighbor::Ipv4::Interface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "AppNav-Compress")
{
appnav_compress.yfilter = yfilter;
}
if(value_path == "AppNav-UnCompress")
{
appnav_uncompress.yfilter = yfilter;
}
if(value_path == "ATM")
{
atm.yfilter = yfilter;
}
if(value_path == "ATM-ACR")
{
atm_acr.yfilter = yfilter;
}
if(value_path == "BDI")
{
bdi.yfilter = yfilter;
}
if(value_path == "CEM")
{
cem.yfilter = yfilter;
}
if(value_path == "CEM-ACR")
{
cem_acr.yfilter = yfilter;
}
if(value_path == "Embedded-Service-Engine")
{
embedded_service_engine.yfilter = yfilter;
}
if(value_path == "Ethernet")
{
ethernet.yfilter = yfilter;
}
if(value_path == "FastEthernet")
{
fastethernet.yfilter = yfilter;
}
if(value_path == "GigabitEthernet")
{
gigabitethernet.yfilter = yfilter;
}
if(value_path == "FiveGigabitEthernet")
{
fivegigabitethernet.yfilter = yfilter;
}
if(value_path == "TwentyFiveGigE")
{
twentyfivegige.yfilter = yfilter;
}
if(value_path == "TwoGigabitEthernet")
{
twogigabitethernet.yfilter = yfilter;
}
if(value_path == "FortyGigabitEthernet")
{
fortygigabitethernet.yfilter = yfilter;
}
if(value_path == "HundredGigE")
{
hundredgige.yfilter = yfilter;
}
if(value_path == "LISP")
{
lisp.yfilter = yfilter;
}
if(value_path == "Loopback")
{
loopback.yfilter = yfilter;
}
if(value_path == "Multilink")
{
multilink.yfilter = yfilter;
}
if(value_path == "nve")
{
nve.yfilter = yfilter;
}
if(value_path == "overlay")
{
overlay.yfilter = yfilter;
}
if(value_path == "Port-channel")
{
port_channel.yfilter = yfilter;
}
if(value_path == "pseudowire")
{
pseudowire.yfilter = yfilter;
}
if(value_path == "SM")
{
sm.yfilter = yfilter;
}
if(value_path == "Cellular")
{
cellular.yfilter = yfilter;
}
if(value_path == "Serial")
{
serial.yfilter = yfilter;
}
if(value_path == "TenGigabitEthernet")
{
tengigabitethernet.yfilter = yfilter;
}
if(value_path == "Tunnel")
{
tunnel.yfilter = yfilter;
}
if(value_path == "Virtual-Template")
{
virtual_template.yfilter = yfilter;
}
if(value_path == "Vlan")
{
vlan.yfilter = yfilter;
}
if(value_path == "VirtualPortGroup")
{
virtualportgroup.yfilter = yfilter;
}
if(value_path == "vasileft")
{
vasileft.yfilter = yfilter;
}
if(value_path == "vasiright")
{
vasiright.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM-subinterface" || name == "ATM-ACRsubinterface" || name == "LISP-subinterface" || name == "Port-channel-subinterface" || name == "AppNav-Compress" || name == "AppNav-UnCompress" || name == "ATM" || name == "ATM-ACR" || name == "BDI" || name == "CEM" || name == "CEM-ACR" || name == "Embedded-Service-Engine" || name == "Ethernet" || name == "FastEthernet" || name == "GigabitEthernet" || name == "FiveGigabitEthernet" || name == "TwentyFiveGigE" || name == "TwoGigabitEthernet" || name == "FortyGigabitEthernet" || name == "HundredGigE" || name == "LISP" || name == "Loopback" || name == "Multilink" || name == "nve" || name == "overlay" || name == "Port-channel" || name == "pseudowire" || name == "SM" || name == "Cellular" || name == "Serial" || name == "TenGigabitEthernet" || name == "Tunnel" || name == "Virtual-Template" || name == "Vlan" || name == "VirtualPortGroup" || name == "vasileft" || name == "vasiright")
return true;
return false;
}
Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMSubinterface::ATMSubinterface()
:
atm{YType::str, "ATM"}
{
yang_name = "ATM-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMSubinterface::~ATMSubinterface()
{
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMSubinterface::has_data() const
{
if (is_presence_container) return true;
return atm.is_set;
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(atm.yfilter);
}
std::string Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ATM-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (atm.is_set || is_set(atm.yfilter)) leaf_name_data.push_back(atm.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ATM")
{
atm = value;
atm.value_namespace = name_space;
atm.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ATM")
{
atm.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM")
return true;
return false;
}
Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMACRsubinterface::ATMACRsubinterface()
:
atm_acr{YType::str, "ATM-ACR"}
{
yang_name = "ATM-ACRsubinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMACRsubinterface::~ATMACRsubinterface()
{
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMACRsubinterface::has_data() const
{
if (is_presence_container) return true;
return atm_acr.is_set;
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMACRsubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(atm_acr.yfilter);
}
std::string Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMACRsubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ATM-ACRsubinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMACRsubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (atm_acr.is_set || is_set(atm_acr.yfilter)) leaf_name_data.push_back(atm_acr.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMACRsubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMACRsubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMACRsubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ATM-ACR")
{
atm_acr = value;
atm_acr.value_namespace = name_space;
atm_acr.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMACRsubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ATM-ACR")
{
atm_acr.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::ATMACRsubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM-ACR")
return true;
return false;
}
Native::Router::Eigrp::Neighbor::Ipv4::Interface::LISPSubinterface::LISPSubinterface()
:
lisp{YType::str, "LISP"}
{
yang_name = "LISP-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Neighbor::Ipv4::Interface::LISPSubinterface::~LISPSubinterface()
{
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::LISPSubinterface::has_data() const
{
if (is_presence_container) return true;
return lisp.is_set;
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::LISPSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lisp.yfilter);
}
std::string Native::Router::Eigrp::Neighbor::Ipv4::Interface::LISPSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "LISP-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Neighbor::Ipv4::Interface::LISPSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lisp.is_set || is_set(lisp.yfilter)) leaf_name_data.push_back(lisp.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Neighbor::Ipv4::Interface::LISPSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Neighbor::Ipv4::Interface::LISPSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::Neighbor::Ipv4::Interface::LISPSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "LISP")
{
lisp = value;
lisp.value_namespace = name_space;
lisp.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Neighbor::Ipv4::Interface::LISPSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "LISP")
{
lisp.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::LISPSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "LISP")
return true;
return false;
}
Native::Router::Eigrp::Neighbor::Ipv4::Interface::PortChannelSubinterface::PortChannelSubinterface()
:
port_channel{YType::str, "Port-channel"}
{
yang_name = "Port-channel-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Neighbor::Ipv4::Interface::PortChannelSubinterface::~PortChannelSubinterface()
{
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::PortChannelSubinterface::has_data() const
{
if (is_presence_container) return true;
return port_channel.is_set;
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::PortChannelSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(port_channel.yfilter);
}
std::string Native::Router::Eigrp::Neighbor::Ipv4::Interface::PortChannelSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "Port-channel-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Neighbor::Ipv4::Interface::PortChannelSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (port_channel.is_set || is_set(port_channel.yfilter)) leaf_name_data.push_back(port_channel.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Neighbor::Ipv4::Interface::PortChannelSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Neighbor::Ipv4::Interface::PortChannelSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::Neighbor::Ipv4::Interface::PortChannelSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "Port-channel")
{
port_channel = value;
port_channel.value_namespace = name_space;
port_channel.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Neighbor::Ipv4::Interface::PortChannelSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "Port-channel")
{
port_channel.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Neighbor::Ipv4::Interface::PortChannelSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "Port-channel")
return true;
return false;
}
Native::Router::Eigrp::Network::Network()
:
number{YType::str, "number"},
wild_card{YType::str, "wild-card"}
{
yang_name = "network"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::Network::~Network()
{
}
bool Native::Router::Eigrp::Network::has_data() const
{
if (is_presence_container) return true;
return number.is_set
|| wild_card.is_set;
}
bool Native::Router::Eigrp::Network::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(number.yfilter)
|| ydk::is_set(wild_card.yfilter);
}
std::string Native::Router::Eigrp::Network::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "network";
ADD_KEY_TOKEN(number, "number");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::Network::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (number.is_set || is_set(number.yfilter)) leaf_name_data.push_back(number.get_name_leafdata());
if (wild_card.is_set || is_set(wild_card.yfilter)) leaf_name_data.push_back(wild_card.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::Network::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::Network::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::Network::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "number")
{
number = value;
number.value_namespace = name_space;
number.value_namespace_prefix = name_space_prefix;
}
if(value_path == "wild-card")
{
wild_card = value;
wild_card.value_namespace = name_space;
wild_card.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::Network::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "number")
{
number.yfilter = yfilter;
}
if(value_path == "wild-card")
{
wild_card.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::Network::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "number" || name == "wild-card")
return true;
return false;
}
Native::Router::Eigrp::OffsetList::OffsetList()
:
nsr_list(this, {"nsr_list"})
, ol_acl(this, {"ol_acl"})
{
yang_name = "offset-list"; yang_parent_name = "eigrp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::OffsetList::~OffsetList()
{
}
bool Native::Router::Eigrp::OffsetList::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<nsr_list.len(); index++)
{
if(nsr_list[index]->has_data())
return true;
}
for (std::size_t index=0; index<ol_acl.len(); index++)
{
if(ol_acl[index]->has_data())
return true;
}
return false;
}
bool Native::Router::Eigrp::OffsetList::has_operation() const
{
for (std::size_t index=0; index<nsr_list.len(); index++)
{
if(nsr_list[index]->has_operation())
return true;
}
for (std::size_t index=0; index<ol_acl.len(); index++)
{
if(ol_acl[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::Router::Eigrp::OffsetList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "offset-list";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::OffsetList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::OffsetList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "nsr-list")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::OffsetList::NsrList>();
ent_->parent = this;
nsr_list.append(ent_);
return ent_;
}
if(child_yang_name == "ol-acl")
{
auto ent_ = std::make_shared<Native::Router::Eigrp::OffsetList::OlAcl>();
ent_->parent = this;
ol_acl.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::OffsetList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : nsr_list.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : ol_acl.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::Router::Eigrp::OffsetList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::Router::Eigrp::OffsetList::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::Router::Eigrp::OffsetList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "nsr-list" || name == "ol-acl")
return true;
return false;
}
Native::Router::Eigrp::OffsetList::NsrList::NsrList()
:
nsr_list{YType::uint16, "nsr-list"},
in{YType::empty, "in"},
out{YType::empty, "out"}
{
yang_name = "nsr-list"; yang_parent_name = "offset-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::OffsetList::NsrList::~NsrList()
{
}
bool Native::Router::Eigrp::OffsetList::NsrList::has_data() const
{
if (is_presence_container) return true;
return nsr_list.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::OffsetList::NsrList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(nsr_list.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::OffsetList::NsrList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "nsr-list";
ADD_KEY_TOKEN(nsr_list, "nsr-list");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::OffsetList::NsrList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (nsr_list.is_set || is_set(nsr_list.yfilter)) leaf_name_data.push_back(nsr_list.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::OffsetList::NsrList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::OffsetList::NsrList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::OffsetList::NsrList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "nsr-list")
{
nsr_list = value;
nsr_list.value_namespace = name_space;
nsr_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::OffsetList::NsrList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "nsr-list")
{
nsr_list.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::OffsetList::NsrList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "nsr-list" || name == "in" || name == "out")
return true;
return false;
}
Native::Router::Eigrp::OffsetList::OlAcl::OlAcl()
:
ol_acl{YType::str, "ol-acl"},
in{YType::empty, "in"},
out{YType::empty, "out"}
{
yang_name = "ol-acl"; yang_parent_name = "offset-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::Router::Eigrp::OffsetList::OlAcl::~OlAcl()
{
}
bool Native::Router::Eigrp::OffsetList::OlAcl::has_data() const
{
if (is_presence_container) return true;
return ol_acl.is_set
|| in.is_set
|| out.is_set;
}
bool Native::Router::Eigrp::OffsetList::OlAcl::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ol_acl.yfilter)
|| ydk::is_set(in.yfilter)
|| ydk::is_set(out.yfilter);
}
std::string Native::Router::Eigrp::OffsetList::OlAcl::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ol-acl";
ADD_KEY_TOKEN(ol_acl, "ol-acl");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::Router::Eigrp::OffsetList::OlAcl::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ol_acl.is_set || is_set(ol_acl.yfilter)) leaf_name_data.push_back(ol_acl.get_name_leafdata());
if (in.is_set || is_set(in.yfilter)) leaf_name_data.push_back(in.get_name_leafdata());
if (out.is_set || is_set(out.yfilter)) leaf_name_data.push_back(out.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::Router::Eigrp::OffsetList::OlAcl::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Eigrp::OffsetList::OlAcl::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::Router::Eigrp::OffsetList::OlAcl::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ol-acl")
{
ol_acl = value;
ol_acl.value_namespace = name_space;
ol_acl.value_namespace_prefix = name_space_prefix;
}
if(value_path == "in")
{
in = value;
in.value_namespace = name_space;
in.value_namespace_prefix = name_space_prefix;
}
if(value_path == "out")
{
out = value;
out.value_namespace = name_space;
out.value_namespace_prefix = name_space_prefix;
}
}
void Native::Router::Eigrp::OffsetList::OlAcl::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ol-acl")
{
ol_acl.yfilter = yfilter;
}
if(value_path == "in")
{
in.yfilter = yfilter;
}
if(value_path == "out")
{
out.yfilter = yfilter;
}
}
bool Native::Router::Eigrp::OffsetList::OlAcl::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ol-acl" || name == "in" || name == "out")
return true;
return false;
}
const Enum::YLeaf Native::Router::Eigrp::AddressFamily::AfIpVrfList::UnicastMulticast::unicast {0, "unicast"};
const Enum::YLeaf Native::Router::Eigrp::AddressFamily::AfIpVrfList::UnicastMulticast::multicast {1, "multicast"};
}
}
| 32.831744
| 940
| 0.687723
|
CiscoDevNet
|
f5650ac27d80d71ec2b9ad6f7a23a1bc4c539f77
| 27,677
|
cpp
|
C++
|
tests/gtests/test_batch_normalization_forward.cpp
|
PerfXLab/mkl-dnn
|
0fc7bd337d827d310d029e5f4219eaf72ca12825
|
[
"Apache-2.0"
] | 9
|
2016-11-30T07:35:33.000Z
|
2021-05-09T01:15:06.000Z
|
tests/gtests/test_batch_normalization_forward.cpp
|
PerfXLab/mkl-dnn
|
0fc7bd337d827d310d029e5f4219eaf72ca12825
|
[
"Apache-2.0"
] | null | null | null |
tests/gtests/test_batch_normalization_forward.cpp
|
PerfXLab/mkl-dnn
|
0fc7bd337d827d310d029e5f4219eaf72ca12825
|
[
"Apache-2.0"
] | null | null | null |
/*******************************************************************************
* Copyright 2016 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
#include <cmath>
#include "mkldnn_test_common.hpp"
#include "gtest/gtest.h"
#include "mkldnn.hpp"
namespace mkldnn {
struct test_bnorm_desc_t {
int mb, c;
int h, w;
float eps;
};
template <typename data_t>
void check_bnorm_fwd(test_bnorm_desc_t &bnd,
const memory &src, const memory &weights, memory &dst)
{
const data_t *src_data = (const data_t *)src.get_data_handle();
const data_t *weights_data = (const data_t *)weights.get_data_handle();
data_t *dst_data = (data_t *)dst.get_data_handle();
data_t *workspace_data = new data_t[2*bnd.c];
const memory::desc src_d = src.get_primitive_desc().desc();
const memory::desc weights_d = weights.get_primitive_desc().desc();
const memory::desc dst_d = dst.get_primitive_desc().desc();
#pragma omp parallel for
for (int c = 0; c < bnd.c; c++) {
workspace_data[c] = data_t(0);
for (int n = 0; n < bnd.mb; n++)
for (int h = 0; h < bnd.h; h++)
for (int w = 0; w < bnd.w; w++) {
int sidx = n * bnd.c * bnd.h * bnd.w + c * bnd.h * bnd.w
+ h * bnd.w + w;
workspace_data[c] += src_data[map_index(src_d, sidx)];
}
workspace_data[c] /= bnd.mb * bnd.h * bnd.w;
workspace_data[bnd.c + c] = data_t(0);
for (int n = 0; n < bnd.mb; n++)
for (int h = 0; h < bnd.h; h++)
for (int w = 0; w < bnd.w; w++) {
int sidx = n * bnd.c * bnd.h * bnd.w + c * bnd.h * bnd.w
+ h * bnd.w + w;
data_t tmp = src_data[map_index(src_d, sidx)]
- workspace_data[c];
workspace_data[bnd.c + c] += tmp * tmp;
}
workspace_data[bnd.c + c] = workspace_data[bnd.c + c]
/ (bnd.mb * bnd.h * bnd.w) + bnd.eps;
workspace_data[bnd.c + c] = data_t(1)
/ sqrt(workspace_data[bnd.c + c]);
for (int n = 0; n < bnd.mb; n++)
for (int h = 0; h < bnd.h; h++)
for (int w = 0; w < bnd.w; w++) {
int sdidx = n * bnd.c * bnd.h * bnd.w + c * bnd.h * bnd.w
+ h * bnd.w + w;
data_t ref_dst = weights_data[map_index(weights_d, c)]
* (src_data[map_index(src_d, sdidx)]
- workspace_data[c]) * workspace_data[bnd.c + c]
+ weights_data[map_index(weights_d, bnd.c + c)];
data_t out = dst_data[map_index(dst_d, sdidx)];
data_t eps = 1.e-6 * bnd.mb * bnd.h * bnd.w;
data_t norm_max = std::max(fabs(out), fabs(ref_dst));
if (norm_max < eps) norm_max = data_t(1);
EXPECT_NEAR((out - ref_dst) / norm_max, 0., eps);
}
}
delete[] workspace_data;
}
struct bnorm_fwd_test_params {
prop_kind aprop_kind;
const engine::kind engine_kind;
memory::format src_format;
memory::format dst_format;
memory::format weights_format;
test_bnorm_desc_t test_bnd;
};
template <typename data_t>
class bnorm_forward_test : public ::testing::TestWithParam<bnorm_fwd_test_params> {
protected:
virtual void SetUp()
{
bnorm_fwd_test_params p
= ::testing::TestWithParam<bnorm_fwd_test_params>::GetParam();
ASSERT_TRUE(p.engine_kind == engine::kind::cpu);
ASSERT_TRUE(p.aprop_kind == prop_kind::forward_training
|| p.aprop_kind == prop_kind::forward_scoring);
auto eng = engine(p.engine_kind, 0);
memory::data_type data_type = data_traits<data_t>::data_type;
ASSERT_EQ(data_type, mkldnn::memory::data_type::f32);
test_bnorm_desc_t bnd = p.test_bnd;
bool with_workspace = p.aprop_kind == prop_kind::forward_training;
auto src_desc = create_md(
{ bnd.mb, bnd.c, bnd.h, bnd.w }, data_type, p.src_format);
auto dst_desc = create_md(
{ bnd.mb, bnd.c, bnd.h, bnd.w }, data_type, p.dst_format);
auto src_primitive_desc = memory::primitive_desc(src_desc, eng);
auto dst_primitive_desc = memory::primitive_desc(dst_desc, eng);
auto src_size = src_primitive_desc.get_size();
auto dst_size = dst_primitive_desc.get_size();
// TODO: free
data_t *src_data = new data_t[src_size];
data_t *weights_data = nullptr;
data_t *workspace_data = nullptr;
data_t *dst_data = new data_t[dst_size];
auto src = memory(src_primitive_desc, src_data);
auto dst = memory(dst_primitive_desc, dst_data);
auto bn_desc
= batch_normalization_forward::desc(p.aprop_kind, src_desc, bnd.eps);
auto bn_prim_desc = batch_normalization_forward::primitive_desc(bn_desc, eng);
auto weights_primitive_desc = bn_prim_desc.weights_primitive_desc();
auto weights_size = weights_primitive_desc.get_size();
weights_data = new data_t[weights_size];
auto weights = memory(weights_primitive_desc, weights_data);
fill_data<data_t>(
src.get_primitive_desc().get_size() / sizeof(data_t),
(data_t *)src.get_data_handle());
fill_data<data_t>(
weights.get_primitive_desc().get_size() / sizeof(data_t),
(data_t *)weights.get_data_handle());
std::vector<primitive> pipeline;
auto s = stream(stream::kind::lazy);
if (with_workspace) {
auto workspace_primitive_desc =
bn_prim_desc.workspace_primitive_desc();
auto workspace_size = workspace_primitive_desc.get_size();
workspace_data = new data_t[workspace_size];
auto workspace = memory(workspace_primitive_desc, workspace_data);
auto bn = batch_normalization_forward(bn_prim_desc,
src, weights, workspace, dst);
pipeline.push_back(bn);
s.submit(pipeline).wait();
} else {
auto bn = batch_normalization_forward(bn_prim_desc, src, weights, dst);
pipeline.push_back(bn);
s.submit(pipeline).wait();
}
check_bnorm_fwd<data_t>(bnd, src, weights, dst);
}
};
using bnorm_forward_test_float = bnorm_forward_test<float>;
using bnorm_fwd_test_params_float = bnorm_fwd_test_params;
TEST_P(bnorm_forward_test_float, TestsBNorm)
{
}
INSTANTIATE_TEST_CASE_P(TestBNormForward, bnorm_forward_test_float,
::testing::Values(bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw, memory::format::nchw,
memory::format::nc, { 2, 10, 4, 4, 0.1 } }));
INSTANTIATE_TEST_CASE_P(
TestBNormForwardBlocked, bnorm_forward_test_float,
::testing::Values(
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 8, 4, 4, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 16, 4, 4, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 16, 8, 8, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 16, 16, 8, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 16, 16, 10, 0.1 } }));
INSTANTIATE_TEST_CASE_P(
TestBNormGoogleNetForwardNCHW, bnorm_forward_test_float,
::testing::Values(
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 64, 112, 112, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 64, 56, 56, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 192, 56, 56, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 96, 28, 28, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 16, 28, 28, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 64, 28, 28, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 128, 28, 28, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 32, 28, 28, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 96, 28, 28, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 96, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 16, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 192, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 208, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 48, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 64, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 112, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 24, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 160, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 224, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 128, 4, 4, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 128, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 512, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 256, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 144, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 32, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 228, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 528, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 320, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 160, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 32, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 256, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 320, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 128, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 192, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 48, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nchw,
memory::format::nchw, memory::format::nc,
{ 2, 384, 7, 7, 0.1 } }));
INSTANTIATE_TEST_CASE_P(
TestBNormGoogleNetForwardBlocked, bnorm_forward_test_float,
::testing::Values(
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 64, 112, 112, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 64, 56, 56, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 192, 56, 56, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 96, 28, 28, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 16, 28, 28, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 64, 28, 28, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 128, 28, 28, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 32, 28, 28, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 96, 28, 28, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 96, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 16, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 192, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 208, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 48, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 64, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 112, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 24, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 160, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 224, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 128, 4, 4, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 128, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 512, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 256, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 144, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 32, 14, 14, 0.1 } },
/* size is not supported by nChw8c format yet
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 228, 14, 14, 0.1 } },
*/
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 528, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 320, 14, 14, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 160, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 32, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 256, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 320, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 128, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 192, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 48, 7, 7, 0.1 } },
bnorm_fwd_test_params_float{ prop_kind::forward_training,
engine::kind::cpu, memory::format::nChw8c,
memory::format::nChw8c, memory::format::nc,
{ 2, 384, 7, 7, 0.1 } }));
}
| 54.268627
| 86
| 0.509773
|
PerfXLab
|
f565250754ce6915087897513c950b1ca3f3ead6
| 979
|
hpp
|
C++
|
src/include/guinsoodb/execution/operator/helper/physical_transaction.hpp
|
GuinsooLab/guinsoodb
|
f200538868738ae460f62fb89211deec946cefff
|
[
"MIT"
] | 1
|
2021-04-22T05:41:54.000Z
|
2021-04-22T05:41:54.000Z
|
src/include/guinsoodb/execution/operator/helper/physical_transaction.hpp
|
GuinsooLab/guinsoodb
|
f200538868738ae460f62fb89211deec946cefff
|
[
"MIT"
] | null | null | null |
src/include/guinsoodb/execution/operator/helper/physical_transaction.hpp
|
GuinsooLab/guinsoodb
|
f200538868738ae460f62fb89211deec946cefff
|
[
"MIT"
] | 1
|
2021-12-12T10:24:57.000Z
|
2021-12-12T10:24:57.000Z
|
//===----------------------------------------------------------------------===//
// GuinsooDB
//
// guinsoodb/execution/operator/helper/physical_transaction.hpp
//
//
//===----------------------------------------------------------------------===//
#pragma once
#include "guinsoodb/execution/physical_operator.hpp"
#include "guinsoodb/parser/parsed_data/transaction_info.hpp"
namespace guinsoodb {
//! PhysicalTransaction represents a transaction operator (e.g. BEGIN or COMMIT)
class PhysicalTransaction : public PhysicalOperator {
public:
explicit PhysicalTransaction(unique_ptr<TransactionInfo> info, idx_t estimated_cardinality)
: PhysicalOperator(PhysicalOperatorType::TRANSACTION, {LogicalType::BOOLEAN}, estimated_cardinality),
info(move(info)) {
}
unique_ptr<TransactionInfo> info;
public:
void GetChunkInternal(ExecutionContext &context, DataChunk &chunk, PhysicalOperatorState *state) override;
};
} // namespace guinsoodb
| 31.580645
| 107
| 0.642492
|
GuinsooLab
|
f5661c3d682c8d7272445b97b709789955e07a11
| 1,845
|
cpp
|
C++
|
src/+cv/getDerivKernels.cpp
|
1123852253/mexopencv
|
17db690133299f561924a45e9092673a4df66c5b
|
[
"BSD-3-Clause"
] | 571
|
2015-01-04T06:23:19.000Z
|
2022-03-31T07:37:19.000Z
|
src/+cv/getDerivKernels.cpp
|
1123852253/mexopencv
|
17db690133299f561924a45e9092673a4df66c5b
|
[
"BSD-3-Clause"
] | 362
|
2015-01-06T14:20:46.000Z
|
2022-01-20T08:10:46.000Z
|
src/+cv/getDerivKernels.cpp
|
1123852253/mexopencv
|
17db690133299f561924a45e9092673a4df66c5b
|
[
"BSD-3-Clause"
] | 300
|
2015-01-20T03:21:27.000Z
|
2022-03-31T07:36:37.000Z
|
/**
* @file getDerivKernels.cpp
* @brief mex interface for cv::getDerivKernels
* @ingroup imgproc
* @author Kota Yamaguchi
* @date 2011
*/
#include "mexopencv.hpp"
#include "opencv2/imgproc.hpp"
using namespace std;
using namespace cv;
namespace {
/// KSize map for option processing
const ConstMap<string,int> KSizeMap = ConstMap<string,int>
("Scharr", CV_SCHARR);
}
/**
* Main entry called from Matlab
* @param nlhs number of left-hand-side arguments
* @param plhs pointers to mxArrays in the left-hand-side
* @param nrhs number of right-hand-side arguments
* @param prhs pointers to mxArrays in the right-hand-side
*/
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
// Check the number of arguments
nargchk((nrhs%2)==0 && nlhs<=2);
// Argument vector
vector<MxArray> rhs(prhs, prhs+nrhs);
// Option processing
int dx = 1;
int dy = 1;
int ksize = 3;
bool normalize = false;
int ktype = CV_32F;
for (int i=0; i<nrhs; i+=2) {
string key(rhs[i].toString());
if (key == "Dx")
dx = rhs[i+1].toInt();
else if (key == "Dy")
dy = rhs[i+1].toInt();
else if (key == "KSize")
ksize = (rhs[i+1].isChar()) ?
KSizeMap[rhs[i+1].toString()] : rhs[i+1].toInt();
else if (key == "Normalize")
normalize = rhs[i+1].toBool();
else if (key == "KType")
ktype = (rhs[i+1].isChar()) ?
ClassNameMap[rhs[i+1].toString()] : rhs[i+1].toInt();
else
mexErrMsgIdAndTxt("mexopencv:error",
"Unrecognized option %s", key.c_str());
}
// Process
Mat kx, ky;
getDerivKernels(kx, ky, dx, dy, ksize, normalize, ktype);
plhs[0] = MxArray(kx);
if (nlhs>1)
plhs[1] = MxArray(ky);
}
| 27.954545
| 76
| 0.579946
|
1123852253
|
f56626377ee919eb985e59ff970d60429b09c740
| 4,006
|
inl
|
C++
|
ShaderAnalysis/ShaderOperation.inl
|
bo3b/iZ3D
|
ced8b3a4b0a152d0177f2e94008918efc76935d5
|
[
"MIT"
] | 27
|
2020-11-12T19:24:54.000Z
|
2022-03-27T23:10:45.000Z
|
ShaderAnalysis/ShaderOperation.inl
|
bo3b/iZ3D
|
ced8b3a4b0a152d0177f2e94008918efc76935d5
|
[
"MIT"
] | 2
|
2020-11-02T06:30:39.000Z
|
2022-02-23T18:39:55.000Z
|
ShaderAnalysis/ShaderOperation.inl
|
bo3b/iZ3D
|
ced8b3a4b0a152d0177f2e94008918efc76935d5
|
[
"MIT"
] | 3
|
2021-08-16T00:21:08.000Z
|
2022-02-23T19:19:36.000Z
|
//////////////////////////////////////////////////////////////////////////
// ShaderOperation inline function
D3D10_SB_OPCODE_TYPE shader_analyzer::ShaderOperation::getType() const{
return DECODE_D3D10_SB_OPCODE_TYPE(m_pData[0]);
}
D3D10_SB_CUSTOMDATA_CLASS shader_analyzer::ShaderOperation::getCustomDataClass() const {
return DECODE_D3D10_SB_CUSTOMDATA_CLASS(m_pData[0]);
}
bool shader_analyzer::ShaderOperation::isSaturated() const{
return DECODE_IS_D3D10_SB_INSTRUCTION_SATURATE_ENABLED(m_pData[0]) != 0;
}
D3D10_SB_INSTRUCTION_TEST_BOOLEAN shader_analyzer::ShaderOperation::getTestBoolean() const{
return DECODE_D3D10_SB_INSTRUCTION_TEST_BOOLEAN(m_pData[0]);
}
D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE shader_analyzer::ShaderOperation::getInstructionReturnType() const{
return DECODE_D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE(m_pData[0]);
}
bool shader_analyzer::ShaderOperation::isOpcodeExtended() const{
return DECODE_IS_D3D10_SB_OPCODE_EXTENDED(m_pData[0]) != 0;
}
unsigned shader_analyzer::ShaderOperation::getLength() const
{
return m_length;
}
unsigned shader_analyzer::ShaderOperation::getInstructionLength() const
{
return DECODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(m_pData[0]);
}
bool shader_analyzer::ShaderOperation::isCustomData() const
{
return getType() == D3D10_SB_OPCODE_CUSTOMDATA;
}
bool shader_analyzer::ShaderOperation::isDeclaration() const
{
return ((getType() >= D3D10_SB_OPCODE_DCL_RESOURCE) && (getType() <= D3D10_SB_OPCODE_DCL_GLOBAL_FLAGS)) ||
((getType() >= D3D11_SB_OPCODE_DCL_STREAM) && (getType() <= D3D11_SB_OPCODE_DCL_RESOURCE_STRUCTURED)) ||
(getType() == D3D11_SB_OPCODE_DCL_GS_INSTANCE_COUNT);
}
bool shader_analyzer::ShaderOperation::isAppropriateForProjectionMatrixFinding() const
{
switch(getType())
{
case D3D10_SB_OPCODE_ADD:
case D3D10_SB_OPCODE_DP2:
case D3D10_SB_OPCODE_DP3:
case D3D10_SB_OPCODE_DP4:
case D3D10_SB_OPCODE_MAD:
case D3D10_SB_OPCODE_MAX:
case D3D10_SB_OPCODE_MIN:
case D3D10_SB_OPCODE_MUL:
case D3D10_SB_OPCODE_MOV:
case D3D10_SB_OPCODE_MOVC:
return true;
}
return false;
}
bool shader_analyzer::ShaderOperation::isIntCommand() const
{
switch(getType())
{
case D3D10_SB_OPCODE_IADD:
case D3D10_SB_OPCODE_IGE:
case D3D10_SB_OPCODE_IEQ:
case D3D10_SB_OPCODE_ILT:
case D3D10_SB_OPCODE_IMAD:
case D3D10_SB_OPCODE_IMAX:
case D3D10_SB_OPCODE_IMIN:
case D3D10_SB_OPCODE_IMUL:
case D3D10_SB_OPCODE_INE:
case D3D10_SB_OPCODE_INEG:
case D3D10_SB_OPCODE_ISHL:
case D3D10_SB_OPCODE_ISHR:
case D3D10_SB_OPCODE_ITOF:
return true;
}
return false;
}
bool shader_analyzer::ShaderOperation::isScalarCommand() const
{
switch(getType())
{
case D3D10_SB_OPCODE_DP2:
case D3D10_SB_OPCODE_DP3:
case D3D10_SB_OPCODE_DP4:
return true;
}
return false;
}
unsigned shader_analyzer::ShaderOperation::getDependentComponents(
const shader_analyzer::ShaderOperand::EComponentState inComp, const ShaderOperand* pGivenOperand ) const
{
unsigned comp = inComp;
if (isScalarCommand())
{
switch( getType() )
{
case D3D10_SB_OPCODE_DP3:
comp = ShaderOperand::X_STATE | ShaderOperand::Y_STATE | ShaderOperand::Z_STATE;
break;
case D3D10_SB_OPCODE_DP2:
comp = ShaderOperand::X_STATE | ShaderOperand::Y_STATE;
break;
case D3D10_SB_OPCODE_DP4:
default:
comp = ShaderOperand::X_STATE | ShaderOperand::Y_STATE |
ShaderOperand::Z_STATE | ShaderOperand::W_STATE;
}
}
return pGivenOperand->getComponentState(comp);
}
bool shader_analyzer::ShaderOperation::isIncreaseIdent() const
{
switch( getType() )
{
case D3D10_SB_OPCODE_IF:
case D3D10_SB_OPCODE_LOOP:
case D3D10_SB_OPCODE_SWITCH:
case D3D10_SB_OPCODE_ELSE:
case D3D10_SB_OPCODE_CASE:
return true;
default:
return false;
}
}
bool shader_analyzer::ShaderOperation::isDecreaseIdent() const
{
switch( getType() )
{
case D3D10_SB_OPCODE_ENDIF:
case D3D10_SB_OPCODE_ENDLOOP:
case D3D10_SB_OPCODE_ENDSWITCH:
case D3D10_SB_OPCODE_ELSE:
case D3D10_SB_OPCODE_CASE:
return true;
default:
return false;
}
}
| 26.012987
| 108
| 0.785821
|
bo3b
|
f56662c5ac784b7aa06620aabf2ac48d75077a16
| 4,942
|
cpp
|
C++
|
applications/3DimViewer/src/CRegion3DPreviewVisualizer.cpp
|
SindenDev/3dimviewer
|
e23a3147edc35034ef4b75eae9ccdcbc7192b1a1
|
[
"Apache-2.0"
] | 6
|
2020-04-14T16:10:55.000Z
|
2021-05-21T07:13:55.000Z
|
applications/3DimViewer/src/CRegion3DPreviewVisualizer.cpp
|
SindenDev/3dimviewer
|
e23a3147edc35034ef4b75eae9ccdcbc7192b1a1
|
[
"Apache-2.0"
] | null | null | null |
applications/3DimViewer/src/CRegion3DPreviewVisualizer.cpp
|
SindenDev/3dimviewer
|
e23a3147edc35034ef4b75eae9ccdcbc7192b1a1
|
[
"Apache-2.0"
] | 2
|
2020-07-24T16:25:38.000Z
|
2021-01-19T09:23:18.000Z
|
///////////////////////////////////////////////////////////////////////////////
// $Id$
//
// 3DimViewer
// Lightweight 3D DICOM viewer.
//
// Copyright 2008-2016 3Dim Laboratory s.r.o.
//
// 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 "CRegion3DPreviewVisualizer.h"
#include <osg/CullFace>
#include <osg/PolygonMode>
#include <osg/CPseudoMaterial.h>
#include <graph/osg/NodeMasks.h>
osg::CRegion3DPreviewVisualizer::CRegion3DPreviewVisualizer()
{
setName("CRegion3DPreviewVisualizer");
m_pTransform = new osg::Geode();
m_trianglesGeometry = new osg::Geometry;
m_geomVertices = new osg::Vec3Array;
m_geomNormals = new osg::Vec3Array;
m_geomIndices = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES);
m_geomVertexColors = new osg::Vec4Array(1);
(*m_geomVertexColors)[0] = osg::Vec4(0.0, 0.0, 0.0, 0.0);
m_trianglesGeometry->setVertexArray(m_geomVertices);
m_trianglesGeometry->setNormalArray(m_geomNormals, osg::Array::BIND_PER_VERTEX);
m_trianglesGeometry->addPrimitiveSet(m_geomIndices);
m_trianglesGeometry->setColorArray(m_geomVertexColors, osg::Array::BIND_OVERALL);
m_pTransform->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON | osg::StateAttribute::PROTECTED);
m_pTransform->getOrCreateStateSet()->setAttributeAndModes(new osg::CullFace(osg::CullFace::BACK), osg::StateAttribute::OFF);
m_pTransform->addDrawable(m_trianglesGeometry);
addChild(m_pTransform);
m_materialRegular = new osg::CPseudoMaterial();
m_materialRegular->uniform("Shininess")->set(20.0f);
m_materialRegular->uniform("Specularity")->set(0.5f);
m_materialRegular->applySingleLightSetup();
m_materialRegular->apply(this);
setVisibility(false);
setNodeMask(MASK_REGION_PREVIEW);
}
osg::CRegion3DPreviewVisualizer::~CRegion3DPreviewVisualizer()
{
}
void osg::CRegion3DPreviewVisualizer::setVisibility(bool visible)
{
setOnOffState(visible);
}
void osg::CRegion3DPreviewVisualizer::update(const osg::Vec4& color)
{
std::lock_guard<std::mutex> lock(m_mutex);
m_geomVertices->clear();
m_geomIndices->clear();
m_geomNormals->clear();
std::vector<int> normalsCnt;
size_t verticesCnt = m_vertices.size();
size_t indiciesCnt = m_indicies.size();
for (size_t i = 0; i < verticesCnt; ++i)
{
m_geomVertices->push_back(geometry::convert3<osg::Vec3, geometry::Vec3>(m_vertices.at(i)));
m_geomNormals->push_back(osg::Vec3f(0.0, 0.0, 0.0));
normalsCnt.push_back(0);
}
for (size_t i = 0; i < indiciesCnt; i += 3)
{
int index1 = m_indicies[i];
int index2 = m_indicies[i + 1];
int index3 = m_indicies[i + 2];
m_geomIndices->push_back(index1);
m_geomIndices->push_back(index2);
m_geomIndices->push_back(index3);
osg::Vec3 p1 = m_geomVertices->at(index1);
osg::Vec3 p2 = m_geomVertices->at(index2);
osg::Vec3 p3 = m_geomVertices->at(index3);
osg::Vec3 normal = (p2 - p1) ^ (p3 - p1);
normal.normalize();
osg::Vec3 n1 = m_geomNormals->at(index1);
osg::Vec3 n2 = m_geomNormals->at(index2);
osg::Vec3 n3 = m_geomNormals->at(index3);
m_geomNormals->at(index1) = (normal + n1);
m_geomNormals->at(index2) = (normal + n2);
m_geomNormals->at(index3) = (normal + n3);
normalsCnt[index1]++;
normalsCnt[index2]++;
normalsCnt[index3]++;
}
for (size_t i = 0; i < verticesCnt; ++i)
{
assert(normalsCnt[i] > 0);
m_geomNormals->at(i) /= normalsCnt[i];
}
(*m_geomVertexColors)[0] = color;
m_geomVertices->dirty();
m_geomIndices->dirty();
m_geomNormals->dirty();
m_geomVertexColors->dirty();
m_trianglesGeometry->dirtyGLObjects();
m_trianglesGeometry->dirtyBound();
}
void osg::CRegion3DPreviewVisualizer::setData(const std::vector<geometry::Vec3>& vertices, const std::vector<int>& indicies)
{
std::lock_guard<std::mutex> lock(m_mutex);
m_vertices.clear();
m_vertices.resize(0);
for (size_t i = 0; i < vertices.size(); ++i)
{
m_vertices.push_back(vertices.at(i));
}
m_indicies.clear();
m_indicies.resize(0);
for (size_t i = 0; i < indicies.size(); ++i)
{
m_indicies.push_back(indicies.at(i));
}
}
| 30.695652
| 128
| 0.654189
|
SindenDev
|
f5673e6808f3ee87a89552fe1ed540a7471a5c2f
| 4,247
|
cpp
|
C++
|
mex/quantilenorm_cuda/check_mexutils.cpp
|
dgoodwin208/ExSeqProcessing
|
cd7f8ff461af16aad22ac033d2cbd5f0aa935628
|
[
"MIT"
] | 7
|
2020-06-03T21:12:35.000Z
|
2022-02-03T02:36:20.000Z
|
mex/quantilenorm_cuda/check_mexutils.cpp
|
RuihanZhang2015/ExSeqProcessing
|
c9c3719b9e583def8a6401d16698363c6fe45574
|
[
"MIT"
] | 2
|
2020-05-15T20:00:30.000Z
|
2020-05-15T20:01:00.000Z
|
mex/quantilenorm_cuda/check_mexutils.cpp
|
RuihanZhang2015/ExSeqProcessing
|
c9c3719b9e583def8a6401d16698363c6fe45574
|
[
"MIT"
] | 5
|
2020-06-01T18:50:18.000Z
|
2021-09-15T18:39:28.000Z
|
#include <vector>
#include <string>
#include "spdlog/spdlog.h"
#include "mex.h"
#include "mex-utils/tiffs.h"
#include "mex-utils/hdf5.h"
void
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
std::shared_ptr<spdlog::logger> logger;
try {
spdlog::set_async_mode(4096, spdlog::async_overflow_policy::block_retry, nullptr, std::chrono::seconds(2));
//spdlog::set_async_mode(4096, spdlog::async_overflow_policy::block_retry, nullptr);
spdlog::set_level(spdlog::level::trace);
logger = spdlog::get("mex_logger");
if (logger == nullptr) {
logger = spdlog::basic_logger_mt("mex_logger", "logs/mex-check.log");
}
//logger->flush_on(spdlog::level::err);
logger->flush_on(spdlog::level::info);
} catch (const spdlog::spdlog_ex& ex) {
mexErrMsgIdAndTxt("MATLAB:check_mexutils:logNoInit", "Log initialization failed: %s", ex.what());
}
try {
logger->info("{:=>50}", " check_mexutils start");
/* Check for proper number of input and output arguments */
if (nrhs != 1) {
mexErrMsgIdAndTxt( "MATLAB:check_mexutils:minrhs", "1 input argument required.");
}
if (nlhs > 0) {
mexErrMsgIdAndTxt( "MATLAB:check_mexutils:maxrhs", "Too many output arguments.");
}
/* make sure input arguments are expected types */
if ( !mxIsCell(prhs[0])) {
mexErrMsgIdAndTxt("MATLAB:check_mexutils:notCell", "1st input arg must be type cell.");
}
const mxArray *root_cell_ptr = prhs[0];
mwSize total_num_cells = mxGetNumberOfElements(root_cell_ptr);
if (total_num_cells == 0) {
mexErrMsgIdAndTxt("MATLAB:check_mexutils:invalidInput", "Filename is not given.");
}
std::vector<std::string> fnames;
for (int i = 0; i < total_num_cells; i++) {
const mxArray *elem_ptr = mxGetCell(root_cell_ptr, i);
if (elem_ptr == NULL) {
mexErrMsgIdAndTxt("MATLAB:check_mexutils:invalidInput", "Empty cell.");
}
if ( !mxIsChar(elem_ptr)) {
mexErrMsgIdAndTxt("MATLAB:check_mexutils:invalidInput", "Invalid input filename.");
}
std::string fname(mxArrayToString(elem_ptr));
fnames.push_back(fname);
logger->debug("in[{}] = {}", i, fnames[i].c_str());
if (fname.substr(fname.size() - 4, 4) != ".tif" && fname.substr(fname.size() - 3, 3) != ".h5") {
mexErrMsgIdAndTxt("MATLAB:check_mexutils:invalidInput", "Invalid input filetype.");
}
}
size_t image_width, image_height, num_slices;
bool use_hdf5;
if (fnames[0].substr(fnames[0].size() - 4, 4) == ".tif") {
mexutils::gettiffinfo(fnames[0], image_width, image_height, num_slices);
use_hdf5 = false;
} else if (fnames[0].substr(fnames[0].size() - 3, 3) == ".h5") {
mexutils::gethdf5finfo(fnames[0], image_width, image_height, num_slices);
use_hdf5 = true;
}
if (use_hdf5) {
for (auto h5_file : fnames) {
logger->info("loadhdf5 start {}", h5_file);
std::shared_ptr<std::vector<uint16_t>> image = std::make_shared<std::vector<uint16_t>>();
mexutils::loadhdf5(h5_file, 0, num_slices - 1, image_height, image_width, image);
logger->info("slice ({}), image={}", num_slices, image->size());
logger->info("loadhdf5 end {}", h5_file);
}
} else {
for (auto tif_file : fnames) {
logger->info("loadtiff start {}", tif_file);
std::shared_ptr<std::vector<uint16_t>> image = std::make_shared<std::vector<uint16_t>>();
mexutils::loadtiff(tif_file, 0, num_slices, image);
logger->info("slice ({}), image={}", image->size());
logger->info("loadtiff end {}", tif_file);
}
}
logger->info("{:=>50}", " check_mexutils end");
logger->flush();
spdlog::drop_all();
} catch (...) {
logger->flush();
throw;
}
return;
}
| 37.919643
| 115
| 0.56793
|
dgoodwin208
|
f568a503a0c54e953a84d5c720cdc8f04bd72855
| 9,893
|
cpp
|
C++
|
src/VM/VM.cpp
|
Feral-Lang/Feral
|
908c507c823c8b836d3e2007baf77329c2d6b8bf
|
[
"MIT"
] | 131
|
2020-03-19T15:22:37.000Z
|
2021-12-19T02:37:01.000Z
|
src/VM/VM.cpp
|
Feral-Lang/Feral
|
908c507c823c8b836d3e2007baf77329c2d6b8bf
|
[
"MIT"
] | 14
|
2020-04-06T05:50:15.000Z
|
2021-06-26T06:19:04.000Z
|
src/VM/VM.cpp
|
Feral-Lang/Feral
|
908c507c823c8b836d3e2007baf77329c2d6b8bf
|
[
"MIT"
] | 20
|
2020-04-06T07:28:30.000Z
|
2021-09-05T14:46:25.000Z
|
/*
MIT License
Copyright (c) 2020 Feral Language repositories
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.
*/
#include "VM/VM.hpp"
#include <cstdarg>
#include <cstdlib>
#include <string>
#include "Common/Env.hpp"
#include "Common/FS.hpp"
#include "Common/String.hpp"
#include "VM/Vars.hpp"
// env: FERAL_PATHS
vm_state_t::vm_state_t(const std::string &self_bin, const std::string &self_base,
const std::vector<std::string> &args, const size_t &flags,
const bool &is_thread_copy)
: exit_called(false), exec_stack_count_exceeded(false), exit_code(0), exec_flags(flags),
exec_stack_max(EXEC_STACK_MAX_DEFAULT), exec_stack_count(0),
tru(new var_bool_t(true, 0, 0)), fals(new var_bool_t(false, 0, 0)),
nil(new var_nil_t(0, 0)), vm_stack(new vm_stack_t()),
dlib(is_thread_copy ? nullptr : new dyn_lib_t()), src_args(nullptr), m_self_bin(self_bin),
m_self_base(self_base), m_src_load_fn(nullptr), m_src_read_code_fn(nullptr),
m_is_thread_copy(is_thread_copy)
{
if(m_is_thread_copy) return;
init_typenames(*this);
std::vector<var_base_t *> src_args_vec;
for(auto &arg : args) {
src_args_vec.push_back(new var_str_t(arg, 0, 0));
}
src_args = new var_vec_t(src_args_vec, false, 0, 0);
std::vector<std::string> extra_search_paths = str::split(env::get("FERAL_PATHS"), ';');
for(auto &path : extra_search_paths) {
m_inc_locs.push_back(path + "/include/feral");
m_dll_locs.push_back(path + "/lib/feral");
}
m_inc_locs.push_back(m_self_base + "/include/feral");
m_dll_locs.push_back(m_self_base + "/lib/feral");
}
vm_state_t::~vm_state_t()
{
delete vm_stack;
if(!m_is_thread_copy)
for(auto &typefn : m_typefns) delete typefn.second;
for(auto &g : m_globals) var_dref(g.second);
for(auto &src : all_srcs) var_dref(src.second);
var_dref(nil);
var_dref(fals);
var_dref(tru);
var_dref(src_args);
for(auto &deinit_fn : m_dll_deinit_fns) {
deinit_fn.second();
}
if(m_is_thread_copy) return;
delete dlib;
}
void vm_state_t::push_src(srcfile_t *src, const size_t &idx)
{
if(all_srcs.find(src->path()) == all_srcs.end()) {
all_srcs[src->path()] = new var_src_t(src, new vars_t(), src->id(), idx);
}
var_iref(all_srcs[src->path()]);
src_stack.push_back(all_srcs[src->path()]);
}
void vm_state_t::push_src(const std::string &src_path)
{
assert(all_srcs.find(src_path) != all_srcs.end());
var_iref(all_srcs[src_path]);
src_stack.push_back(all_srcs[src_path]);
}
void vm_state_t::pop_src()
{
var_dref(src_stack.back());
src_stack.pop_back();
}
void vm_state_t::add_typefn(const std::uintptr_t &type, const std::string &name, var_base_t *fn,
const bool iref)
{
if(m_typefns.find(type) == m_typefns.end()) {
m_typefns[type] = new vars_frame_t();
}
if(m_typefns[type]->exists(name)) {
fprintf(stderr, "function '%s' for type '%s' already exists\n", name.c_str(),
type_name(type).c_str());
assert(false);
return;
}
m_typefns[type]->add(name, fn, iref);
}
var_base_t *vm_state_t::get_typefn(var_base_t *var, const std::string &name)
{
auto it = m_typefns.find(var->typefn_id());
var_base_t *res = nullptr;
if(it == m_typefns.end()) {
if(var->attr_based()) goto attr_based;
return m_typefns[type_id<var_all_t>()]->get(name);
}
res = it->second->get(name);
if(res) return res;
return m_typefns[type_id<var_all_t>()]->get(name);
attr_based:
it = m_typefns.find(var->type());
if(it == m_typefns.end()) return m_typefns[type_id<var_all_t>()]->get(name);
res = it->second->get(name);
if(res) return res;
return m_typefns[type_id<var_all_t>()]->get(name);
}
void vm_state_t::set_typename(const std::uintptr_t &type, const std::string &name)
{
m_typenames[type] = name;
}
std::string vm_state_t::type_name(const std::uintptr_t &type)
{
if(m_typenames.find(type) != m_typenames.end()) {
return m_typenames[type];
}
return "typeid<" + std::to_string(type) + ">";
}
std::string vm_state_t::type_name(const var_base_t *val)
{
return type_name(val->type());
}
void vm_state_t::gadd(const std::string &name, var_base_t *val, const bool iref)
{
if(m_globals.find(name) != m_globals.end()) return;
if(iref) var_iref(val);
m_globals[name] = val;
}
var_base_t *vm_state_t::gget(const std::string &name)
{
if(m_globals.find(name) == m_globals.end()) return nullptr;
return m_globals[name];
}
bool vm_state_t::mod_exists(const std::vector<std::string> &locs, std::string &mod,
const std::string &ext, std::string &dir)
{
if(mod.front() != '~' && mod.front() != '/' && mod.front() != '.') {
for(auto &loc : locs) {
if(fs::exists(loc + "/" + mod + ext)) {
mod = fs::abs_path(loc + "/" + mod + ext, &dir);
return true;
}
}
} else {
if(mod.front() == '~') {
mod.erase(mod.begin());
std::string home = env::get("HOME");
mod.insert(mod.begin(), home.begin(), home.end());
} else if(mod.front() == '.') {
// cannot have a module exists query with '.' outside all srcs
assert(src_stack.size() > 0);
mod.erase(mod.begin());
mod = src_stack.back()->src()->dir() + mod;
}
if(fs::exists(mod + ext)) {
mod = fs::abs_path(mod + ext, &dir);
return true;
}
}
return false;
}
bool vm_state_t::nmod_load(const std::string &mod_str, const size_t &src_id, const size_t &idx)
{
std::string mod = mod_str.substr(mod_str.find_last_of('/') + 1);
std::string mod_file = mod_str;
std::string mod_dir;
mod_file.insert(mod_file.find_last_of('/') + 1, "libferal");
if(!mod_exists(m_dll_locs, mod_file, nmod_ext(), mod_dir)) {
fail(src_id, idx, "module file: %s not found in locations: %s",
(mod_file + nmod_ext()).c_str(), str::stringify(m_dll_locs).c_str());
return false;
}
if(dlib->fexists(mod_file)) return true;
if(!dlib->load(mod_file)) {
fail(src_id, idx, "unable to load module file: %s", mod_file.c_str(),
str::stringify(m_dll_locs).c_str());
return false;
}
mod_init_fn_t init_fn = (mod_init_fn_t)dlib->get(mod_file, "init_" + mod);
if(init_fn == nullptr) {
fail(src_id, idx, "module file: %s does not contain init function (%s)",
mod_file.c_str(), ("init_" + mod).c_str());
dlib->unload(mod_file);
return false;
}
if(!init_fn(*this, src_id, idx)) {
dlib->unload(mod_file);
fail(src_id, idx, "init function in module file: %s didn't return okay",
mod_file.c_str());
return false;
}
// set deinit function if available
mod_deinit_fn_t deinit_fn = (mod_deinit_fn_t)dlib->get(mod_file, "deinit_" + mod);
if(deinit_fn) m_dll_deinit_fns[mod_file] = deinit_fn;
return true;
}
// updated mod_str with actual file name (full canonical path)
int vm_state_t::fmod_load(std::string &mod_file, const size_t &src_id, const size_t &idx)
{
std::string mod_dir;
if(!mod_exists(m_inc_locs, mod_file, fmod_ext(), mod_dir)) {
fail(src_id, idx, "import file: %s not found in locations: %s",
(mod_file + fmod_ext()).c_str(), str::stringify(m_inc_locs).c_str());
return E_FAIL;
}
if(all_srcs.find(mod_file) != all_srcs.end()) return E_OK;
Errors err = E_OK;
srcfile_t *src = m_src_load_fn(mod_file, mod_dir, exec_flags, false, err, 0, -1);
if(err != E_OK) {
if(src) delete src;
return err;
}
push_src(src, 0);
int res = vm::exec(*this);
pop_src();
return res;
}
void vm_state_t::fail(const size_t &src_id, const size_t &idx, const char *msg, ...)
{
va_list vargs;
va_start(vargs, msg);
if(fails.empty() || this->exit_called) {
for(auto &src : all_srcs) {
if(src.second->src()->id() == src_id) {
src.second->src()->fail(idx, msg, vargs);
break;
}
}
} else {
static char err[4096];
vsprintf(err, msg, vargs);
fails.push(new var_str_t(err, src_id, idx), false);
}
va_end(vargs);
}
void vm_state_t::fail(const size_t &src_id, const size_t &idx, var_base_t *val, const char *msg,
const bool &iref)
{
if(iref) var_iref(val);
if(fails.empty() || this->exit_called) {
for(auto &src : all_srcs) {
if(src.second->src()->id() == src_id) {
std::string data;
val->to_str(*this, data, src_id, idx);
var_dref(val);
if(msg) src.second->src()->fail(idx, "%s (%s)", msg, data.c_str());
else
src.second->src()->fail(idx, data.c_str());
break;
}
}
} else {
fails.push(val, false);
}
}
bool vm_state_t::load_core_mods()
{
std::vector<std::string> mods = {"core", "utils"};
for(auto &mod : mods) {
if(!nmod_load(mod, 0, 0)) return false;
}
return true;
}
vm_state_t *vm_state_t::thread_copy(const size_t &src_id, const size_t &idx)
{
vm_state_t *vm = new vm_state_t(m_self_bin, m_self_base, {}, exec_flags, true);
for(auto &s : all_srcs) {
vm->all_srcs[s.first] =
static_cast<var_src_t *>(s.second->thread_copy(src_id, idx));
}
for(auto &s : src_stack) {
vm->src_stack.push_back(vm->all_srcs[s->src()->path()]);
}
vm->dlib = dlib; // don't delete in destructor
var_iref(src_args);
vm->src_args = src_args;
vm->m_src_load_fn = m_src_load_fn;
vm->m_src_read_code_fn = m_src_read_code_fn;
vm->m_inc_locs = m_inc_locs;
vm->m_dll_locs = m_dll_locs;
vm->m_globals = m_globals;
for(auto &glob : vm->m_globals) {
var_iref(glob.second);
}
vm->m_typefns = m_typefns; // do not delete in destructor
vm->m_typenames = m_typenames;
// don't copy m_dll_deinit_fns as that will be called by the main thread
return vm;
}
const char *nmod_ext()
{
#if __linux__ || __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __bsdi__ || __DragonFly__
return ".so";
#elif __APPLE__
return ".dylib";
#endif
}
const char *fmod_ext(const bool compiled)
{
if(compiled) return ".cfer";
return ".fer";
}
| 29.01173
| 96
| 0.675124
|
Feral-Lang
|
f568cc4741f7e6838bddbed87284daeb0d7d505d
| 2,637
|
hpp
|
C++
|
examples/c/h2o2/chem_utils.hpp
|
stgeke/pyJac-v2
|
c2716a05df432efd8e5f6cc5cc3d46b72c24c019
|
[
"MIT"
] | null | null | null |
examples/c/h2o2/chem_utils.hpp
|
stgeke/pyJac-v2
|
c2716a05df432efd8e5f6cc5cc3d46b72c24c019
|
[
"MIT"
] | null | null | null |
examples/c/h2o2/chem_utils.hpp
|
stgeke/pyJac-v2
|
c2716a05df432efd8e5f6cc5cc3d46b72c24c019
|
[
"MIT"
] | null | null | null |
#ifndef CHEM_UTILS_HPP
#define CHEM_UTILS_HPP
#ifdef _OPENMP
#include <omp.h>
#else
#warning 'OpenMP not found! Unexpected results may occur if using more than one thread.'
#define omp_get_num_threads() (1)
#endif
#include "mechanism.hpp"
#include "chem_utils.hpp"
#ifndef work_size
#define work_size (omp_get_num_threads())
#endif
#include <math.h>
void eval_b(double const *__restrict__ phi, double *__restrict__ b);
void eval_h(double const *__restrict__ phi, double *__restrict__ h);
void eval_cp(double const *__restrict__ phi, double *__restrict__ cp);
static double const T_mid[9] = { 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0 };
static double const a_hi[9 * 7] = { 3.3372792, -4.94024731e-05, 4.99456778e-07, -1.79566394e-10, 2.00255376e-14, -950.158922, -3.20502331, 2.50000001, -2.30842973e-11, 1.61561948e-14, -4.73515235e-18, 4.98197357e-22, 25473.6599, -0.446682914, 2.56942078, -8.59741137e-05, 4.19484589e-08, -1.00177799e-11, 1.22833691e-15, 29217.5791, 4.78433864, 3.28253784, 0.00148308754, -7.57966669e-07, 2.09470555e-10, -2.16717794e-14, -1088.45772, 5.45323129, 3.09288767, 0.000548429716, 1.26505228e-07, -8.79461556e-11, 1.17412376e-14, 3858.657, 4.4766961, 3.03399249, 0.00217691804, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, -30004.2971, 4.9667701, 4.0172109, 0.00223982013, -6.3365815e-07, 1.1424637e-10, -1.07908535e-14, 111.856713, 3.78510215, 4.16500285, 0.00490831694, -1.90139225e-06, 3.71185986e-10, -2.87908305e-14, -17861.7877, 2.91615662, 2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.366 };
static double const a_lo[9 * 7] = { 2.34433112, 0.00798052075, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12, -917.935173, 0.683010238, 2.5, 7.05332819e-13, -1.99591964e-15, 2.30081632e-18, -9.27732332e-22, 25473.6599, -0.446682853, 3.1682671, -0.00327931884, 6.64306396e-06, -6.12806624e-09, 2.11265971e-12, 29122.2592, 2.05193346, 3.78245636, -0.00299673416, 9.84730201e-06, -9.68129509e-09, 3.24372837e-12, -1063.94356, 3.65767573, 3.99201543, -0.00240131752, 4.61793841e-06, -3.88113333e-09, 1.3641147e-12, 3615.08056, -0.103925458, 4.19864056, -0.0020364341, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, -30293.7267, -0.849032208, 4.30179801, -0.00474912051, 2.11582891e-05, -2.42763894e-08, 9.29225124e-12, 294.80804, 3.71666245, 4.27611269, -0.000542822417, 1.67335701e-05, -2.15770813e-08, 8.62454363e-12, -17702.5821, 3.43505074, 2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.366 };
void chem_utils(double const *__restrict__ t, double *__restrict__ b, double const *__restrict__ phi, double *__restrict__ h, double *__restrict__ cp, double *__restrict__ rwk);
#endif
| 109.875
| 888
| 0.731134
|
stgeke
|
f568eac4a45a9abd8b3ca10d7f12e762040a912c
| 855
|
hpp
|
C++
|
Microtone/include/microtone/midi_input.hpp
|
DanielToby/microtone
|
10538a23fb67933abe5b492eb4ae771bd646f8d6
|
[
"MIT"
] | null | null | null |
Microtone/include/microtone/midi_input.hpp
|
DanielToby/microtone
|
10538a23fb67933abe5b492eb4ae771bd646f8d6
|
[
"MIT"
] | null | null | null |
Microtone/include/microtone/midi_input.hpp
|
DanielToby/microtone
|
10538a23fb67933abe5b492eb4ae771bd646f8d6
|
[
"MIT"
] | null | null | null |
#pragma once
#include <microtone/microtone_platform.hpp>
#include <functional>
#include <memory>
#include <string>
#include <vector>
namespace microtone {
//enum class MidiStatusMessage {
// NoteOn = 0b10010000,
// NoteOff = 0b10000000,
// ControlChange = 0b10110000
//};
using OnMidiDataFn = std::function<void(int status, int note, int velocity)>;
class MidiInput {
public:
explicit MidiInput();
MidiInput(const MidiInput&) = delete;
MidiInput& operator=(const MidiInput&) = delete;
MidiInput(MidiInput&&) noexcept;
MidiInput& operator=(MidiInput&&) noexcept;
~MidiInput();
int portCount() const;
std::string portName(int portNumber) const;
void openPort(int portNumber);
void start(OnMidiDataFn onReceivedDataFn);
void stop();
private:
class impl;
std::unique_ptr<impl> _impl;
};
}
| 20.853659
| 77
| 0.694737
|
DanielToby
|
f5695a903889d0c821e0f3fd31befb4246c7a99a
| 346
|
cpp
|
C++
|
Online Judges/URI/1564/main.cpp
|
AnneLivia/URI-Online
|
02ff972be172a62b8abe25030c3676f6c04efd1b
|
[
"MIT"
] | 64
|
2019-03-17T08:56:28.000Z
|
2022-01-14T02:31:21.000Z
|
Online Judges/URI/1564/main.cpp
|
AnneLivia/URI-Online
|
02ff972be172a62b8abe25030c3676f6c04efd1b
|
[
"MIT"
] | 1
|
2020-12-24T07:16:30.000Z
|
2021-03-23T20:51:05.000Z
|
Online Judges/URI/1564/main.cpp
|
AnneLivia/URI-Online
|
02ff972be172a62b8abe25030c3676f6c04efd1b
|
[
"MIT"
] | 19
|
2019-05-25T10:48:16.000Z
|
2022-01-07T10:07:46.000Z
|
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
string complain;
while(getline(cin,complain)) {
if(complain.compare("0") == 0)
cout << "vai ter copa!\n";
else if(complain.compare("") == 0)
break;
else
cout << "vai ter duas!\n";
}
return 0;
}
| 18.210526
| 42
| 0.508671
|
AnneLivia
|
f56a2565622f44844754e5a211e68fef25c95406
| 2,981
|
cpp
|
C++
|
contracts/libc++/upstream/test/std/utilities/any/any.class/any.modifiers/swap.pass.cpp
|
caokun8008/ckeos
|
889093599eb59c90e4cbcff2817f4421302fada1
|
[
"MIT"
] | 2,151
|
2020-04-18T07:31:17.000Z
|
2022-03-31T08:39:18.000Z
|
contracts/libc++/upstream/test/std/utilities/any/any.class/any.modifiers/swap.pass.cpp
|
mirrowall/factschain
|
b5253228e42e4bfad65085397a2b31632c2cf8ee
|
[
"MIT"
] | 395
|
2020-04-18T08:22:18.000Z
|
2021-12-08T13:04:49.000Z
|
contracts/libc++/upstream/test/std/utilities/any/any.class/any.modifiers/swap.pass.cpp
|
mirrowall/factschain
|
b5253228e42e4bfad65085397a2b31632c2cf8ee
|
[
"MIT"
] | 338
|
2020-04-18T08:03:10.000Z
|
2022-03-29T12:33:22.000Z
|
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11
// XFAIL: with_system_cxx_lib=macosx10.10
// XFAIL: with_system_cxx_lib=macosx10.9
// XFAIL: with_system_cxx_lib=macosx10.7
// XFAIL: with_system_cxx_lib=macosx10.8
// <any>
// any::swap(any &) noexcept
// Test swap(large, small) and swap(small, large)
#include <any>
#include <cassert>
#include "any_helpers.h"
using std::any;
using std::any_cast;
template <class LHS, class RHS>
void test_swap() {
assert(LHS::count == 0);
assert(RHS::count == 0);
{
any a1((LHS(1)));
any a2(RHS{2});
assert(LHS::count == 1);
assert(RHS::count == 1);
a1.swap(a2);
assert(LHS::count == 1);
assert(RHS::count == 1);
assertContains<RHS>(a1, 2);
assertContains<LHS>(a2, 1);
}
assert(LHS::count == 0);
assert(RHS::count == 0);
assert(LHS::copied == 0);
assert(RHS::copied == 0);
}
template <class Tp>
void test_swap_empty() {
assert(Tp::count == 0);
{
any a1((Tp(1)));
any a2;
assert(Tp::count == 1);
a1.swap(a2);
assert(Tp::count == 1);
assertContains<Tp>(a2, 1);
assertEmpty(a1);
}
assert(Tp::count == 0);
{
any a1((Tp(1)));
any a2;
assert(Tp::count == 1);
a2.swap(a1);
assert(Tp::count == 1);
assertContains<Tp>(a2, 1);
assertEmpty(a1);
}
assert(Tp::count == 0);
assert(Tp::copied == 0);
}
void test_noexcept()
{
any a1;
any a2;
static_assert(
noexcept(a1.swap(a2))
, "any::swap(any&) must be noexcept"
);
}
void test_self_swap() {
{
// empty
any a;
a.swap(a);
assertEmpty(a);
}
{ // small
using T = small;
any a{T{42}};
T::reset();
a.swap(a);
assertContains<T>(a, 42);
assert(T::count == 1);
assert(T::copied == 0);
LIBCPP_ASSERT(T::moved == 0);
}
assert(small::count == 0);
{ // large
using T = large;
any a{T{42}};
T::reset();
a.swap(a);
assertContains<T>(a, 42);
assert(T::count == 1);
assert(T::copied == 0);
LIBCPP_ASSERT(T::moved == 0);
}
assert(large::count == 0);
}
int main()
{
test_noexcept();
test_swap_empty<small>();
test_swap_empty<large>();
test_swap<small1, small2>();
test_swap<large1, large2>();
test_swap<small, large>();
test_swap<large, small>();
test_self_swap();
}
| 21.141844
| 80
| 0.503187
|
caokun8008
|
f56c1a059c68e2a01a528a7212afe8852f5643d5
| 25,925
|
cc
|
C++
|
talk/owt/sdk/base/win/videorendererd3d11.cc
|
juicechu/owt-client-native
|
2c09dee92a5fec63f6775df5cd30d85306fee0db
|
[
"Apache-2.0"
] | 294
|
2019-02-20T01:44:34.000Z
|
2022-03-30T15:52:55.000Z
|
talk/owt/sdk/base/win/videorendererd3d11.cc
|
juicechu/owt-client-native
|
2c09dee92a5fec63f6775df5cd30d85306fee0db
|
[
"Apache-2.0"
] | 335
|
2019-02-20T11:54:49.000Z
|
2022-03-29T14:26:34.000Z
|
talk/owt/sdk/base/win/videorendererd3d11.cc
|
juicechu/owt-client-native
|
2c09dee92a5fec63f6775df5cd30d85306fee0db
|
[
"Apache-2.0"
] | 163
|
2019-02-18T06:56:26.000Z
|
2022-03-30T13:37:24.000Z
|
// Copyright (C) <2021> Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
#include "talk/owt/sdk/base/win/videorendererd3d11.h"
#include <array>
#include <cstdio>
#include "rtc_base/logging.h"
#include <system_error>
#include "talk/owt/sdk/base/nativehandlebuffer.h"
#include "talk/owt/sdk/base/win/d3dnativeframe.h"
#include "talk/owt/sdk/include/cpp/owt/base/globalconfiguration.h"
#include "talk/owt/sdk/include/cpp/owt/base/videorendererinterface.h"
#include "third_party/libyuv/include/libyuv/convert.h"
#include "webrtc/api/video/i420_buffer.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
using namespace rtc;
namespace owt {
namespace base {
// Driver specific VPE interface for SR/FRC.
static const GUID GUID_VPE_INTERFACE = {
0xedd1d4b9,
0x8659,
0x4cbc,
{0xa4, 0xd6, 0x98, 0x31, 0xa2, 0x16, 0x3a, 0xc3}};
#define VPE_FN_SCALING_MODE_PARAM 0x37
#define VPE_FN_MODE_PARAM 0x20
#define VPE_FN_SET_VERSION_PARAM 0x01
#define VPE_FN_SR_SET_PARAM 0x401
#define VPE_FN_SET_CPU_GPU_COPY_PARAM 0x2B
WebrtcVideoRendererD3D11Impl::WebrtcVideoRendererD3D11Impl(HWND wnd)
: wnd_(wnd), clock_(Clock::GetRealTimeClock()) {
CreateDXGIFactory(__uuidof(IDXGIFactory2), (void**)(&dxgi_factory_));
sr_enabled_ = SupportSuperResolution();
}
// The swapchain needs to use window height/width of even number.
bool WebrtcVideoRendererD3D11Impl::GetWindowSizeForSwapChain(int& width, int& height) {
if (!wnd_ || !IsWindow(wnd_))
return false;
RECT rect;
GetClientRect(wnd_, &rect);
width = rect.right - rect.left;
height = rect.bottom - rect.top;
if (width % 2) {
width += 1;
}
if (height % 2) {
height += 1;
}
return true;
}
void WebrtcVideoRendererD3D11Impl::OnFrame(
const webrtc::VideoFrame& video_frame) {
uint16_t width = video_frame.video_frame_buffer()->width();
uint16_t height = video_frame.video_frame_buffer()->height();
if (width == 0 || height == 0) {
RTC_LOG(LS_ERROR) << "Invalid video frame size.";
return;
}
if (!wnd_ || !IsWindow(wnd_) || !IsWindowVisible(wnd_))
return;
// Window width here is used to scale down the I420 frame,
// so we're not rounding it up to even number.
RECT rect;
GetClientRect(wnd_, &rect);
int window_width = rect.right - rect.left;
int window_height = rect.bottom - rect.top;
if (video_frame.video_frame_buffer()->type() ==
webrtc::VideoFrameBuffer::Type::kNative) {
D3D11ImageHandle* native_handle = reinterpret_cast<D3D11ImageHandle*>(
reinterpret_cast<owt::base::NativeHandleBuffer*>(
video_frame.video_frame_buffer().get())
->native_handle());
if (native_handle == nullptr) {
RTC_LOG(LS_ERROR) << "Invalid video buffer handle.";
return;
}
ID3D11Device* render_device = native_handle->d3d11_device;
// TODO(johny): Revisit this when capture/encode zero-copy is enabled.
// the D3D11 device may not be shared by capturer.
if (!render_device) {
RTC_LOG(LS_ERROR) << "Invalid d3d11 device passed.";
return;
}
HRESULT hr = S_OK;
ID3D11Texture2D* texture = native_handle->texture;
// Validate window
if (wnd_ && dxgi_factory_ && IsWindow(wnd_) && texture) {
hr = S_OK;
} else {
RTC_LOG(LS_ERROR) << "Invalid window or texture.";
return;
}
RenderNativeHandleFrame(video_frame);
} else { // I420 frame passed.
// First scale down to target window size.
webrtc::VideoFrame new_frame(video_frame);
rtc::scoped_refptr<webrtc::I420Buffer> scaled_buffer =
I420Buffer::Create(window_width, window_height);
auto i420_buffer = video_frame.video_frame_buffer()->ToI420();
scaled_buffer->ScaleFrom(*i420_buffer);
new_frame.set_video_frame_buffer(scaled_buffer);
RenderI420Frame_DX11(new_frame);
}
return;
}
bool WebrtcVideoRendererD3D11Impl::InitD3D11(int width, int height) {
HRESULT hr = S_OK;
UINT creation_flags = 0;
D3D_FEATURE_LEVEL feature_levels_in[] = {D3D_FEATURE_LEVEL_9_1, D3D_FEATURE_LEVEL_9_2,
D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_11_1};
D3D_FEATURE_LEVEL feature_levels_out;
hr = D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr,
creation_flags, feature_levels_in,
sizeof(feature_levels_in) / sizeof(D3D_FEATURE_LEVEL),
D3D11_SDK_VERSION, &d3d11_device_, &feature_levels_out,
&d3d11_device_context_);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to create D3D11 device for I420 renderer.";
return false;
}
d3d11_raw_inited_ = true;
hr = d3d11_device_->QueryInterface(__uuidof(ID3D10Multithread),
(void**)(&p_mt));
hr = p_mt->SetMultithreadProtected(true);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to enable multi-thread protection.";
return false;
}
return true;
}
bool WebrtcVideoRendererD3D11Impl::InitSwapChain(int width,
int height, bool reset) {
if (width <= 0 || height <= 0) {
RTC_LOG(LS_ERROR) << "Invalid video width for swapchain creation.";
return false;
}
if (!d3d11_device_ || !wnd_) {
RTC_LOG(LS_ERROR) << "Invalid device for swapchain creation.";
return false;
}
HRESULT hr = S_OK;
if (!GetWindowSizeForSwapChain(window_width_, window_height_)) {
RTC_LOG(LS_ERROR) << "Failed to get window size for swapchian.";
return false;
}
webrtc::MutexLock lock(&d3d11_texture_lock_);
if (swap_chain_for_hwnd_) {
DXGI_SWAP_CHAIN_DESC desc;
ZeroMemory(&desc, sizeof(desc));
hr = swap_chain_for_hwnd_->GetDesc(&desc);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to get desc for swapchain";
return false;
}
if (desc.BufferDesc.Width != (unsigned int)window_width_ ||
desc.BufferDesc.Height != (unsigned int)window_height_) {
d3d11_device_context_->ClearState();
d3d11_device_context_->Flush();
hr = swap_chain_for_hwnd_->ResizeBuffers(0, window_width_, window_height_,
DXGI_FORMAT_UNKNOWN, desc.Flags);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to resize buffer for swapchain.";
return false;
}
} else {
return true;
}
}
DXGI_SWAP_CHAIN_DESC1 desc;
ZeroMemory(&desc, sizeof(DXGI_SWAP_CHAIN_DESC1));
desc.BufferCount = 2;
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
desc.Height = window_height_;
desc.Width = window_width_;
desc.Scaling = DXGI_SCALING_STRETCH;
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
desc.Stereo = false;
desc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
CComPtr<IDXGIDevice2> dxgi_device;
hr = d3d11_device_->QueryInterface(__uuidof(IDXGIDevice1),
(void**)&dxgi_device);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to query dxgi device.";
return false;
}
Microsoft::WRL::ComPtr<IDXGIAdapter> adapter = nullptr;
Microsoft::WRL::ComPtr<IDXGIFactory2> factory = nullptr;
hr = dxgi_device->GetAdapter(&adapter);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to get the adatper.";
return false;
}
hr = adapter->GetParent(IID_PPV_ARGS(&factory));
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to get dxgi factory.";
return false;
}
d3d11_device_context_->ClearState();
d3d11_device_context_->Flush();
if (swap_chain_for_hwnd_)
swap_chain_for_hwnd_.Release();
hr = factory->CreateSwapChainForHwnd(d3d11_device_, wnd_, &desc, nullptr, nullptr, &swap_chain_for_hwnd_);
if (FAILED(hr)) {
std::string message = std::system_category().message(hr);
RTC_LOG(LS_ERROR) << "Failed to create swapchain for hwnd." << message;
return false;
}
return true;
}
void WebrtcVideoRendererD3D11Impl::RenderNativeHandleFrame(
const webrtc::VideoFrame& video_frame) {
D3D11ImageHandle* native_handle = reinterpret_cast<D3D11ImageHandle*>(
reinterpret_cast<owt::base::NativeHandleBuffer*>(
video_frame.video_frame_buffer().get())
->native_handle());
if (native_handle == nullptr)
return;
ID3D11Device* render_device = native_handle->d3d11_device;
if (!render_device) {
RTC_LOG(LS_ERROR) << "Decoder passed an invalid d3d11 device.";
return;
}
d3d11_device_ = render_device;
d3d11_texture_ = native_handle->texture;
if (d3d11_texture_ == nullptr)
return;
d3d11_device_->GetImmediateContext(&d3d11_device_context_);
if (d3d11_device_context_ == nullptr)
return;
RenderNV12DXGIMPO(video_frame.width(), video_frame.height());
}
void WebrtcVideoRendererD3D11Impl::RenderNV12DXGIMPO(int width, int height) {
HRESULT hr = S_OK;
if (!d3d11_mpo_inited_) {
bool ret = InitMPO(width, height);
if (!ret)
return;
}
if (!GetWindowSizeForSwapChain(window_width_, window_height_)) {
RTC_LOG(LS_ERROR) << "Failed to get window size for swapchain.";
return;
}
if (!d3d11_video_device_) {
hr = d3d11_device_->QueryInterface(__uuidof(ID3D11VideoDevice),
(void**)&d3d11_video_device_);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR)
<< "Failed to get d3d11 video device from d3d11 device.";
return;
}
}
if (swap_chain_for_hwnd_) {
DXGI_SWAP_CHAIN_DESC desc;
hr = swap_chain_for_hwnd_->GetDesc(&desc);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to get the swapchain descriptor.";
return;
}
if (desc.BufferDesc.Width != (unsigned int)window_width_ ||
desc.BufferDesc.Height != (unsigned int)window_height_) {
// Hold the lock to avoid rendering when resizing buffer.
webrtc::MutexLock lock(&d3d11_texture_lock_);
d3d11_device_context_->ClearState();
hr = swap_chain_for_hwnd_->ResizeBuffers(0, window_width_, window_height_,
DXGI_FORMAT_UNKNOWN, desc.Flags);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Resizing compositor swapchain failed.";
return;
}
}
}
// We are actually not resetting video processor when no input/output size change.
bool reset = false;
if (!d3d11_video_context_) {
hr = d3d11_device_context_->QueryInterface(__uuidof(ID3D11VideoContext),
(void**)&d3d11_video_context_);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Querying d3d11 video context failed.";
return;
}
}
if (!CreateVideoProcessor(width, height, reset))
return;
RenderD3D11Texture(width, height);
}
bool WebrtcVideoRendererD3D11Impl::InitMPO(int width, int height) {
HRESULT hr = S_OK;
hr = d3d11_device_->QueryInterface(__uuidof(ID3D11Device2),
(void**)&d3d11_device2_);
if (FAILED(hr))
return false;
hr = d3d11_device_->QueryInterface(&dxgi_device2_);
if (FAILED(hr))
return false;
CComPtr<IDCompositionDesktopDevice> desktop_device;
hr = DCompositionCreateDevice2(dxgi_device2_, IID_PPV_ARGS(&desktop_device));
if (FAILED(hr))
return false;
hr = desktop_device->QueryInterface(&comp_device2_);
if (FAILED(hr))
return false;
hr = desktop_device->CreateTargetForHwnd(wnd_, false, &comp_target_);
if (FAILED(hr))
return false;
hr = comp_device2_->CreateVisual(&root_visual_);
if (FAILED(hr))
return false;
hr = comp_device2_->CreateVisual(&visual_preview_);
if (FAILED(hr))
return false;
root_visual_->AddVisual(visual_preview_, FALSE, nullptr);
hr = comp_target_->SetRoot(root_visual_);
if (FAILED(hr))
return false;
hr = root_visual_->SetBitmapInterpolationMode(
DCOMPOSITION_BITMAP_INTERPOLATION_MODE_LINEAR);
if (FAILED(hr))
return false;
CComPtr<IDXGIAdapter> adapter = nullptr;
hr = dxgi_device2_->GetAdapter(&adapter);
if (FAILED(hr))
return false;
Microsoft::WRL::ComPtr<IDXGIFactoryMedia> pMediaFactory;
hr = adapter->GetParent(__uuidof(IDXGIFactoryMedia), (void**)&pMediaFactory);
if (FAILED(hr))
return false;
DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
RECT rect;
GetClientRect(wnd_, &rect);
if (!GetWindowSizeForSwapChain(window_width_, window_height_)) {
RTC_LOG(LS_ERROR) << "Failed to get window size for creating swapchain.";
return false;
}
swapChainDesc.Width = window_width_;
swapChainDesc.Height = window_height_;
swapChainDesc.Format = DXGI_FORMAT_NV12;
swapChainDesc.Stereo = false;
swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling.
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferCount = 2;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO;
swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
// The composition surface handle is only used to create YUV swap chains
// since CreateSwapChainForComposition can't do that.
HANDLE handle = INVALID_HANDLE_VALUE;
hr = DCompositionCreateSurfaceHandle(COMPOSITIONOBJECT_ALL_ACCESS, nullptr,
&handle);
if (FAILED(hr))
return false;
hr = pMediaFactory->CreateSwapChainForCompositionSurfaceHandle(
dxgi_device2_, handle, &swapChainDesc, nullptr, &swap_chain_for_hwnd_);
if (FAILED(hr))
return false;
hr = root_visual_->SetContent(swap_chain_for_hwnd_);
if (FAILED(hr))
return false;
hr = comp_device2_->Commit();
if (FAILED(hr))
return false;
d3d11_mpo_inited_ = true;
return true;
}
bool WebrtcVideoRendererD3D11Impl::CreateVideoProcessor(int width,
int height,
bool reset) {
HRESULT hr = S_OK;
if (width < 0 || height < 0)
return false;
if (!GetWindowSizeForSwapChain(window_width_, window_height_))
return false;
D3D11_VIDEO_PROCESSOR_CONTENT_DESC content_desc;
ZeroMemory(&content_desc, sizeof(content_desc));
if (video_processor_.p && video_processor_enum_.p) {
hr = video_processor_enum_->GetVideoProcessorContentDesc(&content_desc);
if (FAILED(hr))
return false;
if (content_desc.InputWidth != (unsigned int)width ||
content_desc.InputHeight != (unsigned int)height ||
content_desc.OutputWidth != window_width_ ||
content_desc.OutputHeight != window_height_ || reset) {
video_processor_enum_.Release();
video_processor_.Release();
} else {
return true;
}
}
ZeroMemory(&content_desc, sizeof(content_desc));
content_desc.InputFrameFormat = D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE;
content_desc.InputFrameRate.Numerator = 30;
content_desc.InputFrameRate.Denominator = 1;
content_desc.InputWidth = width;
content_desc.InputHeight = height;
content_desc.OutputWidth = window_width_;
content_desc.OutputHeight = window_height_;
content_desc.OutputFrameRate.Numerator = 30;
content_desc.OutputFrameRate.Denominator = 1;
content_desc.Usage = D3D11_VIDEO_USAGE_OPTIMAL_SPEED;
hr = d3d11_video_device_->CreateVideoProcessorEnumerator(
&content_desc, &video_processor_enum_);
if (FAILED(hr))
return false;
hr = d3d11_video_device_->CreateVideoProcessor(video_processor_enum_, 0,
&video_processor_);
if (FAILED(hr))
return false;
return true;
}
void WebrtcVideoRendererD3D11Impl::RenderD3D11Texture(int width, int height) {
webrtc::MutexLock lock(&d3d11_texture_lock_);
HRESULT hr = S_OK;
if (swap_chain_for_hwnd_ == nullptr) {
RTC_LOG(LS_ERROR) << "Invalid swapchain.";
return;
}
Microsoft::WRL::ComPtr<ID3D11Texture2D> dxgi_back_buffer;
hr = swap_chain_for_hwnd_->GetBuffer(0, IID_PPV_ARGS(&dxgi_back_buffer));
if (FAILED(hr)) {
std::string message = std::system_category().message(hr);
RTC_LOG(LS_ERROR) << "Failed to get back buffer:" << message;
return;
}
D3D11_TEXTURE2D_DESC back_buffer_desc;
dxgi_back_buffer->GetDesc(&back_buffer_desc);
D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC output_view_desc;
ZeroMemory(&output_view_desc, sizeof(output_view_desc));
output_view_desc.ViewDimension = D3D11_VPOV_DIMENSION_TEXTURE2D;
output_view_desc.Texture2D.MipSlice = 0;
Microsoft::WRL::ComPtr<ID3D11VideoProcessorOutputView> output_view;
hr = d3d11_video_device_->CreateVideoProcessorOutputView(
dxgi_back_buffer.Get(), video_processor_enum_, &output_view_desc,
&output_view);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to create output view.";
return;
}
D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC input_view_desc;
ZeroMemory(&input_view_desc, sizeof(input_view_desc));
input_view_desc.FourCC = 0;
input_view_desc.ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D;
input_view_desc.Texture2D.MipSlice = 0;
input_view_desc.Texture2D.ArraySlice = 0;
Microsoft::WRL::ComPtr<ID3D11VideoProcessorInputView> input_view;
hr = d3d11_video_device_->CreateVideoProcessorInputView(
d3d11_texture_, video_processor_enum_, &input_view_desc, &input_view);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to create input view.";
return;
}
D3D11_VIDEO_PROCESSOR_STREAM stream_data;
ZeroMemory(&stream_data, sizeof(stream_data));
stream_data.Enable = TRUE;
stream_data.OutputIndex = 0;
stream_data.InputFrameOrField = 0;
stream_data.PastFrames = 0;
stream_data.FutureFrames = 0;
stream_data.ppPastSurfaces = nullptr;
stream_data.ppFutureSurfaces = nullptr;
stream_data.pInputSurface = input_view.Get();
stream_data.ppPastSurfacesRight = nullptr;
stream_data.ppFutureSurfacesRight = nullptr;
stream_data.pInputSurfaceRight = nullptr;
RECT rect = {0};
rect.right = width;
rect.bottom = height;
d3d11_video_context_->VideoProcessorSetStreamSourceRect(video_processor_, 0,
true, &rect);
d3d11_video_context_->VideoProcessorSetStreamFrameFormat(
video_processor_, 0, D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE);
// Setup VPE for SR.
if (sr_enabled_) {
VPE_FUNCTION function_params;
VPE_VERSION vpe_version = {};
VPE_MODE vpe_mode = {};
SR_SCALING_MODE sr_scaling_params = {};
VPE_SR_PARAMS sr_params = {};
void* p_ext_data = nullptr;
UINT data_size = 0;
const GUID* p_ext_guid = nullptr;
// Set VPE version
ZeroMemory(&function_params, sizeof(function_params));
vpe_version.Version = (UINT)VPE_VERSION_3_0;
function_params.Function = VPE_FN_SET_VERSION_PARAM;
function_params.pVPEVersion = &vpe_version;
p_ext_data = &function_params;
data_size = sizeof(function_params);
p_ext_guid = &GUID_VPE_INTERFACE;
hr = d3d11_video_context_->VideoProcessorSetOutputExtension(
video_processor_, p_ext_guid, data_size, p_ext_data);
if (FAILED(hr))
goto sr_fail;
// Clear mode
ZeroMemory(&function_params, sizeof(function_params));
vpe_mode.Mode = VPE_MODE_NONE;
function_params.Function = VPE_FN_MODE_PARAM;
function_params.pVPEMode = &vpe_mode;
p_ext_data = &function_params;
data_size = sizeof(function_params);
p_ext_guid = &GUID_VPE_INTERFACE;
hr = d3d11_video_context_->VideoProcessorSetOutputExtension(
video_processor_, p_ext_guid, data_size, p_ext_data);
if (FAILED(hr))
goto sr_fail;
// Set SR parameters
ZeroMemory(&function_params, sizeof(function_params));
sr_params.bEnable = true;
sr_params.SRMode = DEFAULT_SCENARIO_MODE;
function_params.Function = VPE_FN_SR_SET_PARAM;
function_params.pSRParams = &sr_params;
p_ext_data = &function_params;
data_size = sizeof(function_params);
p_ext_guid = &GUID_VPE_INTERFACE;
hr = d3d11_video_context_->VideoProcessorSetOutputExtension(
video_processor_, p_ext_guid, data_size, p_ext_data);
if (FAILED(hr))
goto sr_fail;
}
sr_fail:
hr = d3d11_video_context_->VideoProcessorBlt(
video_processor_, output_view.Get(), 0, 1, &stream_data);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to blit.";
return;
}
hr = swap_chain_for_hwnd_->Present(1, 0);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to present the back buffer.";
return;
}
}
void WebrtcVideoRendererD3D11Impl::RenderI420Frame_DX11(
const webrtc::VideoFrame& video_frame) {
if (!d3d11_raw_inited_ &&
!InitD3D11(video_frame.width(), video_frame.height())) {
RTC_LOG(LS_ERROR) << "Failed to init d3d11 device.";
return;
}
if (!InitSwapChain(video_frame.width(), video_frame.height(), false)) {
RTC_LOG(LS_ERROR) << "Failed to init swapchain.";
return;
}
{
webrtc::MutexLock lock(&d3d11_texture_lock_);
if (d3d11_texture_) {
d3d11_texture_->Release();
d3d11_texture_ = nullptr;
}
}
if (!CreateStagingTexture(video_frame.width(), video_frame.height())) {
RTC_LOG(LS_ERROR) << "Failed to create staging texture.";
return;
}
HRESULT hr = S_OK;
p_mt->Enter();
D3D11_MAPPED_SUBRESOURCE sub_resource = {0};
hr = d3d11_device_context_->Map(d3d11_staging_texture_, 0, D3D11_MAP_READ_WRITE, 0, &sub_resource);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to map texture.";
return;
}
libyuv::I420ToARGB(video_frame.video_frame_buffer()->GetI420()->DataY(),
video_frame.video_frame_buffer()->GetI420()->StrideY(),
video_frame.video_frame_buffer()->GetI420()->DataU(),
video_frame.video_frame_buffer()->GetI420()->StrideU(),
video_frame.video_frame_buffer()->GetI420()->DataV(),
video_frame.video_frame_buffer()->GetI420()->StrideV(),
static_cast<uint8_t*>(sub_resource.pData),
sub_resource.RowPitch,
video_frame.video_frame_buffer()->width(),
video_frame.video_frame_buffer()->height());
d3d11_device_context_->Unmap(d3d11_staging_texture_, 0);
D3D11_TEXTURE2D_DESC desc = {0};
d3d11_staging_texture_->GetDesc(&desc);
desc.Usage = D3D11_USAGE_DEFAULT;
desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED;
desc.BindFlags = D3D11_BIND_RENDER_TARGET;
hr = d3d11_device_->CreateTexture2D(&desc, nullptr, &d3d11_texture_);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to create render target texture.";
return;
}
{
webrtc::MutexLock lock(&d3d11_texture_lock_);
d3d11_device_context_->CopyResource(d3d11_texture_, d3d11_staging_texture_);
d3d11_texture_->GetDesc(&d3d11_texture_desc_);
}
if (!d3d11_video_device_) {
hr = d3d11_device_->QueryInterface(__uuidof(ID3D11VideoDevice),
(void**)&d3d11_video_device_);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to query d3d11 video device.";
return;
}
}
if (!d3d11_video_context_) {
hr = d3d11_device_context_->QueryInterface(__uuidof(ID3D11VideoContext),
(void**)&d3d11_video_context_);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to get d3d11 video context.";
return;
}
}
p_mt->Leave();
if (!CreateVideoProcessor(video_frame.width(), video_frame.height(),
false)) {
RTC_LOG(LS_ERROR) << "Failed to create video processor.";
return;
}
RenderD3D11Texture(video_frame.width(), video_frame.height());
}
bool WebrtcVideoRendererD3D11Impl::CreateStagingTexture(int width, int height) {
if ((width < 0) || (height < 0))
return false;
if (d3d11_staging_texture_) {
D3D11_TEXTURE2D_DESC desc = {0};
d3d11_staging_texture_->GetDesc(&desc);
if (desc.Width != (unsigned int)width ||
desc.Height != (unsigned int)height) {
d3d11_staging_texture_->Release();
d3d11_staging_texture_ = nullptr;
} else
return true;
}
HRESULT hr = S_OK;
D3D11_TEXTURE2D_DESC desc = {0};
desc.Width = (unsigned int)width;
desc.Height = (unsigned int)height;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_STAGING;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE | D3D11_CPU_ACCESS_READ;
desc.MiscFlags = 0;
desc.BindFlags = 0;
hr = d3d11_device_->CreateTexture2D(&desc, nullptr,
&d3d11_staging_texture_);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to create staging texture.";
return false;
}
return true;
}
// Checks support for super resolution.
bool WebrtcVideoRendererD3D11Impl::SupportSuperResolution() {
return GlobalConfiguration::GetVideoSuperResolutionEnabled();
}
} // namespace base
} // namespace owt
| 33.451613
| 109
| 0.66866
|
juicechu
|
f56e921f53097385bf35ef6a78776e7f53bb6164
| 434
|
cpp
|
C++
|
prime check.cpp
|
Glenn-Po/LearningCandCPP
|
4cd2d3386dbe6691a007c42036fb9ebe932e011e
|
[
"Apache-2.0"
] | null | null | null |
prime check.cpp
|
Glenn-Po/LearningCandCPP
|
4cd2d3386dbe6691a007c42036fb9ebe932e011e
|
[
"Apache-2.0"
] | null | null | null |
prime check.cpp
|
Glenn-Po/LearningCandCPP
|
4cd2d3386dbe6691a007c42036fb9ebe932e011e
|
[
"Apache-2.0"
] | null | null | null |
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
#define AND &&
#define OR ||
int main(){
start:
int num, i, j=0, k;
printf("Enter value of the number\n");
scanf("%d", &num);
for(i=2;i<num;i++){
if(num%i==0){
j=1;
break;
}
}
if(j==0&&num!=1)// if(!j&&num!=1)
printf("%d is prime\n\n", num);
else
printf("%d is not prime\n\n", num);
goto start;
getch();
}
| 17.36
| 39
| 0.520737
|
Glenn-Po
|
f56f11e512d1836bbac467400352b945f3e21f96
| 3,961
|
cpp
|
C++
|
OrderParameters/P2.cpp
|
Yusheng-cai/mdanalysis
|
db7386bfc6dc14af94df34feee5db2d7f2649cf4
|
[
"MIT"
] | null | null | null |
OrderParameters/P2.cpp
|
Yusheng-cai/mdanalysis
|
db7386bfc6dc14af94df34feee5db2d7f2649cf4
|
[
"MIT"
] | null | null | null |
OrderParameters/P2.cpp
|
Yusheng-cai/mdanalysis
|
db7386bfc6dc14af94df34feee5db2d7f2649cf4
|
[
"MIT"
] | null | null | null |
#include "P2.h"
namespace OrderParametersRegistry
{
registry_<P2> registerP2("p2");
}
P2::P2(const OrderParametersInput& input)
:liquid_crystal(input)
{
registerOutput("p2",[this](void)-> Real {return this->getP2();});
registerOutput("p20", [this](void) -> Real {return this->getP20();});
registerOutput("p21", [this](void) -> Real {return this->getP21();});
registerOutput("p22", [this](void) -> Real {return this->getP22();});
registerOutput("qxx", [this](void)->Real {return this->getQxx();});
registerOutput("qxy", [this](void)->Real {return this->getQxy();});
registerOutput("qxz", [this](void)->Real {return this ->getQxz();});
registerOutput("qyy", [this](void)->Real {return this->getQyy();});
registerOutput("qyz", [this](void) ->Real {return this->getQyz();});
registerOutput("v0x", [this](void) -> Real {return this -> getv0x();});
registerOutput("v0y", [this](void) -> Real {return this -> getv0y();});
registerOutput("v0z", [this](void) -> Real {return this -> getv0z();});
}
void P2::calculate()
{
getUij();
calcQtensor();
// find the p2 variable as well as the eigenvalue
auto orderedEigPair = Qtensor::orderedeig_Qtensor(Qtensor_);
P2_OP_ = -2.0*orderedEigPair.second[1];
for (int i=0;i<3;i++)
{
v0_[i] = orderedEigPair.first[i][0];
v1_[i] = orderedEigPair.first[i][1];
v2_[i] = orderedEigPair.first[i][2];
}
// calculate p2 in each of the directions of the eigenvectors
p2_0_ = 0.0;
p2_1_ = 0.0;
p2_2_ = 0.0;
for (int i=0;i<uij_.size();i++)
{
p2_0_ += 3*std::pow(Qtensor::vec_dot(uij_[i], v0_),2.0) - 1;
p2_1_ += 3*std::pow(Qtensor::vec_dot(uij_[i], v1_),2.0) - 1;
p2_2_ += 3*std::pow(Qtensor::vec_dot(uij_[i], v2_),2.0) - 1;
}
auto& headatomgroup_ = getAtomGroup(headgroupname_);
auto& tailatomgroup_ = getAtomGroup(tailgroupname_);
auto& headatoms_ = headatomgroup_.getAtoms();
auto& tailatoms_ = tailatomgroup_.getAtoms();
Real N = tailgroupsize_;
p2_0_ /= (2.0*N);
p2_1_ /= (2.0*N);
p2_2_ /= (2.0*N);
auto headatomDerivatives_ = accessDerivatives(headgroupname_);
auto tailatomDerivatives_ = accessDerivatives(tailgroupname_);
// clear all the derivatives stored in derivativesOutputs
clearDerivativesOutputs();
#pragma omp parallel
{
#pragma omp for
for (int i=0;i<tailgroupsize_;i++)
{
Real3 uij = uij_[i];
Real norm = norms_[i];
auto derivative = dP2dr(N, norm, v1_, uij);
auto headatom = headatoms_[i];
auto tailatom = tailatoms_[i];
headatomDerivatives_.insertOMP(headatom.index, derivative.first);
tailatomDerivatives_.insertOMP(tailatom.index, derivative.second);
}
}
headatomDerivatives_.CombineAndClearOMPBuffer();
tailatomDerivatives_.CombineAndClearOMPBuffer();
// for (int i=0;i<headatomDerivatives_.size();i++)
// {
// auto deriv = headatomDerivatives_.getAtomDerivativeByIndex(i);
// std::cout << "For atom index " << deriv.index << ":";
// for (int j=0;j<3;j++)
// {
// std::cout << deriv.derivatives[j] << " ";
// }
// std::cout << "\n";
// }
}
std::pair<P2::Real3,P2::Real3> P2::dP2dr(Real N, Real norm, Real3& eigvec, Real3& director)
{
std::pair<Real3,Real3> pair_;
// (v1 \dot u)
Real dotproduct = Qtensor::vec_dot(eigvec, director);
Real factor = - 6.0/(N*norm);
Real3 output;
output.fill(0);
for (int i=0;i<3;i++)
{
output[i] += eigvec[i] - director[i]*dotproduct;
}
output = Qtensor::vec_mult(factor, output);
Real3 output2 = Qtensor::vec_mult(-1.0, output);
pair_.first = output;
pair_.second = output2;
return pair_;
}
void P2::update()
{
P2_OP_ = 0;
v1_.fill(0);
Qtensor_.fill({});
}
| 29.559701
| 91
| 0.597071
|
Yusheng-cai
|
f56f42393dcd7bbdf7a16ed4a3bab670337e57c3
| 1,445
|
cpp
|
C++
|
libs/geometry/doc/src/examples/geometries/adapted/boost_range/strided.cpp
|
Ron2014/boost_1_48_0
|
19673f69677ffcba7c7bd6e08ec07ee3962f161c
|
[
"BSL-1.0"
] | null | null | null |
libs/geometry/doc/src/examples/geometries/adapted/boost_range/strided.cpp
|
Ron2014/boost_1_48_0
|
19673f69677ffcba7c7bd6e08ec07ee3962f161c
|
[
"BSL-1.0"
] | null | null | null |
libs/geometry/doc/src/examples/geometries/adapted/boost_range/strided.cpp
|
Ron2014/boost_1_48_0
|
19673f69677ffcba7c7bd6e08ec07ee3962f161c
|
[
"BSL-1.0"
] | null | null | null |
// Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example
// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to 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)
//[boost_range_strided
//` Shows how to use a Boost.Geometry ring, strided by Boost.Range adaptor
#include <iostream>
#include <boost/assign.hpp>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/ring.hpp>
#include <boost/geometry/geometries/adapted/boost_range/strided.hpp>
int main()
{
using namespace boost::assign;
using boost::adaptors::strided;
typedef boost::geometry::model::d2::point_xy<int> xy;
boost::geometry::model::ring<xy> ring;
ring += xy(0, 0);
ring += xy(0, 1);
ring += xy(0, 2);
ring += xy(1, 2);
ring += xy(2, 2);
ring += xy(2, 0);
boost::geometry::correct(ring);
std::cout
<< "Normal : " << boost::geometry::dsv(ring) << std::endl
<< "Strided: " << boost::geometry::dsv(ring | strided(2)) << std::endl;
return 0;
}
//]
//[boost_range_strided_output
/*`
Output:
[pre
Normal : ((0, 0), (0, 1), (0, 2), (1, 2), (2, 2), (2, 0), (0, 0))
Strided: ((0, 0), (0, 2), (2, 2), (0, 0))
]
*/
//]
| 25.350877
| 80
| 0.60692
|
Ron2014
|
f5703111efbc8754cd3628c9aaf6e583e14b392b
| 16,341
|
cpp
|
C++
|
Engine/Source/ThirdParty/PhysX/PhysX_3.4/Source/GeomUtils/src/contact/GuLegacyContactBoxHeightField.cpp
|
windystrife/UnrealEngine_NVIDIAGameWork
|
b50e6338a7c5b26374d66306ebc7807541ff815e
|
[
"MIT"
] | 1
|
2022-01-29T18:36:12.000Z
|
2022-01-29T18:36:12.000Z
|
Engine/Source/ThirdParty/PhysX/PhysX_3.4/Source/GeomUtils/src/contact/GuLegacyContactBoxHeightField.cpp
|
windystrife/UnrealEngine_NVIDIAGameWork
|
b50e6338a7c5b26374d66306ebc7807541ff815e
|
[
"MIT"
] | null | null | null |
Engine/Source/ThirdParty/PhysX/PhysX_3.4/Source/GeomUtils/src/contact/GuLegacyContactBoxHeightField.cpp
|
windystrife/UnrealEngine_NVIDIAGameWork
|
b50e6338a7c5b26374d66306ebc7807541ff815e
|
[
"MIT"
] | null | null | null |
// This code contains NVIDIA Confidential Information and is disclosed to you
// under a form of NVIDIA software license agreement provided separately to you.
//
// Notice
// NVIDIA Corporation and its licensors retain all intellectual property and
// proprietary rights in and to this software and related documentation and
// any modifications thereto. Any use, reproduction, disclosure, or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA Corporation is strictly prohibited.
//
// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Information and code furnished is believed to be accurate and reliable.
// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
// information or for any infringement of patents or other rights of third parties that may
// result from its use. No license is granted by implication or otherwise under any patent
// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
// This code supersedes and replaces all information previously supplied.
// NVIDIA Corporation products are not authorized for use as critical
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "GuContactMethodImpl.h"
#include "GuGeometryUnion.h"
#include "GuHeightFieldUtil.h"
#include "CmRenderBuffer.h"
#include "GuContactBuffer.h"
#include "GuContactMethodImpl.h"
#include "GuLegacyTraceLineCallback.h"
#include "PsFPU.h"
#include "CmMatrix34.h"
using namespace physx;
#define DISTANCE_BASED_TEST
/////////
#if 0
#include "CmRenderOutput.h"
#include "PxsContext.h"
static void gVisualizeBox(const Gu::Box& box, PxcNpThreadContext& context, PxU32 color=0xffffff)
{
PxMat33 rot(box.rot.column0, box.rot.column1, box.rot.column2);
PxMat44 m(rot, box.center);
Cm::DebugBox db(box.extents);
Cm::RenderOutput& out = context.mRenderOutput;
out << color << m;
out << db;
}
static void gVisualizeLine(const PxVec3& a, const PxVec3& b, PxcNpThreadContext& context, PxU32 color=0xffffff)
{
PxMat44 m = PxMat44(PxIdentity);
Cm::RenderOutput& out = context.mRenderOutput;
out << color << m << Cm::RenderOutput::LINES << a << b;
}
#endif
/////////
// ptchernev TODO: make sure these are ok before shipping
static const bool gCompileBoxVertex = true;
static const bool gCompileEdgeEdge = true;
static const bool gCompileHeightFieldVertex = true;
static const PxReal signs[24] =
{
-1,-1,-1,
-1,-1, 1,
-1, 1,-1,
-1, 1, 1,
1,-1,-1,
1,-1, 1,
1, 1,-1,
1, 1, 1,
};
static const PxU8 edges[24] =
{
0,1,
1,3,
3,2,
2,0,
4,5,
5,7,
7,6,
6,4,
0,4,
1,5,
2,6,
3,7,
};
static bool GuDepenetrateBox( const PxVec3& point,
const PxVec3& safeNormal,
const PxVec3& dimensions,
float /*contactDistance*/,
PxVec3& normal,
PxReal& distance)
{
PxVec3 faceNormal(PxReal(0));
PxReal distance1 = -PX_MAX_REAL; // cant be more
PxReal distance2 = -PX_MAX_REAL; // cant be more
PxI32 poly1 = -1;
PxI32 poly2 = -2;
for (PxU32 poly = 0; poly < 6; poly++)
{
PxU32 dim = poly % 3;
PxReal sign = (poly > 2) ? -PxReal(1) : PxReal(1);
PxVec3 n(PxVec3(0));
n[dim] = sign;
PxReal proj = n[dim] * safeNormal[dim];
PxReal d = n[dim] * (point[dim] - sign * dimensions[dim]);
#ifdef DISTANCE_BASED_TEST
// PT: I'm not really sure about contactDistance here
// AP: enabling this causes jitter in DE2740
//d -= contactDistance;
#endif
if (d >= 0)
return false;
if (proj > 0)
{
if (d > distance1) // less penetration
{
distance1 = d;
faceNormal = n;
poly1 = PxI32(poly);
}
// distance2 / d = 1 / proj
PxReal tmp = d / proj;
if (tmp > distance2)
{
distance2 = tmp;
poly2 = PxI32(poly);
}
}
}
if (poly1 == poly2)
{
PX_ASSERT(faceNormal.magnitudeSquared() != 0.0f);
normal = faceNormal;
distance = -distance1;
}
else
{
normal = safeNormal;
distance = -distance2;
}
return true;
}
//Box-Heightfield and Convex-Heightfield do not support positive values for contactDistance,
//and if in this case we would emit contacts normally, we'd cause things to jitter.
//as a workaround we add contactDistance to the distance values that we emit in contacts.
//this has the effect that the biasing will work exactly as if we had specified a legacy skinWidth of (contactDistance - restDistance)
namespace physx
{
namespace Gu
{
bool legacyContactBoxHeightfield(GU_CONTACT_METHOD_ARGS)
{
PX_UNUSED(renderOutput);
PX_UNUSED(cache);
//PXC_WARN_ONCE(contactDistance > 0.0f, "PxcContactBoxHeightField: Box-Heightfield does not support distance based contact generation! Ignoring contactOffset > 0!");
// Get actual shape data
const PxBoxGeometry& shapeBox = shape0.get<const PxBoxGeometry>();
const PxHeightFieldGeometryLL& hfGeom = shape1.get<const PxHeightFieldGeometryLL>();
const Gu::HeightField& hf = *static_cast<Gu::HeightField*>(hfGeom.heightField);
const Gu::HeightFieldUtil hfUtil(hfGeom, hf);
PX_ASSERT(contactBuffer.count==0);
Cm::Matrix34 boxShapeAbsPose(transform0);
Cm::Matrix34 hfShapeAbsPose(transform1);
const PxMat33& left = hfShapeAbsPose.m;
const PxMat33& right = boxShapeAbsPose.m;
Cm::Matrix34 boxShape2HfShape(left.getInverse()* right, left.getInverse()*(boxShapeAbsPose.p - hfShapeAbsPose.p));
// Get box vertices.
PxVec3 boxVertices[8];
PxVec3 boxVertexNormals[8];
for(PxU32 i=0; i<8; i++)
{
boxVertices[i] = PxVec3(shapeBox.halfExtents.x*signs[3*i], shapeBox.halfExtents.y*signs[3*i+1], shapeBox.halfExtents.z*signs[3*i+2]);
boxVertexNormals[i] = PxVec3(signs[3*i], signs[3*i+1], signs[3*i+2]);
boxVertexNormals[i].normalize();
}
// Transform box vertices to HeightFieldShape space.
PxVec3 boxVerticesInHfShape[8];
PxVec3 boxVertexNormalsInHfShape[8];
for(PxU32 i=0; i<8; i++)
{
boxVerticesInHfShape[i] = boxShape2HfShape.transform(boxVertices[i]);
boxVertexNormalsInHfShape[i] = boxShape2HfShape.rotate(boxVertexNormals[i]);
}
// bounds of box on HeightField.
PxVec3 aabbMin(boxVerticesInHfShape[0]);
PxVec3 aabbMax(boxVerticesInHfShape[0]);
for(PxU32 i=1; i<8; i++)
{
for(PxU32 dim = 0; dim < 3; dim++)
{
aabbMin[dim] = PxMin(aabbMin[dim], boxVerticesInHfShape[i][dim]);
aabbMax[dim] = PxMax(aabbMax[dim], boxVerticesInHfShape[i][dim]);
}
}
const bool thicknessNegOrNull = (hf.getThicknessFast() <= 0.0f); // PT: don't do this each time! FCMPs are slow.
// Compute the height field extreme over the bounds area.
// PxReal hfExtreme = thicknessNegOrNull ? -PX_MAX_REAL : PX_MAX_REAL;
// PT: we already computed those!
// const PxReal oneOverRowScale = 1.0f / shapeHeightField.rowScale;
// const PxReal oneOverColumnScale = 1.0f / shapeHeightField.columnScale;
const PxReal oneOverRowScale = hfUtil.getOneOverRowScale();
const PxReal oneOverColumnScale = hfUtil.getOneOverColumnScale();
PxU32 minRow;
PxU32 maxRow;
PxU32 minColumn;
PxU32 maxColumn;
if (hfGeom.rowScale < 0)
{
minRow = hf.getMinRow(aabbMax.x * oneOverRowScale);
maxRow = hf.getMaxRow(aabbMin.x * oneOverRowScale);
}
else
{
minRow = hf.getMinRow(aabbMin.x * oneOverRowScale);
maxRow = hf.getMaxRow(aabbMax.x * oneOverRowScale);
}
if (hfGeom.columnScale < 0)
{
minColumn = hf.getMinColumn(aabbMax.z * oneOverColumnScale);
maxColumn = hf.getMaxColumn(aabbMin.z * oneOverColumnScale);
}
else
{
minColumn = hf.getMinColumn(aabbMin.z * oneOverColumnScale);
maxColumn = hf.getMaxColumn(aabbMax.z * oneOverColumnScale);
}
PxReal hfExtreme = hf.computeExtreme(minRow, maxRow, minColumn, maxColumn);
//hfExtreme *= hfShape.getHeightScale();
hfExtreme *= hfGeom.heightScale;
// Return if convex is on the wrong side of the extreme.
if (thicknessNegOrNull)
{
if (aabbMin.y > hfExtreme) return false;
}
else
{
if (aabbMax.y < hfExtreme) return false;
}
// Test box vertices.
if (gCompileBoxVertex)
{
for(PxU32 i=0; i<8; i++)
{
const int32_t* tmp = reinterpret_cast<const int32_t*>(&boxVertexNormalsInHfShape[i].y);
// PT: orientation culling
if(*tmp>0)
// if(PX_SIR(boxVertexNormalsInHfShape[i].y)>0)
continue;
const PxVec3& boxVertexInHfShape = boxVerticesInHfShape[i];
#if 0
PxVec3 pt = boxShapeAbsPose.transform(boxVertices[i]);
PxVec3 worldNormal = boxShapeAbsPose.rotate(boxVertexNormals[i]);
//gVisualizeLine(pt, pt+PxVec3(1.0f,0.0f,0.0f), context, PxDebugColor::eARGB_RED);
//gVisualizeLine(pt, pt+PxVec3(0.0f,1.0f,0.0f), context, PxDebugColor::eARGB_GREEN);
//gVisualizeLine(pt, pt+PxVec3(0.0f,0.0f,1.0f), context, PxDebugColor::eARGB_BLUE);
gVisualizeLine(pt, pt+worldNormal, context, PxDebugColor::eARGB_MAGENTA);
#endif
//////// SAME CODE AS IN CONVEX-HF
const bool insideExtreme =
thicknessNegOrNull ? (boxVertexInHfShape.y < hfExtreme + params.mContactDistance) : (boxVertexInHfShape.y > hfExtreme-params.mContactDistance);
//if (insideExtreme && hfShape.isShapePointOnHeightField(boxVertexInHfShape.x, boxVertexInHfShape.z))
if (insideExtreme && hfUtil.isShapePointOnHeightField(boxVertexInHfShape.x, boxVertexInHfShape.z))
{
//PxReal y = hfShape.getHeightAtShapePoint(boxVertexInHfShape.x, boxVertexInHfShape.z);
// const PxReal y = hfUtil.getHeightAtShapePoint(boxVertexInHfShape.x, boxVertexInHfShape.z);
// PT: compute this once, reuse results (3 times!)
// PT: TODO: also reuse this in EE tests
PxReal fracX, fracZ;
const PxU32 vertexIndex = hfUtil.getHeightField().computeCellCoordinates(
boxVertexInHfShape.x * oneOverRowScale, boxVertexInHfShape.z * oneOverColumnScale, fracX, fracZ);
const PxReal y = hfUtil.getHeightAtShapePoint2(vertexIndex, fracX, fracZ);
const PxReal dy = boxVertexInHfShape.y - y;
#ifdef DISTANCE_BASED_TEST
if (hf.isDeltaHeightInsideExtent(dy, params.mContactDistance))
#else
if (hf.isDeltaHeightInsideExtent(dy))
#endif
{
const PxU32 faceIndex = hfUtil.getFaceIndexAtShapePointNoTest2(vertexIndex, fracX, fracZ);
if (faceIndex != 0xffffffff)
{
// PxcMaterialIndex material = hfShape.getTriangleMaterial(feature);
PxVec3 n;
//n = hfShape.getNormalAtShapePoint(boxVertexInHfShape.x, boxVertexInHfShape.z);
// n = hfUtil.getNormalAtShapePoint(boxVertexInHfShape.x, boxVertexInHfShape.z);
n = hfUtil.getNormalAtShapePoint2(vertexIndex, fracX, fracZ);
n = n.getNormalized();
contactBuffer
#ifdef DISTANCE_BASED_TEST
.contact(boxShapeAbsPose.transform(boxVertices[i]), hfShapeAbsPose.rotate(n), n.y*dy/* + contactDistance*/, faceIndex);
#else
.contact(boxShapeAbsPose.transform(boxVertices[i]), hfShapeAbsPose.rotate(n), n.y*dy + contactDistance, feature);//add contactDistance to compensate for fact that we don't support dist based contacts! See comment at start of funct.
#endif
}
}
}
////////~SAME CODE AS IN CONVEX-HF
}
}
// Test box edges.
if (gCompileEdgeEdge)
{
// create helper class for the trace segment
GuContactHeightfieldTraceSegmentHelper traceSegmentHelper(hfUtil);
for(PxU32 i=0; i<12; i++)
{
// PT: orientation culling
//float worldNormalY = (boxVertexNormalsInHfShape[edges[2*i]].y + boxVertexNormalsInHfShape[edges[2*i+1]].y)*0.5f;
float worldNormalY = boxVertexNormalsInHfShape[edges[2*i]].y + boxVertexNormalsInHfShape[edges[2*i+1]].y;
if(worldNormalY>0.0f)
continue;
const PxVec3& v0 = boxVerticesInHfShape[edges[2*i]];
const PxVec3& v1 = boxVerticesInHfShape[edges[2*i+1]];
#if 0
PxVec3 pt0 = boxShapeAbsPose.transform(boxVertices[edges[2*i]]);
PxVec3 pt1 = boxShapeAbsPose.transform(boxVertices[edges[2*i+1]]);
PxVec3 worldNormal0 = boxShapeAbsPose.rotate(boxVertexNormals[edges[2*i]]);
PxVec3 worldNormal1 = boxShapeAbsPose.rotate(boxVertexNormals[edges[2*i+1]]);
PxVec3 pt = (pt0 + pt1)*0.5f;
PxVec3 worldNormal = (worldNormal0 + worldNormal1)*0.5f;
gVisualizeLine(pt, pt+worldNormal, context, PxDebugColor::eARGB_CYAN);
#endif
if (hf.getThicknessFast()) // PT: errr...? not the same test as in the convex code?
{
if ((v0.y > hfExtreme) && (v1.y > hfExtreme)) continue;
}
else
{
if ((v0.y < hfExtreme) && (v1.y < hfExtreme)) continue;
}
GuContactTraceSegmentCallback cb(v1 - v0,
contactBuffer,
hfShapeAbsPose, params.mContactDistance/*, context.mRenderOutput*/);
//context.mRenderOutput << PxVec3(1,0,0) << Gu::Debug::convertToPxMat44(transform1)
// << Cm::RenderOutput::LINES << v0+PxVec3(0.01f) << v1+PxVec3(0.01f);
//hfShape.traceSegment<PxcContactTraceSegmentCallback>(v0, v1, &cb);
traceSegmentHelper.traceSegment(v0, v1, &cb);
}
}
// Test HeightField vertices.
if (gCompileHeightFieldVertex)
{
// Iterate over all HeightField vertices inside the bounds.
for(PxU32 row = minRow; row <= maxRow; row++)
{
for(PxU32 column = minColumn; column <= maxColumn; column++)
{
const PxU32 vertexIndex = row * hf.getNbColumnsFast() + column;
//if (!hfShape.isCollisionVertex(vertexIndex)) continue;
if (!hfUtil.isCollisionVertex(vertexIndex, row, column)) continue;
// Check if hf vertex is inside the box.
//PxVec3 hfVertex;
//hfVertex.set(hfShape.getRowScale() * row, hfShape.getHeightScale() * hfShape.getHeight(vertexIndex), hfShape.getColumnScale() * column);
// const PxVec3 hfVertex(shapeHeightField.rowScale * row, shapeHeightField.columnScale * hfShape.getHeight(vertexIndex), shapeHeightField.columnScale * column);
const PxVec3 hfVertex(hfGeom.rowScale * row, hfGeom.heightScale * hf.getHeight(vertexIndex), hfGeom.columnScale * column);
const PxVec3 hfVertexInBoxShape = boxShape2HfShape.transformTranspose(hfVertex);
if ((PxAbs(hfVertexInBoxShape.x) - shapeBox.halfExtents.x - params.mContactDistance < 0)
&& (PxAbs(hfVertexInBoxShape.y) - shapeBox.halfExtents.y - params.mContactDistance < 0)
&& (PxAbs(hfVertexInBoxShape.z) - shapeBox.halfExtents.z - params.mContactDistance < 0))
{
// ptchernev: should have done this in HeightFieldShape
// check if this really is a collision vertex
//PxVec3 hfVertexNormal = thicknessNegOrNull ? hfShape.getVertexNormal(vertexIndex) : -hfShape.getVertexNormal(vertexIndex);
// PxVec3 hfVertexNormal = thicknessNegOrNull ? hfUtil.getVertexNormal(vertexIndex) : -hfUtil.getVertexNormal(vertexIndex);
const PxVec3 nrm = hfUtil.getVertexNormal(vertexIndex, row, column);
PxVec3 hfVertexNormal = thicknessNegOrNull ? nrm : -nrm;
hfVertexNormal = hfVertexNormal.getNormalized();
const PxVec3 hfVertexNormalInBoxShape = boxShape2HfShape.rotateTranspose(hfVertexNormal);
PxVec3 normal;
PxReal depth;
if (!GuDepenetrateBox(hfVertexInBoxShape, -hfVertexNormalInBoxShape, shapeBox.halfExtents, params.mContactDistance, normal, depth))
{
continue;
}
// PxMat33 rot(boxShape2HfShape[0],boxShape2HfShape[1],boxShape2HfShape[2]);
// PxVec3 normalInHfShape = rot * (-normal);
PxVec3 normalInHfShape = boxShape2HfShape.rotate(-normal);
//hfShape.clipShapeNormalToVertexVoronoi(normalInHfShape, vertexIndex);
hfUtil.clipShapeNormalToVertexVoronoi(normalInHfShape, vertexIndex, row, column);
if (normalInHfShape.dot(hfVertexNormal) < PX_EPS_REAL)
{
// hmm, I dont think this can happen
continue;
}
normalInHfShape = normalInHfShape.getNormalized();
const PxU32 faceIndex = hfUtil.getVertexFaceIndex(vertexIndex, row, column);
contactBuffer
.contact(hfShapeAbsPose.transform(hfVertex), hfShapeAbsPose.rotate(normalInHfShape),
#ifdef DISTANCE_BASED_TEST
-depth,
#else
-depth + contactDistance, //add contactDistance to compensate for fact that we don't support dist based contacts! See comment at start of funct.
#endif
faceIndex);
}
}
}
}
return contactBuffer.count > 0;
}
}//Gu
}//physx
| 34.257862
| 238
| 0.722538
|
windystrife
|
f570942c98e0a35d5b42c055a449cce387b9108c
| 747
|
cpp
|
C++
|
ECE551-cpp/005_read2/test.cpp
|
yo1995/cht_Duke_courses
|
d889e85e677f419c67c12e78143f3e8143457944
|
[
"MIT"
] | 8
|
2019-03-28T18:37:32.000Z
|
2022-03-29T22:15:05.000Z
|
ECE551-cpp/005_read2/test.cpp
|
yo1995/cht_Duke_courses
|
d889e85e677f419c67c12e78143f3e8143457944
|
[
"MIT"
] | null | null | null |
ECE551-cpp/005_read2/test.cpp
|
yo1995/cht_Duke_courses
|
d889e85e677f419c67c12e78143f3e8143457944
|
[
"MIT"
] | 13
|
2018-09-12T19:56:46.000Z
|
2020-11-24T22:48:46.000Z
|
#include<stdio.h>
int anotherFunction(int a, int b) {
int answer = 42;
int x = 0;
printf("In anotherFunction(%d,%d)\n",a,b);
while (b > a) {
printf("a is %d, b is %d\n", a, b);
answer = answer + (b - a);
b -= x;
a += x / 2;
x++;
}
return answer;
}
int someFunction(int x, int y) {
int a = x + y;
if (x < y) {
for (int i = 0; i < x; i++) {
printf("In the loop with i = %d, a = %d\n", i, a);
a = a + x;
}
}
else {
y = anotherFunction(y,a+4);
}
return a * y;
}
int main(void) {
int x = 2;
int a = someFunction(x,3);
printf("a = %d\n", a);
printf("x = %d\n", x);
int b = someFunction(3,x);
printf("b = %d\n", b);
printf("x = %d\n", x);
return 0;
}
//end of code
| 16.977273
| 56
| 0.46988
|
yo1995
|
f5724329d3de88907fdafdec3919176b6b5cf6d7
| 3,211
|
cpp
|
C++
|
test/WdtMiscTests.cpp
|
davide125/wdt
|
aaec2a1f235a2257e0ca100032aa55df9ad5cc08
|
[
"BSD-3-Clause"
] | 2,894
|
2015-07-21T17:14:23.000Z
|
2022-03-30T15:48:29.000Z
|
test/WdtMiscTests.cpp
|
davide125/wdt
|
aaec2a1f235a2257e0ca100032aa55df9ad5cc08
|
[
"BSD-3-Clause"
] | 202
|
2015-07-21T23:27:02.000Z
|
2022-03-07T22:46:39.000Z
|
test/WdtMiscTests.cpp
|
davide125/wdt
|
aaec2a1f235a2257e0ca100032aa55df9ad5cc08
|
[
"BSD-3-Clause"
] | 493
|
2015-07-21T17:28:47.000Z
|
2022-03-04T18:53:46.000Z
|
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <wdt/Wdt.h>
#include <wdt/test/TestCommon.h>
#include <thread>
using namespace std;
namespace facebook {
namespace wdt {
TEST(BasicTest, ReceiverAcceptTimeout) {
Wdt &wdt = Wdt::initializeWdt("unit test ReceiverAcceptTimeout");
WdtOptions &opts = wdt.getWdtOptions();
opts.accept_timeout_millis = 1;
opts.max_accept_retries = 1;
opts.max_retries = 1;
WdtTransferRequest req(0, 2, "/tmp/wdtTest");
req.wdtNamespace = "foo";
EXPECT_EQ(OK, wdt.wdtReceiveStart("foo", req));
EXPECT_EQ(CONN_ERROR, wdt.wdtReceiveFinish("foo"));
// Receiver object is still alive but has given up - we should not be able
// to connect:
req.directory = "/bin";
EXPECT_EQ(CONN_ERROR, wdt.wdtSend(req));
}
TEST(BasicTest, MultiWdtSender) {
TemporaryDirectory tmpDir;
auto baseDir = tmpDir.dir();
LOG(INFO) << "Testing in " << baseDir;
string srcDir = baseDir + "/src";
string srcFile = "file1";
string targetDir = baseDir + "/dst";
string srcFileFullPath = srcDir + "/" + srcFile;
Wdt &wdt = Wdt::initializeWdt("unit test MultiWdtSender");
WdtOptions &options = wdt.getWdtOptions();
options.avg_mbytes_per_sec = 100;
WdtTransferRequest req(/* start port */ 0,
/* num ports */ 1, targetDir);
req.wdtNamespace = "foo";
mkdir(srcDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
{
// Create 400mb srcFile
const int32_t size = 1024 * 1024;
uint a[size];
FILE *pFile;
pFile = fopen(srcFileFullPath.c_str(), "wb");
for (int i = 0; i < 100; ++i) {
fwrite(a, 1, sizeof(a), pFile);
}
fclose(pFile);
}
EXPECT_EQ(OK, wdt.wdtReceiveStart("foo", req));
req.directory = string(srcDir);
auto sender1Thread = thread(
[&wdt, &req]() { EXPECT_EQ(OK, wdt.wdtSend(req, nullptr, true)); });
auto sender2Thread = thread([&wdt, &req]() {
/* sleep override */
std::this_thread::sleep_for(std::chrono::seconds(1));
EXPECT_EQ(ALREADY_EXISTS, wdt.wdtSend(req, nullptr, true));
});
sender1Thread.join();
sender2Thread.join();
EXPECT_EQ(OK, wdt.wdtReceiveFinish("foo"));
}
TEST(BasicTest, ThrottlerWithoutReporting) {
WdtOptions options;
options.avg_mbytes_per_sec = 1;
shared_ptr<Throttler> throttler =
std::make_shared<Throttler>(options.getThrottlerOptions());
const int toWrite = 2 * kMbToB;
const int blockSize = 1024;
int written = 0;
throttler->startTransfer();
const auto startTime = Clock::now();
while (written < toWrite) {
throttler->limit(blockSize);
written += blockSize;
}
const auto endTime = Clock::now();
throttler->endTransfer();
int durationMs = durationMillis(endTime - startTime);
EXPECT_GT(durationMs, 1900);
EXPECT_LT(durationMs, 2200);
}
}
} // namespace end
int main(int argc, char *argv[]) {
FLAGS_logtostderr = true;
testing::InitGoogleTest(&argc, argv);
GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
google::InitGoogleLogging(argv[0]);
int ret = RUN_ALL_TESTS();
return ret;
}
| 29.458716
| 76
| 0.676425
|
davide125
|
f5730831935cf3f3201474cd1687c8667f892079
| 27,817
|
cpp
|
C++
|
pnwtl/controls/pntabcontrol.cpp
|
Adept-Space/pn
|
d722f408cf3c3b8d0b8028846c0199969b6a103c
|
[
"BSD-3-Clause"
] | null | null | null |
pnwtl/controls/pntabcontrol.cpp
|
Adept-Space/pn
|
d722f408cf3c3b8d0b8028846c0199969b6a103c
|
[
"BSD-3-Clause"
] | null | null | null |
pnwtl/controls/pntabcontrol.cpp
|
Adept-Space/pn
|
d722f408cf3c3b8d0b8028846c0199969b6a103c
|
[
"BSD-3-Clause"
] | null | null | null |
/**
* @file pntabcontrol.cpp
* @brief Tab Control for PN
* @author Simon Steele
* @note Copyright (c) 2010 Simon Steele - http://untidy.net/
*
* Based on the CustomTabControl and modified from the VS tabs implementation there
* with the intent of creating a cleaner look.
*
* Programmer's Notepad 2 : The license file (license.[txt|html]) describes
* the conditions under which this source may be modified / distributed.
*/
#include "stdafx.h"
#include "pntabcontrol.h"
////////////////////////////////////////////////////////////////////////////////
// PN Customised Drawing for Tab Control
LRESULT CPNTabControl::OnSettingChange(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
DWORD dwStyle = this->GetStyle();
// Initialize/Reinitialize font
// Visual Studio.Net seems to use the "icon" font for the tabs
LOGFONT lfIcon = { 0 };
::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lfIcon), &lfIcon, 0);
bool bResetFont = true;
if(!m_font.IsNull())
{
LOGFONT lf = {0};
if(m_font.GetLogFont(&lf))
{
if(lstrcmpi(lf.lfFaceName, lfIcon.lfFaceName) == 0 &&
lf.lfHeight == lfIcon.lfHeight)
{
bResetFont = false;
}
}
}
if(bResetFont)
{
if(!m_font.IsNull()) m_font.DeleteObject();
if(!m_fontSel.IsNull()) m_fontSel.DeleteObject();
HFONT font = m_font.CreateFontIndirect(&lfIcon);
if(font==NULL)
{
m_font.Attach(AtlGetDefaultGuiFont());
}
if(CTCS_BOLDSELECTEDTAB == (dwStyle & CTCS_BOLDSELECTEDTAB))
{
lfIcon.lfWeight = FW_BOLD;
}
font = m_fontSel.CreateFontIndirect(&lfIcon);
if(font==NULL)
{
m_fontSel.Attach(AtlGetDefaultGuiFont());
}
}
// Background brush
if(!m_hbrBackground.IsNull()) m_hbrBackground.DeleteObject();
m_hbrBackground.CreateSysColorBrush(COLOR_BTNFACE);
m_clrTextInactiveTab = ::GetSysColor(COLOR_BTNTEXT);
m_clrSelectedTab = ::GetSysColor(COLOR_WINDOW);
m_settings.iIndent = 5;
m_settings.iPadding = 4;
m_settings.iMargin = 3;
m_settings.iSelMargin = 3;
int nHeightLogicalUnits = -lfIcon.lfHeight;
// In MSDN for "LOGFONT", they give the following formula for calculating
// the log font height given a point size.
//long lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
const int nNominalFontLogicalUnits = 11; // 8 point Tahoma with 96 DPI
m_nFontSizeTextTopOffset = (BYTE)((nHeightLogicalUnits - nNominalFontLogicalUnits) / 2);
UpdateLayout();
Invalidate();
return 0;
}
void CPNTabControl::DrawBackground(RECT rcClient, LPNMCTCCUSTOMDRAW lpNMCustomDraw)
{
WTL::CDCHandle dc( lpNMCustomDraw->nmcd.hdc );
// Set up the text color and background mode
dc.SetTextColor(lpNMCustomDraw->clrBtnText);
dc.SetBkMode(TRANSPARENT);
RECT rcClip = {0};
dc.GetClipBox(&rcClip);
if(::EqualRect(&rcClip, &m_rcCloseButton) ||
::EqualRect(&rcClip, &m_rcScrollRight) ||
::EqualRect(&rcClip, &m_rcScrollLeft))
{
// Paint needed in only "other button" area
HBRUSH hOldBrush = dc.SelectBrush(lpNMCustomDraw->hBrushBackground);
dc.PatBlt(rcClip.left, rcClip.top, rcClip.right-rcClip.left, rcClip.bottom-rcClip.top, PATCOPY);
dc.SelectBrush(hOldBrush);
}
else
{
// Paint needed in tab item area or more
// Erase Background
// (do it here instead of a handler for WM_ERASEBKGND
// so that we can do flicker-free drawing with the help
// of COffscreenDrawRect that's in the base class)
// TODO: Don't "erase" entire client area.
// Do a smarter erase of just what needs it
RECT rc = rcClient;
HBRUSH hOldBrush = dc.SelectBrush(lpNMCustomDraw->hBrushBackground);
dc.PatBlt(rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, PATCOPY);
dc.SelectBrush(hOldBrush);
// Connect with the client area.
DWORD dwStyle = this->GetStyle();
if(CTCS_BOTTOM == (dwStyle & CTCS_BOTTOM))
{
rc.bottom = rc.top;
dc.FillSolidRect(&rc, lpNMCustomDraw->clrBtnFace);
CPen penText;
penText.CreatePen(PS_SOLID, 1, lpNMCustomDraw->clrBtnHighlight);
CPenHandle penOld = dc.SelectPen(penText);
dc.MoveTo(rc.left, rc.bottom);
dc.LineTo(rc.right, rc.bottom);
dc.SelectPen(penOld);
}
else
{
int nOrigTop = rc.top;
rc.top = rc.bottom - 2;
dc.FillSolidRect(&rc, lpNMCustomDraw->clrBtnFace);
CPen penHilight;
penHilight.CreatePen(PS_SOLID, 1, lpNMCustomDraw->clrBtnHighlight);
CPenHandle penOld = dc.SelectPen(penHilight);
dc.MoveTo(rc.left, rc.top-1);
dc.LineTo(rc.right, rc.top-1);
rc.top = nOrigTop;
CPen penShadow, pen3D;
penShadow.CreatePen(PS_SOLID, 1, lpNMCustomDraw->clrBtnShadow);
pen3D.CreatePen(PS_SOLID, 1, lpNMCustomDraw->clrBtnFace);
dc.SelectPen(penShadow);
dc.MoveTo(rc.left, rc.bottom);
dc.LineTo(rc.left, rc.top);
dc.LineTo(rc.right-1, rc.top);
if(0 == (dwStyle & CTCS_FLATEDGE))
{
dc.SelectPen(penHilight);
}
dc.LineTo(rc.right-1, rc.bottom);
dc.SelectPen(pen3D);
dc.MoveTo(rc.right-2, rc.bottom-3);
dc.LineTo(rc.right-2, rc.top);
dc.MoveTo(rc.left+1, rc.bottom-3);
dc.LineTo(rc.left+1, rc.top);
dc.SelectPen(penOld);
}
}
}
void CPNTabControl::DrawItem_InitBounds(DWORD dwStyle, RECT rcItem, RECT& rcTab, RECT& rcText, int& nIconVerticalCenter)
{
if(CTCS_BOTTOM == (dwStyle & CTCS_BOTTOM))
{
rcTab.top += 1;
rcTab.bottom -= 2;
rcText.top = rcTab.top + m_nFontSizeTextTopOffset;
rcText.bottom = rcItem.bottom;
//nIconVerticalCenter = rcTab.top + (rc.bottom - rcTab.top) / 2;
//nIconVerticalCenter = rcTab.top + rcText.Height() / 2;
nIconVerticalCenter = (rcItem.bottom + rcItem.top) / 2 + rcTab.top / 2;
}
else
{
rcTab.top += 1;
rcTab.bottom -= 2;
rcText.top = rcItem.top + m_nFontSizeTextTopOffset;
rcText.bottom = rcItem.bottom;
nIconVerticalCenter = (rcItem.bottom + rcItem.top) / 2 + rcTab.top / 2;
}
}
void CPNTabControl::DrawItem_TabSelected(DWORD dwStyle, LPNMCTCCUSTOMDRAW lpNMCustomDraw, RECT& rcTab)
{
// Tab is selected, so paint tab folder
bool bHighlighted = (CDIS_MARKED == (lpNMCustomDraw->nmcd.uItemState & CDIS_MARKED));
WTL::CDCHandle dc(lpNMCustomDraw->nmcd.hdc);
rcTab.right--;
if(bHighlighted)
{
dc.FillSolidRect(&rcTab, lpNMCustomDraw->clrHighlight);
}
else
{
dc.FillSolidRect(&rcTab, lpNMCustomDraw->clrSelectedTab);
}
WTL::CPen penText, penHilight, penShadow;
penText.CreatePen(PS_SOLID, 1, lpNMCustomDraw->clrBtnText);
penHilight.CreatePen(PS_SOLID, 1, lpNMCustomDraw->clrBtnHighlight);
penShadow.CreatePen(PS_SOLID, 1, lpNMCustomDraw->clrBtnShadow);
if(CTCS_BOTTOM == (dwStyle & CTCS_BOTTOM))
{
WTL::CPenHandle penOld = dc.SelectPen(penHilight);
//dc.MoveTo(rcTab.right, rcTab.top);
dc.MoveTo(rcTab.right, rcTab.bottom);
dc.LineTo(rcTab.left, rcTab.bottom);
dc.SelectPen(penShadow);
dc.MoveTo(rcTab.right-1, rcTab.top);
dc.LineTo(rcTab.right-1, rcTab.bottom - 1);
dc.SelectPen(penOld);
}
else
{
WTL::CPenHandle penOld = dc.SelectPen(penHilight);
dc.MoveTo(rcTab.left, rcTab.bottom-1);
dc.LineTo(rcTab.left, rcTab.top);
dc.LineTo(rcTab.right, rcTab.top);
dc.SelectPen(penShadow);
//dc.LineTo(rcTab.right, rcTab.bottom);
dc.MoveTo(rcTab.right-1, rcTab.top);
dc.LineTo(rcTab.right-1, rcTab.bottom - 2);
dc.SelectPen(penOld);
}
}
void CPNTabControl::DrawItem_TabInactive(DWORD dwStyle, LPNMCTCCUSTOMDRAW lpNMCustomDraw, RECT& rcTab)
{
// Tab is not selected
bool bHighlighted = (CDIS_MARKED == (lpNMCustomDraw->nmcd.uItemState & CDIS_MARKED));
int nItem = (int)lpNMCustomDraw->nmcd.dwItemSpec;
WTL::CDCHandle dc( lpNMCustomDraw->nmcd.hdc );
if(bHighlighted)
{
if(CTCS_BOTTOM == (dwStyle & CTCS_BOTTOM))
{
RECT rcHighlight = {rcTab.left+1, rcTab.top+3, rcTab.right-2, rcTab.bottom-1};
if(nItem - 1 == m_iCurSel) rcHighlight.left += 1; // Item to the right of the selected tab
dc.FillSolidRect(&rcHighlight, lpNMCustomDraw->clrHighlight);
}
else
{
RECT rcHighlight = {rcTab.left+1, rcTab.top+2, rcTab.right-2, rcTab.bottom-2};
if(nItem - 1 == m_iCurSel) rcHighlight.left += 1; // Item to the right of the selected tab
dc.FillSolidRect(&rcHighlight, lpNMCustomDraw->clrHighlight);
}
}
WTL::CPen pen;
pen.CreatePen(PS_SOLID, 1, lpNMCustomDraw->clrBtnShadow);
WTL::CPenHandle penOld = dc.SelectPen(pen);
if(CTCS_BOTTOM == (dwStyle & CTCS_BOTTOM))
{
// Important! Be sure and keep within "our" tab area horizontally
dc.MoveTo(rcTab.right-1, rcTab.top);
dc.LineTo(rcTab.right-1, rcTab.bottom - 1);
}
else
{
// Important! Be sure and keep within "our" tab area horizontally
dc.MoveTo(rcTab.right-1, rcTab.top);
dc.LineTo(rcTab.right-1, rcTab.bottom - 2);
}
dc.SelectPen(penOld);
}
void CPNTabControl::DrawItem_ImageAndText(DWORD /*dwStyle*/, LPNMCTCCUSTOMDRAW lpNMCustomDraw, int nIconVerticalCenter, RECT& rcTab, RECT& rcText)
{
WTL::CDCHandle dc( lpNMCustomDraw->nmcd.hdc );
bool bHighlighted = (CDIS_MARKED == (lpNMCustomDraw->nmcd.uItemState & CDIS_MARKED));
bool bSelected = (CDIS_SELECTED == (lpNMCustomDraw->nmcd.uItemState & CDIS_SELECTED));
bool bHot = (CDIS_HOT == (lpNMCustomDraw->nmcd.uItemState & CDIS_HOT));
int nItem = (int)lpNMCustomDraw->nmcd.dwItemSpec;
CTabViewTabItem* pItem = this->GetItem(nItem);
HFONT hOldFont = dc.SelectFont(lpNMCustomDraw->hFontInactive);
COLORREF crPrevious = 0;
if(bHighlighted)
{
crPrevious = dc.SetTextColor(lpNMCustomDraw->clrHighlightText);
}
else if(bHot)
{
crPrevious = dc.SetTextColor(lpNMCustomDraw->clrHighlightHotTrack);
}
else if(bSelected)
{
crPrevious = dc.SetTextColor(lpNMCustomDraw->clrTextSelected);
}
else
{
crPrevious = dc.SetTextColor(lpNMCustomDraw->clrTextInactive);
}
//--------------------------------------------
// This is how CDotNetTabCtrlImpl interprets padding, margin, etc.:
//
// M - Margin
// P - Padding
// I - Image
// Text - Tab Text
//
// With image:
// __________________________
//
// | M | I | P | Text | P | M |
// --------------------------
//
// Without image:
// ______________________
//
// | M | P | Text | P | M |
// ----------------------
//rcText.left += (bSelected ? m_settings.iSelMargin : m_settings.iMargin);
rcText.left += m_settings.iMargin;
rcText.right -= m_settings.iMargin;
if (pItem->UsingImage() && !m_imageList.IsNull())
{
// Draw the image.
IMAGEINFO ii = {0};
int nImageIndex = pItem->GetImageIndex();
m_imageList.GetImageInfo(nImageIndex, &ii);
if((ii.rcImage.right - ii.rcImage.left) < (rcTab.right - rcTab.left))
{
int nImageHalfHeight = (ii.rcImage.bottom - ii.rcImage.top) / 2;
m_imageList.Draw(dc, nImageIndex, rcText.left, nIconVerticalCenter - nImageHalfHeight + m_nFontSizeTextTopOffset, ILD_NORMAL);
}
// Offset on the right of the image.
rcText.left += (ii.rcImage.right - ii.rcImage.left);
}
if (rcText.left + m_nMinWidthToDisplayText < rcText.right)
{
::InflateRect(&rcText, -m_settings.iPadding, 0);
_CSTRING_NS::CString sText = pItem->GetText();
dc.DrawText(sText, sText.GetLength(), &rcText, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_PATH_ELLIPSIS | DT_NOPREFIX);
}
dc.SetTextColor(crPrevious);
dc.SelectFont(hOldFont);
}
void CPNTabControl::DrawCloseButton(LPNMCTCCUSTOMDRAW lpNMCustomDraw)
{
WTL::CDCHandle dc( lpNMCustomDraw->nmcd.hdc );
WTL::CPen penButtons;
penButtons.CreatePen(PS_SOLID, 1, lpNMCustomDraw->clrTextInactive);
WTL::CBrush brushArrow;
brushArrow.CreateSolidBrush(lpNMCustomDraw->clrTextInactive);
WTL::CPenHandle penOld = dc.SelectPen(penButtons);
WTL::CBrushHandle brushOld = dc.SelectBrush(brushArrow);
RECT rcX = m_rcCloseButton;
if(ectcMouseDownL_CloseButton == (m_dwState & ectcMouseDown))
{
if(ectcMouseOver_CloseButton == (m_dwState & ectcMouseOver))
{
::OffsetRect(&rcX, 1, 1);
}
}
const int sp = 4;
dc.MoveTo(rcX.left+sp+ -1, rcX.top+sp);
dc.LineTo(rcX.right-sp -1, rcX.bottom-sp);
dc.MoveTo(rcX.left+sp, rcX.top+sp);
dc.LineTo(rcX.right-sp, rcX.bottom-sp);
dc.MoveTo(rcX.left+sp -1, rcX.bottom-sp -1);
dc.LineTo(rcX.right-sp -1, rcX.top+sp -1 );
dc.MoveTo(rcX.left+sp, rcX.bottom-sp -1);
dc.LineTo(rcX.right-sp, rcX.top+sp -1);
if(ectcMouseDownL_CloseButton == (m_dwState & ectcMouseDown))
{
if(ectcMouseOver_CloseButton == (m_dwState & ectcMouseOver))
{
dc.DrawEdge(&m_rcCloseButton, BDR_SUNKENOUTER, BF_RECT);
}
}
else if(ectcHotTrack_CloseButton == (m_dwState & ectcHotTrack))
{
dc.DrawEdge(&m_rcCloseButton, BDR_RAISEDINNER, BF_RECT);
}
dc.SelectBrush(brushOld);
dc.SelectPen(penOld);
}
void CPNTabControl::DrawScrollButtons(LPNMCTCCUSTOMDRAW lpNMCustomDraw)
{
WTL::CDCHandle dc( lpNMCustomDraw->nmcd.hdc );
WTL::CPen penButtons;
penButtons.CreatePen(PS_SOLID, 1, lpNMCustomDraw->clrTextInactive);
WTL::CBrush brushArrow;
brushArrow.CreateSolidBrush(lpNMCustomDraw->clrTextInactive);
WTL::CPenHandle penOld = dc.SelectPen(penButtons);
WTL::CBrushHandle brushOld = dc.SelectBrush(brushArrow);
RECT rcArrowRight = m_rcScrollRight;
RECT rcArrowLeft = m_rcScrollLeft;
if(ectcMouseDownL_ScrollRight == (m_dwState & ectcMouseDown))
{
if(ectcMouseOver_ScrollRight == (m_dwState & ectcMouseOver))
{
if(ectcOverflowRight == (m_dwState & ectcOverflowRight))
{
::OffsetRect(&rcArrowRight, 1, 1);
}
}
}
if(ectcMouseDownL_ScrollLeft == (m_dwState & ectcMouseDown))
{
if(ectcMouseOver_ScrollLeft == (m_dwState & ectcMouseOver))
{
if(ectcOverflowLeft == (m_dwState & ectcOverflowLeft))
{
::OffsetRect(&rcArrowLeft, 1, 1);
}
}
}
const int spRight = 5;
const int spLeft = 6;
POINT ptsArrowRight[] = {
{rcArrowRight.left+spRight, rcArrowRight.top+spRight -2},
{rcArrowRight.left+spRight, rcArrowRight.bottom-spRight +1},
{rcArrowRight.right-spRight -1, (rcArrowRight.bottom + m_rcScrollRight.top) / 2},
{rcArrowRight.left+spRight, rcArrowRight.top+spRight -2}
};
if(ectcOverflowRight != (m_dwState & ectcOverflowRight))
{
dc.Polyline(ptsArrowRight, 4);
}
else
{
dc.Polygon(ptsArrowRight, 4);
if(ectcMouseDownL_ScrollRight == (m_dwState & ectcMouseDown))
{
if(ectcMouseOver_ScrollRight == (m_dwState & ectcMouseOver))
{
dc.DrawEdge(&m_rcScrollRight, BDR_SUNKENOUTER, BF_RECT);
}
}
else if(ectcHotTrack_ScrollRight == (m_dwState & ectcHotTrack))
{
dc.DrawEdge(&m_rcScrollRight, BDR_RAISEDINNER, BF_RECT);
}
}
POINT ptsArrowLeft[] = {
{rcArrowLeft.right-spLeft, rcArrowLeft.top+spLeft -3},
{rcArrowLeft.right-spLeft, rcArrowLeft.bottom-spLeft +2},
{rcArrowLeft.left+spLeft -1, (rcArrowLeft.bottom + m_rcScrollLeft.top) / 2},
{rcArrowLeft.right-spLeft, rcArrowLeft.top+spLeft -3}
};
if(ectcOverflowLeft != (m_dwState & ectcOverflowLeft))
{
dc.Polyline(ptsArrowLeft, 4);
}
else
{
dc.Polygon(ptsArrowLeft, 4);
if(ectcMouseDownL_ScrollLeft == (m_dwState & ectcMouseDown))
{
if(ectcMouseOver_ScrollLeft == (m_dwState & ectcMouseOver))
{
dc.DrawEdge(&m_rcScrollLeft, BDR_SUNKENOUTER, BF_RECT);
}
}
else if(ectcHotTrack_ScrollLeft == (m_dwState & ectcHotTrack))
{
dc.DrawEdge(&m_rcScrollLeft, BDR_RAISEDINNER, BF_RECT);
}
}
dc.SelectBrush(brushOld);
dc.SelectPen(penOld);
}
void CPNTabControl::InitializeDrawStruct(LPNMCTCCUSTOMDRAW lpNMCustomDraw)
{
//DWORD dwStyle = this->GetStyle();
lpNMCustomDraw->hFontInactive = m_font;
lpNMCustomDraw->hFontSelected = m_fontSel;
lpNMCustomDraw->hBrushBackground = m_hbrBackground;
lpNMCustomDraw->clrTextSelected = ::GetSysColor(COLOR_BTNTEXT);
lpNMCustomDraw->clrTextInactive = ::GetSysColor(COLOR_BTNTEXT);
lpNMCustomDraw->clrSelectedTab = m_clrSelectedTab;
lpNMCustomDraw->clrBtnFace = ::GetSysColor(COLOR_BTNFACE);
lpNMCustomDraw->clrBtnShadow = ::GetSysColor(COLOR_BTNSHADOW);
lpNMCustomDraw->clrBtnHighlight = ::GetSysColor(COLOR_BTNHIGHLIGHT);
lpNMCustomDraw->clrBtnText = ::GetSysColor(COLOR_BTNTEXT);
lpNMCustomDraw->clrHighlight = ::GetSysColor(COLOR_HIGHLIGHT);
#if WINVER >= 0x0500 || _WIN32_WINNT >= 0x0500
lpNMCustomDraw->clrHighlightHotTrack = ::GetSysColor(COLOR_HOTLIGHT);
#else
lpNMCustomDraw->clrHighlightHotTrack = ::GetSysColor(COLOR_HIGHLIGHT);
#endif
lpNMCustomDraw->clrHighlightText = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
}
void CPNTabControl::DoPrePaint(RECT rcClient, LPNMCTCCUSTOMDRAW lpNMCustomDraw)
{
DrawBackground(rcClient, lpNMCustomDraw);
}
void CPNTabControl::DoItemPaint(LPNMCTCCUSTOMDRAW lpNMCustomDraw)
{
bool bSelected = (CDIS_SELECTED == (lpNMCustomDraw->nmcd.uItemState & CDIS_SELECTED));
// NOTE: lpNMCustomDraw->nmcd.rc is in logical coordinates
RECT &rcItem = lpNMCustomDraw->nmcd.rc;
DWORD dwStyle = GetStyle();
RECT rcTab = rcItem;
RECT rcText = rcItem;
int nIconVerticalCenter = 0;
DrawItem_InitBounds(dwStyle, rcItem, rcTab, rcText, nIconVerticalCenter);
if(bSelected)
{
DrawItem_TabSelected(dwStyle, lpNMCustomDraw, rcTab);
}
else
{
DrawItem_TabInactive(dwStyle, lpNMCustomDraw, rcTab);
}
DrawItem_ImageAndText(dwStyle, lpNMCustomDraw, nIconVerticalCenter, rcTab, rcText);
}
void CPNTabControl::DoPostPaint(RECT /*rcClient*/, LPNMCTCCUSTOMDRAW lpNMCustomDraw)
{
DWORD dwStyle = this->GetStyle();
if(0 == (dwStyle & (CTCS_CLOSEBUTTON | CTCS_SCROLL)))
{
return;
}
// Close Button
if(CTCS_CLOSEBUTTON == (dwStyle & CTCS_CLOSEBUTTON))
{
if( (m_iCurSel >= 0) && ((size_t)m_iCurSel < m_Items.GetCount()) )
{
TItem* pItem = m_Items[m_iCurSel];
ATLASSERT(pItem != NULL);
if((pItem != NULL) && pItem->CanClose())
{
DrawCloseButton(lpNMCustomDraw);
}
}
}
// Scroll Buttons
if(CTCS_SCROLL == (dwStyle & CTCS_SCROLL))
{
DrawScrollButtons(lpNMCustomDraw);
}
}
void CPNTabControl::CalcSize_NonClient(LPRECT prcTabItemArea)
{
// account for "non-client" areas
// TODO: For the short term, we will use this
// for the non-client areas on the left and right.
// The drawing code for the tabs already accounts
// for the "non-client" areas on the top and bottom, and
// would need to be updated if we account for it here.
// Tab item rect methods also would need to be
// updated to account for the non-client areas
// on top and bottom (and effected drawing code
// would need to be updated).
DWORD dwStyle = this->GetStyle();
if(CTCS_BOTTOM == (dwStyle & CTCS_BOTTOM))
{
// TODO: Update to actually specify the
// non-client areas, and adjust all of the
// effected drawing code, as well as
// tab item rect related things
//prcTabItemArea->top += 3;
}
else
{
//prcTabItemArea->left += 2;
//prcTabItemArea->right -= 2;
// TODO: Update to actually specify the top and bottom
// non-client areas, and adjust all of the
// effected drawing code, as well as
// tab item rect related things
//prcTabItemArea->top += 1;
//// We would have bottom as 3, but we want the
//// selected tab to actually paint over highlight part
//prcTabItemArea->bottom -= 2;
}
}
void CPNTabControl::CalcSize_CloseButton(LPRECT prcTabItemArea)
{
//int nButtonSizeX = ::GetSystemMetrics(SM_CXSMSIZE);
//int nButtonSizeY = ::GetSystemMetrics(SM_CYSMSIZE);
// NOTE: After several tests, VS.Net does NOT depend on
// any system metric for the button size, so neither will we.
int nButtonSizeX = 15;
int nButtonSizeY = 15;
if((prcTabItemArea->right - prcTabItemArea->left) < nButtonSizeX)
{
::SetRectEmpty(&m_rcCloseButton);
return;
}
m_rcCloseButton = *prcTabItemArea;
DWORD dwStyle = GetStyle();
if (CTCS_BOTTOM == (dwStyle & CTCS_BOTTOM))
{
m_rcCloseButton.top += 3;
m_rcCloseButton.right -= 3;
}
else
{
m_rcCloseButton.top += 1;
m_rcCloseButton.bottom -= 2;
m_rcCloseButton.right -= 2;
}
m_rcCloseButton.top = (m_rcCloseButton.bottom + m_rcCloseButton.top - nButtonSizeY) / 2;
m_rcCloseButton.bottom = m_rcCloseButton.top + nButtonSizeY;
m_rcCloseButton.left = m_rcCloseButton.right - (nButtonSizeX);
if(m_tooltip.IsWindow())
{
m_tooltip.SetToolRect(m_hWnd, (UINT)ectcToolTip_Close, &m_rcCloseButton);
}
// Adjust the tab area
prcTabItemArea->right = m_rcCloseButton.left;
}
void CPNTabControl::CalcSize_ScrollButtons(LPRECT prcTabItemArea)
{
//int nButtonSizeX = ::GetSystemMetrics(SM_CXSMSIZE);
//int nButtonSizeY = ::GetSystemMetrics(SM_CYSMSIZE);
// NOTE: After several tests, VS.Net does NOT depend on
// any system metric for the button size, so neither will we.
int nButtonSizeX = 15;
int nButtonSizeY = 15;
if((prcTabItemArea->right - prcTabItemArea->left) < nButtonSizeX)
{
::SetRectEmpty(&m_rcScrollRight);
::SetRectEmpty(&m_rcScrollLeft);
return;
}
RECT rcScroll = *prcTabItemArea;
DWORD dwStyle = GetStyle();
if (CTCS_BOTTOM == (dwStyle & CTCS_BOTTOM))
{
rcScroll.top += 3;
if(0 == (dwStyle & CTCS_CLOSEBUTTON))
{
rcScroll.right -= 3;
}
}
else
{
rcScroll.top += 1;
rcScroll.bottom -= 2;
if(0 == (dwStyle & CTCS_CLOSEBUTTON))
{
rcScroll.right -= 2;
}
}
rcScroll.top = (rcScroll.bottom + rcScroll.top - nButtonSizeY) / 2;
rcScroll.bottom = rcScroll.top + nButtonSizeY;
m_rcScrollRight = rcScroll;
m_rcScrollLeft = rcScroll;
m_rcScrollRight.left = m_rcScrollRight.right - nButtonSizeX;
m_rcScrollLeft.right = m_rcScrollRight.left;
m_rcScrollLeft.left = m_rcScrollLeft.right - nButtonSizeX;
if(m_tooltip.IsWindow())
{
m_tooltip.SetToolRect(m_hWnd, (UINT)ectcToolTip_ScrollRight, &m_rcScrollRight);
m_tooltip.SetToolRect(m_hWnd, (UINT)ectcToolTip_ScrollLeft, &m_rcScrollLeft);
}
// Adjust the tab area
prcTabItemArea->right = m_rcScrollLeft.left;
}
void CPNTabControl::UpdateLayout_Default(RECT rcTabItemArea)
{
long nMinInactiveWidth = 0x7FFFFFFF;
long nMaxInactiveWidth = 0;
//DWORD dwStyle = this->GetStyle();
WTL::CClientDC dc(m_hWnd);
//HFONT hOldFont = dc.SelectFont(lpNMCustomDraw->hFontInactive);
HFONT hOldFont = dc.SelectFont(m_font);
LONG nTabAreaWidth = (rcTabItemArea.right - rcTabItemArea.left);
RECT rcItem = rcTabItemArea;
// rcItem.top and rcItem.bottom aren't really going to change
// Recalculate tab positions and widths
// See DrawItem_ImageAndText for a discussion of how CDotNetTabCtrlImpl
// interprets margin, padding, etc.
size_t nCount = m_Items.GetCount();
int xpos = 0;
HFONT hRestoreNormalFont = NULL;
for( size_t i=0; i<nCount; ++i )
{
bool bSelected = ((int)i == m_iCurSel);
TItem* pItem = m_Items[i];
ATLASSERT(pItem != NULL);
rcItem.left = rcItem.right = xpos;
//rcItem.right += ((bSelected ? m_settings.iSelMargin : m_settings.iMargin));
rcItem.right += m_settings.iMargin;
if(pItem->UsingImage() && !m_imageList.IsNull())
{
IMAGEINFO ii = {0};
int nImageIndex = pItem->GetImageIndex();
m_imageList.GetImageInfo(nImageIndex, &ii);
rcItem.right += (ii.rcImage.right - ii.rcImage.left);
}
if(pItem->UsingText())
{
RECT rcText = {0};
_CSTRING_NS::CString sText = pItem->GetText();
dc.DrawText(sText, sText.GetLength(), &rcText, DT_SINGLELINE | DT_CALCRECT | DT_NOPREFIX);
rcItem.right += (rcText.right - rcText.left) + (m_settings.iPadding * 2);
}
rcItem.right += m_settings.iMargin;
pItem->SetRect(rcItem);
xpos += (rcItem.right - rcItem.left);
if(hRestoreNormalFont != NULL)
{
dc.SelectFont(hRestoreNormalFont);
hRestoreNormalFont = NULL;
}
if(!bSelected)
{
if((rcItem.right - rcItem.left) < nMinInactiveWidth)
{
nMinInactiveWidth = (rcItem.right - rcItem.left);
}
if((rcItem.right - rcItem.left) > nMaxInactiveWidth)
{
nMaxInactiveWidth = (rcItem.right - rcItem.left);
}
}
}
xpos += m_settings.iIndent;
if(xpos > nTabAreaWidth && nCount > 0 && m_iCurSel >= 0)
{
// Our desired widths are more than the width of the client area.
// We need to have some or all of the tabs give up some real estate
// We'll try to let the selected tab have its fully desired width.
// If it can't, we'll make all the tabs the same width.
RECT rcSelected = m_Items[m_iCurSel]->GetRect();
LONG nSelectedWidth = (rcSelected.right - rcSelected.left);
long cxClientInactiveTabs = nTabAreaWidth - (m_settings.iIndent * 2) - nSelectedWidth;
long cxDesiredInactiveTabs = xpos - (m_settings.iIndent * 2) - nSelectedWidth;
double nRatioWithSelectionFullSize = 0.0;
if(cxDesiredInactiveTabs != 0)
{
nRatioWithSelectionFullSize = (double) (cxClientInactiveTabs) / (double)(cxDesiredInactiveTabs);
}
long nInactiveSameSizeWidth = (m_nMinWidthToDisplayText + (m_settings.iMargin*2) + (m_settings.iPadding));
if(cxClientInactiveTabs > (nInactiveSameSizeWidth * (long)(nCount-1)))
{
// There should be enough room to display the entire contents of
// the selected tab plus something for the inactive tabs
bool bMakeInactiveSameSize = ((nMinInactiveWidth * nRatioWithSelectionFullSize) < nInactiveSameSizeWidth);
xpos = m_settings.iIndent;
for(size_t i=0; i<nCount; ++i )
{
TItem* pItem = m_Items[i];
ATLASSERT(pItem != NULL);
RECT rcItemDesired = pItem->GetRect();
rcItem.left = rcItem.right = xpos;
if((int)i == m_iCurSel)
{
rcItem.right += (rcItemDesired.right - rcItemDesired.left);
}
else
{
if(bMakeInactiveSameSize && (nCount != 1))
{
rcItem.right += (long)((cxClientInactiveTabs / (nCount-1)) + 0.5);
}
else
{
rcItem.right += (long)(((rcItemDesired.right - rcItemDesired.left) * nRatioWithSelectionFullSize) + 0.5);
}
}
pItem->SetRect(rcItem);
xpos += (rcItem.right-rcItem.left);
}
}
else
{
// We're down pretty small, so just make all the tabs the same width
int cxItem = (nTabAreaWidth - (m_settings.iIndent*2)) / (int)nCount;
xpos = m_settings.iIndent;
for(size_t i=0; i<nCount; ++i)
{
rcItem.left = rcItem.right = xpos;
rcItem.right += cxItem;
m_Items[i]->SetRect(rcItem);
xpos += (rcItem.right-rcItem.left);
}
}
}
dc.SelectFont(hOldFont);
}
void CPNTabControl::UpdateLayout_ScrollToFit(RECT rcTabItemArea)
{
//DWORD dwStyle = this->GetStyle();
// When we scroll to fit, we ignore what's passed in for the
// tab item area rect, and use the client rect instead
RECT rcClient;
this->GetClientRect(&rcClient);
WTL::CClientDC dc(m_hWnd);
//HFONT hOldFont = dc.SelectFont(lpNMCustomDraw->hFontInactive);
HFONT hOldFont = dc.SelectFont(m_font);
RECT rcItem = rcClient;
// rcItem.top and rcItem.bottom aren't really going to change
// Recalculate tab positions and widths
// See DrawItem_ImageAndText for a discussion of how CDotNetTabCtrlImpl
// interprets margin, padding, etc.
size_t nCount = m_Items.GetCount();
int xpos = m_settings.iIndent;
HFONT hRestoreNormalFont = NULL;
for( size_t i=0; i<nCount; ++i )
{
// bool bSelected = ((int)i == m_iCurSel);
TItem* pItem = m_Items[i];
ATLASSERT(pItem != NULL);
rcItem.left = rcItem.right = xpos;
//rcItem.right += ((bSelected ? m_settings.iSelMargin : m_settings.iMargin));
rcItem.right += m_settings.iMargin;
if(pItem->UsingImage() && !m_imageList.IsNull())
{
IMAGEINFO ii = {0};
int nImageIndex = pItem->GetImageIndex();
m_imageList.GetImageInfo(nImageIndex, &ii);
rcItem.right += (ii.rcImage.right - ii.rcImage.left);
}
if(pItem->UsingText())
{
RECT rcText = {0};
_CSTRING_NS::CString sText = pItem->GetText();
dc.DrawText(sText, sText.GetLength(), &rcText, DT_SINGLELINE | DT_CALCRECT | DT_NOPREFIX);
rcItem.right += (rcText.right - rcText.left) + (m_settings.iPadding * 2);
}
rcItem.right += m_settings.iMargin;
pItem->SetRect(rcItem);
xpos += (rcItem.right - rcItem.left);
if(hRestoreNormalFont != NULL)
{
dc.SelectFont(hRestoreNormalFont);
hRestoreNormalFont = NULL;
}
}
xpos += m_settings.iIndent;
// If we've been scrolled to the left, and resize so
// there's more client area to the right, adjust the
// scroll offset accordingly.
if((xpos + m_iScrollOffset) < rcTabItemArea.right)
{
m_iScrollOffset = (rcTabItemArea.right - xpos);
}
dc.SelectFont(hOldFont);
}
| 28.413687
| 146
| 0.704389
|
Adept-Space
|
f576eb0ba27290f4584053bdb523a0cd48fa1183
| 5,778
|
cpp
|
C++
|
core/fxge/apple/fx_apple_platform.cpp
|
ADVAN-ELAA-8QM-PRC1/platform-external-pdfium
|
e67ae11a46c7b9f48ebc2efab8ca58cc9982cb38
|
[
"BSD-3-Clause"
] | 18
|
2015-01-07T21:02:47.000Z
|
2021-01-19T02:14:58.000Z
|
core/fxge/apple/fx_apple_platform.cpp
|
ADVAN-ELAA-8QM-PRC1/platform-external-pdfium
|
e67ae11a46c7b9f48ebc2efab8ca58cc9982cb38
|
[
"BSD-3-Clause"
] | 1
|
2017-02-14T01:38:56.000Z
|
2017-02-15T06:01:13.000Z
|
core/fxge/apple/fx_apple_platform.cpp
|
ADVAN-ELAA-8QM-PRC1/platform-external-pdfium
|
e67ae11a46c7b9f48ebc2efab8ca58cc9982cb38
|
[
"BSD-3-Clause"
] | 10
|
2015-07-04T06:37:40.000Z
|
2021-04-08T09:31:20.000Z
|
// Copyright 2014 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 "core/fxcrt/fx_system.h"
#ifndef _SKIA_SUPPORT_
#include "core/fxge/agg/fx_agg_driver.h"
#endif
#include "core/fxge/apple/apple_int.h"
#include "core/fxge/cfx_facecache.h"
#include "core/fxge/cfx_gemodule.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/dib/dib_int.h"
#include "core/fxge/fx_freetype.h"
#include "core/fxge/ge/cfx_cliprgn.h"
#include "core/fxge/ge/fx_text_int.h"
#ifndef _SKIA_SUPPORT_
namespace {
void DoNothing(void* info, const void* data, size_t size) {}
bool CGDrawGlyphRun(CGContextRef pContext,
int nChars,
const FXTEXT_CHARPOS* pCharPos,
CFX_Font* pFont,
const CFX_Matrix* pObject2Device,
FX_FLOAT font_size,
uint32_t argb) {
if (nChars == 0)
return true;
bool bNegSize = font_size < 0;
if (bNegSize)
font_size = -font_size;
CFX_Matrix new_matrix;
if (pObject2Device)
new_matrix.Concat(*pObject2Device);
CQuartz2D& quartz2d =
static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData())
->m_quartz2d;
if (!pFont->GetPlatformFont()) {
if (pFont->GetPsName() == "DFHeiStd-W5")
return false;
pFont->SetPlatformFont(
quartz2d.CreateFont(pFont->GetFontData(), pFont->GetSize()));
if (!pFont->GetPlatformFont())
return false;
}
CFX_FixedBufGrow<uint16_t, 32> glyph_indices(nChars);
CFX_FixedBufGrow<CGPoint, 32> glyph_positions(nChars);
for (int i = 0; i < nChars; i++) {
glyph_indices[i] =
pCharPos[i].m_ExtGID ? pCharPos[i].m_ExtGID : pCharPos[i].m_GlyphIndex;
if (bNegSize)
glyph_positions[i].x = -pCharPos[i].m_Origin.x;
else
glyph_positions[i].x = pCharPos[i].m_Origin.x;
glyph_positions[i].y = pCharPos[i].m_Origin.y;
}
if (bNegSize) {
new_matrix.a = -new_matrix.a;
new_matrix.c = -new_matrix.c;
} else {
new_matrix.b = -new_matrix.b;
new_matrix.d = -new_matrix.d;
}
quartz2d.setGraphicsTextMatrix(pContext, &new_matrix);
return quartz2d.drawGraphicsString(pContext, pFont->GetPlatformFont(),
font_size, glyph_indices, glyph_positions,
nChars, argb, nullptr);
}
} // namespace
void CFX_AggDeviceDriver::InitPlatform() {
CQuartz2D& quartz2d =
static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData())
->m_quartz2d;
m_pPlatformGraphics = quartz2d.createGraphics(m_pBitmap);
}
void CFX_AggDeviceDriver::DestroyPlatform() {
CQuartz2D& quartz2d =
static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData())
->m_quartz2d;
if (m_pPlatformGraphics) {
quartz2d.destroyGraphics(m_pPlatformGraphics);
m_pPlatformGraphics = nullptr;
}
}
bool CFX_AggDeviceDriver::DrawDeviceText(int nChars,
const FXTEXT_CHARPOS* pCharPos,
CFX_Font* pFont,
const CFX_Matrix* pObject2Device,
FX_FLOAT font_size,
uint32_t argb) {
if (!pFont)
return false;
bool bBold = pFont->IsBold();
if (!bBold && pFont->GetSubstFont() &&
pFont->GetSubstFont()->m_Weight >= 500 &&
pFont->GetSubstFont()->m_Weight <= 600) {
return false;
}
for (int i = 0; i < nChars; i++) {
if (pCharPos[i].m_bGlyphAdjust)
return false;
}
CGContextRef ctx = CGContextRef(m_pPlatformGraphics);
if (!ctx)
return false;
CGContextSaveGState(ctx);
CGContextSetTextDrawingMode(ctx, kCGTextFillClip);
CGRect rect_cg;
CGImageRef pImageCG = nullptr;
if (m_pClipRgn) {
rect_cg =
CGRectMake(m_pClipRgn->GetBox().left, m_pClipRgn->GetBox().top,
m_pClipRgn->GetBox().Width(), m_pClipRgn->GetBox().Height());
const CFX_DIBitmap* pClipMask = m_pClipRgn->GetMask().GetObject();
if (pClipMask) {
CGDataProviderRef pClipMaskDataProvider = CGDataProviderCreateWithData(
nullptr, pClipMask->GetBuffer(),
pClipMask->GetPitch() * pClipMask->GetHeight(), DoNothing);
CGFloat decode_f[2] = {255.f, 0.f};
pImageCG = CGImageMaskCreate(
pClipMask->GetWidth(), pClipMask->GetHeight(), 8, 8,
pClipMask->GetPitch(), pClipMaskDataProvider, decode_f, false);
CGDataProviderRelease(pClipMaskDataProvider);
}
} else {
rect_cg = CGRectMake(0, 0, m_pBitmap->GetWidth(), m_pBitmap->GetHeight());
}
rect_cg = CGContextConvertRectToDeviceSpace(ctx, rect_cg);
if (pImageCG)
CGContextClipToMask(ctx, rect_cg, pImageCG);
else
CGContextClipToRect(ctx, rect_cg);
bool ret = CGDrawGlyphRun(ctx, nChars, pCharPos, pFont, pObject2Device,
font_size, argb);
if (pImageCG)
CGImageRelease(pImageCG);
CGContextRestoreGState(ctx);
return ret;
}
#endif // _SKIA_SUPPORT_
void CFX_FaceCache::InitPlatform() {}
void CFX_FaceCache::DestroyPlatform() {}
CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph_Nativetext(
const CFX_Font* pFont,
uint32_t glyph_index,
const CFX_Matrix* pMatrix,
int dest_width,
int anti_alias) {
return nullptr;
}
void CFX_Font::ReleasePlatformResource() {
if (m_pPlatformFont) {
CQuartz2D& quartz2d =
static_cast<CApplePlatform*>(CFX_GEModule::Get()->GetPlatformData())
->m_quartz2d;
quartz2d.DestroyFont(m_pPlatformFont);
m_pPlatformFont = nullptr;
}
}
| 31.402174
| 80
| 0.649533
|
ADVAN-ELAA-8QM-PRC1
|
f5793f6671b6cbbe299301fbcb23340696806b46
| 1,653
|
cpp
|
C++
|
library/dynamicProgramming/palindromicPartitioning.cpp
|
bluedawnstar/algorithm_library
|
4c7f64ec61fc2ba059b64ad7ba20fcb5b838ced6
|
[
"Unlicense"
] | 40
|
2017-11-26T05:29:18.000Z
|
2020-11-13T00:29:26.000Z
|
library/dynamicProgramming/palindromicPartitioning.cpp
|
bluedawnstar/algorithm_library
|
4c7f64ec61fc2ba059b64ad7ba20fcb5b838ced6
|
[
"Unlicense"
] | 101
|
2019-02-09T06:06:09.000Z
|
2021-12-25T16:55:37.000Z
|
library/dynamicProgramming/palindromicPartitioning.cpp
|
bluedawnstar/algorithm_library
|
4c7f64ec61fc2ba059b64ad7ba20fcb5b838ced6
|
[
"Unlicense"
] | 6
|
2017-01-03T14:17:58.000Z
|
2021-01-22T10:37:04.000Z
|
#include <string>
#include <functional>
#include <vector>
#include <algorithm>
using namespace std;
#include "palindromicPartitioning.h"
/////////// For Testing ///////////////////////////////////////////////////////
#include <time.h>
#include <cassert>
#include <string>
#include <iostream>
#include "../common/iostreamhelper.h"
#include "../common/profile.h"
void testPalindromicPartitioning() {
//return; //TODO: if you want to test, make this line a comment.
cout << "--- Palindromic Partitioning -----------------------------" << endl;
{
vector<pair<string, int>> in{
{ "aab", 1 },
{ "aba", 0 },
{ "abc", 2 }
};
for (auto& it : in) {
int ans = PalindromicPartitioning::minCut(it.first);
if (ans != it.second)
cout << "Mismatched : " << ans << ", " << it.second << endl;
assert(ans == it.second);
}
}
{
vector<tuple<string, int, int>> in{
{ "abc" , 2, 1 },
{ "aabbc" , 3, 0 },
{ "abbcdefb", 8, 0 },
{ "abcdefa" , 4, 2 }
};
for (auto& it : in) {
int ans1 = PalindromicPartitioning::palindromePartitionMemoization(get<0>(it), get<1>(it));
int ans2 = PalindromicPartitioning::palindromePartitionDP(get<0>(it), get<1>(it));
if (ans1 != get<2>(it) || ans2 != get<2>(it))
cout << "Mismatched : " << ans1 << ", " << ans2 << ", " << get<2>(it) << endl;
assert(ans1 == get<2>(it));
assert(ans2 == get<2>(it));
}
}
cout << "OK!" << endl;
}
| 29
| 103
| 0.46582
|
bluedawnstar
|
f579c75ed37e1c290f5e63bae9a94ad5f9169ae4
| 468
|
cpp
|
C++
|
solved-lightOj/1225.cpp
|
Maruf-Tuhin/Online_Judge
|
cf9b2a522e8b1a9623d3996a632caad7fd67f751
|
[
"MIT"
] | 1
|
2019-03-31T05:47:30.000Z
|
2019-03-31T05:47:30.000Z
|
solved-lightOj/1225.cpp
|
the-redback/competitive-programming
|
cf9b2a522e8b1a9623d3996a632caad7fd67f751
|
[
"MIT"
] | null | null | null |
solved-lightOj/1225.cpp
|
the-redback/competitive-programming
|
cf9b2a522e8b1a9623d3996a632caad7fd67f751
|
[
"MIT"
] | null | null | null |
#include <cstdio>
#include <cstring>
main()
{
char a[15],b[15];
int i,j,l,t,k;
scanf("%d",&t);
getchar();
for(i=1;i<=t;i++)
{
gets(a);
l=strlen(a);
for(j=l-1,k=0;j>=0;j--,k++)
{
b[k]=a[j];
}
b[k]='\0';
if(strcmp(a,b)==0)
{
printf("Case %d: Yes\n",i);
}
else
{
printf("Case %d: No\n",i);
}
}
return 0;
}
| 15.6
| 39
| 0.333333
|
Maruf-Tuhin
|
f57a92b4a74fcff655a756b83424e97b70e55d7c
| 51,462
|
cpp
|
C++
|
src/utils/MSFraggerAdapter.cpp
|
avasq011/FinalProject_OpenMS_76ers
|
6c9e2c295df6ec0eb296a3badfcdff245a869d59
|
[
"BSL-1.0",
"Zlib",
"Apache-2.0"
] | 1
|
2019-07-15T20:50:22.000Z
|
2019-07-15T20:50:22.000Z
|
src/utils/MSFraggerAdapter.cpp
|
avasq011/FinalProject_OpenMS_76ers
|
6c9e2c295df6ec0eb296a3badfcdff245a869d59
|
[
"BSL-1.0",
"Zlib",
"Apache-2.0"
] | 150
|
2017-09-05T09:43:12.000Z
|
2020-02-03T10:07:36.000Z
|
src/utils/MSFraggerAdapter.cpp
|
avasq011/FinalProject_OpenMS_76ers
|
6c9e2c295df6ec0eb296a3badfcdff245a869d59
|
[
"BSL-1.0",
"Zlib",
"Apache-2.0"
] | 2
|
2018-04-02T18:41:20.000Z
|
2018-08-11T21:39:24.000Z
|
// --------------------------------------------------------------------------
// OpenMS -- Open-Source Mass Spectrometry
// --------------------------------------------------------------------------
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
// ETH Zurich, and Freie Universitaet Berlin 2002-2018.
//
// This software is released under a three-clause BSD license:
// * 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 any author or any participating institution
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
// For a full list of authors, refer to the file AUTHORS.
// --------------------------------------------------------------------------
// 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 ANY OF THE AUTHORS OR THE CONTRIBUTING
// INSTITUTIONS 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.
//
// --------------------------------------------------------------------------
// $Maintainer: Lukas Zimmermann $
// $Authors: Lukas Zimmermann, Leon Bichmann $
// --------------------------------------------------------------------------
#include <OpenMS/APPLICATIONS/TOPPBase.h>
#include <OpenMS/FORMAT/FileHandler.h>
#include <OpenMS/FORMAT/IdXMLFile.h>
#include <OpenMS/FORMAT/PepXMLFile.h>
#include <OpenMS/CHEMISTRY/ProteaseDB.h>
#include <OpenMS/SYSTEM/JavaInfo.h>
#include <QtCore/QDir>
#include <QtCore/QProcess>
#include <iostream>
using namespace OpenMS;
using namespace std;
//-------------------------------------------------------------
//Doxygen docu
//-------------------------------------------------------------
/**
@page TOPP_MSFraggerAdapter MSFraggerAdapter
@brief Peptide Identification with MSFragger
<CENTER>
<table>
<tr>
<td ALIGN = "center" BGCOLOR="#EBEBEB"> pot. predecessor tools </td>
<td VALIGN="middle" ROWSPAN=2> \f$ \longrightarrow \f$ MSFraggerAdapter \f$ \longrightarrow \f$</td>
<td ALIGN = "center" BGCOLOR="#EBEBEB"> pot. successor tools </td>
</tr>
<tr>
<td VALIGN="middle" ALIGN = "center" ROWSPAN=1> any signal-/preprocessing tool @n (in mzML format)</td>
<td VALIGN="middle" ALIGN = "center" ROWSPAN=1> @ref TOPP_IDFilter or @n any protein/peptide processing tool</td>
</tr>
</table>
</CENTER>
@em MSFragger must be installed before this adapter can be used.
All MSFragger parameters (as specified in the fragger.params file) have been transcribed to parameters of this OpenMS util.
It is not possible to provide an explicit fragger.params file to avoid redundancy with the ini file.
This adapter creates an fragger.params file prior to calling MSFragger. If the fragger.params file should be inspected, set the
-debug option to 2. MSFraggerAdapter will print the path to the working directory to standard out.
MSFragger can process multiple input files (mzML, mzXML) one after another. The number of output files specified must match
the number of input spectra files. The output file is then matched to the input file by index. The default parameters of the
adapter are the same as given by the official MSFragger manual.
Please cite:
Andy T Kong, Felipe V Leprevost, Dmitry M Avtonomov, Dattatreya Mellacheruvu & Alexey I Nesvizhskii
MSFragger: ultrafast and comprehensive peptide identification in mass spectrometry–based proteomics
Nature Methods volume 14, pages 513–520 (2017) doi:10.1038/nmeth.4256
<B>The command line parameters of this tool are:</B>
@verbinclude UTILS_MSFraggerAdapter.cli
<B>INI file documentation of this tool:</B>
@htmlinclude UTILS_MSFraggerAdapter.html
*/
// We do not want this class to show up in the docu:
/// @cond TOPPCLASSES
class TOPPMSFraggerAdapter final :
public TOPPBase
{
public:
static const String java_executable;
static const String java_heapmemory;
static const String executable;
static const String in;
static const String out;
static const String opt_out;
static const String database;
// tolerance
static const String precursor_mass_tolerance;
static const String precursor_mass_unit;
static const String precursor_true_tolerance;
static const String precursor_true_unit;
static const String fragment_mass_tolerance;
static const String fragment_mass_unit;
static const String isotope_error;
// digest
static const String search_enzyme_name;
static const String search_enzyme_cutafter;
static const String search_enzyme_nocutbefore;
static const String num_enzyme_termini;
static const String allowed_missed_cleavage;
static const String digest_min_length;
static const String digest_max_length;
static const String digest_mass_range_min;
static const String digest_mass_range_max;
// varmod
static const String clip_nterm_m;
static const String varmod_masses;
static const String varmod_syntax;
static const String varmod_enable_common;
static const String not_allow_multiple_variable_mods_on_residue;
static const String max_variable_mods_per_mod;
static const String max_variable_mods_combinations;
// spectrum
static const String minimum_peaks;
static const String use_topn_peaks;
static const String minimum_ratio;
static const String clear_mz_range_min;
static const String clear_mz_range_max;
static const String max_fragment_charge;
static const String override_charge;
static const String precursor_charge_min;
static const String precursor_charge_max;
// search
static const String track_zero_topn;
static const String zero_bin_accept_expect;
static const String zero_bin_mult_expect;
static const String add_topn_complementary;
static const String min_fragments_modeling;
static const String min_matched_fragments;
static const String output_report_topn;
static const String output_max_expect;
// statmod
static const String add_cterm_peptide;
static const String add_nterm_peptide;
static const String add_cterm_protein;
static const String add_nterm_protein;
static const String add_G_glycine;
static const String add_A_alanine;
static const String add_S_serine;
static const String add_P_proline;
static const String add_V_valine;
static const String add_T_threonine;
static const String add_C_cysteine;
static const String add_L_leucine;
static const String add_I_isoleucine;
static const String add_N_asparagine;
static const String add_D_aspartic_acid;
static const String add_Q_glutamine;
static const String add_K_lysine;
static const String add_E_glutamic_acid;
static const String add_M_methionine;
static const String add_H_histidine;
static const String add_F_phenylalanine;
static const String add_R_arginine;
static const String add_Y_tyrosine;
static const String add_W_tryptophan;
// Log level for verbose output
static const int LOG_LEVEL_VERBOSE;
TOPPMSFraggerAdapter() :
TOPPBase("MSFraggerAdapter", "Peptide Identification with MSFragger", false,
{
{"Kong AT, Leprevost FV, Avtonomov DM, Mellacheruvu D, Nesvizhskii AI",
"MSFragger: ultrafast and comprehensive peptide identification in mass spectrometry–based proteomics",
"Nature Methods volume 14, pages 513–520 (2017)",
"doi:10.1038/nmeth.4256"}
}),
working_directory(""),
java_exe(""),
exe(""),
parameter_file_path(""),
input_file(),
output_file()
{
}
protected:
void registerOptionsAndFlags_() override
{
const StringList emptyStrings;
const std::vector< double > emptyDoubles;
const StringList validUnits = ListUtils::create<String>("Da,ppm");
const StringList isotope_error_and_enzyme_termini = ListUtils::create<String>("0,1,2");
const StringList zero_to_five = ListUtils::create<String>("0,1,2,3,4,5");
// Java executable
registerInputFile_(TOPPMSFraggerAdapter::java_executable, "<file>", "java", "The Java executable. Usually Java is on the system PATH. If Java is not found, use this parameter to specify the full path to Java", false, false, ListUtils::create<String>("skipexists"));
registerIntOption_(TOPPMSFraggerAdapter::java_heapmemory, "<num>", 3500, "Maximum Java heap size (in MB)", false);
// Handle executable
registerInputFile_(TOPPMSFraggerAdapter::executable, "<path_to_executable>", "", "Path to the MSFragger executable to use; may be empty if the executable is globally available.", false, false, ListUtils::create<String>("skipexists"));
// Input file
registerInputFile_(TOPPMSFraggerAdapter::in, "<file>", "", "Input File with specta for MSFragger");
setValidFormats_(TOPPMSFraggerAdapter::in, ListUtils::create<String>("mzML,mzXML"));
// Output file
registerOutputFile_(TOPPMSFraggerAdapter::out, "<file>", "", "MSFragger output file");
setValidFormats_(TOPPMSFraggerAdapter::out, ListUtils::create<String>("idXML"), true);
// Optional output file
registerOutputFile_(TOPPMSFraggerAdapter::opt_out, "<file>", "", "MSFragger optional output file", false);
setValidFormats_(TOPPMSFraggerAdapter::opt_out, ListUtils::create<String>("pepXML"), true);
// Path to database to search
registerInputFile_(TOPPMSFraggerAdapter::database, "<path_to_fasta>", "", "Protein FASTA database file path", true, false);
setValidFormats_(TOPPMSFraggerAdapter::database, ListUtils::create<String>("FASTA,fasta,fa,fas"), false);
// TOPP tolerance
registerTOPPSubsection_("tolerance", "Search Tolerances");
// Precursor mass tolerance and unit
_registerNonNegativeDouble(TOPPMSFraggerAdapter::precursor_mass_tolerance, "<precursor_mass_tolerance>", 20.0, "Precursor mass tolerance (window is +/- this value)", false, false);
registerStringOption_(TOPPMSFraggerAdapter::precursor_mass_unit, "<precursor_mass_unit>", "ppm", "Unit of precursor mass tolerance", false, false);
setValidStrings_(TOPPMSFraggerAdapter::precursor_mass_unit, validUnits);
// Precursor true tolerance
_registerNonNegativeDouble(TOPPMSFraggerAdapter::precursor_true_tolerance, "<precursor_true_tolerance>", 0.0, "True precursor mass tolerance (window is +/- this value). Used for tie breaker of results (in spectrally ambiguous cases) and zero bin boosting in open searches (0 disables these features). This option is STRONGLY recommended for open searches.", false, false);
registerStringOption_(TOPPMSFraggerAdapter::precursor_true_unit, "<precursor_true_unit>", "ppm", "Unit of precursor true tolerance", false, false);
setValidStrings_(TOPPMSFraggerAdapter::precursor_true_unit, validUnits);
// Fragment mass tolerance
_registerNonNegativeDouble(TOPPMSFraggerAdapter::fragment_mass_tolerance, "<fragment_mass_tolerance>", 20.0, "Fragment mass tolerance (window is +/- this value)", false, false);
registerStringOption_(TOPPMSFraggerAdapter::fragment_mass_unit, "<fragment_mass_unit>", "ppm", "Unit of fragment mass tolerance", false, false);
setValidStrings_(TOPPMSFraggerAdapter::fragment_mass_unit, validUnits);
// Isotope error
registerStringOption_(TOPPMSFraggerAdapter::isotope_error, "<isotope_error>", "0", "Isotope correction for MS/MS events triggered on isotopic peaks. Should be set to 0 (disabled) for open search or 0/1/2 for correction of narrow window searches. Shifts the precursor mass window to multiples of this value multiplied by the mass of C13-C12.", false, false);
setValidStrings_(TOPPMSFraggerAdapter::isotope_error, isotope_error_and_enzyme_termini);
// TOPP digest
registerTOPPSubsection_("digest", "In-Silico Digestion Parameters");
// Enzyme
StringList enzyme_names;
ProteaseDB::getInstance()->getAllNames(enzyme_names);
registerStringOption_(TOPPMSFraggerAdapter::search_enzyme_name, "<search_enzyme_name>", "Trypsin", "Name of the enzyme to be written to the pepXML file", false, false);
setValidStrings_(TOPPMSFraggerAdapter::search_enzyme_name, enzyme_names);
// Cut after
registerStringOption_(TOPPMSFraggerAdapter::search_enzyme_cutafter, "<search_enzyme_cutafter>", "KR", "Residues after which the enzyme cuts (specified as a string of amino acids)", false , false);
// No cut before
registerStringOption_(TOPPMSFraggerAdapter::search_enzyme_nocutbefore, "<search_enzyme_nocutbefore>", "P", "Residues that the enzyme will not cut before", false, false);
// Number of enzyme termini
registerStringOption_(TOPPMSFraggerAdapter::num_enzyme_termini, "<num_enzyme_termini>", "fully", "Number of enzyme termini (non-enzymatic (0), semi (1), fully (2)", false, false);
setValidStrings_(TOPPMSFraggerAdapter::num_enzyme_termini, ListUtils::create<String>("non-enzymatic,semi,fully"));
// Allowed missed cleavages
registerStringOption_(TOPPMSFraggerAdapter::allowed_missed_cleavage, "<allowed_missed_cleavage>", "2", "Allowed number of missed cleavages", false, false);
setValidStrings_(TOPPMSFraggerAdapter::allowed_missed_cleavage, zero_to_five); // 5 is the max. allowed value according to MSFragger
// Digest min length
_registerNonNegativeInt(TOPPMSFraggerAdapter::digest_min_length, "<digest_min_length>", 7, "Minimum length of peptides to be generated during in-silico digestion", false, false);
// Digest max length
_registerNonNegativeInt(TOPPMSFraggerAdapter::digest_max_length, "<digest_max_length>", 64, "Maximum length of peptides to be generated during in-silico digestion", false, false);
// Digest min mass range
_registerNonNegativeDouble(TOPPMSFraggerAdapter::digest_mass_range_min, "<digest_mass_range_min>", 500.0, "Min mass of peptides to be generated (Da)", false, false);
// Digest max mass range
_registerNonNegativeDouble(TOPPMSFraggerAdapter::digest_mass_range_max, "<digest_mass_range_max>", 5000.0, "Max mass of peptides to be generated (Da)", false, false);
// TOPP varmod
registerTOPPSubsection_("varmod", "Variable Modification Parameters");
// Clip nterm M
registerFlag_(TOPPMSFraggerAdapter::clip_nterm_m, "Specifies the trimming of a protein N-terminal methionine as a variable modification", false);
// Modifications
registerDoubleList_(TOPPMSFraggerAdapter::varmod_masses, "<varmod1_mass .. varmod7_mass>", emptyDoubles , "Masses for variable modifications", false, false);
registerStringList_(TOPPMSFraggerAdapter::varmod_syntax, "<varmod1_syntax .. varmod7_syntax>", emptyStrings, "Syntax Strings for variable modifications", false, false);
registerFlag_(TOPPMSFraggerAdapter::varmod_enable_common, "Enable common variable modifications (15.9949 M and 42.0106 [^)", false);
// allow_multiple_variable_mods_on_residue
registerFlag_(TOPPMSFraggerAdapter::not_allow_multiple_variable_mods_on_residue, "Do not allow any one amino acid to be modified by multiple variable modifications", false);
// Max variable mods per mod
registerStringOption_(TOPPMSFraggerAdapter::max_variable_mods_per_mod, "<max_variable_mods_per_mod>", "2", "Maximum number of residues that can be occupied by each variable modification", false, false);
setValidStrings_(TOPPMSFraggerAdapter::max_variable_mods_per_mod, zero_to_five);
// Max variable mods combinations
_registerNonNegativeInt(TOPPMSFraggerAdapter::max_variable_mods_combinations, "<max_variable_mods_combinations>", 5000, "Maximum allowed number of modified variably modified peptides from each peptide sequence, (maximum of 65534). If a greater number than the maximum is generated, only the unmodified peptide is considered", false, false);
setMaxInt_(TOPPMSFraggerAdapter::max_variable_mods_combinations, 65534);
// TOPP spectrum
registerTOPPSubsection_("spectrum", "Spectrum Processing Parameters");
_registerNonNegativeInt(TOPPMSFraggerAdapter::minimum_peaks, "<minimum_peaks>", 10, "Minimum number of peaks in experimental spectrum for matching", false, false);
_registerNonNegativeInt(TOPPMSFraggerAdapter::use_topn_peaks, "<use_topN_peaks>", 50, "Pre-process experimental spectrum to only use top N peaks", false, false);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::minimum_ratio, "<minimum_ratio>", 0.0, "Filters out all peaks in experimental spectrum less intense than this multiple of the base peak intensity", false, false);
setMaxFloat_(TOPPMSFraggerAdapter::minimum_ratio, 1.0);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::clear_mz_range_min, "<clear_mz_range_min>", 0.0, "Removes peaks in this m/z range prior to matching (minimum value). Useful for iTRAQ/TMT experiments (i.e. 0.0 150.0)", false, false);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::clear_mz_range_max, "<clear_mz_range_max>", 0.0, "Removes peaks in this m/z range prior to matching (maximum value). Useful for iTRAQ/TMT experiments (i.e. 0.0 150.0)", false, false);
registerStringOption_(TOPPMSFraggerAdapter::max_fragment_charge, "<max_fragment_charge>", "2", "Maximum charge state for theoretical fragments to match", false, false);
setValidStrings_(TOPPMSFraggerAdapter::max_fragment_charge, ListUtils::create<String>("1,2,3,4"));
registerFlag_(TOPPMSFraggerAdapter::override_charge, "Ignores precursor charge and uses charge state specified in precursor_charge range (parameters: spectrum:precursor_charge_min and spectrum:precursor_charge_max)" , false);
_registerNonNegativeInt(TOPPMSFraggerAdapter::precursor_charge_min, "<precursor_charge_min>", 1, "Min charge of precursor charge range to consider. If specified, also spectrum:override_charge must be set)" , false, false);
_registerNonNegativeInt(TOPPMSFraggerAdapter::precursor_charge_max, "<precursor_charge_max>", 4, "Max charge of precursor charge range to consider. If specified, also spectrum:override_charge must be set)" , false, false);
registerTOPPSubsection_("search", "Open Search Features");
_registerNonNegativeInt(TOPPMSFraggerAdapter::track_zero_topn, "<track_zero_topn>", 0, "Track top N unmodified peptide results separately from main results internally for boosting features. Should be set to a number greater than search:output_report_topN if zero bin boosting is desired", false, false);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::zero_bin_accept_expect, "<zero_bin_accept_expect>", 0.0, "Ranks a zero-bin hit above all non-zero-bin hit if it has expectation less than this value", false, false);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::zero_bin_mult_expect, "<zero_bin_mult_expect>", 1.0, "Multiplies expect value of PSMs in the zero-bin during results ordering (set to less than 1 for boosting)", false, false);
_registerNonNegativeInt(TOPPMSFraggerAdapter::add_topn_complementary, "<add_topn_complementary>", 0, "Inserts complementary ions corresponding to the top N most intense fragments in each experimental spectrum. Useful for recovery of modified peptides near C-terminus in open search. 0 disables this option", false, false);
_registerNonNegativeInt(TOPPMSFraggerAdapter::min_fragments_modeling, "<min_fragments_modeling>", 3, "Minimum number of matched peaks in PSM for inclusion in statistical modeling", false, false);
_registerNonNegativeInt(TOPPMSFraggerAdapter::min_matched_fragments, "<min_matched_fragments>", 4, "Minimum number of matched peaks for PSM to be reported. MSFragger recommends a minimum of 4 for narrow window searching and 6 for open searches", false, false);
_registerNonNegativeInt(TOPPMSFraggerAdapter::output_report_topn, "<output_report_topn>", 1, "Reports top N PSMs per input spectrum", false, false);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::output_max_expect, "<output_max_expect>", 50.0, "Suppresses reporting of PSM if top hit has expectation greater than this threshold", false, false);
registerTOPPSubsection_("statmod", "Static Modification Parameters");
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_cterm_peptide, "<add_cterm_peptide>", 0.0, "Statically add mass in Da to C-terminal of peptide", false, false);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_nterm_peptide, "<add_nterm_peptide>", 0.0, "Statically add mass in Da to N-terminal of peptide", false, false);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_cterm_protein, "<add_cterm_protein>", 0.0, "Statically add mass in Da to C-terminal of protein", false, false);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_nterm_protein, "<add_nterm_protein>", 0.0, "Statically add mass in Da to N-terminal of protein", false, false);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_G_glycine, "<add_G_glycine>", 0.0, "Statically add mass to glycine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_A_alanine, "<add_A_alanine>", 0.0, "Statically add mass to alanine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_S_serine, "<add_S_serine>", 0.0, "Statically add mass to serine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_P_proline, "<add_P_proline>", 0.0, "Statically add mass to proline", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_V_valine, "<add_V_valine>", 0.0, "Statically add mass to valine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_T_threonine, "<add_T_threonine>", 0.0, "Statically add mass to threonine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_C_cysteine, "<add_C_cysteine>", 57.021464, "Statically add mass to cysteine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_L_leucine, "<add_L_leucine>", 0.0, "Statically add mass to leucine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_I_isoleucine, "<add_I_isoleucine>", 0.0, "Statically add mass to isoleucine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_N_asparagine, "<add_N_asparagine>", 0.0, "Statically add mass to asparagine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_D_aspartic_acid, "<add_D_aspartic_acid>", 0.0, "Statically add mass to aspartic_acid", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_Q_glutamine, "<add_Q_glutamine>", 0.0, "Statically add mass to glutamine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_K_lysine, "<add_K_lysine>", 0.0, "Statically add mass to lysine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_E_glutamic_acid, "<add_E_glutamic_acid>", 0.0, "Statically add mass to glutamic_acid", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_M_methionine, "<add_M_methionine>", 0.0, "Statically add mass to methionine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_H_histidine, "<add_H_histidine>", 0.0, "Statically add mass to histidine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_F_phenylalanine, "<add_F_phenylalanine>", 0.0, "Statically add mass to phenylalanine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_R_arginine, "<add_R_arginine>", 0.0, "Statically add mass to arginine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_Y_tyrosine, "<add_Y_tyrosine>", 0.0, "Statically add mass to tyrosine", false, true);
_registerNonNegativeDouble(TOPPMSFraggerAdapter::add_W_tryptophan, "<add_W_tryptophan>", 0.0, "Statically add mass to tryptophan", false, true);
}
ExitCodes main_(int, const char**) override
{
try
{
// java executable
this->java_exe = this->getStringOption_(TOPPMSFraggerAdapter::java_executable);
if (!JavaInfo::canRun(this->java_exe, true))
{
_fatalError("Java executable cannot be run!");
}
// executable
this->exe = this->getStringOption_(TOPPMSFraggerAdapter::executable);
if (this->exe.empty())
{
// looks for MSFRAGGER_PATH in the environment
QString qmsfragger_path = QProcessEnvironment::systemEnvironment().value("MSFRAGGER_PATH");
if (qmsfragger_path.isEmpty())
{
_fatalError("No executable for MSFragger could be found!");
}
this->exe = qmsfragger_path;
}
// input, output, database name
const String database = this->getStringOption_(TOPPMSFraggerAdapter::database);
input_file = (this->getStringOption_(TOPPMSFraggerAdapter::in)).toQString();
output_file = this->getStringOption_(TOPPMSFraggerAdapter::out);
optional_output_file = this->getStringOption_(TOPPMSFraggerAdapter::opt_out);
// tolerance
const double arg_precursor_mass_tolerance(this->getDoubleOption_(TOPPMSFraggerAdapter::precursor_mass_tolerance));
const String & arg_precursor_mass_unit = this->getStringOption_(TOPPMSFraggerAdapter::precursor_mass_unit);
const double arg_precursor_true_tolerance(this->getDoubleOption_(TOPPMSFraggerAdapter::precursor_true_tolerance));
const String & arg_precursor_true_unit = this->getStringOption_(TOPPMSFraggerAdapter::precursor_true_unit);
const double arg_fragment_mass_tolerance(this->getDoubleOption_(TOPPMSFraggerAdapter::fragment_mass_tolerance));
const String & arg_fragment_mass_unit = this->getStringOption_(TOPPMSFraggerAdapter::fragment_mass_unit);
const String & arg_isotope_error = this->getStringOption_(TOPPMSFraggerAdapter::isotope_error);
// digest
const String & arg_search_enzyme_name = this->getStringOption_(TOPPMSFraggerAdapter::search_enzyme_name);
const String & arg_search_enzyme_cutafter = this->getStringOption_(TOPPMSFraggerAdapter::search_enzyme_cutafter);
const String & arg_search_enzyme_nocutbefore = this->getStringOption_(TOPPMSFraggerAdapter::search_enzyme_nocutbefore);
std::map< String,int > num_enzyme_termini;
num_enzyme_termini["non-enzymatic"] = 0;
num_enzyme_termini["semi"] = 1;
num_enzyme_termini["fully"] = 2;
const int arg_num_enzyme_termini = num_enzyme_termini[this->getStringOption_(TOPPMSFraggerAdapter::num_enzyme_termini)];
const String & arg_allowed_missed_cleavage = this->getStringOption_(TOPPMSFraggerAdapter::allowed_missed_cleavage);
const int arg_digest_min_length = this->getIntOption_(TOPPMSFraggerAdapter::digest_min_length);
const int arg_digest_max_length = this->getIntOption_(TOPPMSFraggerAdapter::digest_max_length);
ensureRange(arg_digest_min_length, arg_digest_max_length, "Maximum length of digest is not allowed to be smaller than minimum length of digest");
const double arg_digest_mass_range_min = this->getDoubleOption_(TOPPMSFraggerAdapter::digest_mass_range_min);
const double arg_digest_mass_range_max = this->getDoubleOption_(TOPPMSFraggerAdapter::digest_mass_range_max);
ensureRange(arg_digest_mass_range_min, arg_digest_mass_range_max, "Maximum digest mass is not allowed to be smaller than minimum digest mass!");
// varmod
const bool arg_clip_nterm_m = this->getFlag_(clip_nterm_m);
std::vector< double > arg_varmod_masses = this->getDoubleList_(TOPPMSFraggerAdapter::varmod_masses);
std::vector< String > arg_varmod_syntax = this->getStringList_(TOPPMSFraggerAdapter::varmod_syntax);
// assignment of mass to syntax is by index, so the vectors have to be the same length
if (arg_varmod_masses.size() != arg_varmod_syntax.size())
{
_fatalError("List of arguments for the parameters 'varmod_masses' and 'varmod_syntax' must have the same length!");
}
// only up to 7 variable modifications are allowed
if (arg_varmod_masses.size() > 7)
{
_fatalError("MSFragger is restricted to at most 7 variable modifications.");
}
// add common variable modifications if requested
if (this->getFlag_(varmod_enable_common))
{
// oxidation on methionine
this->_addVarMod(arg_varmod_masses, arg_varmod_syntax, 15.9949, "M");
// N-terminal acetylation
this->_addVarMod(arg_varmod_masses, arg_varmod_syntax, 42.0106, "[^");
}
const bool arg_not_allow_multiple_variable_mods_on_residue = this->getFlag_(TOPPMSFraggerAdapter::not_allow_multiple_variable_mods_on_residue);
const String & arg_max_variable_mods_per_mod = this->getStringOption_(TOPPMSFraggerAdapter::max_variable_mods_per_mod);
const int arg_max_variable_mods_combinations = this->getIntOption_(TOPPMSFraggerAdapter::max_variable_mods_combinations);
// spectrum
const int arg_minimum_peaks = this->getIntOption_(TOPPMSFraggerAdapter::minimum_peaks);
const int arg_use_topn_peaks = this->getIntOption_(TOPPMSFraggerAdapter::use_topn_peaks);
const double arg_minimum_ratio = this->getDoubleOption_(TOPPMSFraggerAdapter::minimum_ratio);
const double arg_clear_mz_range_min = this->getDoubleOption_(TOPPMSFraggerAdapter::clear_mz_range_min);
const double arg_clear_mz_range_max = this->getDoubleOption_(TOPPMSFraggerAdapter::clear_mz_range_max);
ensureRange(arg_clear_mz_range_min, arg_clear_mz_range_max, "Maximum clear mz value is not allowed to be smaller than minimum clear mz value!");
const String & arg_max_fragment_charge = this->getStringOption_(TOPPMSFraggerAdapter::max_fragment_charge);
const bool arg_override_charge = this->getFlag_(TOPPMSFraggerAdapter::override_charge);
const int arg_precursor_charge_min = this->getIntOption_(TOPPMSFraggerAdapter::precursor_charge_min);
const int arg_precursor_charge_max = this->getIntOption_(TOPPMSFraggerAdapter::precursor_charge_max);
ensureRange(arg_precursor_charge_min, arg_precursor_charge_max, "Maximum precursor charge is not allowed to be smaller than minimum precursor charge!");
// ensures that the user is aware of overriding the precursoe charges
if ((arg_precursor_charge_min != 1 || arg_precursor_charge_max != 4) && !arg_override_charge)
{
_fatalError("If you want to ignore the precursor charge, please also set the -" + override_charge + " flag!");
}
// search
const int arg_track_zero_topn = this->getIntOption_(TOPPMSFraggerAdapter::track_zero_topn);
const double arg_zero_bin_accept_expect = this->getDoubleOption_(TOPPMSFraggerAdapter::zero_bin_accept_expect);
const double arg_zero_bin_mult_expect = this->getDoubleOption_(TOPPMSFraggerAdapter::zero_bin_mult_expect);
const int arg_add_topn_complementary = this->getIntOption_(TOPPMSFraggerAdapter::add_topn_complementary);
const int arg_min_fragments_modeling = this->getIntOption_(TOPPMSFraggerAdapter::min_fragments_modeling);
const int arg_min_matched_fragments = this->getIntOption_(TOPPMSFraggerAdapter::min_matched_fragments);
const int arg_output_report_topn = this->getIntOption_(TOPPMSFraggerAdapter::output_report_topn);
const double arg_output_max_expect = this->getDoubleOption_(TOPPMSFraggerAdapter::output_max_expect);
// statmod
const double arg_add_cterm_peptide = this->getDoubleOption_(TOPPMSFraggerAdapter::add_cterm_peptide);
const double arg_add_nterm_peptide = this->getDoubleOption_(TOPPMSFraggerAdapter::add_nterm_peptide);
const double arg_add_cterm_protein = this->getDoubleOption_(TOPPMSFraggerAdapter::add_cterm_protein);
const double arg_add_nterm_protein = this->getDoubleOption_(TOPPMSFraggerAdapter::add_nterm_protein);
const double arg_add_G_glycine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_G_glycine);
const double arg_add_A_alanine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_A_alanine);
const double arg_add_S_serine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_S_serine);
const double arg_add_P_proline = this->getDoubleOption_(TOPPMSFraggerAdapter::add_P_proline);
const double arg_add_V_valine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_V_valine);
const double arg_add_T_threonine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_T_threonine);
const double arg_add_C_cysteine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_C_cysteine);
const double arg_add_L_leucine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_L_leucine);
const double arg_add_I_isoleucine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_I_isoleucine);
const double arg_add_N_asparagine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_N_asparagine);
const double arg_add_D_aspartic_acid = this->getDoubleOption_(TOPPMSFraggerAdapter::add_D_aspartic_acid);
const double arg_add_Q_glutamine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_Q_glutamine);
const double arg_add_K_lysine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_K_lysine);
const double arg_add_E_glutamic_acid = this->getDoubleOption_(TOPPMSFraggerAdapter::add_E_glutamic_acid);
const double arg_add_M_methionine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_M_methionine);
const double arg_add_H_histidine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_H_histidine);
const double arg_add_F_phenylalanine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_F_phenylalanine);
const double arg_add_R_arginine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_R_arginine);
const double arg_add_Y_tyrosine = this->getDoubleOption_(TOPPMSFraggerAdapter::add_Y_tyrosine);
const double arg_add_W_tryptophan = this->getDoubleOption_(TOPPMSFraggerAdapter::add_W_tryptophan);
// parameters have been read in and verified, they are now going to be written into the fragger.params file in a temporary directory
QString working_directory = this->makeAutoRemoveTempDirectory_().toQString();
const QFileInfo tmp_param_file(this->working_directory, "fragger.params");
this->parameter_file_path = String(tmp_param_file.absoluteFilePath());
writeDebug_("Parameter file for MSFragger: '" + this->parameter_file_path + "'", TOPPMSFraggerAdapter::LOG_LEVEL_VERBOSE);
writeDebug_("Working Directory: '" + String(this->working_directory) + "'", TOPPMSFraggerAdapter::LOG_LEVEL_VERBOSE);
writeDebug_("If you want to keep the working directory and the parameter file, set the -debug to 2", 1);
ofstream os(this->parameter_file_path.c_str());
// Write all the parameters into the file
os << "database_name = " << String(database)
<< "\nnum_threads = " << this->getIntOption_("threads")
<< "\n\nprecursor_mass_tolerance = " << arg_precursor_mass_tolerance
<< "\nprecursor_mass_units = " << (arg_precursor_mass_unit == "Da" ? 0 : 1)
<< "\nprecursor_true_tolerance = " << arg_precursor_true_tolerance
<< "\nprecursor_true_units = " << (arg_precursor_true_unit == "Da" ? 0 : 1)
<< "\nfragment_mass_tolerance = " << arg_fragment_mass_tolerance
<< "\nfragment_mass_units = " << (arg_fragment_mass_unit == "Da" ? 0 : 1)
<< "\n\nisotope_error = " << arg_isotope_error
<< "\n\nsearch_enzyme_name = " << arg_search_enzyme_name
<< "\nsearch_enzyme_cutafter = " << arg_search_enzyme_cutafter
<< "\nsearch_enzyme_butnotafter = " << arg_search_enzyme_nocutbefore
<< "\n\nnum_enzyme_termini = " << arg_num_enzyme_termini
<< "\nallowed_missed_cleavage = " << arg_allowed_missed_cleavage
<< "\n\nclip_nTerm_M = " << arg_clip_nterm_m << '\n';
// Write variable modifications (and also write to log)
writeLog_("Variable Modifications set to:");
for (Size i = 0; i < arg_varmod_masses.size(); ++i)
{
const String varmod = "variable_mod_0" + String(i+1) + " = " + String(arg_varmod_masses[i]) + " " + String(arg_varmod_syntax[i]);
os << "\n" << varmod;
writeLog_(varmod);
}
os << std::endl
<< "\nallow_multiple_variable_mods_on_residue = " << (arg_not_allow_multiple_variable_mods_on_residue ? 0 : 1)
<< "\nmax_variable_mods_per_mod = " << arg_max_variable_mods_per_mod
<< "\nmax_variable_mods_combinations = " << arg_max_variable_mods_combinations
<< "\n\noutput_file_extension = " << "pepXML"
<< "\noutput_format = " << "pepXML"
<< "\noutput_report_topN = " << arg_output_report_topn
<< "\noutput_max_expect = " << arg_output_max_expect
<< "\n\nprecursor_charge = " << arg_precursor_charge_min << " " << arg_precursor_charge_max
<< "\noverride_charge = " << (arg_override_charge ? 1 : 0)
<< "\n\ndigest_min_length = " << arg_digest_min_length
<< "\ndigest_max_length = " << arg_digest_max_length
<< "\ndigest_mass_range = " << arg_digest_mass_range_min << " " << arg_digest_mass_range_max
<< "\nmax_fragment_charge = " << arg_max_fragment_charge
<< "\n\ntrack_zero_topN = " << arg_track_zero_topn
<< "\nzero_bin_accept_expect = " << arg_zero_bin_accept_expect
<< "\nzero_bin_mult_expect = " << arg_zero_bin_mult_expect
<< "\nadd_topN_complementary = " << arg_add_topn_complementary
<< "\n\nminimum_peaks = " << arg_minimum_peaks
<< "\nuse_topN_peaks = " << arg_use_topn_peaks
<< "\nmin_fragments_modelling = " << arg_min_fragments_modeling
<< "\nmin_matched_fragments = " << arg_min_matched_fragments
<< "\nminimum_ratio = " << arg_minimum_ratio
<< "\nclear_mz_range = " << arg_clear_mz_range_min << " " << arg_clear_mz_range_max
<< "\nadd_Cterm_peptide = " << arg_add_cterm_peptide
<< "\nadd_Nterm_peptide = " << arg_add_nterm_peptide
<< "\nadd_Cterm_protein = " << arg_add_cterm_protein
<< "\nadd_Nterm_protein = " << arg_add_nterm_protein
<< "\n\nadd_G_glycine = " << arg_add_G_glycine
<< "\nadd_A_alanine = " << arg_add_A_alanine
<< "\nadd_S_serine = " << arg_add_S_serine
<< "\nadd_P_proline = " << arg_add_P_proline
<< "\nadd_V_valine = " << arg_add_V_valine
<< "\nadd_T_threonine = " << arg_add_T_threonine
<< "\nadd_C_cysteine = " << arg_add_C_cysteine
<< "\nadd_L_leucine = " << arg_add_L_leucine
<< "\nadd_I_isoleucine = " << arg_add_I_isoleucine
<< "\nadd_N_asparagine = " << arg_add_N_asparagine
<< "\nadd_D_aspartic_acid = " << arg_add_D_aspartic_acid
<< "\nadd_Q_glutamine = " << arg_add_Q_glutamine
<< "\nadd_K_lysine = " << arg_add_K_lysine
<< "\nadd_E_glutamic_acid = " << arg_add_E_glutamic_acid
<< "\nadd_M_methionine = " << arg_add_M_methionine
<< "\nadd_H_histidine = " << arg_add_H_histidine
<< "\nadd_F_phenylalanine = " << arg_add_F_phenylalanine
<< "\nadd_R_arginine = " << arg_add_R_arginine
<< "\nadd_Y_tyrosine = " << arg_add_Y_tyrosine
<< "\nadd_W_tryptophan = " << arg_add_W_tryptophan;
os.close();
}
catch (int)
{
return ILLEGAL_PARAMETERS;
}
QStringList process_params; // the actual process is Java, not MSFragger
process_params << "-Xmx" + QString::number(this->getIntOption_(java_heapmemory)) + "m"
<< "-jar" << this->exe.toQString()
<< this->parameter_file_path.toQString()
<< input_file;
QProcess process_msfragger;
process_msfragger.setWorkingDirectory(this->working_directory);
if (this->debug_level_ >= TOPPMSFraggerAdapter::LOG_LEVEL_VERBOSE)
{
writeDebug_("COMMAND LINE CALL IS:", 1);
String command_line = this->java_exe;
for (const auto& process_param : process_params)
{
command_line += (" " + process_param);
}
writeDebug_(command_line, TOPPMSFraggerAdapter::LOG_LEVEL_VERBOSE);
}
process_msfragger.start(this->java_exe.toQString(), process_params);
if (!process_msfragger.waitForFinished(-1) || process_msfragger.exitCode() != 0)
{
OPENMS_LOG_FATAL_ERROR << "FATAL: Invocation of MSFraggerAdapter has failed. Error code was: " << process_msfragger.exitCode() << std::endl;
const QString msfragger_stdout(process_msfragger.readAllStandardOutput());
const QString msfragger_stderr(process_msfragger.readAllStandardError());
writeLog_(msfragger_stdout);
writeLog_(msfragger_stderr);
writeLog_(String(process_msfragger.exitCode()));
return EXTERNAL_PROGRAM_ERROR;
}
// convert from pepXML to idXML
String pepxmlfile = File::removeExtension(input_file) + "." + "pepXML";
std::vector<PeptideIdentification> peptide_identifications;
std::vector<ProteinIdentification> protein_identifications;
PepXMLFile().load(pepxmlfile, protein_identifications, peptide_identifications);
for (auto it = protein_identifications.begin(); it != protein_identifications.end(); it++)
{
it->setSearchEngine("MSFragger");
}
IdXMLFile().store(output_file, protein_identifications, peptide_identifications);
// remove the msfragger pepXML output from the user lcoation
if (optional_output_file.empty())
{
File::remove(pepxmlfile);
}
else
{
// rename the pepXML file to the opt_out
QFile::rename(pepxmlfile.toQString(), optional_output_file.toQString());
}
// remove ".pepindex" database file
if (this->debug_level_ < 2)
{
String db_index = this->getStringOption_(TOPPMSFraggerAdapter::database) + ".1.pepindex";
File::remove(db_index);
}
return EXECUTION_OK;
}
private:
QString working_directory;
String java_exe;
String exe;
String parameter_file_path;
QString input_file;
String output_file;
String optional_output_file;
// adds variable modification if not already present
void _addVarMod(std::vector< double > & masses, std::vector< String > & syntaxes, const double mass, const String & syntax) const
{
const std::vector< double >::iterator it1 = std::find(masses.begin(), masses.end(), mass);
const std::vector< String >::iterator it2 = std::find(syntaxes.begin(), syntaxes.end(), syntax);
// add the provided variable modification if not already present
if ( it1 == masses.end()
|| it2 == syntaxes.end()
|| std::distance(masses.begin(), it1) != std::distance(syntaxes.begin(), it2))
{
masses.push_back(mass);
syntaxes.push_back(syntax);
}
}
inline void _registerNonNegativeInt(const String & param_name, const String & argument, const int default_value, const String & description, const bool required, const bool advanced)
{
this->registerIntOption_(param_name, argument, default_value, description, required, advanced);
this->setMinInt_(param_name, 0);
}
inline void _registerNonNegativeDouble(const String & param_name, const String & argument, const double default_value, const String & description, const bool required, const bool advanced)
{
this->registerDoubleOption_(param_name, argument, default_value, description, required, advanced);
this->setMinFloat_(param_name, 0.0);
}
inline void _fatalError(const String & message)
{
OPENMS_LOG_FATAL_ERROR << "FATAL: " << message << std::endl;
throw 1;
}
void checkUnique(const StringList & elements, const String & message)
{
for (Size i = 0; i < elements.size(); ++i)
{
for (Size j = 0; j < i; ++j)
{
if (elements[i] == elements[j])
{
_fatalError(message);
}
}
}
}
inline void ensureRange(const double left, const double right, const String & message) const
{
if (right < left)
{
OPENMS_LOG_ERROR << "FATAL: " << message << std::endl;
throw 1;
}
}
};
const String TOPPMSFraggerAdapter::java_executable = "java_executable";
const String TOPPMSFraggerAdapter::java_heapmemory = "java_heapmemory";
const String TOPPMSFraggerAdapter::executable = "executable";
const String TOPPMSFraggerAdapter::in = "in";
const String TOPPMSFraggerAdapter::out = "out";
const String TOPPMSFraggerAdapter::opt_out = "opt_out";
const String TOPPMSFraggerAdapter::database = "database";
// tolerance
const String TOPPMSFraggerAdapter::precursor_mass_tolerance = "tolerance:precursor_mass_tolerance";
const String TOPPMSFraggerAdapter::precursor_mass_unit = "tolerance:precursor_mass_unit";
const String TOPPMSFraggerAdapter::precursor_true_tolerance = "tolerance:precursor_true_tolerance";
const String TOPPMSFraggerAdapter::precursor_true_unit = "tolerance:precursor_true_unit";
const String TOPPMSFraggerAdapter::fragment_mass_tolerance = "tolerance:fragment_mass_tolerance";
const String TOPPMSFraggerAdapter::fragment_mass_unit = "tolerance:fragment_mass_unit";
const String TOPPMSFraggerAdapter::isotope_error = "tolerance:isotope_error";
// digest
const String TOPPMSFraggerAdapter::search_enzyme_name = "digest:search_enzyme_name";
const String TOPPMSFraggerAdapter::search_enzyme_cutafter = "digest:search_enzyme_cutafter";
const String TOPPMSFraggerAdapter::search_enzyme_nocutbefore = "digest:search_enzyme_nocutbefore";
const String TOPPMSFraggerAdapter::num_enzyme_termini = "digest:num_enzyme_termini";
const String TOPPMSFraggerAdapter::allowed_missed_cleavage = "digest:allowed_missed_cleavage";
const String TOPPMSFraggerAdapter::digest_min_length = "digest:min_length";
const String TOPPMSFraggerAdapter::digest_max_length = "digest:max_length";
const String TOPPMSFraggerAdapter::digest_mass_range_min = "digest:mass_range_min";
const String TOPPMSFraggerAdapter::digest_mass_range_max = "digest:mass_range_max";
// varmod
const String TOPPMSFraggerAdapter::clip_nterm_m = "varmod:clip_nterm_m";
const String TOPPMSFraggerAdapter::varmod_masses = "varmod:masses";
const String TOPPMSFraggerAdapter::varmod_syntax = "varmod:syntaxes";
const String TOPPMSFraggerAdapter::varmod_enable_common = "varmod:enable_common";
const String TOPPMSFraggerAdapter::not_allow_multiple_variable_mods_on_residue = "varmod:not_allow_multiple_variable_mods_on_residue";
const String TOPPMSFraggerAdapter::max_variable_mods_per_mod = "varmod:max_variable_mods_per_mod";
const String TOPPMSFraggerAdapter::max_variable_mods_combinations = "varmod:max_variable_mods_combinations";
// spectrum
const String TOPPMSFraggerAdapter::minimum_peaks = "spectrum:minimum_peaks";
const String TOPPMSFraggerAdapter::use_topn_peaks = "spectrum:use_topn_peaks";
const String TOPPMSFraggerAdapter::minimum_ratio = "spectrum:minimum_ratio";
const String TOPPMSFraggerAdapter::clear_mz_range_min = "spectrum:clear_mz_range_min";
const String TOPPMSFraggerAdapter::clear_mz_range_max = "spectrum:clear_mz_range_max";
const String TOPPMSFraggerAdapter::max_fragment_charge = "spectrum:max_fragment_charge";
const String TOPPMSFraggerAdapter::override_charge = "spectrum:override_charge";
const String TOPPMSFraggerAdapter::precursor_charge_min = "spectrum:precursor_charge_min";
const String TOPPMSFraggerAdapter::precursor_charge_max = "spectrum:precursor_charge_max";
// search
const String TOPPMSFraggerAdapter::track_zero_topn = "search:track_zero_topn";
const String TOPPMSFraggerAdapter::zero_bin_accept_expect = "search:zero_bin_accept_expect";
const String TOPPMSFraggerAdapter::zero_bin_mult_expect = "search:zero_bin_mult_expect";
const String TOPPMSFraggerAdapter::add_topn_complementary = "search:add_topn_complementary";
const String TOPPMSFraggerAdapter::min_fragments_modeling = "search:min_fragments_modeling";
const String TOPPMSFraggerAdapter::min_matched_fragments = "search:min_matched_fragments";
const String TOPPMSFraggerAdapter::output_report_topn = "search:output_report_topn";
const String TOPPMSFraggerAdapter::output_max_expect = "search:output_max_expect";
// statmod
const String TOPPMSFraggerAdapter::add_cterm_peptide = "statmod:add_cterm_peptide";
const String TOPPMSFraggerAdapter::add_nterm_peptide = "statmod:add_nterm_peptide";
const String TOPPMSFraggerAdapter::add_cterm_protein = "statmod:add_cterm_protein";
const String TOPPMSFraggerAdapter::add_nterm_protein = "statmod:add_nterm_protein";
const String TOPPMSFraggerAdapter::add_G_glycine = "statmod:add_G_glycine";
const String TOPPMSFraggerAdapter::add_A_alanine = "statmod:add_A_alanine";
const String TOPPMSFraggerAdapter::add_S_serine = "statmod:add_S_serine";
const String TOPPMSFraggerAdapter::add_P_proline = "statmod:add_P_proline";
const String TOPPMSFraggerAdapter::add_V_valine = "statmod:add_V_valine";
const String TOPPMSFraggerAdapter::add_T_threonine = "statmod:add_T_threonine";
const String TOPPMSFraggerAdapter::add_C_cysteine = "statmod:add_C_cysteine";
const String TOPPMSFraggerAdapter::add_L_leucine = "statmod:add_L_leucine";
const String TOPPMSFraggerAdapter::add_I_isoleucine = "statmod:add_I_isoleucine";
const String TOPPMSFraggerAdapter::add_N_asparagine = "statmod:add_N_asparagine";
const String TOPPMSFraggerAdapter::add_D_aspartic_acid = "statmod:add_D_aspartic_acid";
const String TOPPMSFraggerAdapter::add_Q_glutamine = "statmod:add_Q_glutamine";
const String TOPPMSFraggerAdapter::add_K_lysine = "statmod:add_K_lysine";
const String TOPPMSFraggerAdapter::add_E_glutamic_acid = "statmod:add_E_glutamic_acid";
const String TOPPMSFraggerAdapter::add_M_methionine = "statmod:add_M_methionine";
const String TOPPMSFraggerAdapter::add_H_histidine = "statmod:add_H_histidine";
const String TOPPMSFraggerAdapter::add_F_phenylalanine = "statmod:add_F_phenylalanine";
const String TOPPMSFraggerAdapter::add_R_arginine = "statmod:add_R_arginine";
const String TOPPMSFraggerAdapter::add_Y_tyrosine = "statmod:add_Y_tyrosine";
const String TOPPMSFraggerAdapter::add_W_tryptophan = "statmod:add_W_tryptophan";
const int TOPPMSFraggerAdapter::LOG_LEVEL_VERBOSE = 1;
int main(int argc, const char** argv)
{
TOPPMSFraggerAdapter tool;
return tool.main(argc, argv);
}
/// @endcond
| 60.614841
| 376
| 0.74179
|
avasq011
|
f57abae448967498b08b6dca28ee511fb8f8f4fa
| 324,668
|
cc
|
C++
|
third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
|
DamieFC/chromium
|
54ce2d3c77723697efd22cfdb02aea38f9dfa25c
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1
|
2020-10-18T02:33:40.000Z
|
2020-10-18T02:33:40.000Z
|
third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
|
DamieFC/chromium
|
54ce2d3c77723697efd22cfdb02aea38f9dfa25c
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 3
|
2021-05-17T16:28:52.000Z
|
2021-05-21T22:42:22.000Z
|
third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
|
DamieFC/chromium
|
54ce2d3c77723697efd22cfdb02aea38f9dfa25c
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/css/basic_shape_functions.h"
#include "third_party/blink/renderer/core/css/css_axis_value.h"
#include "third_party/blink/renderer/core/css/css_color.h"
#include "third_party/blink/renderer/core/css/css_counter_value.h"
#include "third_party/blink/renderer/core/css/css_cursor_image_value.h"
#include "third_party/blink/renderer/core/css/css_custom_ident_value.h"
#include "third_party/blink/renderer/core/css/css_font_feature_value.h"
#include "third_party/blink/renderer/core/css/css_font_selector.h"
#include "third_party/blink/renderer/core/css/css_font_variation_value.h"
#include "third_party/blink/renderer/core/css/css_function_value.h"
#include "third_party/blink/renderer/core/css/css_grid_template_areas_value.h"
#include "third_party/blink/renderer/core/css/css_identifier_value.h"
#include "third_party/blink/renderer/core/css/css_initial_color_value.h"
#include "third_party/blink/renderer/core/css/css_layout_function_value.h"
#include "third_party/blink/renderer/core/css/css_numeric_literal_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value_mappings.h"
#include "third_party/blink/renderer/core/css/css_quad_value.h"
#include "third_party/blink/renderer/core/css/css_reflect_value.h"
#include "third_party/blink/renderer/core/css/css_resolution_units.h"
#include "third_party/blink/renderer/core/css/css_string_value.h"
#include "third_party/blink/renderer/core/css/css_uri_value.h"
#include "third_party/blink/renderer/core/css/css_value_list.h"
#include "third_party/blink/renderer/core/css/css_value_pair.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_fast_paths.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_local_context.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_mode.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_token.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_token_range.h"
#include "third_party/blink/renderer/core/css/parser/css_property_parser.h"
#include "third_party/blink/renderer/core/css/parser/font_variant_east_asian_parser.h"
#include "third_party/blink/renderer/core/css/parser/font_variant_ligatures_parser.h"
#include "third_party/blink/renderer/core/css/parser/font_variant_numeric_parser.h"
#include "third_party/blink/renderer/core/css/properties/computed_style_utils.h"
#include "third_party/blink/renderer/core/css/properties/css_parsing_utils.h"
#include "third_party/blink/renderer/core/css/properties/longhands.h"
#include "third_party/blink/renderer/core/css/resolver/style_builder_converter.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
#include "third_party/blink/renderer/core/css/scoped_css_value.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/css/zoom_adjusted_pixel_value.h"
#include "third_party/blink/renderer/core/css_value_keywords.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/layout/counter_node.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/style/grid_area.h"
#include "third_party/blink/renderer/core/style/reference_clip_path_operation.h"
#include "third_party/blink/renderer/core/style/shape_clip_path_operation.h"
#include "third_party/blink/renderer/core/style_property_shorthand.h"
#include "third_party/blink/renderer/platform/geometry/length.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
// Implementations of methods in Longhand subclasses that aren't generated.
namespace blink {
namespace css_longhand {
const CSSValue* AlignContent::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeContentDistributionOverflowPosition(
range, css_parsing_utils::IsContentPositionKeyword);
}
const CSSValue* AlignContent::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::
ValueForContentPositionAndDistributionWithOverflowAlignment(
style.AlignContent());
}
const CSSValue* AlignItems::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
// align-items property does not allow the 'auto' value.
if (css_parsing_utils::IdentMatches<CSSValueID::kAuto>(range.Peek().Id()))
return nullptr;
return css_parsing_utils::ConsumeSelfPositionOverflowPosition(
range, css_parsing_utils::IsSelfPositionKeyword);
}
const CSSValue* AlignItems::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForItemPositionWithOverflowAlignment(
style.AlignItems());
}
const CSSValue* AlignSelf::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeSelfPositionOverflowPosition(
range, css_parsing_utils::IsSelfPositionKeyword);
}
const CSSValue* AlignSelf::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForItemPositionWithOverflowAlignment(
style.AlignSelf());
}
const CSSValue* AlignmentBaseline::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.AlignmentBaseline());
}
const CSSValue* AnimationDelay::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeTime, range, context, kValueRangeAll);
}
const CSSValue* AnimationDelay::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForAnimationDelay(style.Animations());
}
const CSSValue* AnimationDelay::InitialValue() const {
DEFINE_STATIC_LOCAL(
const Persistent<CSSValue>, value,
(CSSNumericLiteralValue::Create(CSSTimingData::InitialDelay(),
CSSPrimitiveValue::UnitType::kSeconds)));
return value;
}
const CSSValue* AnimationDirection::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeIdent<
CSSValueID::kNormal, CSSValueID::kAlternate, CSSValueID::kReverse,
CSSValueID::kAlternateReverse>,
range);
}
const CSSValue* AnimationDirection::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
const CSSAnimationData* animation_data = style.Animations();
if (animation_data) {
for (wtf_size_t i = 0; i < animation_data->DirectionList().size(); ++i) {
list->Append(*ComputedStyleUtils::ValueForAnimationDirection(
animation_data->DirectionList()[i]));
}
} else {
list->Append(*InitialValue());
}
return list;
}
const CSSValue* AnimationDirection::InitialValue() const {
DEFINE_STATIC_LOCAL(const Persistent<CSSValue>, value,
(CSSIdentifierValue::Create(CSSValueID::kNormal)));
return value;
}
const CSSValue* AnimationDuration::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeTime, range, context, kValueRangeNonNegative);
}
const CSSValue* AnimationDuration::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForAnimationDuration(style.Animations());
}
const CSSValue* AnimationDuration::InitialValue() const {
DEFINE_STATIC_LOCAL(
const Persistent<CSSValue>, value,
(CSSNumericLiteralValue::Create(CSSTimingData::InitialDuration(),
CSSPrimitiveValue::UnitType::kSeconds)));
return value;
}
const CSSValue* AnimationFillMode::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeIdent<CSSValueID::kNone, CSSValueID::kForwards,
CSSValueID::kBackwards,
CSSValueID::kBoth>,
range);
}
const CSSValue* AnimationFillMode::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
const CSSAnimationData* animation_data = style.Animations();
if (animation_data) {
for (wtf_size_t i = 0; i < animation_data->FillModeList().size(); ++i) {
list->Append(*ComputedStyleUtils::ValueForAnimationFillMode(
animation_data->FillModeList()[i]));
}
} else {
list->Append(*InitialValue());
}
return list;
}
const CSSValue* AnimationFillMode::InitialValue() const {
DEFINE_STATIC_LOCAL(const Persistent<CSSValue>, value,
(CSSIdentifierValue::Create(CSSValueID::kNone)));
return value;
}
const CSSValue* AnimationIterationCount::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeAnimationIterationCount, range, context);
}
const CSSValue* AnimationIterationCount::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
const CSSAnimationData* animation_data = style.Animations();
if (animation_data) {
for (wtf_size_t i = 0; i < animation_data->IterationCountList().size();
++i) {
list->Append(*ComputedStyleUtils::ValueForAnimationIterationCount(
animation_data->IterationCountList()[i]));
}
} else {
list->Append(*InitialValue());
}
return list;
}
const CSSValue* AnimationIterationCount::InitialValue() const {
DEFINE_STATIC_LOCAL(
const Persistent<CSSValue>, value,
(CSSNumericLiteralValue::Create(CSSAnimationData::InitialIterationCount(),
CSSPrimitiveValue::UnitType::kNumber)));
return value;
}
const CSSValue* AnimationName::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
// Allow quoted name if this is an alias property.
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeAnimationName, range, context,
local_context.UseAliasParsing());
}
const CSSValue* AnimationName::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
const CSSAnimationData* animation_data = style.Animations();
if (animation_data) {
for (wtf_size_t i = 0; i < animation_data->NameList().size(); ++i) {
list->Append(*MakeGarbageCollected<CSSCustomIdentValue>(
animation_data->NameList()[i]));
}
} else {
list->Append(*InitialValue());
}
return list;
}
const CSSValue* AnimationName::InitialValue() const {
DEFINE_STATIC_LOCAL(const Persistent<CSSValue>, value,
(CSSIdentifierValue::Create(CSSValueID::kNone)));
return value;
}
void AnimationName::ApplyValue(StyleResolverState& state,
const ScopedCSSValue& scoped_value) const {
// TODO(futhark): Set the TreeScope on CSSAnimationData.
ApplyValue(state, scoped_value.GetCSSValue());
}
const CSSValue* AnimationPlayState::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeIdent<CSSValueID::kRunning,
CSSValueID::kPaused>,
range);
}
const CSSValue* AnimationPlayState::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
const CSSAnimationData* animation_data = style.Animations();
if (animation_data) {
for (wtf_size_t i = 0; i < animation_data->PlayStateList().size(); ++i) {
list->Append(*ComputedStyleUtils::ValueForAnimationPlayState(
animation_data->PlayStateList()[i]));
}
} else {
list->Append(*InitialValue());
}
return list;
}
const CSSValue* AnimationPlayState::InitialValue() const {
DEFINE_STATIC_LOCAL(const Persistent<CSSValue>, value,
(CSSIdentifierValue::Create(CSSValueID::kRunning)));
return value;
}
const CSSValue* AnimationTimeline::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeAnimationTimeline, range, context);
}
const CSSValue* AnimationTimeline::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
const CSSAnimationData* animation_data = style.Animations();
if (animation_data) {
for (const auto& timeline : animation_data->TimelineList())
list->Append(*ComputedStyleUtils::ValueForStyleNameOrKeyword(timeline));
} else {
list->Append(*InitialValue());
}
return list;
}
const CSSValue* AnimationTimeline::InitialValue() const {
return CSSIdentifierValue::Create(CSSValueID::kAuto);
}
const CSSValue* AnimationTimingFunction::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeAnimationTimingFunction, range, context);
}
const CSSValue* AnimationTimingFunction::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForAnimationTimingFunction(
style.Animations());
}
const CSSValue* AnimationTimingFunction::InitialValue() const {
DEFINE_STATIC_LOCAL(const Persistent<CSSValue>, value,
(CSSIdentifierValue::Create(CSSValueID::kEase)));
return value;
}
const CSSValue* AspectRatio::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
// Syntax: auto | auto 1/2 | 1/2 auto
CSSValue* auto_value = nullptr;
if (range.Peek().Id() == CSSValueID::kAuto)
auto_value = css_parsing_utils::ConsumeIdent(range);
if (range.AtEnd())
return auto_value;
CSSValue* width =
css_parsing_utils::ConsumeNumber(range, context, kValueRangeNonNegative);
if (!width)
return nullptr;
CSSValue* height = nullptr;
if (css_parsing_utils::ConsumeSlashIncludingWhitespace(range)) {
height = css_parsing_utils::ConsumeNumber(range, context,
kValueRangeNonNegative);
if (!height)
return nullptr;
} else {
// A missing height is treated as 1.
height = CSSNumericLiteralValue::Create(
1.0f, CSSPrimitiveValue::UnitType::kNumber);
}
CSSValueList* ratio_list = CSSValueList::CreateSlashSeparated();
ratio_list->Append(*width);
if (height)
ratio_list->Append(*height);
if (!range.AtEnd()) {
if (auto_value)
return nullptr;
if (range.Peek().Id() != CSSValueID::kAuto)
return nullptr;
auto_value = css_parsing_utils::ConsumeIdent(range);
}
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
if (auto_value)
list->Append(*auto_value);
list->Append(*ratio_list);
return list;
}
const CSSValue* AspectRatio::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
auto& ratio = style.AspectRatio();
if (ratio.GetTypeForComputedStyle() == EAspectRatioType::kAuto)
return CSSIdentifierValue::Create(CSSValueID::kAuto);
CSSValueList* ratio_list = CSSValueList::CreateSlashSeparated();
ratio_list->Append(*CSSNumericLiteralValue::Create(
ratio.GetRatio().Width(), CSSPrimitiveValue::UnitType::kNumber));
ratio_list->Append(*CSSNumericLiteralValue::Create(
ratio.GetRatio().Height(), CSSPrimitiveValue::UnitType::kNumber));
if (ratio.GetTypeForComputedStyle() == EAspectRatioType::kRatio)
return ratio_list;
DCHECK_EQ(ratio.GetTypeForComputedStyle(), EAspectRatioType::kAutoAndRatio);
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*CSSIdentifierValue::Create(CSSValueID::kAuto));
list->Append(*ratio_list);
return list;
}
const CSSValue* BackdropFilter::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeFilterFunctionList(range, context);
}
const CSSValue* BackdropFilter::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForFilter(style, style.BackdropFilter());
}
void BackdropFilter::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.Style()->SetBackdropFilter(
StyleBuilderConverter::ConvertFilterOperations(state, value,
PropertyID()));
}
const CSSValue* BackfaceVisibility::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(
(style.BackfaceVisibility() == EBackfaceVisibility::kHidden)
? CSSValueID::kHidden
: CSSValueID::kVisible);
}
const CSSValue* BackgroundAttachment::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeBackgroundAttachment, range);
}
const CSSValue* BackgroundAttachment::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
for (const FillLayer* curr_layer = &style.BackgroundLayers(); curr_layer;
curr_layer = curr_layer->Next())
list->Append(*CSSIdentifierValue::Create(curr_layer->Attachment()));
return list;
}
const CSSValue* BackgroundBlendMode::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeBackgroundBlendMode, range);
}
const CSSValue* BackgroundBlendMode::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
for (const FillLayer* curr_layer = &style.BackgroundLayers(); curr_layer;
curr_layer = curr_layer->Next())
list->Append(*CSSIdentifierValue::Create(curr_layer->GetBlendMode()));
return list;
}
const CSSValue* BackgroundClip::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ParseBackgroundBox(
range, local_context, css_parsing_utils::AllowTextValue::kAllow);
}
const CSSValue* BackgroundClip::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
const FillLayer* curr_layer = &style.BackgroundLayers();
for (; curr_layer; curr_layer = curr_layer->Next()) {
EFillBox box = curr_layer->Clip();
list->Append(*CSSIdentifierValue::Create(box));
}
return list;
}
const CSSValue* BackgroundColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context,
IsQuirksModeBehavior(context.Mode()));
}
const blink::Color BackgroundColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
StyleColor background_color = style.BackgroundColor();
if (style.ShouldForceColor(background_color)) {
return To<Longhand>(GetCSSPropertyInternalForcedBackgroundColor())
.ColorIncludingFallback(false, style);
}
return background_color.Resolve(style.GetCurrentColor(),
style.UsedColorScheme());
}
const CSSValue* BackgroundColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (allow_visited_style) {
return cssvalue::CSSColor::Create(style.VisitedDependentColor(*this).Rgb());
}
StyleColor background_color = style.BackgroundColor();
if (style.ShouldForceColor(background_color)) {
return GetCSSPropertyInternalForcedBackgroundColor()
.CSSValueFromComputedStyle(style, nullptr, allow_visited_style);
}
// https://drafts.csswg.org/cssom/#resolved-values
// For this property, the resolved value is the used value.
return ComputedStyleUtils::CurrentColorOrValidColor(
style, background_color, CSSValuePhase::kUsedValue);
}
const CSSValue* BackgroundImage::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeImageOrNone, range, context);
}
const CSSValue* BackgroundImage::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
const FillLayer& fill_layer = style.BackgroundLayers();
return ComputedStyleUtils::BackgroundImageOrWebkitMaskImage(
style, allow_visited_style, fill_layer);
}
const CSSValue* BackgroundOrigin::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ParseBackgroundBox(
range, local_context, css_parsing_utils::AllowTextValue::kForbid);
}
const CSSValue* BackgroundOrigin::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
const FillLayer* curr_layer = &style.BackgroundLayers();
for (; curr_layer; curr_layer = curr_layer->Next()) {
EFillBox box = curr_layer->Origin();
list->Append(*CSSIdentifierValue::Create(box));
}
return list;
}
const CSSValue* BackgroundPositionX::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumePositionLonghand<CSSValueID::kLeft,
CSSValueID::kRight>,
range, context);
}
const CSSValue* BackgroundPositionX::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
const FillLayer* curr_layer = &style.BackgroundLayers();
return ComputedStyleUtils::BackgroundPositionXOrWebkitMaskPositionX(
style, curr_layer);
}
const CSSValue* BackgroundPositionY::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumePositionLonghand<CSSValueID::kTop,
CSSValueID::kBottom>,
range, context);
}
const CSSValue* BackgroundPositionY::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
const FillLayer* curr_layer = &style.BackgroundLayers();
return ComputedStyleUtils::BackgroundPositionYOrWebkitMaskPositionY(
style, curr_layer);
}
const CSSValue* BackgroundSize::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ParseBackgroundOrMaskSize(
range, context, local_context, WebFeature::kNegativeBackgroundSize);
}
const CSSValue* BackgroundSize::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
const FillLayer& fill_layer = style.BackgroundLayers();
return ComputedStyleUtils::BackgroundImageOrWebkitMaskSize(style, fill_layer);
}
const CSSValue* BaselineShift::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kBaseline || id == CSSValueID::kSub ||
id == CSSValueID::kSuper)
return css_parsing_utils::ConsumeIdent(range);
CSSParserContext::ParserModeOverridingScope scope(context, kSVGAttributeMode);
return css_parsing_utils::ConsumeLengthOrPercent(range, context,
kValueRangeAll);
}
const CSSValue* BaselineShift::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
switch (style.BaselineShiftType()) {
case EBaselineShiftType::kSuper:
return CSSIdentifierValue::Create(CSSValueID::kSuper);
case EBaselineShiftType::kSub:
return CSSIdentifierValue::Create(CSSValueID::kSub);
case EBaselineShiftType::kLength:
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.BaselineShift(), style);
}
NOTREACHED();
return nullptr;
}
void BaselineShift::ApplyInherit(StyleResolverState& state) const {
state.Style()->SetBaselineShiftType(state.ParentStyle()->BaselineShiftType());
state.Style()->SetBaselineShift(state.ParentStyle()->BaselineShift());
}
void BaselineShift::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
if (auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) {
EBaselineShiftType baseline_shift_type = EBaselineShiftType::kLength;
switch (identifier_value->GetValueID()) {
case CSSValueID::kBaseline:
baseline_shift_type = EBaselineShiftType::kLength;
break;
case CSSValueID::kSub:
baseline_shift_type = EBaselineShiftType::kSub;
break;
case CSSValueID::kSuper:
baseline_shift_type = EBaselineShiftType::kSuper;
break;
default:
NOTREACHED();
}
state.Style()->SetBaselineShiftType(baseline_shift_type);
state.Style()->SetBaselineShift(Length::Fixed());
} else {
state.Style()->SetBaselineShiftType(EBaselineShiftType::kLength);
state.Style()->SetBaselineShift(StyleBuilderConverter::ConvertLength(
state, To<CSSPrimitiveValue>(value)));
}
}
const CSSValue* BlockSize::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeWidthOrHeight(range, context);
}
bool BlockSize::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && (layout_object->IsBox() || layout_object->IsSVG());
}
const CSSValue* BorderBlockEndColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const CSSValue* BorderBlockEndWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderWidth(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* BorderBlockStartColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const CSSValue* BorderBlockStartWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderWidth(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* BorderBottomColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeBorderColorSide(range, context,
local_context);
}
const blink::Color BorderBottomColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
StyleColor border_bottom_color = style.BorderBottomColor();
if (style.ShouldForceColor(border_bottom_color)) {
return To<Longhand>(GetCSSPropertyInternalForcedBorderColor())
.ColorIncludingFallback(false, style);
}
return ComputedStyleUtils::BorderSideColor(
style, border_bottom_color, style.BorderBottomStyle(), visited_link);
}
const CSSValue* BorderBottomColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
StyleColor border_bottom_color = style.BorderBottomColor();
if (style.ShouldForceColor(border_bottom_color)) {
return GetCSSPropertyInternalForcedBorderColor().CSSValueFromComputedStyle(
style, nullptr, allow_visited_style);
}
// https://drafts.csswg.org/cssom/#resolved-values
// For this property, the resolved value is the used value.
return allow_visited_style
? cssvalue::CSSColor::Create(
style.VisitedDependentColor(*this).Rgb())
: ComputedStyleUtils::CurrentColorOrValidColor(
style, border_bottom_color, CSSValuePhase::kUsedValue);
}
const CSSValue* BorderBottomLeftRadius::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ParseBorderRadiusCorner(range, context);
}
const CSSValue* BorderBottomLeftRadius::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForBorderRadiusCorner(
style.BorderBottomLeftRadius(), style);
}
const CSSValue* BorderBottomRightRadius::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ParseBorderRadiusCorner(range, context);
}
const CSSValue* BorderBottomRightRadius::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForBorderRadiusCorner(
style.BorderBottomRightRadius(), style);
}
const CSSValue* BorderBottomStyle::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.BorderBottomStyle());
}
const CSSValue* BorderBottomWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ParseBorderWidthSide(range, context, local_context);
}
const CSSValue* BorderBottomWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.BorderBottomWidth(), style);
}
const CSSValue* BorderCollapse::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.BorderCollapse() == EBorderCollapse::kCollapse)
return CSSIdentifierValue::Create(CSSValueID::kCollapse);
return CSSIdentifierValue::Create(CSSValueID::kSeparate);
}
const CSSValue* BorderEndEndRadius::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ParseBorderRadiusCorner(range, context);
}
const CSSValue* BorderEndStartRadius::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ParseBorderRadiusCorner(range, context);
}
const CSSValue* BorderImageOutset::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderImageOutset(range, context);
}
const CSSValue* BorderImageOutset::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForNinePieceImageQuad(
style.BorderImage().Outset(), style);
}
const CSSValue* BorderImageOutset::InitialValue() const {
DEFINE_STATIC_LOCAL(const Persistent<CSSQuadValue>, value,
(MakeGarbageCollected<CSSQuadValue>(
CSSNumericLiteralValue::Create(
0, CSSPrimitiveValue::UnitType::kInteger),
CSSQuadValue::kSerializeAsQuad)));
return value;
}
const CSSValue* BorderImageRepeat::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderImageRepeat(range);
}
const CSSValue* BorderImageRepeat::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForNinePieceImageRepeat(style.BorderImage());
}
const CSSValue* BorderImageRepeat::InitialValue() const {
DEFINE_STATIC_LOCAL(const Persistent<CSSValue>, value,
(CSSIdentifierValue::Create(CSSValueID::kStretch)));
return value;
}
const CSSValue* BorderImageSlice::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderImageSlice(
range, context, css_parsing_utils::DefaultFill::kNoFill);
}
const CSSValue* BorderImageSlice::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForNinePieceImageSlice(style.BorderImage());
}
const CSSValue* BorderImageSlice::InitialValue() const {
DEFINE_STATIC_LOCAL(
const Persistent<cssvalue::CSSBorderImageSliceValue>, value,
(MakeGarbageCollected<cssvalue::CSSBorderImageSliceValue>(
MakeGarbageCollected<CSSQuadValue>(
CSSNumericLiteralValue::Create(
100, CSSPrimitiveValue::UnitType::kPercentage),
CSSQuadValue::kSerializeAsQuad),
/* fill */ false)));
return value;
}
const CSSValue* BorderImageSource::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeImageOrNone(range, context);
}
const CSSValue* BorderImageSource::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.BorderImageSource()) {
return style.BorderImageSource()->ComputedCSSValue(style,
allow_visited_style);
}
return CSSIdentifierValue::Create(CSSValueID::kNone);
}
const CSSValue* BorderImageSource::InitialValue() const {
DEFINE_STATIC_LOCAL(const Persistent<CSSValue>, value,
(CSSIdentifierValue::Create(CSSValueID::kNone)));
return value;
}
void BorderImageSource::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.Style()->SetBorderImageSource(
state.GetStyleImage(CSSPropertyID::kBorderImageSource, value));
}
const CSSValue* BorderImageWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderImageWidth(range, context);
}
const CSSValue* BorderImageWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForNinePieceImageQuad(
style.BorderImage().BorderSlices(), style);
}
const CSSValue* BorderImageWidth::InitialValue() const {
DEFINE_STATIC_LOCAL(const Persistent<CSSQuadValue>, value,
(MakeGarbageCollected<CSSQuadValue>(
CSSNumericLiteralValue::Create(
1, CSSPrimitiveValue::UnitType::kInteger),
CSSQuadValue::kSerializeAsQuad)));
return value;
}
const CSSValue* BorderInlineEndColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const CSSValue* BorderInlineEndWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderWidth(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* BorderInlineStartColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const CSSValue* BorderInlineStartWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderWidth(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* BorderLeftColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeBorderColorSide(range, context,
local_context);
}
const blink::Color BorderLeftColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
StyleColor border_left_color = style.BorderLeftColor();
if (style.ShouldForceColor(border_left_color)) {
return To<Longhand>(GetCSSPropertyInternalForcedBorderColor())
.ColorIncludingFallback(false, style);
}
return ComputedStyleUtils::BorderSideColor(
style, border_left_color, style.BorderLeftStyle(), visited_link);
}
const CSSValue* BorderLeftColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
StyleColor border_left_color = style.BorderLeftColor();
if (style.ShouldForceColor(border_left_color)) {
return GetCSSPropertyInternalForcedBorderColor().CSSValueFromComputedStyle(
style, nullptr, allow_visited_style);
}
// https://drafts.csswg.org/cssom/#resolved-values
// For this property, the resolved value is the used value.
return allow_visited_style
? cssvalue::CSSColor::Create(
style.VisitedDependentColor(*this).Rgb())
: ComputedStyleUtils::CurrentColorOrValidColor(
style, border_left_color, CSSValuePhase::kUsedValue);
}
const CSSValue* BorderLeftStyle::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.BorderLeftStyle());
}
const CSSValue* BorderLeftWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ParseBorderWidthSide(range, context, local_context);
}
const CSSValue* BorderLeftWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.BorderLeftWidth(), style);
}
const CSSValue* BorderRightColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeBorderColorSide(range, context,
local_context);
}
const blink::Color BorderRightColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
StyleColor border_right_color = style.BorderRightColor();
if (style.ShouldForceColor(border_right_color)) {
return To<Longhand>(GetCSSPropertyInternalForcedBorderColor())
.ColorIncludingFallback(false, style);
}
return ComputedStyleUtils::BorderSideColor(style, border_right_color,
style.BorderRightStyle(), false);
}
const CSSValue* BorderRightColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
StyleColor border_right_color = style.BorderRightColor();
if (style.ShouldForceColor(border_right_color)) {
return GetCSSPropertyInternalForcedBorderColor().CSSValueFromComputedStyle(
style, nullptr, allow_visited_style);
}
// https://drafts.csswg.org/cssom/#resolved-values
// For this property, the resolved value is the used value.
return allow_visited_style
? cssvalue::CSSColor::Create(
style.VisitedDependentColor(*this).Rgb())
: ComputedStyleUtils::CurrentColorOrValidColor(
style, border_right_color, CSSValuePhase::kUsedValue);
}
const CSSValue* BorderRightStyle::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.BorderRightStyle());
}
const CSSValue* BorderRightWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ParseBorderWidthSide(range, context, local_context);
}
const CSSValue* BorderRightWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.BorderRightWidth(), style);
}
const CSSValue* BorderStartStartRadius::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ParseBorderRadiusCorner(range, context);
}
const CSSValue* BorderStartEndRadius::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ParseBorderRadiusCorner(range, context);
}
const CSSValue* BorderTopColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeBorderColorSide(range, context,
local_context);
}
const blink::Color BorderTopColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
StyleColor border_top_color = style.BorderTopColor();
if (style.ShouldForceColor(border_top_color)) {
return To<Longhand>(GetCSSPropertyInternalForcedBorderColor())
.ColorIncludingFallback(false, style);
}
return ComputedStyleUtils::BorderSideColor(
style, border_top_color, style.BorderTopStyle(), visited_link);
}
const CSSValue* BorderTopColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
StyleColor border_top_color = style.BorderTopColor();
if (style.ShouldForceColor(border_top_color)) {
return GetCSSPropertyInternalForcedBorderColor().CSSValueFromComputedStyle(
style, nullptr, allow_visited_style);
}
// https://drafts.csswg.org/cssom/#resolved-values
// For this property, the resolved value is the used value.
return allow_visited_style
? cssvalue::CSSColor::Create(
style.VisitedDependentColor(*this).Rgb())
: ComputedStyleUtils::ComputedStyleUtils::CurrentColorOrValidColor(
style, border_top_color, CSSValuePhase::kUsedValue);
}
const CSSValue* BorderTopLeftRadius::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ParseBorderRadiusCorner(range, context);
}
const CSSValue* BorderTopLeftRadius::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForBorderRadiusCorner(
style.BorderTopLeftRadius(), style);
}
const CSSValue* BorderTopRightRadius::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ParseBorderRadiusCorner(range, context);
}
const CSSValue* BorderTopRightRadius::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForBorderRadiusCorner(
style.BorderTopRightRadius(), style);
}
const CSSValue* BorderTopStyle::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.BorderTopStyle());
}
const CSSValue* BorderTopWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ParseBorderWidthSide(range, context, local_context);
}
const CSSValue* BorderTopWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.BorderTopWidth(), style);
}
const CSSValue* Bottom::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context,
css_parsing_utils::UnitlessUnlessShorthand(local_context));
}
bool Bottom::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* Bottom::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForPositionOffset(style, *this,
layout_object);
}
const CSSValue* BoxShadow::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeShadow(
range, context, css_parsing_utils::AllowInsetAndSpread::kAllow);
}
const CSSValue* BoxShadow::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
// https://drafts.csswg.org/cssom/#resolved-values
// For this property, the resolved value is the used value.
return ComputedStyleUtils::ValueForShadowList(style.BoxShadow(), style, true,
CSSValuePhase::kUsedValue);
}
const CSSValue* BoxSizing::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.BoxSizing() == EBoxSizing::kContentBox)
return CSSIdentifierValue::Create(CSSValueID::kContentBox);
return CSSIdentifierValue::Create(CSSValueID::kBorderBox);
}
const CSSValue* BreakAfter::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.BreakAfter());
}
const CSSValue* BreakBefore::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.BreakBefore());
}
const CSSValue* BreakInside::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.BreakInside());
}
const CSSValue* BufferedRendering::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.BufferedRendering());
}
const CSSValue* CaptionSide::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.CaptionSide());
}
const CSSValue* CaretColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color CaretColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
StyleAutoColor auto_color = style.CaretColor();
// TODO(rego): We may want to adjust the caret color if it's the same as
// the background to ensure good visibility and contrast.
StyleColor result = auto_color.IsAutoColor() ? StyleColor::CurrentColor()
: auto_color.ToStyleColor();
if (style.ShouldForceColor(result))
return style.GetInternalForcedCurrentColor();
return result.Resolve(style.GetCurrentColor(), style.UsedColorScheme());
}
const CSSValue* CaretColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (allow_visited_style) {
return cssvalue::CSSColor::Create(style.VisitedDependentColor(*this).Rgb());
}
StyleAutoColor auto_color = style.CaretColor();
// TODO(rego): We may want to adjust the caret color if it's the same as
// the background to ensure good visibility and contrast.
StyleColor result = auto_color.IsAutoColor() ? StyleColor::CurrentColor()
: auto_color.ToStyleColor();
if (style.ShouldForceColor(result)) {
return cssvalue::CSSColor::Create(
style.GetInternalForcedCurrentColor().Rgb());
}
// https://drafts.csswg.org/cssom/#resolved-values
// For this property, the resolved value is the used value.
return ComputedStyleUtils::ValueForStyleAutoColor(style, style.CaretColor(),
CSSValuePhase::kUsedValue);
}
void CaretColor::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetCaretColor(StyleAutoColor::AutoColor());
}
void CaretColor::ApplyInherit(StyleResolverState& state) const {
state.Style()->SetCaretColor(state.ParentStyle()->CaretColor());
}
void CaretColor::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.Style()->SetCaretColor(
StyleBuilderConverter::ConvertStyleAutoColor(state, value));
}
const CSSValue* Clear::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.Clear());
}
namespace {
CSSValue* ConsumeClipComponent(CSSParserTokenRange& range,
const CSSParserContext& context) {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeLength(
range, context, kValueRangeAll, css_parsing_utils::UnitlessQuirk::kAllow);
}
} // namespace
const CSSValue* Clip::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
if (range.Peek().FunctionId() != CSSValueID::kRect)
return nullptr;
CSSParserTokenRange args = css_parsing_utils::ConsumeFunction(range);
// rect(t, r, b, l) || rect(t r b l)
CSSValue* top = ConsumeClipComponent(args, context);
if (!top)
return nullptr;
bool needs_comma = css_parsing_utils::ConsumeCommaIncludingWhitespace(args);
CSSValue* right = ConsumeClipComponent(args, context);
if (!right || (needs_comma &&
!css_parsing_utils::ConsumeCommaIncludingWhitespace(args)))
return nullptr;
CSSValue* bottom = ConsumeClipComponent(args, context);
if (!bottom || (needs_comma &&
!css_parsing_utils::ConsumeCommaIncludingWhitespace(args)))
return nullptr;
CSSValue* left = ConsumeClipComponent(args, context);
if (!left || !args.AtEnd())
return nullptr;
return MakeGarbageCollected<CSSQuadValue>(top, right, bottom, left,
CSSQuadValue::kSerializeAsRect);
}
const CSSValue* Clip::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.HasAutoClip())
return CSSIdentifierValue::Create(CSSValueID::kAuto);
CSSValue* top = ComputedStyleUtils::ZoomAdjustedPixelValueOrAuto(
style.Clip().Top(), style);
CSSValue* right = ComputedStyleUtils::ZoomAdjustedPixelValueOrAuto(
style.Clip().Right(), style);
CSSValue* bottom = ComputedStyleUtils::ZoomAdjustedPixelValueOrAuto(
style.Clip().Bottom(), style);
CSSValue* left = ComputedStyleUtils::ZoomAdjustedPixelValueOrAuto(
style.Clip().Left(), style);
return MakeGarbageCollected<CSSQuadValue>(top, right, bottom, left,
CSSQuadValue::kSerializeAsRect);
}
const CSSValue* ClipPath::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
if (cssvalue::CSSURIValue* url =
css_parsing_utils::ConsumeUrl(range, context))
return url;
return css_parsing_utils::ConsumeBasicShape(
range, context, css_parsing_utils::AllowPathValue::kAllow);
}
const CSSValue* ClipPath::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (ClipPathOperation* operation = style.ClipPath()) {
if (operation->GetType() == ClipPathOperation::SHAPE) {
return ValueForBasicShape(
style, To<ShapeClipPathOperation>(operation)->GetBasicShape());
}
if (operation->GetType() == ClipPathOperation::REFERENCE) {
AtomicString url = To<ReferenceClipPathOperation>(operation)->Url();
return MakeGarbageCollected<cssvalue::CSSURIValue>(url);
}
}
return CSSIdentifierValue::Create(CSSValueID::kNone);
}
const CSSValue* ClipRule::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.ClipRule());
}
const CSSValue* Color::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context,
IsQuirksModeBehavior(context.Mode()));
}
const blink::Color Color::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
if (style.ShouldForceColor(style.GetColor())) {
return To<Longhand>(GetCSSPropertyInternalForcedColor())
.ColorIncludingFallback(false, style);
}
return style.GetCurrentColor();
}
const CSSValue* Color::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.ShouldForceColor(style.GetColor())) {
return GetCSSPropertyInternalForcedColor().CSSValueFromComputedStyle(
style, nullptr, allow_visited_style);
}
return cssvalue::CSSColor::Create(
allow_visited_style ? style.VisitedDependentColor(*this).Rgb()
: style.GetCurrentColor().Rgb());
}
void Color::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetColor(state.Style()->InitialColorForColorScheme());
}
void Color::ApplyInherit(StyleResolverState& state) const {
state.Style()->SetColor(state.ParentStyle()->GetColor());
}
void Color::ApplyValue(StyleResolverState& state, const CSSValue& value) const {
// As per the spec, 'color: currentColor' is treated as 'color: inherit'
auto* identifier_value = DynamicTo<CSSIdentifierValue>(value);
if (identifier_value &&
identifier_value->GetValueID() == CSSValueID::kCurrentcolor) {
ApplyInherit(state);
return;
}
if (auto* initial_color_value = DynamicTo<CSSInitialColorValue>(value)) {
DCHECK_EQ(state.GetElement(), state.GetDocument().documentElement());
state.Style()->SetColor(state.Style()->InitialColorForColorScheme());
return;
}
state.Style()->SetColor(
StyleBuilderConverter::ConvertStyleColor(state, value));
}
const CSSValue* ColorInterpolation::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.ColorInterpolation());
}
const CSSValue* ColorInterpolationFilters::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.ColorInterpolationFilters());
}
const CSSValue* ColorRendering::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.ColorRendering());
}
const CSSValue* ColorScheme::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNormal)
return css_parsing_utils::ConsumeIdent(range);
CSSValueList* values = CSSValueList::CreateSpaceSeparated();
do {
CSSValueID id = range.Peek().Id();
// 'normal' is handled above, and 'default' is reserved for future use.
// 'revert' is not yet implemented as a keyword, but still skip it for
// compat and interop.
if (id == CSSValueID::kNormal || id == CSSValueID::kRevert ||
id == CSSValueID::kDefault) {
return nullptr;
}
CSSValue* value =
css_parsing_utils::ConsumeIdent<CSSValueID::kDark, CSSValueID::kLight>(
range);
if (!value)
value = css_parsing_utils::ConsumeCustomIdent(range, context);
if (!value)
return nullptr;
values->Append(*value);
} while (!range.AtEnd());
return values;
}
const CSSValue* ColorScheme::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.ColorScheme().IsEmpty())
return CSSIdentifierValue::Create(CSSValueID::kNormal);
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
for (auto ident : style.ColorScheme()) {
list->Append(*MakeGarbageCollected<CSSCustomIdentValue>(ident));
}
return list;
}
const CSSValue* ColorScheme::InitialValue() const {
return CSSIdentifierValue::Create(CSSValueID::kNormal);
}
void ColorScheme::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetColorScheme(Vector<AtomicString>());
state.Style()->SetDarkColorScheme(false);
}
void ColorScheme::ApplyInherit(StyleResolverState& state) const {
state.Style()->SetColorScheme(state.ParentStyle()->ColorScheme());
state.Style()->SetDarkColorScheme(state.ParentStyle()->DarkColorScheme());
}
void ColorScheme::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
if (const auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) {
DCHECK(identifier_value->GetValueID() == CSSValueID::kNormal);
state.Style()->SetColorScheme(Vector<AtomicString>());
state.Style()->SetDarkColorScheme(false);
} else if (const auto* scheme_list = DynamicTo<CSSValueList>(value)) {
bool prefers_dark =
state.GetDocument().GetStyleEngine().GetPreferredColorScheme() ==
mojom::blink::PreferredColorScheme::kDark;
bool has_dark = false;
bool has_light = false;
Vector<AtomicString> color_schemes;
for (auto& item : *scheme_list) {
if (const auto* custom_ident = DynamicTo<CSSCustomIdentValue>(*item)) {
color_schemes.push_back(custom_ident->Value());
} else if (const auto* ident = DynamicTo<CSSIdentifierValue>(*item)) {
color_schemes.push_back(ident->CssText());
if (ident->GetValueID() == CSSValueID::kDark)
has_dark = true;
else if (ident->GetValueID() == CSSValueID::kLight)
has_light = true;
} else {
NOTREACHED();
}
}
state.Style()->SetColorScheme(color_schemes);
state.Style()->SetDarkColorScheme(has_dark && (!has_light || prefers_dark));
if (has_dark) {
// Record kColorSchemeDarkSupportedOnRoot if dark is present (though dark
// may not be used). This metric is also recorded in
// StyleEngine::UpdateColorSchemeMetrics if a meta tag supports dark.
auto& doc = state.GetDocument();
if (doc.documentElement() == state.ElementContext().GetElement())
UseCounter::Count(doc, WebFeature::kColorSchemeDarkSupportedOnRoot);
}
} else {
NOTREACHED();
}
}
const CSSValue* ColumnCount::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColumnCount(range, context);
}
const CSSValue* ColumnCount::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.HasAutoColumnCount())
return CSSIdentifierValue::Create(CSSValueID::kAuto);
return CSSNumericLiteralValue::Create(style.ColumnCount(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* ColumnFill::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetColumnFill());
}
const CSSValue* ColumnGap::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeGapLength(range, context);
}
const CSSValue* ColumnGap::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool) const {
return ComputedStyleUtils::ValueForGapLength(style.ColumnGap(), style);
}
const CSSValue* ColumnRuleColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color ColumnRuleColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
StyleColor column_rule_color = style.ColumnRuleColor();
if (style.ShouldForceColor(column_rule_color))
return style.GetInternalForcedCurrentColor();
return column_rule_color.Resolve(style.GetCurrentColor(),
style.UsedColorScheme());
}
const CSSValue* ColumnRuleColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return allow_visited_style ? cssvalue::CSSColor::Create(
style.VisitedDependentColor(*this).Rgb())
: ComputedStyleUtils::CurrentColorOrValidColor(
style, style.ColumnRuleColor(),
CSSValuePhase::kComputedValue);
}
const CSSValue* ColumnRuleStyle::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.ColumnRuleStyle());
}
const CSSValue* ColumnRuleWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeLineWidth(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* ColumnRuleWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.ColumnRuleWidth(), style);
}
const CSSValue* ColumnSpan::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeIdent<CSSValueID::kAll, CSSValueID::kNone>(
range);
}
const CSSValue* ColumnSpan::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(static_cast<unsigned>(style.GetColumnSpan())
? CSSValueID::kAll
: CSSValueID::kNone);
}
const CSSValue* ColumnWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColumnWidth(range, context);
}
const CSSValue* ColumnWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.HasAutoColumnWidth())
return CSSIdentifierValue::Create(CSSValueID::kAuto);
return ZoomAdjustedPixelValue(style.ColumnWidth(), style);
}
// none | strict | content | [ size || layout || style || paint ]
const CSSValue* Contain::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
if (id == CSSValueID::kStrict || id == CSSValueID::kContent) {
list->Append(*css_parsing_utils::ConsumeIdent(range));
return list;
}
CSSIdentifierValue* size = nullptr;
CSSIdentifierValue* layout = nullptr;
CSSIdentifierValue* style = nullptr;
CSSIdentifierValue* paint = nullptr;
while (true) {
id = range.Peek().Id();
if ((id == CSSValueID::kSize ||
(RuntimeEnabledFeatures::CSSContainSize1DEnabled() &&
(id == CSSValueID::kBlockSize || id == CSSValueID::kInlineSize))) &&
!size) {
size = css_parsing_utils::ConsumeIdent(range);
} else if (id == CSSValueID::kLayout && !layout) {
layout = css_parsing_utils::ConsumeIdent(range);
} else if (id == CSSValueID::kStyle && !style) {
style = css_parsing_utils::ConsumeIdent(range);
} else if (id == CSSValueID::kPaint && !paint) {
paint = css_parsing_utils::ConsumeIdent(range);
} else {
break;
}
}
if (size)
list->Append(*size);
if (layout)
list->Append(*layout);
if (style) {
context.Count(WebFeature::kCSSValueContainStyle);
list->Append(*style);
}
if (paint)
list->Append(*paint);
if (!list->length())
return nullptr;
return list;
}
const CSSValue* Contain::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (!style.Contain())
return CSSIdentifierValue::Create(CSSValueID::kNone);
if (style.Contain() == kContainsStrict)
return CSSIdentifierValue::Create(CSSValueID::kStrict);
if (style.Contain() == kContainsContent)
return CSSIdentifierValue::Create(CSSValueID::kContent);
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
if ((style.Contain() & kContainsSize) == kContainsSize) {
list->Append(*CSSIdentifierValue::Create(CSSValueID::kSize));
} else {
if (style.Contain() & kContainsInlineSize)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kInlineSize));
else if (style.Contain() & kContainsBlockSize)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kBlockSize));
}
if (style.Contain() & kContainsLayout)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kLayout));
if (style.Contain() & kContainsStyle)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kStyle));
if (style.Contain() & kContainsPaint)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kPaint));
DCHECK(list->length());
return list;
}
const CSSValue* ContainIntrinsicSize::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
CSSValue* width =
css_parsing_utils::ConsumeLength(range, context, kValueRangeNonNegative);
if (!width)
return nullptr;
CSSValue* height =
css_parsing_utils::ConsumeLength(range, context, kValueRangeNonNegative);
if (!height)
height = width;
return MakeGarbageCollected<CSSValuePair>(width, height,
CSSValuePair::kDropIdenticalValues);
}
const CSSValue* ContainIntrinsicSize::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
auto& size = style.ContainIntrinsicSize();
if (size.Width().IsAuto()) {
DCHECK(size.Height().IsAuto());
return CSSIdentifierValue::Create(CSSValueID::kAuto);
}
return MakeGarbageCollected<CSSValuePair>(
ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.ContainIntrinsicSize().Width(), style),
ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.ContainIntrinsicSize().Height(), style),
CSSValuePair::kDropIdenticalValues);
}
const CSSValue* ContainerName::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeContainerName(range, context);
}
const CSSValue* ContainerName::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
if (style.ContainerName().IsNull())
return CSSIdentifierValue::Create(CSSValueID::kNone);
return MakeGarbageCollected<CSSCustomIdentValue>(style.ContainerName());
}
const CSSValue* ContainerType::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeContainerType(range);
}
const CSSValue* ContainerType::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
if (style.ContainerType() == kContainerTypeNone)
return CSSIdentifierValue::Create(CSSValueID::kNone);
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
if (style.ContainerType() & kContainerTypeInlineSize)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kInlineSize));
if (style.ContainerType() & kContainerTypeBlockSize)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kBlockSize));
return list;
}
namespace {
CSSValue* ConsumeAttr(CSSParserTokenRange args,
const CSSParserContext& context) {
if (args.Peek().GetType() != kIdentToken)
return nullptr;
AtomicString attr_name =
args.ConsumeIncludingWhitespace().Value().ToAtomicString();
if (!args.AtEnd())
return nullptr;
if (context.IsHTMLDocument())
attr_name = attr_name.LowerASCII();
CSSFunctionValue* attr_value =
MakeGarbageCollected<CSSFunctionValue>(CSSValueID::kAttr);
attr_value->Append(*MakeGarbageCollected<CSSCustomIdentValue>(attr_name));
return attr_value;
}
CSSValue* ConsumeCounterContent(CSSParserTokenRange args,
const CSSParserContext& context,
bool counters) {
CSSCustomIdentValue* identifier =
css_parsing_utils::ConsumeCustomIdent(args, context);
if (!identifier)
return nullptr;
CSSStringValue* separator = nullptr;
if (!counters) {
separator = MakeGarbageCollected<CSSStringValue>(String());
} else {
if (!css_parsing_utils::ConsumeCommaIncludingWhitespace(args) ||
args.Peek().GetType() != kStringToken)
return nullptr;
separator = MakeGarbageCollected<CSSStringValue>(
args.ConsumeIncludingWhitespace().Value().ToString());
}
CSSCustomIdentValue* list_style = nullptr;
if (css_parsing_utils::ConsumeCommaIncludingWhitespace(args)) {
// Note: CSS3 spec doesn't allow 'none' but CSS2.1 allows it. We currently
// allow it for backward compatibility.
// See https://github.com/w3c/csswg-drafts/issues/5795 for details.
if (args.Peek().Id() == CSSValueID::kNone) {
list_style = MakeGarbageCollected<CSSCustomIdentValue>("none");
args.ConsumeIncludingWhitespace();
} else {
list_style = css_parsing_utils::ConsumeCounterStyleName(args, context);
}
} else {
list_style = MakeGarbageCollected<CSSCustomIdentValue>("decimal");
}
if (!list_style || !args.AtEnd())
return nullptr;
return MakeGarbageCollected<cssvalue::CSSCounterValue>(identifier, list_style,
separator);
}
} // namespace
const CSSValue* Content::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (css_parsing_utils::IdentMatches<CSSValueID::kNone, CSSValueID::kNormal>(
range.Peek().Id()))
return css_parsing_utils::ConsumeIdent(range);
CSSValueList* values = CSSValueList::CreateSpaceSeparated();
CSSValueList* outer_list = CSSValueList::CreateSlashSeparated();
bool alt_text_present = false;
do {
CSSValue* parsed_value = css_parsing_utils::ConsumeImage(range, context);
if (!parsed_value) {
parsed_value = css_parsing_utils::ConsumeIdent<
CSSValueID::kOpenQuote, CSSValueID::kCloseQuote,
CSSValueID::kNoOpenQuote, CSSValueID::kNoCloseQuote>(range);
}
if (!parsed_value)
parsed_value = css_parsing_utils::ConsumeString(range);
if (!parsed_value) {
if (range.Peek().FunctionId() == CSSValueID::kAttr) {
parsed_value =
ConsumeAttr(css_parsing_utils::ConsumeFunction(range), context);
} else if (range.Peek().FunctionId() == CSSValueID::kCounter) {
parsed_value = ConsumeCounterContent(
css_parsing_utils::ConsumeFunction(range), context, false);
} else if (range.Peek().FunctionId() == CSSValueID::kCounters) {
parsed_value = ConsumeCounterContent(
css_parsing_utils::ConsumeFunction(range), context, true);
}
}
if (!parsed_value) {
if (css_parsing_utils::ConsumeSlashIncludingWhitespace(range)) {
// No values were parsed before the slash, so nothing to apply the
// alternative text to.
if (!values->length())
return nullptr;
alt_text_present = true;
} else {
return nullptr;
}
} else {
values->Append(*parsed_value);
}
} while (!range.AtEnd() && !alt_text_present);
outer_list->Append(*values);
if (alt_text_present) {
CSSStringValue* alt_text = css_parsing_utils::ConsumeString(range);
if (!alt_text)
return nullptr;
outer_list->Append(*alt_text);
}
return outer_list;
}
const CSSValue* Content::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForContentData(style, allow_visited_style);
}
void Content::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetContent(nullptr);
}
void Content::ApplyInherit(StyleResolverState& state) const {
// FIXME: In CSS3, it will be possible to inherit content. In CSS2 it is not.
// This note is a reminder that eventually "inherit" needs to be supported.
}
void Content::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
NOTREACHED();
}
void Content::ApplyValue(StyleResolverState& state,
const ScopedCSSValue& scoped_value) const {
const CSSValue& value = scoped_value.GetCSSValue();
if (auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) {
DCHECK(identifier_value->GetValueID() == CSSValueID::kNormal ||
identifier_value->GetValueID() == CSSValueID::kNone);
if (identifier_value->GetValueID() == CSSValueID::kNone)
state.Style()->SetContent(MakeGarbageCollected<NoneContentData>());
else
state.Style()->SetContent(nullptr);
return;
}
const CSSValueList& outer_list = To<CSSValueList>(value);
ContentData* first_content = nullptr;
ContentData* prev_content = nullptr;
for (auto& item : To<CSSValueList>(outer_list.Item(0))) {
ContentData* next_content = nullptr;
if (item->IsImageGeneratorValue() || item->IsImageSetValue() ||
item->IsImageValue()) {
next_content = MakeGarbageCollected<ImageContentData>(
state.GetStyleImage(CSSPropertyID::kContent, *item));
} else if (const auto* counter_value =
DynamicTo<cssvalue::CSSCounterValue>(item.Get())) {
next_content = MakeGarbageCollected<CounterContentData>(
AtomicString(counter_value->Identifier()), counter_value->ListStyle(),
AtomicString(counter_value->Separator()),
scoped_value.GetTreeScope());
} else if (auto* item_identifier_value =
DynamicTo<CSSIdentifierValue>(item.Get())) {
QuoteType quote_type;
switch (item_identifier_value->GetValueID()) {
default:
NOTREACHED();
FALLTHROUGH;
case CSSValueID::kOpenQuote:
quote_type = QuoteType::kOpen;
break;
case CSSValueID::kCloseQuote:
quote_type = QuoteType::kClose;
break;
case CSSValueID::kNoOpenQuote:
quote_type = QuoteType::kNoOpen;
break;
case CSSValueID::kNoCloseQuote:
quote_type = QuoteType::kNoClose;
break;
}
next_content = MakeGarbageCollected<QuoteContentData>(quote_type);
} else {
String string;
if (const auto* function_value =
DynamicTo<CSSFunctionValue>(item.Get())) {
DCHECK_EQ(function_value->FunctionType(), CSSValueID::kAttr);
state.Style()->SetHasAttrContent();
// TODO: Can a namespace be specified for an attr(foo)?
QualifiedName attr(
g_null_atom,
To<CSSCustomIdentValue>(function_value->Item(0)).Value(),
g_null_atom);
const AtomicString& attr_value = state.GetElement().getAttribute(attr);
string = attr_value.IsNull() ? g_empty_string : attr_value.GetString();
} else {
string = To<CSSStringValue>(*item).Value();
}
if (prev_content && prev_content->IsText()) {
TextContentData* text_content = To<TextContentData>(prev_content);
text_content->SetText(text_content->GetText() + string);
continue;
}
next_content = MakeGarbageCollected<TextContentData>(string);
}
if (!first_content)
first_content = next_content;
else
prev_content->SetNext(next_content);
prev_content = next_content;
}
// If alt text was provided, it will be present as the final element of the
// outer list.
if (outer_list.length() > 1) {
String string = To<CSSStringValue>(outer_list.Item(1)).Value();
auto* alt_content = MakeGarbageCollected<AltTextContentData>(string);
prev_content->SetNext(alt_content);
}
DCHECK(first_content);
state.Style()->SetContent(first_content);
}
const int kCounterIncrementDefaultValue = 1;
const CSSValue* CounterIncrement::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCounter(range, context,
kCounterIncrementDefaultValue);
}
const CSSValue* CounterIncrement::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForCounterDirectives(
style, CounterNode::kIncrementType);
}
const int kCounterResetDefaultValue = 0;
const CSSValue* CounterReset::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCounter(range, context,
kCounterResetDefaultValue);
}
const CSSValue* CounterReset::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForCounterDirectives(style,
CounterNode::kResetType);
}
const int kCounterSetDefaultValue = 0;
const CSSValue* CounterSet::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCounter(range, context,
kCounterSetDefaultValue);
}
const CSSValue* CounterSet::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForCounterDirectives(style,
CounterNode::kSetType);
}
const CSSValue* Cursor::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
bool in_quirks_mode = IsQuirksModeBehavior(context.Mode());
CSSValueList* list = nullptr;
while (CSSValue* image = css_parsing_utils::ConsumeImage(
range, context,
css_parsing_utils::ConsumeGeneratedImagePolicy::kForbid)) {
double num;
IntPoint hot_spot(-1, -1);
bool hot_spot_specified = false;
if (css_parsing_utils::ConsumeNumberRaw(range, context, num)) {
hot_spot.SetX(clampTo<int>(num));
if (!css_parsing_utils::ConsumeNumberRaw(range, context, num))
return nullptr;
hot_spot.SetY(clampTo<int>(num));
hot_spot_specified = true;
}
if (!list)
list = CSSValueList::CreateCommaSeparated();
list->Append(*MakeGarbageCollected<cssvalue::CSSCursorImageValue>(
*image, hot_spot_specified, hot_spot));
if (!css_parsing_utils::ConsumeCommaIncludingWhitespace(range))
return nullptr;
}
CSSValueID id = range.Peek().Id();
if (!range.AtEnd()) {
if (id == CSSValueID::kWebkitZoomIn)
context.Count(WebFeature::kPrefixedCursorZoomIn);
else if (id == CSSValueID::kWebkitZoomOut)
context.Count(WebFeature::kPrefixedCursorZoomOut);
else if (id == CSSValueID::kWebkitGrab)
context.Count(WebFeature::kPrefixedCursorGrab);
else if (id == CSSValueID::kWebkitGrabbing)
context.Count(WebFeature::kPrefixedCursorGrabbing);
}
CSSValue* cursor_type = nullptr;
if (id == CSSValueID::kHand) {
if (!in_quirks_mode) // Non-standard behavior
return nullptr;
cursor_type = CSSIdentifierValue::Create(CSSValueID::kPointer);
range.ConsumeIncludingWhitespace();
} else if ((id >= CSSValueID::kAuto && id <= CSSValueID::kWebkitZoomOut) ||
id == CSSValueID::kCopy || id == CSSValueID::kNone) {
cursor_type = css_parsing_utils::ConsumeIdent(range);
} else {
return nullptr;
}
if (!list)
return cursor_type;
list->Append(*cursor_type);
return list;
}
const CSSValue* Cursor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = nullptr;
CursorList* cursors = style.Cursors();
if (cursors && cursors->size() > 0) {
list = CSSValueList::CreateCommaSeparated();
for (const CursorData& cursor : *cursors) {
if (StyleImage* image = cursor.GetImage()) {
list->Append(*MakeGarbageCollected<cssvalue::CSSCursorImageValue>(
*image->ComputedCSSValue(style, allow_visited_style),
cursor.HotSpotSpecified(), cursor.HotSpot()));
}
}
}
CSSValue* value = CSSIdentifierValue::Create(style.Cursor());
if (list) {
list->Append(*value);
return list;
}
return value;
}
void Cursor::ApplyInitial(StyleResolverState& state) const {
state.Style()->ClearCursorList();
state.Style()->SetCursor(ComputedStyleInitialValues::InitialCursor());
}
void Cursor::ApplyInherit(StyleResolverState& state) const {
state.Style()->SetCursor(state.ParentStyle()->Cursor());
state.Style()->SetCursorList(state.ParentStyle()->Cursors());
}
void Cursor::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.Style()->ClearCursorList();
if (auto* value_list = DynamicTo<CSSValueList>(value)) {
state.Style()->SetCursor(ECursor::kAuto);
for (const auto& item : *value_list) {
if (const auto* cursor =
DynamicTo<cssvalue::CSSCursorImageValue>(*item)) {
const CSSValue& image = cursor->ImageValue();
state.Style()->AddCursor(
state.GetStyleImage(CSSPropertyID::kCursor, image),
cursor->HotSpotSpecified(), cursor->HotSpot());
} else {
state.Style()->SetCursor(
To<CSSIdentifierValue>(*item).ConvertTo<ECursor>());
}
}
} else {
state.Style()->SetCursor(
To<CSSIdentifierValue>(value).ConvertTo<ECursor>());
}
}
const CSSValue* Cx::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeSVGGeometryPropertyLength(range, context,
kValueRangeAll);
}
const CSSValue* Cx::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(style.Cx(), style);
}
const CSSValue* Cy::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeSVGGeometryPropertyLength(range, context,
kValueRangeAll);
}
const CSSValue* Cy::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(style.Cy(), style);
}
const CSSValue* D::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumePathOrNone(range);
}
const CSSValue* D::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (const StylePath* style_path = style.D())
return style_path->ComputedCSSValue();
return CSSIdentifierValue::Create(CSSValueID::kNone);
}
const CSSValue* Direction::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.Direction());
}
void Direction::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.Style()->SetDirection(
To<CSSIdentifierValue>(value).ConvertTo<TextDirection>());
}
namespace {
static bool IsDisplayOutside(CSSValueID id) {
return id >= CSSValueID::kInline && id <= CSSValueID::kBlock;
}
static bool IsDisplayInside(CSSValueID id) {
if (id >= CSSValueID::kFlowRoot && id <= CSSValueID::kGrid)
return true;
if (id == CSSValueID::kMath)
return RuntimeEnabledFeatures::MathMLCoreEnabled();
return false;
}
static bool IsDisplayBox(CSSValueID id) {
return css_parsing_utils::IdentMatches<CSSValueID::kNone,
CSSValueID::kContents>(id);
}
static bool IsDisplayInternal(CSSValueID id) {
return id >= CSSValueID::kTableRowGroup && id <= CSSValueID::kTableCaption;
}
static bool IsDisplayLegacy(CSSValueID id) {
return id >= CSSValueID::kInlineBlock && id <= CSSValueID::kWebkitInlineFlex;
}
} // namespace
const CSSValue* Display::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValueID id = range.Peek().Id();
CSSIdentifierValue* display_outside = nullptr;
CSSIdentifierValue* display_inside = nullptr;
if (IsDisplayOutside(id)) {
display_outside = css_parsing_utils::ConsumeIdent(range);
if (range.AtEnd())
return display_outside;
id = range.Peek().Id();
if (!IsDisplayInside(id))
return nullptr;
display_inside = css_parsing_utils::ConsumeIdent(range);
} else if (IsDisplayInside(id)) {
display_inside = css_parsing_utils::ConsumeIdent(range);
if (range.AtEnd())
return display_inside;
id = range.Peek().Id();
if (!IsDisplayOutside(id))
return nullptr;
display_outside = css_parsing_utils::ConsumeIdent(range);
}
if (display_outside && display_inside) {
// TODO(crbug.com/995106): should apply to more than just math.
if (display_inside->GetValueID() == CSSValueID::kMath) {
CSSValueList* parsed_values = CSSValueList::CreateSpaceSeparated();
parsed_values->Append(*display_outside);
parsed_values->Append(*display_inside);
return parsed_values;
}
return nullptr;
}
if (id == CSSValueID::kListItem || IsDisplayBox(id) ||
IsDisplayInternal(id) || IsDisplayLegacy(id))
return css_parsing_utils::ConsumeIdent(range);
if (!RuntimeEnabledFeatures::CSSLayoutAPIEnabled())
return nullptr;
if (!context.IsSecureContext())
return nullptr;
CSSValueID function = range.Peek().FunctionId();
if (function != CSSValueID::kLayout && function != CSSValueID::kInlineLayout)
return nullptr;
CSSParserTokenRange range_copy = range;
CSSParserTokenRange args = css_parsing_utils::ConsumeFunction(range_copy);
CSSCustomIdentValue* name =
css_parsing_utils::ConsumeCustomIdent(args, context);
// If we didn't get a custom-ident or didn't exhaust the function arguments
// return nothing.
if (!name || !args.AtEnd())
return nullptr;
range = range_copy;
return MakeGarbageCollected<cssvalue::CSSLayoutFunctionValue>(
name, /* is_inline */ function == CSSValueID::kInlineLayout);
}
const CSSValue* Display::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.IsDisplayLayoutCustomBox()) {
return MakeGarbageCollected<cssvalue::CSSLayoutFunctionValue>(
MakeGarbageCollected<CSSCustomIdentValue>(
style.DisplayLayoutCustomName()),
style.IsDisplayInlineType());
}
if (style.Display() == EDisplay::kBlockMath) {
CSSValueList* values = CSSValueList::CreateSpaceSeparated();
values->Append(*CSSIdentifierValue::Create(CSSValueID::kBlock));
values->Append(*CSSIdentifierValue::Create(CSSValueID::kMath));
return values;
}
return CSSIdentifierValue::Create(style.Display());
}
void Display::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetDisplay(ComputedStyleInitialValues::InitialDisplay());
state.Style()->SetDisplayLayoutCustomName(
ComputedStyleInitialValues::InitialDisplayLayoutCustomName());
}
void Display::ApplyInherit(StyleResolverState& state) const {
state.Style()->SetDisplay(state.ParentStyle()->Display());
state.Style()->SetDisplayLayoutCustomName(
state.ParentStyle()->DisplayLayoutCustomName());
}
void Display::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
if (auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) {
state.Style()->SetDisplay(identifier_value->ConvertTo<EDisplay>());
state.Style()->SetDisplayLayoutCustomName(
ComputedStyleInitialValues::InitialDisplayLayoutCustomName());
return;
}
if (value.IsValueList()) {
state.Style()->SetDisplayLayoutCustomName(
ComputedStyleInitialValues::InitialDisplayLayoutCustomName());
const CSSValueList& display_pair = To<CSSValueList>(value);
DCHECK_EQ(display_pair.length(), 2u);
DCHECK(display_pair.Item(0).IsIdentifierValue());
DCHECK(display_pair.Item(1).IsIdentifierValue());
const auto& outside = To<CSSIdentifierValue>(display_pair.Item(0));
const auto& inside = To<CSSIdentifierValue>(display_pair.Item(1));
// TODO(crbug.com/995106): should apply to more than just math.
DCHECK(inside.GetValueID() == CSSValueID::kMath);
if (outside.GetValueID() == CSSValueID::kBlock)
state.Style()->SetDisplay(EDisplay::kBlockMath);
else
state.Style()->SetDisplay(EDisplay::kMath);
return;
}
const auto& layout_function_value =
To<cssvalue::CSSLayoutFunctionValue>(value);
EDisplay display = layout_function_value.IsInline()
? EDisplay::kInlineLayoutCustom
: EDisplay::kLayoutCustom;
state.Style()->SetDisplay(display);
state.Style()->SetDisplayLayoutCustomName(layout_function_value.GetName());
}
const CSSValue* DominantBaseline::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.DominantBaseline());
}
const CSSValue* EmptyCells::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.EmptyCells());
}
const CSSValue* Fill::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeSVGPaint(range, context);
}
const CSSValue* Fill::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForSVGPaint(style.FillPaint(), style);
}
const blink::Color Fill::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
DCHECK(style.FillPaint().HasColor());
const StyleColor& fill_color = style.FillPaint().GetColor();
if (style.ShouldForceColor(fill_color))
return style.GetInternalForcedCurrentColor();
return fill_color.Resolve(style.GetCurrentColor(), style.UsedColorScheme());
}
const CSSValue* FillOpacity::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeAlphaValue(range, context);
}
const CSSValue* FillOpacity::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.FillOpacity(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* FillRule::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.FillRule());
}
const CSSValue* Filter::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeFilterFunctionList(range, context);
}
const CSSValue* Filter::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForFilter(style, style.Filter());
}
void Filter::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.Style()->SetFilter(StyleBuilderConverter::ConvertFilterOperations(
state, value, PropertyID()));
}
const CSSValue* FlexBasis::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
// FIXME: Support intrinsic dimensions too.
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeLengthOrPercent(range, context,
kValueRangeNonNegative);
}
const CSSValue* FlexBasis::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(style.FlexBasis(),
style);
}
const CSSValue* FlexDirection::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.FlexDirection());
}
const CSSValue* FlexGrow::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeNumber(range, context,
kValueRangeNonNegative);
}
const CSSValue* FlexGrow::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.FlexGrow(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* FlexShrink::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeNumber(range, context,
kValueRangeNonNegative);
}
const CSSValue* FlexShrink::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.FlexShrink(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* FlexWrap::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.FlexWrap());
}
const CSSValue* Float::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.HasOutOfFlowPosition())
return CSSIdentifierValue::Create(CSSValueID::kNone);
return CSSIdentifierValue::Create(style.Floating());
}
const CSSValue* FloodColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color FloodColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
StyleColor flood_color = style.FloodColor();
if (style.ShouldForceColor(flood_color))
return style.GetInternalForcedCurrentColor();
return style.ResolvedColor(flood_color);
}
const CSSValue* FloodColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::CurrentColorOrValidColor(
style, style.FloodColor(), CSSValuePhase::kComputedValue);
}
const CSSValue* FloodOpacity::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeAlphaValue(range, context);
}
const CSSValue* FloodOpacity::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.FloodOpacity(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* FontFamily::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeFontFamily(range);
}
const CSSValue* FontFamily::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForFontFamily(style);
}
void FontFamily::ApplyValue(StyleResolverState& state,
const ScopedCSSValue& scoped_value) const {
state.GetFontBuilder().SetFamilyTreeScope(scoped_value.GetTreeScope());
ApplyValue(state, scoped_value.GetCSSValue());
}
void FontFamily::ApplyInitial(StyleResolverState& state) const {
state.GetFontBuilder().SetFamilyDescription(
FontBuilder::InitialFamilyDescription());
state.GetFontBuilder().SetFamilyTreeScope(nullptr);
}
void FontFamily::ApplyInherit(StyleResolverState& state) const {
state.GetFontBuilder().SetFamilyDescription(
state.ParentFontDescription().GetFamilyDescription());
CSSFontSelector* selector = static_cast<CSSFontSelector*>(
state.ParentStyle()->GetFont().GetFontSelector());
const TreeScope* tree_scope = selector ? selector->GetTreeScope() : nullptr;
state.GetFontBuilder().SetFamilyTreeScope(tree_scope);
}
const CSSValue* FontFeatureSettings::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeFontFeatureSettings(range, context);
}
const CSSValue* FontFeatureSettings::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
const blink::FontFeatureSettings* feature_settings =
style.GetFontDescription().FeatureSettings();
if (!feature_settings || !feature_settings->size())
return CSSIdentifierValue::Create(CSSValueID::kNormal);
CSSValueList* list = CSSValueList::CreateCommaSeparated();
for (wtf_size_t i = 0; i < feature_settings->size(); ++i) {
const FontFeature& feature = feature_settings->at(i);
auto* feature_value = MakeGarbageCollected<cssvalue::CSSFontFeatureValue>(
feature.TagString(), feature.Value());
list->Append(*feature_value);
}
return list;
}
const CSSValue* FontKerning::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetFontDescription().GetKerning());
}
const CSSValue* FontOpticalSizing::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(
style.GetFontDescription().FontOpticalSizing());
}
const CSSValue* FontSizeAdjust::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
DCHECK(RuntimeEnabledFeatures::CSSFontSizeAdjustEnabled());
if (range.Peek().Id() == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeNumber(range, context,
kValueRangeNonNegative);
}
const CSSValue* FontSizeAdjust::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.HasFontSizeAdjust()) {
return CSSNumericLiteralValue::Create(style.FontSizeAdjust(),
CSSPrimitiveValue::UnitType::kNumber);
}
return CSSIdentifierValue::Create(CSSValueID::kNone);
}
const CSSValue* FontSize::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeFontSize(
range, context, css_parsing_utils::UnitlessQuirk::kAllow);
}
const CSSValue* FontSize::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForFontSize(style);
}
const CSSValue* FontStretch::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeFontStretch(range, context);
}
const CSSValue* FontStretch::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForFontStretch(style);
}
const CSSValue* FontStyle::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeFontStyle(range, context);
}
const CSSValue* FontStyle::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForFontStyle(style);
}
const CSSValue* FontVariantCaps::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeIdent<
CSSValueID::kNormal, CSSValueID::kSmallCaps, CSSValueID::kAllSmallCaps,
CSSValueID::kPetiteCaps, CSSValueID::kAllPetiteCaps, CSSValueID::kUnicase,
CSSValueID::kTitlingCaps>(range);
}
const CSSValue* FontVariantCaps::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForFontVariantCaps(style);
}
const CSSValue* FontVariantEastAsian::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNormal)
return css_parsing_utils::ConsumeIdent(range);
FontVariantEastAsianParser east_asian_parser;
do {
if (east_asian_parser.ConsumeEastAsian(range) !=
FontVariantEastAsianParser::ParseResult::kConsumedValue)
return nullptr;
} while (!range.AtEnd());
return east_asian_parser.FinalizeValue();
}
const CSSValue* FontVariantEastAsian::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForFontVariantEastAsian(style);
}
const CSSValue* FontVariantLigatures::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNormal ||
range.Peek().Id() == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
FontVariantLigaturesParser ligatures_parser;
do {
if (ligatures_parser.ConsumeLigature(range) !=
FontVariantLigaturesParser::ParseResult::kConsumedValue)
return nullptr;
} while (!range.AtEnd());
return ligatures_parser.FinalizeValue();
}
const CSSValue* FontVariantLigatures::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForFontVariantLigatures(style);
}
const CSSValue* FontVariantNumeric::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNormal)
return css_parsing_utils::ConsumeIdent(range);
FontVariantNumericParser numeric_parser;
do {
if (numeric_parser.ConsumeNumeric(range) !=
FontVariantNumericParser::ParseResult::kConsumedValue)
return nullptr;
} while (!range.AtEnd());
return numeric_parser.FinalizeValue();
}
const CSSValue* FontVariantNumeric::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForFontVariantNumeric(style);
}
namespace {
cssvalue::CSSFontVariationValue* ConsumeFontVariationTag(
CSSParserTokenRange& range,
const CSSParserContext& context) {
// Feature tag name consists of 4-letter characters.
static const wtf_size_t kTagNameLength = 4;
const CSSParserToken& token = range.ConsumeIncludingWhitespace();
// Feature tag name comes first
if (token.GetType() != kStringToken)
return nullptr;
if (token.Value().length() != kTagNameLength)
return nullptr;
AtomicString tag = token.Value().ToAtomicString();
for (wtf_size_t i = 0; i < kTagNameLength; ++i) {
// Limits the range of characters to 0x20-0x7E, following the tag name rules
// defined in the OpenType specification.
UChar character = tag[i];
if (character < 0x20 || character > 0x7E)
return nullptr;
}
double tag_value = 0;
if (!css_parsing_utils::ConsumeNumberRaw(range, context, tag_value))
return nullptr;
return MakeGarbageCollected<cssvalue::CSSFontVariationValue>(
tag, clampTo<float>(tag_value));
}
} // namespace
const CSSValue* FontVariationSettings::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNormal)
return css_parsing_utils::ConsumeIdent(range);
CSSValueList* variation_settings = CSSValueList::CreateCommaSeparated();
do {
cssvalue::CSSFontVariationValue* font_variation_value =
ConsumeFontVariationTag(range, context);
if (!font_variation_value)
return nullptr;
variation_settings->Append(*font_variation_value);
} while (css_parsing_utils::ConsumeCommaIncludingWhitespace(range));
return variation_settings;
}
const CSSValue* FontVariationSettings::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
const blink::FontVariationSettings* variation_settings =
style.GetFontDescription().VariationSettings();
if (!variation_settings || !variation_settings->size())
return CSSIdentifierValue::Create(CSSValueID::kNormal);
CSSValueList* list = CSSValueList::CreateCommaSeparated();
for (wtf_size_t i = 0; i < variation_settings->size(); ++i) {
const FontVariationAxis& variation_axis = variation_settings->at(i);
cssvalue::CSSFontVariationValue* variation_value =
MakeGarbageCollected<cssvalue::CSSFontVariationValue>(
variation_axis.TagString(), variation_axis.Value());
list->Append(*variation_value);
}
return list;
}
const CSSValue* FontWeight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeFontWeight(range, context);
}
const CSSValue* FontWeight::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForFontWeight(style);
}
const CSSValue* ForcedColorAdjust::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.ForcedColorAdjust());
}
void InternalVisitedColor::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetInternalVisitedColor(
state.Style()->InitialColorForColorScheme());
}
void InternalVisitedColor::ApplyInherit(StyleResolverState& state) const {
auto color = state.ParentStyle()->GetColor();
state.Style()->SetInternalVisitedColor(color);
}
void InternalVisitedColor::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
auto* identifier_value = DynamicTo<CSSIdentifierValue>(value);
if (identifier_value &&
identifier_value->GetValueID() == CSSValueID::kCurrentcolor) {
ApplyInherit(state);
return;
}
if (auto* initial_color_value = DynamicTo<CSSInitialColorValue>(value)) {
DCHECK_EQ(state.GetElement(), state.GetDocument().documentElement());
state.Style()->SetInternalVisitedColor(
state.Style()->InitialColorForColorScheme());
return;
}
state.Style()->SetInternalVisitedColor(
StyleBuilderConverter::ConvertStyleColor(state, value, true));
}
const blink::Color InternalVisitedColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
if (style.ShouldForceColor(style.InternalVisitedColor())) {
return To<Longhand>(GetCSSPropertyInternalForcedVisitedColor())
.ColorIncludingFallback(true, style);
}
return style.GetInternalVisitedCurrentColor();
}
const CSSValue* InternalVisitedColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeColor(range, context,
IsQuirksModeBehavior(context.Mode()));
}
const CSSValue* GridAutoColumns::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeGridTrackList(
range, context, css_parsing_utils::TrackListType::kGridAuto);
}
// Specs mention that getComputedStyle() should return the used value of the
// property instead of the computed one for grid-template-{rows|columns} but
// not for the grid-auto-{rows|columns} as things like grid-auto-columns:
// 2fr; cannot be resolved to a value in pixels as the '2fr' means very
// different things depending on the size of the explicit grid or the number
// of implicit tracks added to the grid. See
// http://lists.w3.org/Archives/Public/www-style/2013Nov/0014.html
const CSSValue* GridAutoColumns::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForGridTrackSizeList(kForColumns, style);
}
const CSSValue* GridAutoFlow::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSIdentifierValue* row_or_column_value =
css_parsing_utils::ConsumeIdent<CSSValueID::kRow, CSSValueID::kColumn>(
range);
CSSIdentifierValue* dense_algorithm =
css_parsing_utils::ConsumeIdent<CSSValueID::kDense>(range);
if (!row_or_column_value) {
row_or_column_value =
css_parsing_utils::ConsumeIdent<CSSValueID::kRow, CSSValueID::kColumn>(
range);
if (!row_or_column_value && !dense_algorithm)
return nullptr;
}
CSSValueList* parsed_values = CSSValueList::CreateSpaceSeparated();
if (row_or_column_value)
parsed_values->Append(*row_or_column_value);
if (dense_algorithm)
parsed_values->Append(*dense_algorithm);
return parsed_values;
}
const CSSValue* GridAutoFlow::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
switch (style.GetGridAutoFlow()) {
case kAutoFlowRow:
case kAutoFlowRowDense:
list->Append(*CSSIdentifierValue::Create(CSSValueID::kRow));
break;
case kAutoFlowColumn:
case kAutoFlowColumnDense:
list->Append(*CSSIdentifierValue::Create(CSSValueID::kColumn));
break;
default:
NOTREACHED();
}
switch (style.GetGridAutoFlow()) {
case kAutoFlowRowDense:
case kAutoFlowColumnDense:
list->Append(*CSSIdentifierValue::Create(CSSValueID::kDense));
break;
default:
// Do nothing.
break;
}
return list;
}
const CSSValue* GridAutoRows::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeGridTrackList(
range, context, css_parsing_utils::TrackListType::kGridAuto);
}
const CSSValue* GridAutoRows::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForGridTrackSizeList(kForRows, style);
}
const CSSValue* GridColumnEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeGridLine(range, context);
}
const CSSValue* GridColumnEnd::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForGridPosition(style.GridColumnEnd());
}
const CSSValue* GridColumnStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeGridLine(range, context);
}
const CSSValue* GridColumnStart::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForGridPosition(style.GridColumnStart());
}
const CSSValue* GridRowEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeGridLine(range, context);
}
const CSSValue* GridRowEnd::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForGridPosition(style.GridRowEnd());
}
const CSSValue* GridRowStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeGridLine(range, context);
}
const CSSValue* GridRowStart::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForGridPosition(style.GridRowStart());
}
const CSSValue* GridTemplateAreas::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
NamedGridAreaMap grid_area_map;
size_t row_count = 0;
size_t column_count = 0;
while (range.Peek().GetType() == kStringToken) {
if (!css_parsing_utils::ParseGridTemplateAreasRow(
range.ConsumeIncludingWhitespace().Value().ToString(),
grid_area_map, row_count, column_count))
return nullptr;
++row_count;
}
if (row_count == 0)
return nullptr;
DCHECK(column_count);
return MakeGarbageCollected<cssvalue::CSSGridTemplateAreasValue>(
grid_area_map, row_count, column_count);
}
const CSSValue* GridTemplateAreas::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (!style.NamedGridAreaRowCount()) {
DCHECK(!style.NamedGridAreaColumnCount());
return CSSIdentifierValue::Create(CSSValueID::kNone);
}
return MakeGarbageCollected<cssvalue::CSSGridTemplateAreasValue>(
style.NamedGridArea(), style.NamedGridAreaRowCount(),
style.NamedGridAreaColumnCount());
}
void GridTemplateAreas::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetImplicitNamedGridColumnLines(
ComputedStyleInitialValues::InitialImplicitNamedGridColumnLines());
state.Style()->SetImplicitNamedGridRowLines(
ComputedStyleInitialValues::InitialImplicitNamedGridRowLines());
state.Style()->SetNamedGridArea(
ComputedStyleInitialValues::InitialNamedGridArea());
state.Style()->SetNamedGridAreaRowCount(
ComputedStyleInitialValues::InitialNamedGridAreaRowCount());
state.Style()->SetNamedGridAreaColumnCount(
ComputedStyleInitialValues::InitialNamedGridAreaColumnCount());
}
void GridTemplateAreas::ApplyInherit(StyleResolverState& state) const {
state.Style()->SetImplicitNamedGridColumnLines(
state.ParentStyle()->ImplicitNamedGridColumnLines());
state.Style()->SetImplicitNamedGridRowLines(
state.ParentStyle()->ImplicitNamedGridRowLines());
state.Style()->SetNamedGridArea(state.ParentStyle()->NamedGridArea());
state.Style()->SetNamedGridAreaRowCount(
state.ParentStyle()->NamedGridAreaRowCount());
state.Style()->SetNamedGridAreaColumnCount(
state.ParentStyle()->NamedGridAreaColumnCount());
}
void GridTemplateAreas::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
if (auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) {
DCHECK_EQ(identifier_value->GetValueID(), CSSValueID::kNone);
ApplyInitial(state);
return;
}
const auto& grid_template_areas_value =
To<cssvalue::CSSGridTemplateAreasValue>(value);
const NamedGridAreaMap& new_named_grid_areas =
grid_template_areas_value.GridAreaMap();
NamedGridLinesMap implicit_named_grid_column_lines;
NamedGridLinesMap implicit_named_grid_row_lines;
StyleBuilderConverter::CreateImplicitNamedGridLinesFromGridArea(
new_named_grid_areas, implicit_named_grid_column_lines, kForColumns);
StyleBuilderConverter::CreateImplicitNamedGridLinesFromGridArea(
new_named_grid_areas, implicit_named_grid_row_lines, kForRows);
state.Style()->SetImplicitNamedGridColumnLines(
implicit_named_grid_column_lines);
state.Style()->SetImplicitNamedGridRowLines(implicit_named_grid_row_lines);
state.Style()->SetNamedGridArea(new_named_grid_areas);
state.Style()->SetNamedGridAreaRowCount(grid_template_areas_value.RowCount());
state.Style()->SetNamedGridAreaColumnCount(
grid_template_areas_value.ColumnCount());
}
const CSSValue* GridTemplateColumns::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeGridTemplatesRowsOrColumns(range, context);
}
bool GridTemplateColumns::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsLayoutGridIncludingNG();
}
const CSSValue* GridTemplateColumns::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForGridTrackList(kForColumns, layout_object,
style);
}
const CSSValue* GridTemplateRows::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeGridTemplatesRowsOrColumns(range, context);
}
bool GridTemplateRows::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsLayoutGridIncludingNG();
}
const CSSValue* GridTemplateRows::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForGridTrackList(kForRows, layout_object,
style);
}
const CSSValue* Height::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeWidthOrHeight(
range, context, css_parsing_utils::UnitlessQuirk::kAllow);
}
bool Height::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && (layout_object->IsBox() || layout_object->IsSVG());
}
const CSSValue* Height::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
if (ComputedStyleUtils::WidthOrHeightShouldReturnUsedValue(layout_object)) {
return ZoomAdjustedPixelValue(
ComputedStyleUtils::UsedBoxSize(*layout_object).Height(), style);
}
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(style.Height(),
style);
}
const CSSValue* Hyphens::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetHyphens());
}
const CSSValue* ImageOrientation::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kFromImage)
return css_parsing_utils::ConsumeIdent(range);
if (range.Peek().Id() == CSSValueID::kNone) {
return css_parsing_utils::ConsumeIdent(range);
}
return nullptr;
}
const CSSValue* ImageOrientation::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.RespectImageOrientation() == kRespectImageOrientation)
return CSSIdentifierValue::Create(CSSValueID::kFromImage);
return CSSIdentifierValue::Create(CSSValueID::kNone);
}
const CSSValue* ImageRendering::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.ImageRendering());
}
const CSSValue* InlineSize::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeWidthOrHeight(range, context);
}
bool InlineSize::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && (layout_object->IsBox() || layout_object->IsSVG());
}
const CSSValue* InsetBlockEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* InsetBlockStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* InsetInlineEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* InsetInlineStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
const blink::Color InternalVisitedBackgroundColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
StyleColor visited_background_color = style.InternalVisitedBackgroundColor();
if (style.ShouldForceColor(visited_background_color)) {
return To<Longhand>(GetCSSPropertyInternalForcedBackgroundColor())
.ColorIncludingFallback(true, style);
}
blink::Color color = visited_background_color.Resolve(
style.GetInternalVisitedCurrentColor(), style.UsedColorScheme());
// TODO: Technically someone could explicitly specify the color
// transparent, but for now we'll just assume that if the background color
// is transparent that it wasn't set. Note that it's weird that we're
// returning unvisited info for a visited link, but given our restriction
// that the alpha values have to match, it makes more sense to return the
// unvisited background color if specified than it does to return black.
// This behavior matches what Firefox 4 does as well.
if (color == blink::Color::kTransparent) {
return style.BackgroundColor().Resolve(style.GetCurrentColor(),
style.UsedColorScheme());
}
return color;
}
const CSSValue* InternalVisitedBackgroundColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeColor(range, context,
IsQuirksModeBehavior(context.Mode()));
}
const blink::Color InternalVisitedBorderLeftColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
StyleColor visited_border_left_color = style.InternalVisitedBorderLeftColor();
if (style.ShouldForceColor(visited_border_left_color)) {
return To<Longhand>(GetCSSPropertyInternalForcedBorderColor())
.ColorIncludingFallback(true, style);
}
return visited_border_left_color.Resolve(
style.GetInternalVisitedCurrentColor(), style.UsedColorScheme());
}
const CSSValue* InternalVisitedBorderLeftColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeBorderColorSide(range, context,
local_context);
}
const blink::Color InternalVisitedBorderTopColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
StyleColor visited_border_top_color = style.InternalVisitedBorderTopColor();
if (style.ShouldForceColor(visited_border_top_color)) {
return To<Longhand>(GetCSSPropertyInternalForcedBorderColor())
.ColorIncludingFallback(true, style);
}
return visited_border_top_color.Resolve(
style.GetInternalVisitedCurrentColor(), style.UsedColorScheme());
}
const CSSValue* InternalVisitedBorderTopColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeBorderColorSide(range, context,
local_context);
}
const blink::Color InternalVisitedCaretColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
StyleAutoColor auto_color = style.InternalVisitedCaretColor();
StyleColor result = auto_color.IsAutoColor() ? StyleColor::CurrentColor()
: auto_color.ToStyleColor();
if (style.ShouldForceColor(result))
return style.GetInternalForcedVisitedCurrentColor();
return result.Resolve(style.GetInternalVisitedCurrentColor(),
style.UsedColorScheme());
}
const CSSValue* InternalVisitedCaretColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return To<Longhand>(GetCSSPropertyCaretColor())
.ParseSingleValue(range, context, local_context);
}
const blink::Color InternalVisitedBorderRightColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
StyleColor visited_border_right_color =
style.InternalVisitedBorderRightColor();
if (style.ShouldForceColor(visited_border_right_color)) {
return To<Longhand>(GetCSSPropertyInternalForcedBorderColor())
.ColorIncludingFallback(true, style);
}
return visited_border_right_color.Resolve(
style.GetInternalVisitedCurrentColor(), style.UsedColorScheme());
}
const CSSValue* InternalVisitedBorderRightColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeBorderColorSide(range, context,
local_context);
}
const blink::Color InternalVisitedBorderBottomColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
StyleColor visited_border_bottom_color =
style.InternalVisitedBorderBottomColor();
if (style.ShouldForceColor(visited_border_bottom_color)) {
return To<Longhand>(GetCSSPropertyInternalForcedBorderColor())
.ColorIncludingFallback(true, style);
}
return visited_border_bottom_color.Resolve(
style.GetInternalVisitedCurrentColor(), style.UsedColorScheme());
}
const CSSValue* InternalVisitedBorderBottomColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeBorderColorSide(range, context,
local_context);
}
const CSSValue* InternalVisitedBorderInlineStartColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeBorderColorSide(range, context,
local_context);
}
const CSSValue* InternalVisitedBorderInlineEndColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeBorderColorSide(range, context,
local_context);
}
const CSSValue* InternalVisitedBorderBlockStartColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeBorderColorSide(range, context,
local_context);
}
const CSSValue* InternalVisitedBorderBlockEndColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeBorderColorSide(range, context,
local_context);
}
const CSSValue* InternalVisitedFill::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeSVGPaint(range, context);
}
const blink::Color InternalVisitedFill::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
const SVGPaint& paint = style.InternalVisitedFillPaint();
// FIXME: This code doesn't support the uri component of the visited link
// paint, https://bugs.webkit.org/show_bug.cgi?id=70006
if (!paint.HasColor()) {
return To<Longhand>(GetCSSPropertyFill())
.ColorIncludingFallback(false, style);
}
const StyleColor& visited_fill_color = paint.GetColor();
if (style.ShouldForceColor(visited_fill_color))
return style.GetInternalForcedVisitedCurrentColor();
return visited_fill_color.Resolve(style.GetInternalVisitedCurrentColor(),
style.UsedColorScheme());
}
const blink::Color InternalVisitedColumnRuleColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
StyleColor visited_column_rule_color = style.InternalVisitedColumnRuleColor();
if (style.ShouldForceColor(visited_column_rule_color))
return style.GetInternalForcedVisitedCurrentColor();
return visited_column_rule_color.Resolve(
style.GetInternalVisitedCurrentColor(), style.UsedColorScheme());
}
const CSSValue* InternalVisitedColumnRuleColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color InternalVisitedOutlineColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
StyleColor visited_outline_color = style.InternalVisitedOutlineColor();
if (style.ShouldForceColor(visited_outline_color)) {
return To<Longhand>(GetCSSPropertyInternalForcedOutlineColor())
.ColorIncludingFallback(true, style);
}
return visited_outline_color.Resolve(style.GetInternalVisitedCurrentColor(),
style.UsedColorScheme());
}
const CSSValue* InternalVisitedOutlineColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return To<Longhand>(GetCSSPropertyOutlineColor())
.ParseSingleValue(range, context, local_context);
}
const CSSValue* InternalVisitedStroke::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeSVGPaint(range, context);
}
const blink::Color InternalVisitedStroke::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
const SVGPaint& paint = style.InternalVisitedStrokePaint();
// FIXME: This code doesn't support the uri component of the visited link
// paint, https://bugs.webkit.org/show_bug.cgi?id=70006
if (!paint.HasColor()) {
return To<Longhand>(GetCSSPropertyStroke())
.ColorIncludingFallback(false, style);
}
const StyleColor& visited_stroke_color = paint.GetColor();
if (style.ShouldForceColor(visited_stroke_color))
return style.GetInternalForcedVisitedCurrentColor();
return visited_stroke_color.Resolve(style.GetInternalVisitedCurrentColor(),
style.UsedColorScheme());
}
const blink::Color InternalVisitedTextDecorationColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
StyleColor visited_decoration_color =
style.DecorationColorIncludingFallback(visited_link);
if (style.ShouldForceColor(visited_decoration_color))
return style.GetInternalForcedVisitedCurrentColor();
return visited_decoration_color.Resolve(
style.GetInternalVisitedCurrentColor(), style.UsedColorScheme());
}
const CSSValue* InternalVisitedTextDecorationColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color InternalVisitedTextEmphasisColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
StyleColor visited_text_emphasis_color =
style.InternalVisitedTextEmphasisColor();
if (style.ShouldForceColor(visited_text_emphasis_color))
return style.GetInternalForcedVisitedCurrentColor();
return visited_text_emphasis_color.Resolve(
style.GetInternalVisitedCurrentColor(), style.UsedColorScheme());
}
const CSSValue* InternalVisitedTextEmphasisColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color InternalVisitedTextFillColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
StyleColor visited_text_fill_color = style.InternalVisitedTextFillColor();
if (style.ShouldForceColor(visited_text_fill_color))
return style.GetInternalForcedVisitedCurrentColor();
return visited_text_fill_color.Resolve(style.GetInternalVisitedCurrentColor(),
style.UsedColorScheme());
}
const CSSValue* InternalVisitedTextFillColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color InternalVisitedTextStrokeColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
StyleColor visited_text_stroke_color = style.InternalVisitedTextStrokeColor();
if (style.ShouldForceColor(visited_text_stroke_color))
return style.GetInternalForcedVisitedCurrentColor();
return visited_text_stroke_color.Resolve(
style.GetInternalVisitedCurrentColor(), style.UsedColorScheme());
}
const CSSValue* InternalVisitedTextStrokeColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color InternalForcedBackgroundColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
blink::Color forced_current_color;
int alpha;
if (visited_link) {
forced_current_color = style.GetInternalForcedVisitedCurrentColor();
alpha = style.InternalVisitedBackgroundColor()
.Resolve(style.GetInternalVisitedCurrentColor(),
style.UsedColorScheme())
.Alpha();
} else {
forced_current_color = style.GetInternalForcedCurrentColor();
alpha = style.BackgroundColor()
.Resolve(style.GetCurrentColor(), style.UsedColorScheme())
.Alpha();
}
return style.InternalForcedBackgroundColor().ResolveWithAlpha(
forced_current_color, style.UsedColorScheme(), alpha,
/* is_forced_color */ true);
}
const CSSValue*
InternalForcedBackgroundColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
bool visited_link = allow_visited_style &&
style.InsideLink() == EInsideLink::kInsideVisitedLink;
return cssvalue::CSSColor::Create(
ColorIncludingFallback(visited_link, style).Rgb());
}
const CSSValue* InternalForcedBackgroundColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeColor(range, context,
IsQuirksModeBehavior(context.Mode()));
}
const blink::Color InternalForcedBorderColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
blink::Color current_color =
visited_link ? style.GetInternalForcedVisitedCurrentColor()
: style.GetInternalForcedCurrentColor();
return style.InternalForcedBorderColor().Resolve(current_color,
style.UsedColorScheme());
}
const CSSValue* InternalForcedBorderColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
bool visited_link = allow_visited_style &&
style.InsideLink() == EInsideLink::kInsideVisitedLink;
return cssvalue::CSSColor::Create(
ColorIncludingFallback(visited_link, style).Rgb());
}
const CSSValue* InternalForcedBorderColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeColor(range, context,
IsQuirksModeBehavior(context.Mode()));
}
void InternalForcedColor::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetInternalForcedColor(
ComputedStyleInitialValues::InitialInternalForcedColor());
}
void InternalForcedColor::ApplyInherit(StyleResolverState& state) const {
auto color = state.ParentStyle()->InternalForcedColor();
state.Style()->SetInternalForcedColor(color);
}
void InternalForcedColor::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
auto* identifier_value = DynamicTo<CSSIdentifierValue>(value);
if (identifier_value &&
identifier_value->GetValueID() == CSSValueID::kCurrentcolor) {
ApplyInherit(state);
return;
}
if (auto* initial_color_value = DynamicTo<CSSInitialColorValue>(value)) {
DCHECK_EQ(state.GetElement(), state.GetDocument().documentElement());
state.Style()->SetInternalForcedColor(
ComputedStyleInitialValues::InitialInternalForcedColor());
return;
}
state.Style()->SetInternalForcedColor(
StyleBuilderConverter::ConvertStyleColor(state, value));
}
const blink::Color InternalForcedColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
return style.GetInternalForcedCurrentColor();
}
const CSSValue* InternalForcedColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return cssvalue::CSSColor::Create(
allow_visited_style ? style.VisitedDependentColor(*this).Rgb()
: style.GetInternalForcedCurrentColor().Rgb());
}
const CSSValue* InternalForcedColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeColor(range, context,
IsQuirksModeBehavior(context.Mode()));
}
const blink::Color InternalForcedOutlineColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
blink::Color current_color =
visited_link ? style.GetInternalForcedVisitedCurrentColor()
: style.GetInternalForcedCurrentColor();
return style.InternalForcedOutlineColor().Resolve(current_color,
style.UsedColorScheme());
}
const CSSValue* InternalForcedOutlineColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
bool visited_link = allow_visited_style &&
style.InsideLink() == EInsideLink::kInsideVisitedLink;
return cssvalue::CSSColor::Create(
ColorIncludingFallback(visited_link, style).Rgb());
}
const CSSValue* InternalForcedOutlineColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeColor(range, context,
IsQuirksModeBehavior(context.Mode()));
}
void InternalForcedVisitedColor::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetInternalForcedVisitedColor(
ComputedStyleInitialValues::InitialInternalForcedVisitedColor());
}
void InternalForcedVisitedColor::ApplyInherit(StyleResolverState& state) const {
auto color = state.ParentStyle()->InternalForcedVisitedColor();
state.Style()->SetInternalForcedVisitedColor(color);
}
void InternalForcedVisitedColor::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
auto* identifier_value = DynamicTo<CSSIdentifierValue>(value);
if (identifier_value &&
identifier_value->GetValueID() == CSSValueID::kCurrentcolor) {
ApplyInherit(state);
return;
}
if (auto* initial_color_value = DynamicTo<CSSInitialColorValue>(value)) {
DCHECK_EQ(state.GetElement(), state.GetDocument().documentElement());
state.Style()->SetInternalForcedVisitedColor(
ComputedStyleInitialValues::InitialInternalForcedVisitedColor());
return;
}
state.Style()->SetInternalForcedVisitedColor(
StyleBuilderConverter::ConvertStyleColor(state, value, true));
}
const blink::Color InternalForcedVisitedColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(visited_link);
return style.GetInternalForcedVisitedCurrentColor();
}
const CSSValue* InternalForcedVisitedColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeColor(range, context,
IsQuirksModeBehavior(context.Mode()));
}
const CSSValue* Isolation::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.Isolation());
}
const CSSValue* JustifyContent::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
// justify-content property does not allow the <baseline-position> values.
if (css_parsing_utils::IdentMatches<CSSValueID::kFirst, CSSValueID::kLast,
CSSValueID::kBaseline>(range.Peek().Id()))
return nullptr;
return css_parsing_utils::ConsumeContentDistributionOverflowPosition(
range, css_parsing_utils::IsContentPositionOrLeftOrRightKeyword);
}
const CSSValue* JustifyContent::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::
ValueForContentPositionAndDistributionWithOverflowAlignment(
style.JustifyContent());
}
const CSSValue* JustifyItems::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSParserTokenRange range_copy = range;
// justify-items property does not allow the 'auto' value.
if (css_parsing_utils::IdentMatches<CSSValueID::kAuto>(range.Peek().Id()))
return nullptr;
CSSIdentifierValue* legacy =
css_parsing_utils::ConsumeIdent<CSSValueID::kLegacy>(range_copy);
CSSIdentifierValue* position_keyword =
css_parsing_utils::ConsumeIdent<CSSValueID::kCenter, CSSValueID::kLeft,
CSSValueID::kRight>(range_copy);
if (!legacy) {
legacy = css_parsing_utils::ConsumeIdent<CSSValueID::kLegacy>(range_copy);
}
if (legacy) {
range = range_copy;
if (position_keyword) {
context.Count(WebFeature::kCSSLegacyAlignment);
return MakeGarbageCollected<CSSValuePair>(
legacy, position_keyword, CSSValuePair::kDropIdenticalValues);
}
return legacy;
}
return css_parsing_utils::ConsumeSelfPositionOverflowPosition(
range, css_parsing_utils::IsSelfPositionOrLeftOrRightKeyword);
}
const CSSValue* JustifyItems::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForItemPositionWithOverflowAlignment(
style.JustifyItems().GetPosition() == ItemPosition::kAuto
? ComputedStyleInitialValues::InitialDefaultAlignment()
: style.JustifyItems());
}
const CSSValue* JustifySelf::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeSelfPositionOverflowPosition(
range, css_parsing_utils::IsSelfPositionOrLeftOrRightKeyword);
}
const CSSValue* JustifySelf::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForItemPositionWithOverflowAlignment(
style.JustifySelf());
}
const CSSValue* Left::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context,
css_parsing_utils::UnitlessUnlessShorthand(local_context));
}
bool Left::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* Left::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForPositionOffset(style, *this,
layout_object);
}
const CSSValue* LetterSpacing::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ParseSpacing(range, context);
}
const CSSValue* LetterSpacing::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (!style.LetterSpacing())
return CSSIdentifierValue::Create(CSSValueID::kNormal);
return ZoomAdjustedPixelValue(style.LetterSpacing(), style);
}
const CSSValue* LightingColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color LightingColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
StyleColor lighting_color = style.LightingColor();
if (style.ShouldForceColor(lighting_color))
return style.GetInternalForcedCurrentColor();
return style.ResolvedColor(lighting_color);
}
const CSSValue* LightingColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::CurrentColorOrValidColor(
style, style.LightingColor(), CSSValuePhase::kComputedValue);
}
const CSSValue* LineBreak::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetLineBreak());
}
const CSSValue* LineHeight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeLineHeight(range, context);
}
const CSSValue* LineHeight::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForLineHeight(style);
}
const CSSValue* LineHeightStep::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeLength(range, context,
kValueRangeNonNegative);
}
const CSSValue* LineHeightStep::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.LineHeightStep(), style);
}
const CSSValue* ListStyleImage::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeImageOrNone(range, context);
}
const CSSValue* ListStyleImage::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.ListStyleImage())
return style.ListStyleImage()->ComputedCSSValue(style, allow_visited_style);
return CSSIdentifierValue::Create(CSSValueID::kNone);
}
void ListStyleImage::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.Style()->SetListStyleImage(
state.GetStyleImage(CSSPropertyID::kListStyleImage, value));
}
const CSSValue* ListStylePosition::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.ListStylePosition());
}
const CSSValue* ListStyleType::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (auto* none = css_parsing_utils::ConsumeIdent<CSSValueID::kNone>(range))
return none;
if (auto* counter_style_name =
css_parsing_utils::ConsumeCounterStyleName(range, context))
return counter_style_name;
return css_parsing_utils::ConsumeString(range);
}
const CSSValue* ListStyleType::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (!style.GetListStyleType())
return CSSIdentifierValue::Create(CSSValueID::kNone);
if (style.GetListStyleType()->IsString()) {
return MakeGarbageCollected<CSSStringValue>(
style.GetListStyleType()->GetStringValue());
}
// TODO(crbug.com/687225): Return a scoped CSSValue?
return MakeGarbageCollected<CSSCustomIdentValue>(
style.GetListStyleType()->GetCounterStyleName());
}
void ListStyleType::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetListStyleType(
ComputedStyleInitialValues::InitialListStyleType());
}
void ListStyleType::ApplyInherit(StyleResolverState& state) const {
state.Style()->SetListStyleType(state.ParentStyle()->GetListStyleType());
}
void ListStyleType::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
NOTREACHED();
}
void ListStyleType::ApplyValue(StyleResolverState& state,
const ScopedCSSValue& scoped_value) const {
const CSSValue& value = scoped_value.GetCSSValue();
if (const auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) {
DCHECK_EQ(CSSValueID::kNone, identifier_value->GetValueID());
state.Style()->SetListStyleType(nullptr);
return;
}
if (const auto* string_value = DynamicTo<CSSStringValue>(value)) {
state.Style()->SetListStyleType(
ListStyleTypeData::CreateString(AtomicString(string_value->Value())));
return;
}
DCHECK(value.IsCustomIdentValue());
const auto& custom_ident_value = To<CSSCustomIdentValue>(value);
state.Style()->SetListStyleType(ListStyleTypeData::CreateCounterStyle(
custom_ident_value.Value(), scoped_value.GetTreeScope()));
}
bool MarginBlockEnd::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* MarginBlockEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
bool MarginBlockStart::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* MarginBlockStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* MarginBottom::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context, css_parsing_utils::UnitlessQuirk::kAllow);
}
bool MarginBottom::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox() &&
(!style || !style->MarginBottom().IsFixed());
}
const CSSValue* MarginBottom::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
const Length& margin_bottom = style.MarginBottom();
if (margin_bottom.IsFixed() || !layout_object || !layout_object->IsBox()) {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(margin_bottom,
style);
}
return ZoomAdjustedPixelValue(To<LayoutBox>(layout_object)->MarginBottom(),
style);
}
bool MarginInlineEnd::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* MarginInlineEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
bool MarginInlineStart::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* MarginInlineStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* MarginLeft::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context, css_parsing_utils::UnitlessQuirk::kAllow);
}
bool MarginLeft::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox() &&
(!style || !style->MarginLeft().IsFixed());
}
const CSSValue* MarginLeft::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
const Length& margin_left = style.MarginLeft();
if (margin_left.IsFixed() || !layout_object || !layout_object->IsBox()) {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(margin_left,
style);
}
return ZoomAdjustedPixelValue(To<LayoutBox>(layout_object)->MarginLeft(),
style);
}
const CSSValue* MarginRight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context, css_parsing_utils::UnitlessQuirk::kAllow);
}
bool MarginRight::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox() &&
(!style || !style->MarginRight().IsFixed());
}
const CSSValue* MarginRight::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
const Length& margin_right = style.MarginRight();
if (margin_right.IsFixed() || !layout_object || !layout_object->IsBox()) {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(margin_right,
style);
}
float value;
const auto& box = *To<LayoutBox>(layout_object);
if (margin_right.IsPercentOrCalc()) {
// LayoutBox gives a marginRight() that is the distance between the
// right-edge of the child box and the right-edge of the containing box,
// when display == EDisplay::kBlock. Let's calculate the absolute value
// of the specified margin-right % instead of relying on LayoutBox's
// marginRight() value.
value = MinimumValueForLength(margin_right,
box.ContainingBlockLogicalWidthForContent())
.ToFloat();
} else {
value = box.MarginRight().ToFloat();
}
return ZoomAdjustedPixelValue(value, style);
}
const CSSValue* MarginTop::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context, css_parsing_utils::UnitlessQuirk::kAllow);
}
bool MarginTop::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox() &&
(!style || !style->MarginTop().IsFixed());
}
const CSSValue* MarginTop::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
const Length& margin_top = style.MarginTop();
if (margin_top.IsFixed() || !layout_object || !layout_object->IsBox()) {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(margin_top,
style);
}
return ZoomAdjustedPixelValue(To<LayoutBox>(layout_object)->MarginTop(),
style);
}
const CSSValue* MarkerEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeUrl(range, context);
}
const CSSValue* MarkerEnd::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForSVGResource(style.MarkerEndResource());
}
const CSSValue* MarkerMid::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeUrl(range, context);
}
const CSSValue* MarkerMid::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForSVGResource(style.MarkerMidResource());
}
const CSSValue* MarkerStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeUrl(range, context);
}
const CSSValue* MarkerStart::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForSVGResource(style.MarkerStartResource());
}
const CSSValue* Mask::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeUrl(range, context);
}
const CSSValue* Mask::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForSVGResource(style.MaskerResource());
}
const CSSValue* MaskType::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.MaskType());
}
const CSSValue* MathShift::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.MathShift());
}
const CSSValue* MathStyle::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.MathStyle());
}
const CSSValue* MathDepth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMathDepth(range, context);
}
const CSSValue* MathDepth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.MathDepth(),
CSSPrimitiveValue::UnitType::kNumber);
}
void MathDepth::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
if (const auto* list = DynamicTo<CSSValueList>(value)) {
DCHECK_EQ(list->length(), 1U);
const auto& relative_value = To<CSSPrimitiveValue>(list->Item(0));
state.Style()->SetMathDepth(state.ParentStyle()->MathDepth() +
relative_value.GetIntValue());
} else if (auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) {
DCHECK(identifier_value->GetValueID() == CSSValueID::kAutoAdd);
unsigned depth = 0;
if (state.ParentStyle()->MathStyle() == EMathStyle::kCompact)
depth += 1;
state.Style()->SetMathDepth(state.ParentStyle()->MathDepth() + depth);
} else if (DynamicTo<CSSPrimitiveValue>(value)) {
state.Style()->SetMathDepth(To<CSSPrimitiveValue>(value).GetIntValue());
}
}
const CSSValue* MaxBlockSize::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMaxWidthOrHeight(range, context);
}
const CSSValue* MaxHeight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMaxWidthOrHeight(
range, context, css_parsing_utils::UnitlessQuirk::kAllow);
}
const CSSValue* MaxHeight::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
const Length& max_height = style.MaxHeight();
if (max_height.IsNone())
return CSSIdentifierValue::Create(CSSValueID::kNone);
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(max_height, style);
}
const CSSValue* MaxInlineSize::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMaxWidthOrHeight(range, context);
}
const CSSValue* MaxWidth::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeMaxWidthOrHeight(
range, context, css_parsing_utils::UnitlessQuirk::kAllow);
}
const CSSValue* MaxWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
const Length& max_width = style.MaxWidth();
if (max_width.IsNone())
return CSSIdentifierValue::Create(CSSValueID::kNone);
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(max_width, style);
}
const CSSValue* MinBlockSize::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeWidthOrHeight(range, context);
}
const CSSValue* MinHeight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeWidthOrHeight(
range, context, css_parsing_utils::UnitlessQuirk::kAllow);
}
const CSSValue* MinHeight::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
if (style.MinHeight().IsAuto())
return ComputedStyleUtils::MinWidthOrMinHeightAuto(style);
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(style.MinHeight(),
style);
}
const CSSValue* MinInlineSize::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeWidthOrHeight(range, context);
}
const CSSValue* MinWidth::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeWidthOrHeight(
range, context, css_parsing_utils::UnitlessQuirk::kAllow);
}
const CSSValue* MinWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
if (style.MinWidth().IsAuto())
return ComputedStyleUtils::MinWidthOrMinHeightAuto(style);
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(style.MinWidth(),
style);
}
const CSSValue* MixBlendMode::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetBlendMode());
}
const CSSValue* ObjectFit::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetObjectFit());
}
const CSSValue* ObjectPosition::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumePosition(range, context,
css_parsing_utils::UnitlessQuirk::kForbid,
absl::optional<WebFeature>());
}
const CSSValue* ObjectPosition::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return MakeGarbageCollected<CSSValuePair>(
ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.ObjectPosition().X(), style),
ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.ObjectPosition().Y(), style),
CSSValuePair::kKeepIdenticalValues);
}
const CSSValue* OffsetAnchor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumePosition(
range, context, css_parsing_utils::UnitlessQuirk::kForbid,
absl::optional<WebFeature>());
}
const CSSValue* OffsetAnchor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForPosition(style.OffsetAnchor(), style);
}
const CSSValue* OffsetDistance::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeLengthOrPercent(range, context,
kValueRangeAll);
}
const CSSValue* OffsetDistance::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.OffsetDistance(), style);
}
const CSSValue* OffsetPath::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeOffsetPath(range, context);
}
const CSSValue* OffsetPath::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (const BasicShape* style_motion_path = style.OffsetPath())
return ValueForBasicShape(style, style_motion_path);
return CSSIdentifierValue::Create(CSSValueID::kNone);
}
const CSSValue* OffsetPosition::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
CSSValue* value = css_parsing_utils::ConsumePosition(
range, context, css_parsing_utils::UnitlessQuirk::kForbid,
absl::optional<WebFeature>());
// Count when we receive a valid position other than 'auto'.
if (value && value->IsValuePair())
context.Count(WebFeature::kCSSOffsetInEffect);
return value;
}
const CSSValue* OffsetPosition::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForPosition(style.OffsetPosition(), style);
}
const CSSValue* OffsetRotate::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeOffsetRotate(range, context);
}
const CSSValue* OffsetRotate::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
if (style.OffsetRotate().type == OffsetRotationType::kAuto)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kAuto));
list->Append(*CSSNumericLiteralValue::Create(
style.OffsetRotate().angle, CSSPrimitiveValue::UnitType::kDegrees));
return list;
}
const CSSValue* Opacity::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeAlphaValue(range, context);
}
const CSSValue* Opacity::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.Opacity(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* Order::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeInteger(range, context);
}
const CSSValue* Order::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.Order(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* OriginTrialTestProperty::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.OriginTrialTestProperty());
;
}
const CSSValue* Orphans::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumePositiveInteger(range, context);
}
const CSSValue* Orphans::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.Orphans(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* OutlineColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
// Allow the special focus color even in HTML Standard parsing mode.
if (range.Peek().Id() == CSSValueID::kWebkitFocusRingColor)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeColor(range, context);
}
const CSSValue* AccentColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeColor(range, context);
}
const CSSValue* AccentColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
StyleAutoColor auto_color = style.AccentColor();
if (auto_color.IsAutoColor()) {
return CSSIdentifierValue::Create(CSSValueID::kAuto);
}
return ComputedStyleUtils::ValueForStyleAutoColor(
style, style.AccentColor(), CSSValuePhase::kComputedValue);
}
void AccentColor::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetAccentColor(StyleAutoColor::AutoColor());
}
void AccentColor::ApplyInherit(StyleResolverState& state) const {
state.Style()->SetAccentColor(state.ParentStyle()->AccentColor());
}
void AccentColor::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.Style()->SetAccentColor(
StyleBuilderConverter::ConvertStyleAutoColor(state, value));
}
const blink::Color OutlineColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
StyleColor outline_color = style.OutlineColor();
if (style.ShouldForceColor(outline_color)) {
return To<Longhand>(GetCSSPropertyInternalForcedOutlineColor())
.ColorIncludingFallback(false, style);
}
return outline_color.Resolve(style.GetCurrentColor(),
style.UsedColorScheme());
}
const CSSValue* OutlineColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
StyleColor outline_color = style.OutlineColor();
if (style.ShouldForceColor(outline_color)) {
return GetCSSPropertyInternalForcedOutlineColor().CSSValueFromComputedStyle(
style, nullptr, allow_visited_style);
}
// https://drafts.csswg.org/cssom/#resolved-values
// For this property, the resolved value is the used value.
return allow_visited_style
? cssvalue::CSSColor::Create(
style.VisitedDependentColor(*this).Rgb())
: ComputedStyleUtils::CurrentColorOrValidColor(
style, outline_color, CSSValuePhase::kUsedValue);
}
const CSSValue* OutlineOffset::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeLength(range, context, kValueRangeAll);
}
const CSSValue* OutlineOffset::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.OutlineOffset(), style);
}
const CSSValue* OutlineStyle::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.OutlineStyleIsAuto())
return CSSIdentifierValue::Create(CSSValueID::kAuto);
return CSSIdentifierValue::Create(style.OutlineStyle());
}
void OutlineStyle::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetOutlineStyleIsAuto(
ComputedStyleInitialValues::InitialOutlineStyleIsAuto());
state.Style()->SetOutlineStyle(EBorderStyle::kNone);
}
void OutlineStyle::ApplyInherit(StyleResolverState& state) const {
state.Style()->SetOutlineStyleIsAuto(
state.ParentStyle()->OutlineStyleIsAuto());
state.Style()->SetOutlineStyle(state.ParentStyle()->OutlineStyle());
}
void OutlineStyle::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
const auto& identifier_value = To<CSSIdentifierValue>(value);
state.Style()->SetOutlineStyleIsAuto(
static_cast<bool>(identifier_value.ConvertTo<OutlineIsAuto>()));
state.Style()->SetOutlineStyle(identifier_value.ConvertTo<EBorderStyle>());
}
const CSSValue* OutlineWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeLineWidth(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* OutlineWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.OutlineWidth(), style);
}
const CSSValue* OverflowAnchor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.OverflowAnchor());
}
const CSSValue* OverflowClipMargin::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.OverflowClipMargin(), style);
}
const CSSValue* OverflowClipMargin::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeLength(range, context,
kValueRangeNonNegative);
}
const CSSValue* OverflowWrap::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.OverflowWrap());
}
const CSSValue* OverflowX::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.OverflowX());
}
const CSSValue* OverflowY::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.OverflowY());
}
const CSSValue* OverscrollBehaviorX::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.OverscrollBehaviorX());
}
const CSSValue* OverscrollBehaviorY::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.OverscrollBehaviorY());
}
bool PaddingBlockEnd::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* PaddingBlockEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(range, context, kValueRangeNonNegative,
css_parsing_utils::UnitlessQuirk::kForbid);
}
bool PaddingBlockStart::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* PaddingBlockStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(range, context, kValueRangeNonNegative,
css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* PaddingBottom::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(range, context, kValueRangeNonNegative,
css_parsing_utils::UnitlessQuirk::kAllow);
}
bool PaddingBottom::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox() &&
(!style || !style->PaddingBottom().IsFixed());
}
const CSSValue* PaddingBottom::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
const Length& padding_bottom = style.PaddingBottom();
if (padding_bottom.IsFixed() || !layout_object || !layout_object->IsBox()) {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(padding_bottom,
style);
}
return ZoomAdjustedPixelValue(
To<LayoutBox>(layout_object)->ComputedCSSPaddingBottom(), style);
}
bool PaddingInlineEnd::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* PaddingInlineEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(range, context, kValueRangeNonNegative,
css_parsing_utils::UnitlessQuirk::kForbid);
}
bool PaddingInlineStart::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* PaddingInlineStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(range, context, kValueRangeNonNegative,
css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* PaddingLeft::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(range, context, kValueRangeNonNegative,
css_parsing_utils::UnitlessQuirk::kAllow);
}
bool PaddingLeft::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox() &&
(!style || !style->PaddingLeft().IsFixed());
}
const CSSValue* PaddingLeft::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
const Length& padding_left = style.PaddingLeft();
if (padding_left.IsFixed() || !layout_object || !layout_object->IsBox()) {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(padding_left,
style);
}
return ZoomAdjustedPixelValue(
To<LayoutBox>(layout_object)->ComputedCSSPaddingLeft(), style);
}
const CSSValue* PaddingRight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(range, context, kValueRangeNonNegative,
css_parsing_utils::UnitlessQuirk::kAllow);
}
bool PaddingRight::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox() &&
(!style || !style->PaddingRight().IsFixed());
}
const CSSValue* PaddingRight::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
const Length& padding_right = style.PaddingRight();
if (padding_right.IsFixed() || !layout_object || !layout_object->IsBox()) {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(padding_right,
style);
}
return ZoomAdjustedPixelValue(
To<LayoutBox>(layout_object)->ComputedCSSPaddingRight(), style);
}
const CSSValue* PaddingTop::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLengthOrPercent(range, context, kValueRangeNonNegative,
css_parsing_utils::UnitlessQuirk::kAllow);
}
bool PaddingTop::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox() &&
(!style || !style->PaddingTop().IsFixed());
}
const CSSValue* PaddingTop::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
const Length& padding_top = style.PaddingTop();
if (padding_top.IsFixed() || !layout_object || !layout_object->IsBox()) {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(padding_top,
style);
}
return ZoomAdjustedPixelValue(
To<LayoutBox>(layout_object)->ComputedCSSPaddingTop(), style);
}
const CSSValue* Page::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeCustomIdent(range, context);
}
const CSSValue* Page::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.Page().IsNull())
return CSSIdentifierValue::Create(CSSValueID::kAuto);
return MakeGarbageCollected<CSSCustomIdentValue>(style.Page());
}
const CSSValue* PaintOrder::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNormal)
return css_parsing_utils::ConsumeIdent(range);
Vector<CSSValueID, 3> paint_type_list;
CSSIdentifierValue* fill = nullptr;
CSSIdentifierValue* stroke = nullptr;
CSSIdentifierValue* markers = nullptr;
do {
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kFill && !fill)
fill = css_parsing_utils::ConsumeIdent(range);
else if (id == CSSValueID::kStroke && !stroke)
stroke = css_parsing_utils::ConsumeIdent(range);
else if (id == CSSValueID::kMarkers && !markers)
markers = css_parsing_utils::ConsumeIdent(range);
else
return nullptr;
paint_type_list.push_back(id);
} while (!range.AtEnd());
// After parsing we serialize the paint-order list. Since it is not possible
// to pop a last list items from CSSValueList without bigger cost, we create
// the list after parsing.
CSSValueID first_paint_order_type = paint_type_list.at(0);
CSSValueList* paint_order_list = CSSValueList::CreateSpaceSeparated();
switch (first_paint_order_type) {
case CSSValueID::kFill:
case CSSValueID::kStroke:
paint_order_list->Append(
first_paint_order_type == CSSValueID::kFill ? *fill : *stroke);
if (paint_type_list.size() > 1) {
if (paint_type_list.at(1) == CSSValueID::kMarkers)
paint_order_list->Append(*markers);
}
break;
case CSSValueID::kMarkers:
paint_order_list->Append(*markers);
if (paint_type_list.size() > 1) {
if (paint_type_list.at(1) == CSSValueID::kStroke)
paint_order_list->Append(*stroke);
}
break;
default:
NOTREACHED();
}
return paint_order_list;
}
const CSSValue* PaintOrder::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
const EPaintOrder paint_order = style.PaintOrder();
if (paint_order == kPaintOrderNormal)
return CSSIdentifierValue::Create(CSSValueID::kNormal);
// Table mapping to the shortest (canonical) form of the property.
//
// Per spec, if any keyword is omitted it will be added last using
// the standard ordering. So "stroke" implies an order "stroke fill
// markers" etc. From a serialization PoV this means we never need
// to emit the last keyword.
//
// https://svgwg.org/svg2-draft/painting.html#PaintOrder
static const uint8_t canonical_form[][2] = {
// kPaintOrderNormal is handled above.
{PT_FILL, PT_NONE}, // kPaintOrderFillStrokeMarkers
{PT_FILL, PT_MARKERS}, // kPaintOrderFillMarkersStroke
{PT_STROKE, PT_NONE}, // kPaintOrderStrokeFillMarkers
{PT_STROKE, PT_MARKERS}, // kPaintOrderStrokeMarkersFill
{PT_MARKERS, PT_NONE}, // kPaintOrderMarkersFillStroke
{PT_MARKERS, PT_STROKE}, // kPaintOrderMarkersStrokeFill
};
DCHECK_LT(static_cast<size_t>(paint_order) - 1, base::size(canonical_form));
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
for (const auto& keyword : canonical_form[paint_order - 1]) {
const auto paint_order_type = static_cast<EPaintOrderType>(keyword);
if (paint_order_type == PT_NONE)
break;
list->Append(*CSSIdentifierValue::Create(paint_order_type));
}
return list;
}
const CSSValue* Perspective::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& localContext) const {
if (range.Peek().Id() == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
CSSPrimitiveValue* parsed_value =
css_parsing_utils::ConsumeLength(range, context, kValueRangeNonNegative);
bool use_legacy_parsing = localContext.UseAliasParsing();
if (!parsed_value && use_legacy_parsing) {
double perspective;
if (!css_parsing_utils::ConsumeNumberRaw(range, context, perspective) ||
perspective < 0.0)
return nullptr;
context.Count(WebFeature::kUnitlessPerspectiveInPerspectiveProperty);
parsed_value = CSSNumericLiteralValue::Create(
perspective, CSSPrimitiveValue::UnitType::kPixels);
}
return parsed_value;
}
const CSSValue* Perspective::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (!style.HasPerspective())
return CSSIdentifierValue::Create(CSSValueID::kNone);
return ZoomAdjustedPixelValue(style.Perspective(), style);
}
const CSSValue* PerspectiveOrigin::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumePosition(range, context,
css_parsing_utils::UnitlessQuirk::kForbid,
absl::optional<WebFeature>());
}
bool PerspectiveOrigin::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* PerspectiveOrigin::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
if (layout_object) {
LayoutRect box;
if (layout_object->IsBox())
box = To<LayoutBox>(layout_object)->BorderBoxRect();
return MakeGarbageCollected<CSSValuePair>(
ZoomAdjustedPixelValue(
MinimumValueForLength(style.PerspectiveOriginX(), box.Width()),
style),
ZoomAdjustedPixelValue(
MinimumValueForLength(style.PerspectiveOriginY(), box.Height()),
style),
CSSValuePair::kKeepIdenticalValues);
} else {
return MakeGarbageCollected<CSSValuePair>(
ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.PerspectiveOriginX(), style),
ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.PerspectiveOriginY(), style),
CSSValuePair::kKeepIdenticalValues);
}
}
const CSSValue* PointerEvents::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.PointerEvents());
}
const CSSValue* Position::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.PositionInternal());
}
void Position::ApplyInherit(StyleResolverState& state) const {
if (!state.ParentNode()->IsDocumentNode())
state.Style()->SetPosition(state.ParentStyle()->GetPosition());
}
const CSSValue* Quotes::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (auto* value =
css_parsing_utils::ConsumeIdent<CSSValueID::kAuto, CSSValueID::kNone>(
range)) {
return value;
}
CSSValueList* values = CSSValueList::CreateSpaceSeparated();
while (!range.AtEnd()) {
CSSStringValue* parsed_value = css_parsing_utils::ConsumeString(range);
if (!parsed_value)
return nullptr;
values->Append(*parsed_value);
}
if (values->length() && values->length() % 2 == 0)
return values;
return nullptr;
}
const CSSValue* Quotes::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (!style.Quotes())
return CSSIdentifierValue::Create(CSSValueID::kAuto);
if (style.Quotes()->size()) {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
for (int i = 0; i < style.Quotes()->size(); i++) {
list->Append(*MakeGarbageCollected<CSSStringValue>(
style.Quotes()->GetOpenQuote(i)));
list->Append(*MakeGarbageCollected<CSSStringValue>(
style.Quotes()->GetCloseQuote(i)));
}
return list;
}
return CSSIdentifierValue::Create(CSSValueID::kNone);
}
const CSSValue* R::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeSVGGeometryPropertyLength(
range, context, kValueRangeNonNegative);
}
const CSSValue* R::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(style.R(), style);
}
const CSSValue* Resize::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.Resize());
}
void Resize::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
const CSSIdentifierValue& identifier_value = To<CSSIdentifierValue>(value);
EResize r = EResize::kNone;
if (identifier_value.GetValueID() == CSSValueID::kAuto) {
if (Settings* settings = state.GetDocument().GetSettings()) {
r = settings->GetTextAreasAreResizable() ? EResize::kBoth
: EResize::kNone;
}
UseCounter::Count(state.GetDocument(), WebFeature::kCSSResizeAuto);
} else {
r = identifier_value.ConvertTo<EResize>();
}
state.Style()->SetResize(r);
}
const CSSValue* Right::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context,
css_parsing_utils::UnitlessUnlessShorthand(local_context));
}
bool Right::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* Right::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForPositionOffset(style, *this,
layout_object);
}
const CSSValue* Rotate::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
DCHECK(RuntimeEnabledFeatures::CSSIndependentTransformPropertiesEnabled());
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
CSSValue* rotation = css_parsing_utils::ConsumeAngle(
range, context, absl::optional<WebFeature>());
CSSValue* axis = css_parsing_utils::ConsumeAxis(range, context);
if (axis)
list->Append(*axis);
else if (!rotation)
return nullptr;
if (!rotation) {
rotation = css_parsing_utils::ConsumeAngle(range, context,
absl::optional<WebFeature>());
if (!rotation)
return nullptr;
}
list->Append(*rotation);
return list;
}
const CSSValue* Rotate::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (!style.Rotate())
return CSSIdentifierValue::Create(CSSValueID::kNone);
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
if (style.Rotate()->X() != 0 || style.Rotate()->Y() != 0 ||
style.Rotate()->Z() != 1) {
const cssvalue::CSSAxisValue* axis =
MakeGarbageCollected<cssvalue::CSSAxisValue>(
style.Rotate()->X(), style.Rotate()->Y(), style.Rotate()->Z());
list->Append(*axis);
}
list->Append(*CSSNumericLiteralValue::Create(
style.Rotate()->Angle(), CSSPrimitiveValue::UnitType::kDegrees));
return list;
}
const CSSValue* RowGap::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeGapLength(range, context);
}
const CSSValue* RowGap::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool) const {
return ComputedStyleUtils::ValueForGapLength(style.RowGap(), style);
}
const CSSValue* Rx::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeSVGGeometryPropertyLength(
range, context, kValueRangeNonNegative);
}
const CSSValue* Rx::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(style.Rx(), style);
}
const CSSValue* Ry::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeSVGGeometryPropertyLength(
range, context, kValueRangeNonNegative);
}
const CSSValue* Ry::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(style.Ry(), style);
}
const CSSValue* Scale::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
DCHECK(RuntimeEnabledFeatures::CSSIndependentTransformPropertiesEnabled());
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
CSSPrimitiveValue* x_scale =
css_parsing_utils::ConsumeNumberOrPercent(range, context, kValueRangeAll);
if (!x_scale)
return nullptr;
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*x_scale);
CSSPrimitiveValue* y_scale =
css_parsing_utils::ConsumeNumberOrPercent(range, context, kValueRangeAll);
if (y_scale) {
CSSPrimitiveValue* z_scale = css_parsing_utils::ConsumeNumberOrPercent(
range, context, kValueRangeAll);
if (z_scale) {
list->Append(*y_scale);
list->Append(*z_scale);
} else if (x_scale->GetDoubleValue() != y_scale->GetDoubleValue()) {
list->Append(*y_scale);
}
}
return list;
}
const CSSValue* Scale::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
ScaleTransformOperation* scale = style.Scale();
if (!scale)
return CSSIdentifierValue::Create(CSSValueID::kNone);
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*CSSNumericLiteralValue::Create(
scale->X(), CSSPrimitiveValue::UnitType::kNumber));
if (scale->Z() == 1) {
if (scale->X() != scale->Y()) {
list->Append(*CSSNumericLiteralValue::Create(
scale->Y(), CSSPrimitiveValue::UnitType::kNumber));
}
} else {
list->Append(*CSSNumericLiteralValue::Create(
scale->Y(), CSSPrimitiveValue::UnitType::kNumber));
list->Append(*CSSNumericLiteralValue::Create(
scale->Z(), CSSNumericLiteralValue::UnitType::kNumber));
}
return list;
}
// https://www.w3.org/TR/css-overflow-4
// auto | [ stable | always ] && both? && force?
const CSSValue* ScrollbarGutter::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (!RuntimeEnabledFeatures::ScrollbarGutterEnabled())
return nullptr;
if (auto* value = css_parsing_utils::ConsumeIdent<CSSValueID::kAuto>(range))
return value;
CSSIdentifierValue* stable_or_always = nullptr;
CSSIdentifierValue* both = nullptr;
CSSIdentifierValue* force = nullptr;
while (!range.AtEnd()) {
if (!stable_or_always) {
if ((stable_or_always =
css_parsing_utils::ConsumeIdent<CSSValueID::kStable,
CSSValueID::kAlways>(range)))
continue;
}
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kBoth && !both)
both = css_parsing_utils::ConsumeIdent(range);
else if (id == CSSValueID::kForce && !force)
force = css_parsing_utils::ConsumeIdent(range);
else
return nullptr;
}
if (!stable_or_always)
return nullptr;
if (both || force) {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*stable_or_always);
if (both)
list->Append(*both);
if (force)
list->Append(*force);
return list;
}
return stable_or_always;
}
const CSSValue* ScrollbarGutter::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
auto scrollbar_gutter = style.ScrollbarGutter();
if (scrollbar_gutter == kScrollbarGutterAuto)
return CSSIdentifierValue::Create(CSSValueID::kAuto);
DCHECK(scrollbar_gutter & (kScrollbarGutterStable | kScrollbarGutterAlways));
CSSValue* main_value = nullptr;
if (scrollbar_gutter & kScrollbarGutterStable)
main_value = CSSIdentifierValue::Create(CSSValueID::kStable);
else
main_value = CSSIdentifierValue::Create(CSSValueID::kAlways);
if (!(scrollbar_gutter & (kScrollbarGutterBoth | kScrollbarGutterForce)))
return main_value;
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*main_value);
if (scrollbar_gutter & kScrollbarGutterBoth)
list->Append(*CSSIdentifierValue::Create(kScrollbarGutterBoth));
if (scrollbar_gutter & kScrollbarGutterForce)
list->Append(*CSSIdentifierValue::Create(kScrollbarGutterForce));
return list;
}
const CSSValue* ScrollbarWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.ScrollbarWidth());
}
const CSSValue* ScrollBehavior::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetScrollBehavior());
}
namespace {
static bool ConsumePan(CSSParserTokenRange& range,
CSSValue** pan_x,
CSSValue** pan_y) {
CSSValueID id = range.Peek().Id();
if ((id == CSSValueID::kPanX || id == CSSValueID::kPanRight ||
id == CSSValueID::kPanLeft) &&
!*pan_x) {
*pan_x = css_parsing_utils::ConsumeIdent(range);
} else if ((id == CSSValueID::kPanY || id == CSSValueID::kPanDown ||
id == CSSValueID::kPanUp) &&
!*pan_y) {
*pan_y = css_parsing_utils::ConsumeIdent(range);
} else {
return false;
}
return true;
}
} // namespace
const CSSValue* ScrollCustomization::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kAuto || id == CSSValueID::kNone) {
list->Append(*css_parsing_utils::ConsumeIdent(range));
return list;
}
CSSValue* pan_x = nullptr;
CSSValue* pan_y = nullptr;
if (!ConsumePan(range, &pan_x, &pan_y))
return nullptr;
if (!range.AtEnd() && !ConsumePan(range, &pan_x, &pan_y))
return nullptr;
if (pan_x)
list->Append(*pan_x);
if (pan_y)
list->Append(*pan_y);
return list;
}
const CSSValue* ScrollCustomization::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ScrollCustomizationFlagsToCSSValue(
style.ScrollCustomization());
}
const CSSValue* ScrollMarginBlockEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLength(range, context, kValueRangeAll,
css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* ScrollMarginBlockStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLength(range, context, kValueRangeAll,
css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* ScrollMarginBottom::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLength(range, context, kValueRangeAll,
css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* ScrollMarginBottom::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.ScrollMarginBottom(), style);
}
const CSSValue* ScrollMarginInlineEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLength(range, context, kValueRangeAll,
css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* ScrollMarginInlineStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLength(range, context, kValueRangeAll,
css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* ScrollMarginLeft::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLength(range, context, kValueRangeAll,
css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* ScrollMarginLeft::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.ScrollMarginLeft(), style);
}
const CSSValue* ScrollMarginRight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLength(range, context, kValueRangeAll,
css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* ScrollMarginRight::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.ScrollMarginRight(), style);
}
const CSSValue* ScrollMarginTop::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeLength(range, context, kValueRangeAll,
css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* ScrollMarginTop::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.ScrollMarginTop(), style);
}
const CSSValue* ScrollPaddingBlockEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingBlockStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingBottom::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingBottom::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.ScrollPaddingBottom(), style);
}
const CSSValue* ScrollPaddingInlineEnd::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingInlineStart::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingLeft::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingLeft::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.ScrollPaddingLeft(), style);
}
const CSSValue* ScrollPaddingRight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingRight::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.ScrollPaddingRight(), style);
}
const CSSValue* ScrollPaddingTop::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeScrollPadding(range, context);
}
const CSSValue* ScrollPaddingTop::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.ScrollPaddingTop(), style);
}
const CSSValue* ScrollSnapAlign::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValue* block_value =
css_parsing_utils::ConsumeIdent<CSSValueID::kNone, CSSValueID::kStart,
CSSValueID::kEnd, CSSValueID::kCenter>(
range);
if (!block_value)
return nullptr;
if (range.AtEnd())
return block_value;
CSSValue* inline_value =
css_parsing_utils::ConsumeIdent<CSSValueID::kNone, CSSValueID::kStart,
CSSValueID::kEnd, CSSValueID::kCenter>(
range);
if (!inline_value)
return block_value;
auto* pair = MakeGarbageCollected<CSSValuePair>(
block_value, inline_value, CSSValuePair::kDropIdenticalValues);
return pair;
}
const CSSValue* ScrollSnapAlign::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForScrollSnapAlign(style.GetScrollSnapAlign(),
style);
}
const CSSValue* ScrollSnapStop::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.ScrollSnapStop());
}
const CSSValue* ScrollSnapType::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValueID axis_id = range.Peek().Id();
if (axis_id != CSSValueID::kNone && axis_id != CSSValueID::kX &&
axis_id != CSSValueID::kY && axis_id != CSSValueID::kBlock &&
axis_id != CSSValueID::kInline && axis_id != CSSValueID::kBoth)
return nullptr;
CSSValue* axis_value = css_parsing_utils::ConsumeIdent(range);
if (range.AtEnd() || axis_id == CSSValueID::kNone)
return axis_value;
CSSValueID strictness_id = range.Peek().Id();
if (strictness_id != CSSValueID::kProximity &&
strictness_id != CSSValueID::kMandatory)
return axis_value;
CSSValue* strictness_value = css_parsing_utils::ConsumeIdent(range);
if (strictness_id == CSSValueID::kProximity)
return axis_value; // Shortest serialization.
auto* pair = MakeGarbageCollected<CSSValuePair>(
axis_value, strictness_value, CSSValuePair::kDropIdenticalValues);
return pair;
}
const CSSValue* ScrollSnapType::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForScrollSnapType(style.GetScrollSnapType(),
style);
}
const CSSValue* ShapeImageThreshold::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeAlphaValue(range, context);
}
const CSSValue* ShapeImageThreshold::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.ShapeImageThreshold(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* ShapeMargin::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeLengthOrPercent(range, context,
kValueRangeNonNegative);
}
const CSSValue* ShapeMargin::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSValue::Create(style.ShapeMargin(), style.EffectiveZoom());
}
const CSSValue* ShapeOutside::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (CSSValue* image_value =
css_parsing_utils::ConsumeImageOrNone(range, context))
return image_value;
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
CSSValue* box_value = css_parsing_utils::ConsumeShapeBox(range);
if (CSSValue* shape_value = css_parsing_utils::ConsumeBasicShape(
range, context, css_parsing_utils::AllowPathValue::kForbid)) {
list->Append(*shape_value);
if (!box_value) {
box_value = css_parsing_utils::ConsumeShapeBox(range);
}
}
if (box_value)
list->Append(*box_value);
if (!list->length())
return nullptr;
return list;
}
const CSSValue* ShapeOutside::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForShape(style, allow_visited_style,
style.ShapeOutside());
}
const CSSValue* ShapeRendering::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.ShapeRendering());
}
static CSSValue* ConsumePageSize(CSSParserTokenRange& range) {
return css_parsing_utils::ConsumeIdent<
CSSValueID::kA3, CSSValueID::kA4, CSSValueID::kA5, CSSValueID::kB4,
CSSValueID::kB5, CSSValueID::kJisB5, CSSValueID::kJisB4,
CSSValueID::kLedger, CSSValueID::kLegal, CSSValueID::kLetter>(range);
}
static float MmToPx(float mm) {
return mm * kCssPixelsPerMillimeter;
}
static float InchToPx(float inch) {
return inch * kCssPixelsPerInch;
}
static FloatSize GetPageSizeFromName(const CSSIdentifierValue& page_size_name) {
switch (page_size_name.GetValueID()) {
case CSSValueID::kA5:
return FloatSize(MmToPx(148), MmToPx(210));
case CSSValueID::kA4:
return FloatSize(MmToPx(210), MmToPx(297));
case CSSValueID::kA3:
return FloatSize(MmToPx(297), MmToPx(420));
case CSSValueID::kB5:
return FloatSize(MmToPx(176), MmToPx(250));
case CSSValueID::kB4:
return FloatSize(MmToPx(250), MmToPx(353));
case CSSValueID::kJisB5:
return FloatSize(MmToPx(182), MmToPx(257));
case CSSValueID::kJisB4:
return FloatSize(MmToPx(257), MmToPx(364));
case CSSValueID::kLetter:
return FloatSize(InchToPx(8.5), InchToPx(11));
case CSSValueID::kLegal:
return FloatSize(InchToPx(8.5), InchToPx(14));
case CSSValueID::kLedger:
return FloatSize(InchToPx(11), InchToPx(17));
default:
NOTREACHED();
return FloatSize(0, 0);
}
}
const CSSValue* Size::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValueList* result = CSSValueList::CreateSpaceSeparated();
if (range.Peek().Id() == CSSValueID::kAuto) {
result->Append(*css_parsing_utils::ConsumeIdent(range));
return result;
}
if (CSSValue* width = css_parsing_utils::ConsumeLength(
range, context, kValueRangeNonNegative)) {
CSSValue* height = css_parsing_utils::ConsumeLength(range, context,
kValueRangeNonNegative);
result->Append(*width);
if (height)
result->Append(*height);
return result;
}
CSSValue* page_size = ConsumePageSize(range);
CSSValue* orientation =
css_parsing_utils::ConsumeIdent<CSSValueID::kPortrait,
CSSValueID::kLandscape>(range);
if (!page_size)
page_size = ConsumePageSize(range);
if (!orientation && !page_size)
return nullptr;
if (page_size)
result->Append(*page_size);
if (orientation)
result->Append(*orientation);
return result;
}
void Size::ApplyInitial(StyleResolverState& state) const {}
void Size::ApplyInherit(StyleResolverState& state) const {}
void Size::ApplyValue(StyleResolverState& state, const CSSValue& value) const {
state.Style()->ResetPageSizeType();
FloatSize size;
PageSizeType page_size_type = PageSizeType::kAuto;
const auto& list = To<CSSValueList>(value);
if (list.length() == 2) {
// <length>{2} | <page-size> <orientation>
const CSSValue& first = list.Item(0);
const CSSValue& second = list.Item(1);
auto* first_primitive_value = DynamicTo<CSSPrimitiveValue>(first);
if (first_primitive_value && first_primitive_value->IsLength()) {
// <length>{2}
size = FloatSize(
first_primitive_value->ComputeLength<float>(
state.CssToLengthConversionData().CopyWithAdjustedZoom(1.0)),
To<CSSPrimitiveValue>(second).ComputeLength<float>(
state.CssToLengthConversionData().CopyWithAdjustedZoom(1.0)));
} else {
// <page-size> <orientation>
size = GetPageSizeFromName(To<CSSIdentifierValue>(first));
DCHECK(To<CSSIdentifierValue>(second).GetValueID() ==
CSSValueID::kLandscape ||
To<CSSIdentifierValue>(second).GetValueID() ==
CSSValueID::kPortrait);
if (To<CSSIdentifierValue>(second).GetValueID() == CSSValueID::kLandscape)
size = size.TransposedSize();
}
page_size_type = PageSizeType::kFixed;
} else {
DCHECK_EQ(list.length(), 1U);
// <length> | auto | <page-size> | [ portrait | landscape]
const CSSValue& first = list.Item(0);
auto* first_primitive_value = DynamicTo<CSSPrimitiveValue>(first);
if (first_primitive_value && first_primitive_value->IsLength()) {
// <length>
page_size_type = PageSizeType::kFixed;
float width = first_primitive_value->ComputeLength<float>(
state.CssToLengthConversionData().CopyWithAdjustedZoom(1.0));
size = FloatSize(width, width);
} else {
const auto& ident = To<CSSIdentifierValue>(first);
switch (ident.GetValueID()) {
case CSSValueID::kAuto:
page_size_type = PageSizeType::kAuto;
break;
case CSSValueID::kPortrait:
page_size_type = PageSizeType::kPortrait;
break;
case CSSValueID::kLandscape:
page_size_type = PageSizeType::kLandscape;
break;
default:
// <page-size>
page_size_type = PageSizeType::kFixed;
size = GetPageSizeFromName(ident);
}
}
}
state.Style()->SetPageSizeType(page_size_type);
state.Style()->SetPageSize(size);
}
const CSSValue* Speak::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.Speak());
}
const CSSValue* StopColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color StopColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
StyleColor stop_color = style.StopColor();
if (style.ShouldForceColor(stop_color))
return style.GetInternalForcedCurrentColor();
return style.ResolvedColor(stop_color);
}
const CSSValue* StopColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::CurrentColorOrValidColor(
style, style.StopColor(), CSSValuePhase::kComputedValue);
}
const CSSValue* StopOpacity::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeAlphaValue(range, context);
}
const CSSValue* StopOpacity::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.StopOpacity(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* Stroke::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeSVGPaint(range, context);
}
const CSSValue* Stroke::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForSVGPaint(style.StrokePaint(), style);
}
const blink::Color Stroke::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
DCHECK(style.StrokePaint().HasColor());
const StyleColor& stroke_color = style.StrokePaint().GetColor();
if (style.ShouldForceColor(stroke_color))
return style.GetInternalForcedCurrentColor();
return stroke_color.Resolve(style.GetCurrentColor(), style.UsedColorScheme());
}
const CSSValue* StrokeDasharray::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
CSSParserContext::ParserModeOverridingScope scope(context, kSVGAttributeMode);
CSSValueList* dashes = CSSValueList::CreateCommaSeparated();
do {
CSSPrimitiveValue* dash = css_parsing_utils::ConsumeLengthOrPercent(
range, context, kValueRangeNonNegative);
if (!dash || (css_parsing_utils::ConsumeCommaIncludingWhitespace(range) &&
range.AtEnd()))
return nullptr;
dashes->Append(*dash);
} while (!range.AtEnd());
return dashes;
}
const CSSValue* StrokeDasharray::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::StrokeDashArrayToCSSValueList(
*style.StrokeDashArray(), style);
}
const CSSValue* StrokeDashoffset::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSParserContext::ParserModeOverridingScope scope(context, kSVGAttributeMode);
return css_parsing_utils::ConsumeLengthOrPercent(
range, context, kValueRangeAll,
css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* StrokeDashoffset::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.StrokeDashOffset(), style);
}
const CSSValue* StrokeLinecap::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.CapStyle());
}
const CSSValue* StrokeLinejoin::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.JoinStyle());
}
const CSSValue* StrokeMiterlimit::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeNumber(range, context,
kValueRangeNonNegative);
}
const CSSValue* StrokeMiterlimit::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.StrokeMiterLimit(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* StrokeOpacity::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeAlphaValue(range, context);
}
const CSSValue* StrokeOpacity::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.StrokeOpacity(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* StrokeWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSParserContext::ParserModeOverridingScope scope(context, kSVGAttributeMode);
return css_parsing_utils::ConsumeLengthOrPercent(
range, context, kValueRangeNonNegative,
css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* StrokeWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
// We store the unzoomed stroke-width value using ConvertUnzoomedLength().
// Don't apply zoom here either.
return CSSValue::Create(style.StrokeWidth().length(), 1);
}
const CSSValue* ContentVisibility::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.ContentVisibility());
}
const CSSValue* ContentVisibility::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kHiddenMatchable &&
!RuntimeEnabledFeatures::CSSContentVisibilityHiddenMatchableEnabled(
context.GetExecutionContext())) {
return nullptr;
}
return css_parsing_utils::ConsumeIdent<CSSValueID::kVisible,
CSSValueID::kAuto, CSSValueID::kHidden,
CSSValueID::kHiddenMatchable>(range);
}
const CSSValue* TabSize::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSPrimitiveValue* parsed_value =
css_parsing_utils::ConsumeNumber(range, context, kValueRangeNonNegative);
if (parsed_value)
return parsed_value;
return css_parsing_utils::ConsumeLength(range, context,
kValueRangeNonNegative);
}
const CSSValue* TabSize::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(
style.GetTabSize().GetPixelSize(1.0),
style.GetTabSize().IsSpaces() ? CSSPrimitiveValue::UnitType::kNumber
: CSSPrimitiveValue::UnitType::kPixels);
}
const CSSValue* TableLayout::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.TableLayout());
}
const CSSValue* TextAlign::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetTextAlign());
}
void TextAlign::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
const auto* ident_value = DynamicTo<CSSIdentifierValue>(value);
if (ident_value &&
ident_value->GetValueID() != CSSValueID::kWebkitMatchParent) {
// Special case for th elements - UA stylesheet text-align does not apply if
// parent's computed value for text-align is not its initial value
// https://html.spec.whatwg.org/C/#tables-2
if (ident_value->GetValueID() == CSSValueID::kInternalCenter &&
state.ParentStyle()->GetTextAlign() !=
ComputedStyleInitialValues::InitialTextAlign())
state.Style()->SetTextAlign(state.ParentStyle()->GetTextAlign());
else
state.Style()->SetTextAlign(ident_value->ConvertTo<ETextAlign>());
} else if (state.ParentStyle()->GetTextAlign() == ETextAlign::kStart) {
state.Style()->SetTextAlign(state.ParentStyle()->IsLeftToRightDirection()
? ETextAlign::kLeft
: ETextAlign::kRight);
} else if (state.ParentStyle()->GetTextAlign() == ETextAlign::kEnd) {
state.Style()->SetTextAlign(state.ParentStyle()->IsLeftToRightDirection()
? ETextAlign::kRight
: ETextAlign::kLeft);
} else {
state.Style()->SetTextAlign(state.ParentStyle()->GetTextAlign());
}
}
const CSSValue* TextAlignLast::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.TextAlignLast());
}
const CSSValue* TextAnchor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.TextAnchor());
}
const CSSValue* TextCombineUpright::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.TextCombine());
}
const CSSValue* TextDecorationColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color TextDecorationColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
StyleColor decoration_color =
style.DecorationColorIncludingFallback(visited_link);
if (style.ShouldForceColor(decoration_color))
return style.GetInternalForcedCurrentColor();
return decoration_color.Resolve(style.GetCurrentColor(),
style.UsedColorScheme());
}
const CSSValue* TextDecorationColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::CurrentColorOrValidColor(
style, style.TextDecorationColor(), CSSValuePhase::kComputedValue);
}
const CSSValue* TextDecorationLine::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeTextDecorationLine(range);
}
const CSSValue* TextDecorationLine::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::RenderTextDecorationFlagsToCSSValue(
style.GetTextDecoration());
}
const CSSValue* TextDecorationSkipInk::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForTextDecorationSkipInk(
style.TextDecorationSkipInk());
}
const CSSValue* TextDecorationStyle::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForTextDecorationStyle(
style.TextDecorationStyle());
}
const CSSValue* TextDecorationThickness::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
DCHECK(RuntimeEnabledFeatures::UnderlineOffsetThicknessEnabled());
if (auto* ident = css_parsing_utils::ConsumeIdent<CSSValueID::kFromFont,
CSSValueID::kAuto>(range)) {
return ident;
}
return css_parsing_utils::ConsumeLengthOrPercent(range, context,
kValueRangeAll);
}
const CSSValue* TextDecorationThickness::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
DCHECK(RuntimeEnabledFeatures::UnderlineOffsetThicknessEnabled());
if (style.GetTextDecorationThickness().IsFromFont())
return CSSIdentifierValue::Create(CSSValueID::kFromFont);
if (style.GetTextDecorationThickness().IsAuto())
return CSSIdentifierValue::Create(CSSValueID::kAuto);
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.GetTextDecorationThickness().Thickness(), style);
}
const CSSValue* TextIndent::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
// [ <length> | <percentage> ] && hanging? && each-line?
// Keywords only allowed when css3Text is enabled.
CSSValue* length_percentage = nullptr;
CSSValue* hanging = nullptr;
CSSValue* each_line = nullptr;
do {
if (!length_percentage) {
length_percentage = css_parsing_utils::ConsumeLengthOrPercent(
range, context, kValueRangeAll,
css_parsing_utils::UnitlessQuirk::kAllow);
if (length_percentage) {
continue;
}
}
if (RuntimeEnabledFeatures::CSS3TextEnabled()) {
CSSValueID id = range.Peek().Id();
if (!hanging && id == CSSValueID::kHanging) {
hanging = css_parsing_utils::ConsumeIdent(range);
continue;
}
if (!each_line && id == CSSValueID::kEachLine) {
each_line = css_parsing_utils::ConsumeIdent(range);
continue;
}
}
return nullptr;
} while (!range.AtEnd());
if (!length_percentage)
return nullptr;
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*length_percentage);
if (hanging)
list->Append(*hanging);
if (each_line)
list->Append(*each_line);
return list;
}
const CSSValue* TextIndent::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.TextIndent(), style));
if (RuntimeEnabledFeatures::CSS3TextEnabled()) {
if (style.GetTextIndentType() == TextIndentType::kHanging)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kHanging));
if (style.GetTextIndentLine() == TextIndentLine::kEachLine)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kEachLine));
}
return list;
}
void TextIndent::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetTextIndent(ComputedStyleInitialValues::InitialTextIndent());
state.Style()->SetTextIndentLine(
ComputedStyleInitialValues::InitialTextIndentLine());
state.Style()->SetTextIndentType(
ComputedStyleInitialValues::InitialTextIndentType());
}
void TextIndent::ApplyInherit(StyleResolverState& state) const {
state.Style()->SetTextIndent(state.ParentStyle()->TextIndent());
state.Style()->SetTextIndentLine(state.ParentStyle()->GetTextIndentLine());
state.Style()->SetTextIndentType(state.ParentStyle()->GetTextIndentType());
}
void TextIndent::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
Length length_or_percentage_value;
TextIndentLine text_indent_line_value =
ComputedStyleInitialValues::InitialTextIndentLine();
TextIndentType text_indent_type_value =
ComputedStyleInitialValues::InitialTextIndentType();
for (auto& list_value : To<CSSValueList>(value)) {
if (auto* list_primitive_value =
DynamicTo<CSSPrimitiveValue>(*list_value)) {
length_or_percentage_value = list_primitive_value->ConvertToLength(
state.CssToLengthConversionData());
} else if (To<CSSIdentifierValue>(*list_value).GetValueID() ==
CSSValueID::kEachLine) {
text_indent_line_value = TextIndentLine::kEachLine;
} else if (To<CSSIdentifierValue>(*list_value).GetValueID() ==
CSSValueID::kHanging) {
text_indent_type_value = TextIndentType::kHanging;
} else {
NOTREACHED();
}
}
state.Style()->SetTextIndent(length_or_percentage_value);
state.Style()->SetTextIndentLine(text_indent_line_value);
state.Style()->SetTextIndentType(text_indent_type_value);
}
const CSSValue* TextJustify::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetTextJustify());
}
const CSSValue* TextOrientation::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetTextOrientation());
}
void TextOrientation::ApplyInitial(StyleResolverState& state) const {
state.SetTextOrientation(
ComputedStyleInitialValues::InitialTextOrientation());
}
void TextOrientation::ApplyInherit(StyleResolverState& state) const {
state.SetTextOrientation(state.ParentStyle()->GetTextOrientation());
}
void TextOrientation::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.SetTextOrientation(
To<CSSIdentifierValue>(value).ConvertTo<ETextOrientation>());
}
const CSSValue* TextOverflow::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.TextOverflow() != ETextOverflow::kClip)
return CSSIdentifierValue::Create(CSSValueID::kEllipsis);
return CSSIdentifierValue::Create(CSSValueID::kClip);
}
const CSSValue* TextRendering::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetFontDescription().TextRendering());
}
const CSSValue* TextShadow::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeShadow(
range, context, css_parsing_utils::AllowInsetAndSpread::kForbid);
}
const CSSValue* TextShadow::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForShadowList(
style.TextShadow(), style, false, CSSValuePhase::kComputedValue);
}
const CSSValue* TextSizeAdjust::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
if (range.Peek().Id() == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumePercent(range, context,
kValueRangeNonNegative);
}
const CSSValue* TextSizeAdjust::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.GetTextSizeAdjust().IsAuto())
return CSSIdentifierValue::Create(CSSValueID::kAuto);
return CSSNumericLiteralValue::Create(
style.GetTextSizeAdjust().Multiplier() * 100,
CSSPrimitiveValue::UnitType::kPercentage);
}
const CSSValue* TextTransform::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.TextTransform());
}
// https://drafts.csswg.org/css-text-decor-4/#text-underline-position-property
// auto | [ from-font | under ] || [ left | right ] - default: auto
const CSSValue* TextUnderlinePosition::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
CSSIdentifierValue* from_font_or_under_value =
RuntimeEnabledFeatures::UnderlineOffsetThicknessEnabled()
? css_parsing_utils::ConsumeIdent<CSSValueID::kFromFont,
CSSValueID::kUnder>(range)
: css_parsing_utils::ConsumeIdent<CSSValueID::kUnder>(range);
CSSIdentifierValue* left_or_right_value =
css_parsing_utils::ConsumeIdent<CSSValueID::kLeft, CSSValueID::kRight>(
range);
if (left_or_right_value && !from_font_or_under_value) {
from_font_or_under_value =
RuntimeEnabledFeatures::UnderlineOffsetThicknessEnabled()
? css_parsing_utils::ConsumeIdent<CSSValueID::kFromFont,
CSSValueID::kUnder>(range)
: css_parsing_utils::ConsumeIdent<CSSValueID::kUnder>(range);
}
if (!from_font_or_under_value && !left_or_right_value)
return nullptr;
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
if (from_font_or_under_value)
list->Append(*from_font_or_under_value);
if (left_or_right_value)
list->Append(*left_or_right_value);
return list;
}
const CSSValue* TextUnderlinePosition::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
auto text_underline_position = style.TextUnderlinePosition();
if (text_underline_position == kTextUnderlinePositionAuto)
return CSSIdentifierValue::Create(CSSValueID::kAuto);
if (text_underline_position == kTextUnderlinePositionFromFont)
return CSSIdentifierValue::Create(CSSValueID::kFromFont);
if (text_underline_position == kTextUnderlinePositionUnder)
return CSSIdentifierValue::Create(CSSValueID::kUnder);
if (text_underline_position == kTextUnderlinePositionLeft)
return CSSIdentifierValue::Create(CSSValueID::kLeft);
if (text_underline_position == kTextUnderlinePositionRight)
return CSSIdentifierValue::Create(CSSValueID::kRight);
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
if (text_underline_position & kTextUnderlinePositionFromFont) {
list->Append(*CSSIdentifierValue::Create(CSSValueID::kFromFont));
} else {
DCHECK(text_underline_position & kTextUnderlinePositionUnder);
list->Append(*CSSIdentifierValue::Create(CSSValueID::kUnder));
}
if (text_underline_position & kTextUnderlinePositionLeft)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kLeft));
if (text_underline_position & kTextUnderlinePositionRight)
list->Append(*CSSIdentifierValue::Create(CSSValueID::kRight));
DCHECK_EQ(list->length(), 2U);
return list;
}
const CSSValue* TextUnderlineOffset::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
DCHECK(RuntimeEnabledFeatures::UnderlineOffsetThicknessEnabled());
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeLengthOrPercent(range, context,
kValueRangeAll);
}
const CSSValue* TextUnderlineOffset::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.TextUnderlineOffset(), style);
}
const CSSValue* Top::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeMarginOrOffset(
range, context,
css_parsing_utils::UnitlessUnlessShorthand(local_context));
}
bool Top::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* Top::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForPositionOffset(style, *this,
layout_object);
}
namespace {
static bool ConsumePan(CSSParserTokenRange& range,
CSSValue*& pan_x,
CSSValue*& pan_y,
CSSValue*& pinch_zoom) {
CSSValueID id = range.Peek().Id();
if ((id == CSSValueID::kPanX || id == CSSValueID::kPanRight ||
id == CSSValueID::kPanLeft) &&
!pan_x) {
pan_x = css_parsing_utils::ConsumeIdent(range);
} else if ((id == CSSValueID::kPanY || id == CSSValueID::kPanDown ||
id == CSSValueID::kPanUp) &&
!pan_y) {
pan_y = css_parsing_utils::ConsumeIdent(range);
} else if (id == CSSValueID::kPinchZoom && !pinch_zoom) {
pinch_zoom = css_parsing_utils::ConsumeIdent(range);
} else {
return false;
}
return true;
}
} // namespace
const CSSValue* TouchAction::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kAuto || id == CSSValueID::kNone ||
id == CSSValueID::kManipulation) {
list->Append(*css_parsing_utils::ConsumeIdent(range));
return list;
}
CSSValue* pan_x = nullptr;
CSSValue* pan_y = nullptr;
CSSValue* pinch_zoom = nullptr;
if (!ConsumePan(range, pan_x, pan_y, pinch_zoom))
return nullptr;
if (!range.AtEnd() && !ConsumePan(range, pan_x, pan_y, pinch_zoom))
return nullptr;
if (!range.AtEnd() && !ConsumePan(range, pan_x, pan_y, pinch_zoom))
return nullptr;
if (pan_x)
list->Append(*pan_x);
if (pan_y)
list->Append(*pan_y);
if (pinch_zoom)
list->Append(*pinch_zoom);
return list;
}
const CSSValue* TouchAction::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::TouchActionFlagsToCSSValue(style.GetTouchAction());
}
const CSSValue* TransformBox::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.TransformBox());
}
const CSSValue* Transform::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ConsumeTransformList(range, context, local_context);
}
bool Transform::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object &&
(layout_object->IsBox() || layout_object->IsSVGChild());
}
const CSSValue* Transform::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
return ComputedStyleUtils::ResolvedTransform(layout_object, style);
}
const CSSValue* TransformOrigin::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValue* result_x = nullptr;
CSSValue* result_y = nullptr;
if (css_parsing_utils::ConsumeOneOrTwoValuedPosition(
range, context, css_parsing_utils::UnitlessQuirk::kForbid, result_x,
result_y)) {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*result_x);
list->Append(*result_y);
CSSValue* result_z =
css_parsing_utils::ConsumeLength(range, context, kValueRangeAll);
if (result_z)
list->Append(*result_z);
return list;
}
return nullptr;
}
bool TransformOrigin::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object &&
(layout_object->IsBox() || layout_object->IsSVGChild());
}
const CSSValue* TransformOrigin::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
if (layout_object) {
FloatRect reference_box = ComputedStyleUtils::ReferenceBoxForTransform(
*layout_object, ComputedStyleUtils::kDontUsePixelSnappedBox);
FloatSize resolved_origin(
FloatValueForLength(style.TransformOriginX(), reference_box.Width()),
FloatValueForLength(style.TransformOriginY(), reference_box.Height()));
list->Append(*ZoomAdjustedPixelValue(resolved_origin.Width(), style));
list->Append(*ZoomAdjustedPixelValue(resolved_origin.Height(), style));
} else {
list->Append(*ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.TransformOriginX(), style));
list->Append(*ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.TransformOriginY(), style));
}
if (style.TransformOriginZ() != 0)
list->Append(*ZoomAdjustedPixelValue(style.TransformOriginZ(), style));
return list;
}
const CSSValue* TransformStyle::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(
(style.TransformStyle3D() == ETransformStyle3D::kPreserve3d)
? CSSValueID::kPreserve3d
: CSSValueID::kFlat);
}
const CSSValue* TransitionDelay::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeTime, range, context, kValueRangeAll);
}
const CSSValue* TransitionDelay::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForAnimationDelay(style.Transitions());
}
const CSSValue* TransitionDelay::InitialValue() const {
DEFINE_STATIC_LOCAL(
const Persistent<CSSValue>, value,
(CSSNumericLiteralValue::Create(CSSTimingData::InitialDelay(),
CSSPrimitiveValue::UnitType::kSeconds)));
return value;
}
const CSSValue* TransitionDuration::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeTime, range, context, kValueRangeNonNegative);
}
const CSSValue* TransitionDuration::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForAnimationDuration(style.Transitions());
}
const CSSValue* TransitionDuration::InitialValue() const {
DEFINE_STATIC_LOCAL(
const Persistent<CSSValue>, value,
(CSSNumericLiteralValue::Create(CSSTimingData::InitialDuration(),
CSSPrimitiveValue::UnitType::kSeconds)));
return value;
}
const CSSValue* TransitionProperty::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValueList* list = css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeTransitionProperty, range, context);
if (!list || !css_parsing_utils::IsValidPropertyList(*list))
return nullptr;
return list;
}
const CSSValue* TransitionProperty::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForTransitionProperty(style.Transitions());
}
const CSSValue* TransitionProperty::InitialValue() const {
DEFINE_STATIC_LOCAL(const Persistent<CSSValue>, value,
(CSSIdentifierValue::Create(CSSValueID::kAll)));
return value;
}
const CSSValue* TransitionTimingFunction::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeAnimationTimingFunction, range, context);
}
const CSSValue* TransitionTimingFunction::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForAnimationTimingFunction(
style.Transitions());
}
const CSSValue* TransitionTimingFunction::InitialValue() const {
DEFINE_STATIC_LOCAL(const Persistent<CSSValue>, value,
(CSSIdentifierValue::Create(CSSValueID::kEase)));
return value;
}
const CSSValue* Translate::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
DCHECK(RuntimeEnabledFeatures::CSSIndependentTransformPropertiesEnabled());
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
CSSValue* translate_x =
css_parsing_utils::ConsumeLengthOrPercent(range, context, kValueRangeAll);
if (!translate_x)
return nullptr;
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*translate_x);
CSSPrimitiveValue* translate_y =
css_parsing_utils::ConsumeLengthOrPercent(range, context, kValueRangeAll);
if (translate_y) {
CSSValue* translate_z =
css_parsing_utils::ConsumeLength(range, context, kValueRangeAll);
if (translate_y->IsZero() && !translate_z)
return list;
list->Append(*translate_y);
if (translate_z) {
list->Append(*translate_z);
}
}
return list;
}
bool Translate::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
}
const CSSValue* Translate::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
if (!style.Translate())
return CSSIdentifierValue::Create(CSSValueID::kNone);
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.Translate()->X(), style));
if (!style.Translate()->Y().IsZero() || style.Translate()->Z() != 0) {
list->Append(*ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.Translate()->Y(), style));
}
if (style.Translate()->Z() != 0)
list->Append(*ZoomAdjustedPixelValue(style.Translate()->Z(), style));
return list;
}
const CSSValue* UnicodeBidi::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetUnicodeBidi());
}
const CSSValue* UserSelect::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.UserSelect());
}
const CSSValue* VectorEffect::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.VectorEffect());
}
const CSSValue* VerticalAlign::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValue* parsed_value = css_parsing_utils::ConsumeIdentRange(
range, CSSValueID::kBaseline, CSSValueID::kWebkitBaselineMiddle);
if (!parsed_value) {
parsed_value = css_parsing_utils::ConsumeLengthOrPercent(
range, context, kValueRangeAll,
css_parsing_utils::UnitlessQuirk::kAllow);
}
return parsed_value;
}
const CSSValue* VerticalAlign::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
switch (style.VerticalAlign()) {
case EVerticalAlign::kBaseline:
return CSSIdentifierValue::Create(CSSValueID::kBaseline);
case EVerticalAlign::kMiddle:
return CSSIdentifierValue::Create(CSSValueID::kMiddle);
case EVerticalAlign::kSub:
return CSSIdentifierValue::Create(CSSValueID::kSub);
case EVerticalAlign::kSuper:
return CSSIdentifierValue::Create(CSSValueID::kSuper);
case EVerticalAlign::kTextTop:
return CSSIdentifierValue::Create(CSSValueID::kTextTop);
case EVerticalAlign::kTextBottom:
return CSSIdentifierValue::Create(CSSValueID::kTextBottom);
case EVerticalAlign::kTop:
return CSSIdentifierValue::Create(CSSValueID::kTop);
case EVerticalAlign::kBottom:
return CSSIdentifierValue::Create(CSSValueID::kBottom);
case EVerticalAlign::kBaselineMiddle:
return CSSIdentifierValue::Create(CSSValueID::kWebkitBaselineMiddle);
case EVerticalAlign::kLength:
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(
style.GetVerticalAlignLength(), style);
}
NOTREACHED();
return nullptr;
}
void VerticalAlign::ApplyInherit(StyleResolverState& state) const {
EVerticalAlign vertical_align = state.ParentStyle()->VerticalAlign();
state.Style()->SetVerticalAlign(vertical_align);
if (vertical_align == EVerticalAlign::kLength) {
state.Style()->SetVerticalAlignLength(
state.ParentStyle()->GetVerticalAlignLength());
}
}
void VerticalAlign::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
if (auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) {
state.Style()->SetVerticalAlign(
identifier_value->ConvertTo<EVerticalAlign>());
} else {
state.Style()->SetVerticalAlignLength(
To<CSSPrimitiveValue>(value).ConvertToLength(
state.CssToLengthConversionData()));
}
}
const CSSValue* Visibility::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.Visibility());
}
const CSSValue* WebkitAppRegion::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.DraggableRegionMode() == EDraggableRegionMode::kNone)
return CSSIdentifierValue::Create(CSSValueID::kNone);
return CSSIdentifierValue::Create(style.DraggableRegionMode() ==
EDraggableRegionMode::kDrag
? CSSValueID::kDrag
: CSSValueID::kNoDrag);
}
void WebkitAppRegion::ApplyInitial(StyleResolverState& state) const {}
void WebkitAppRegion::ApplyInherit(StyleResolverState& state) const {}
void WebkitAppRegion::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
const auto& identifier_value = To<CSSIdentifierValue>(value);
state.Style()->SetDraggableRegionMode(identifier_value.GetValueID() ==
CSSValueID::kDrag
? EDraggableRegionMode::kDrag
: EDraggableRegionMode::kNoDrag);
state.GetDocument().SetHasAnnotatedRegions(true);
}
const CSSValue* Appearance::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
CSSValueID id = range.Peek().Id();
CSSPropertyID property = CSSPropertyID::kAppearance;
if (CSSParserFastPaths::IsValidKeywordPropertyAndValue(property, id,
context.Mode())) {
if (local_context.UseAliasParsing())
property = CSSPropertyID::kAliasWebkitAppearance;
css_parsing_utils::CountKeywordOnlyPropertyUsage(property, context, id);
return css_parsing_utils::ConsumeIdent(range);
}
return nullptr;
}
const CSSValue* Appearance::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.Appearance());
}
const CSSValue* WebkitBorderHorizontalSpacing::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeLength(range, context,
kValueRangeNonNegative);
}
const CSSValue*
WebkitBorderHorizontalSpacing::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.HorizontalBorderSpacing(), style);
}
const CSSValue* WebkitBorderImage::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeWebkitBorderImage(range, context);
}
const CSSValue* WebkitBorderImage::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForNinePieceImage(style.BorderImage(), style,
allow_visited_style);
}
void WebkitBorderImage::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
NinePieceImage image;
CSSToStyleMap::MapNinePieceImage(state, CSSPropertyID::kWebkitBorderImage,
value, image);
state.Style()->SetBorderImage(image);
}
const CSSValue* WebkitBorderVerticalSpacing::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeLength(range, context,
kValueRangeNonNegative);
}
const CSSValue* WebkitBorderVerticalSpacing::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.VerticalBorderSpacing(), style);
}
const CSSValue* WebkitBoxAlign::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.BoxAlign());
}
const CSSValue* WebkitBoxDecorationBreak::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.BoxDecorationBreak() == EBoxDecorationBreak::kSlice)
return CSSIdentifierValue::Create(CSSValueID::kSlice);
return CSSIdentifierValue::Create(CSSValueID::kClone);
}
const CSSValue* WebkitBoxDirection::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.BoxDirection());
}
const CSSValue* WebkitBoxFlex::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeNumber(range, context, kValueRangeAll);
}
const CSSValue* WebkitBoxFlex::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.BoxFlex(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* WebkitBoxOrdinalGroup::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumePositiveInteger(range, context);
}
const CSSValue* WebkitBoxOrdinalGroup::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.BoxOrdinalGroup(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* WebkitBoxOrient::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.BoxOrient());
}
const CSSValue* WebkitBoxPack::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.BoxPack());
}
namespace {
CSSValue* ConsumeReflect(CSSParserTokenRange& range,
const CSSParserContext& context) {
CSSIdentifierValue* direction =
css_parsing_utils::ConsumeIdent<CSSValueID::kAbove, CSSValueID::kBelow,
CSSValueID::kLeft, CSSValueID::kRight>(
range);
if (!direction)
return nullptr;
CSSPrimitiveValue* offset = nullptr;
if (range.AtEnd()) {
offset =
CSSNumericLiteralValue::Create(0, CSSPrimitiveValue::UnitType::kPixels);
} else {
offset = ConsumeLengthOrPercent(range, context, kValueRangeAll,
css_parsing_utils::UnitlessQuirk::kForbid);
if (!offset)
return nullptr;
}
CSSValue* mask = nullptr;
if (!range.AtEnd()) {
mask = css_parsing_utils::ConsumeWebkitBorderImage(range, context);
if (!mask)
return nullptr;
}
return MakeGarbageCollected<cssvalue::CSSReflectValue>(direction, offset,
mask);
}
} // namespace
const CSSValue* WebkitBoxReflect::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return ConsumeReflect(range, context);
}
const CSSValue* WebkitBoxReflect::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForReflection(style.BoxReflect(), style,
allow_visited_style);
}
const CSSValue* InternalFontSizeDelta::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeLength(
range, context, kValueRangeAll, css_parsing_utils::UnitlessQuirk::kAllow);
}
const CSSValue* WebkitFontSmoothing::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetFontDescription().FontSmoothing());
}
const CSSValue* WebkitHighlight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeString(range);
}
const CSSValue* WebkitHighlight::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.Highlight() == g_null_atom)
return CSSIdentifierValue::Create(CSSValueID::kNone);
return MakeGarbageCollected<CSSStringValue>(style.Highlight());
}
const CSSValue* WebkitHyphenateCharacter::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeString(range);
}
const CSSValue* WebkitHyphenateCharacter::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.HyphenationString().IsNull())
return CSSIdentifierValue::Create(CSSValueID::kAuto);
return MakeGarbageCollected<CSSStringValue>(style.HyphenationString());
}
const CSSValue* WebkitLineBreak::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetLineBreak());
}
const CSSValue* WebkitLineClamp::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
// When specifying number of lines, don't allow 0 as a valid value.
return css_parsing_utils::ConsumePositiveInteger(range, context);
}
const CSSValue* WebkitLineClamp::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (!style.HasLineClamp())
return CSSIdentifierValue::Create(CSSValueID::kNone);
return CSSNumericLiteralValue::Create(style.LineClamp(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* WebkitLocale::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeString(range);
}
const CSSValue* WebkitLocale::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.Locale().IsNull())
return CSSIdentifierValue::Create(CSSValueID::kAuto);
return MakeGarbageCollected<CSSStringValue>(style.Locale());
}
void WebkitLocale::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
if (auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) {
DCHECK_EQ(identifier_value->GetValueID(), CSSValueID::kAuto);
state.GetFontBuilder().SetLocale(nullptr);
} else {
state.GetFontBuilder().SetLocale(
LayoutLocale::Get(AtomicString(To<CSSStringValue>(value).Value())));
}
}
const CSSValue* WebkitMaskBoxImageOutset::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderImageOutset(range, context);
}
const CSSValue* WebkitMaskBoxImageOutset::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForNinePieceImageQuad(
style.MaskBoxImage().Outset(), style);
}
const CSSValue* WebkitMaskBoxImageRepeat::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderImageRepeat(range);
}
const CSSValue* WebkitMaskBoxImageRepeat::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForNinePieceImageRepeat(style.MaskBoxImage());
}
const CSSValue* WebkitMaskBoxImageSlice::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderImageSlice(
range, context, css_parsing_utils::DefaultFill::kNoFill);
}
const CSSValue* WebkitMaskBoxImageSlice::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForNinePieceImageSlice(style.MaskBoxImage());
}
const CSSValue* WebkitMaskBoxImageSource::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeImageOrNone(range, context);
}
const CSSValue* WebkitMaskBoxImageSource::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.MaskBoxImageSource()) {
return style.MaskBoxImageSource()->ComputedCSSValue(style,
allow_visited_style);
}
return CSSIdentifierValue::Create(CSSValueID::kNone);
}
void WebkitMaskBoxImageSource::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.Style()->SetMaskBoxImageSource(
state.GetStyleImage(CSSPropertyID::kWebkitMaskBoxImageSource, value));
}
const CSSValue* WebkitMaskBoxImageWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeBorderImageWidth(range, context);
}
const CSSValue* WebkitMaskBoxImageWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForNinePieceImageQuad(
style.MaskBoxImage().BorderSlices(), style);
}
const CSSValue* WebkitMaskClip::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumePrefixedBackgroundBox, range,
css_parsing_utils::AllowTextValue::kAllow);
}
const CSSValue* WebkitMaskClip::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
const FillLayer* curr_layer = &style.MaskLayers();
for (; curr_layer; curr_layer = curr_layer->Next()) {
EFillBox box = curr_layer->Clip();
list->Append(*CSSIdentifierValue::Create(box));
}
return list;
}
const CSSValue* WebkitMaskComposite::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeBackgroundComposite, range);
}
const CSSValue* WebkitMaskComposite::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
const FillLayer* curr_layer = &style.MaskLayers();
for (; curr_layer; curr_layer = curr_layer->Next())
list->Append(*CSSIdentifierValue::Create(curr_layer->Composite()));
return list;
}
const CSSValue* WebkitMaskImage::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumeImageOrNone, range, context);
}
const CSSValue* WebkitMaskImage::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
const FillLayer& fill_layer = style.MaskLayers();
return ComputedStyleUtils::BackgroundImageOrWebkitMaskImage(
style, allow_visited_style, fill_layer);
}
const CSSValue* WebkitMaskOrigin::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumePrefixedBackgroundBox, range,
css_parsing_utils::AllowTextValue::kForbid);
}
const CSSValue* WebkitMaskOrigin::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateCommaSeparated();
const FillLayer* curr_layer = &style.MaskLayers();
for (; curr_layer; curr_layer = curr_layer->Next()) {
EFillBox box = curr_layer->Origin();
list->Append(*CSSIdentifierValue::Create(box));
}
return list;
}
const CSSValue* WebkitMaskPositionX::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumePositionLonghand<CSSValueID::kLeft,
CSSValueID::kRight>,
range, context);
}
const CSSValue* WebkitMaskPositionX::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
const FillLayer* curr_layer = &style.MaskLayers();
return ComputedStyleUtils::BackgroundPositionXOrWebkitMaskPositionX(
style, curr_layer);
}
const CSSValue* WebkitMaskPositionY::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeCommaSeparatedList(
css_parsing_utils::ConsumePositionLonghand<CSSValueID::kTop,
CSSValueID::kBottom>,
range, context);
}
const CSSValue* WebkitMaskPositionY::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
const FillLayer* curr_layer = &style.MaskLayers();
return ComputedStyleUtils::BackgroundPositionYOrWebkitMaskPositionY(
style, curr_layer);
}
const CSSValue* WebkitMaskSize::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) const {
return css_parsing_utils::ParseBackgroundOrMaskSize(
range, context, local_context, WebFeature::kNegativeMaskSize);
}
const CSSValue* WebkitMaskSize::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
const FillLayer& fill_layer = style.MaskLayers();
return ComputedStyleUtils::BackgroundImageOrWebkitMaskSize(style, fill_layer);
}
const CSSValue* WebkitPerspectiveOriginX::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumePositionLonghand<CSSValueID::kLeft,
CSSValueID::kRight>(
range, context);
}
const CSSValue* WebkitPerspectiveOriginY::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumePositionLonghand<CSSValueID::kTop,
CSSValueID::kBottom>(
range, context);
}
const CSSValue* WebkitPrintColorAdjust::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.PrintColorAdjust());
}
const CSSValue* WebkitRtlOrdering::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.RtlOrdering() == EOrder::kVisual
? CSSValueID::kVisual
: CSSValueID::kLogical);
}
const CSSValue* WebkitRubyPosition::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetRubyPosition());
}
const CSSValue* RubyPosition::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
switch (style.GetRubyPosition()) {
case blink::RubyPosition::kBefore:
return CSSIdentifierValue::Create(CSSValueID::kOver);
case blink::RubyPosition::kAfter:
return CSSIdentifierValue::Create(CSSValueID::kUnder);
}
NOTREACHED();
return CSSIdentifierValue::Create(CSSValueID::kOver);
}
const CSSValue* WebkitTapHighlightColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color WebkitTapHighlightColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
StyleColor highlight_color = style.TapHighlightColor();
if (style.ShouldForceColor(highlight_color)) {
return visited_link ? style.GetInternalForcedVisitedCurrentColor()
: style.GetInternalForcedCurrentColor();
}
return style.ResolvedColor(style.TapHighlightColor());
}
const CSSValue* WebkitTapHighlightColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::CurrentColorOrValidColor(
style, style.TapHighlightColor(), CSSValuePhase::kComputedValue);
}
const CSSValue* WebkitTextCombine::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.TextCombine() == ETextCombine::kAll)
return CSSIdentifierValue::Create(CSSValueID::kHorizontal);
return CSSIdentifierValue::Create(style.TextCombine());
}
const CSSValue* WebkitTextDecorationsInEffect::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeTextDecorationLine(range);
}
const CSSValue*
WebkitTextDecorationsInEffect::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::RenderTextDecorationFlagsToCSSValue(
style.TextDecorationsInEffect());
}
const CSSValue* WebkitTextEmphasisColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color WebkitTextEmphasisColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
StyleColor text_emphasis_color = style.TextEmphasisColor();
if (style.ShouldForceColor(text_emphasis_color))
return style.GetInternalForcedCurrentColor();
return text_emphasis_color.Resolve(style.GetCurrentColor(),
style.UsedColorScheme());
}
const CSSValue* WebkitTextEmphasisColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::CurrentColorOrValidColor(
style, style.TextEmphasisColor(), CSSValuePhase::kComputedValue);
}
// [ over | under ] && [ right | left ]?
// If [ right | left ] is omitted, it defaults to right.
const CSSValue* WebkitTextEmphasisPosition::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSIdentifierValue* values[2] = {
css_parsing_utils::ConsumeIdent<CSSValueID::kOver, CSSValueID::kUnder,
CSSValueID::kRight, CSSValueID::kLeft>(
range),
nullptr};
if (!values[0])
return nullptr;
values[1] =
css_parsing_utils::ConsumeIdent<CSSValueID::kOver, CSSValueID::kUnder,
CSSValueID::kRight, CSSValueID::kLeft>(
range);
CSSIdentifierValue* over_under = nullptr;
CSSIdentifierValue* left_right = nullptr;
for (auto* value : values) {
if (!value)
break;
switch (value->GetValueID()) {
case CSSValueID::kOver:
case CSSValueID::kUnder:
if (over_under)
return nullptr;
over_under = value;
break;
case CSSValueID::kLeft:
case CSSValueID::kRight:
if (left_right)
return nullptr;
left_right = value;
break;
default:
NOTREACHED();
break;
}
}
if (!over_under)
return nullptr;
if (!left_right)
left_right = CSSIdentifierValue::Create(CSSValueID::kRight);
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*over_under);
list->Append(*left_right);
return list;
}
const CSSValue* WebkitTextEmphasisPosition::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
switch (style.GetTextEmphasisPosition()) {
case TextEmphasisPosition::kOverRight:
list->Append(*CSSIdentifierValue::Create(CSSValueID::kOver));
list->Append(*CSSIdentifierValue::Create(CSSValueID::kRight));
break;
case TextEmphasisPosition::kOverLeft:
list->Append(*CSSIdentifierValue::Create(CSSValueID::kOver));
list->Append(*CSSIdentifierValue::Create(CSSValueID::kLeft));
break;
case TextEmphasisPosition::kUnderRight:
list->Append(*CSSIdentifierValue::Create(CSSValueID::kUnder));
list->Append(*CSSIdentifierValue::Create(CSSValueID::kRight));
break;
case TextEmphasisPosition::kUnderLeft:
list->Append(*CSSIdentifierValue::Create(CSSValueID::kUnder));
list->Append(*CSSIdentifierValue::Create(CSSValueID::kLeft));
break;
}
return list;
}
const CSSValue* WebkitTextEmphasisStyle::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
CSSValueID id = range.Peek().Id();
if (id == CSSValueID::kNone)
return css_parsing_utils::ConsumeIdent(range);
if (CSSValue* text_emphasis_style = css_parsing_utils::ConsumeString(range))
return text_emphasis_style;
CSSIdentifierValue* fill =
css_parsing_utils::ConsumeIdent<CSSValueID::kFilled, CSSValueID::kOpen>(
range);
CSSIdentifierValue* shape = css_parsing_utils::ConsumeIdent<
CSSValueID::kDot, CSSValueID::kCircle, CSSValueID::kDoubleCircle,
CSSValueID::kTriangle, CSSValueID::kSesame>(range);
if (!fill) {
fill =
css_parsing_utils::ConsumeIdent<CSSValueID::kFilled, CSSValueID::kOpen>(
range);
}
if (fill && shape) {
CSSValueList* parsed_values = CSSValueList::CreateSpaceSeparated();
parsed_values->Append(*fill);
parsed_values->Append(*shape);
return parsed_values;
}
if (fill)
return fill;
if (shape)
return shape;
return nullptr;
}
const CSSValue* WebkitTextEmphasisStyle::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
switch (style.GetTextEmphasisMark()) {
case TextEmphasisMark::kNone:
return CSSIdentifierValue::Create(CSSValueID::kNone);
case TextEmphasisMark::kCustom:
return MakeGarbageCollected<CSSStringValue>(
style.TextEmphasisCustomMark());
case TextEmphasisMark::kAuto:
NOTREACHED();
FALLTHROUGH;
case TextEmphasisMark::kDot:
case TextEmphasisMark::kCircle:
case TextEmphasisMark::kDoubleCircle:
case TextEmphasisMark::kTriangle:
case TextEmphasisMark::kSesame: {
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*CSSIdentifierValue::Create(style.GetTextEmphasisFill()));
list->Append(*CSSIdentifierValue::Create(style.GetTextEmphasisMark()));
return list;
}
}
NOTREACHED();
return nullptr;
}
void WebkitTextEmphasisStyle::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetTextEmphasisFill(
ComputedStyleInitialValues::InitialTextEmphasisFill());
state.Style()->SetTextEmphasisMark(
ComputedStyleInitialValues::InitialTextEmphasisMark());
state.Style()->SetTextEmphasisCustomMark(
ComputedStyleInitialValues::InitialTextEmphasisCustomMark());
}
void WebkitTextEmphasisStyle::ApplyInherit(StyleResolverState& state) const {
state.Style()->SetTextEmphasisFill(
state.ParentStyle()->GetTextEmphasisFill());
state.Style()->SetTextEmphasisMark(
state.ParentStyle()->GetTextEmphasisMark());
state.Style()->SetTextEmphasisCustomMark(
state.ParentStyle()->TextEmphasisCustomMark());
}
void WebkitTextEmphasisStyle::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
if (const auto* list = DynamicTo<CSSValueList>(value)) {
DCHECK_EQ(list->length(), 2U);
for (unsigned i = 0; i < 2; ++i) {
const auto& ident_value = To<CSSIdentifierValue>(list->Item(i));
if (ident_value.GetValueID() == CSSValueID::kFilled ||
ident_value.GetValueID() == CSSValueID::kOpen) {
state.Style()->SetTextEmphasisFill(
ident_value.ConvertTo<TextEmphasisFill>());
} else {
state.Style()->SetTextEmphasisMark(
ident_value.ConvertTo<TextEmphasisMark>());
}
}
state.Style()->SetTextEmphasisCustomMark(g_null_atom);
return;
}
if (auto* string_value = DynamicTo<CSSStringValue>(value)) {
state.Style()->SetTextEmphasisFill(TextEmphasisFill::kFilled);
state.Style()->SetTextEmphasisMark(TextEmphasisMark::kCustom);
state.Style()->SetTextEmphasisCustomMark(
AtomicString(string_value->Value()));
return;
}
const auto& identifier_value = To<CSSIdentifierValue>(value);
state.Style()->SetTextEmphasisCustomMark(g_null_atom);
if (identifier_value.GetValueID() == CSSValueID::kFilled ||
identifier_value.GetValueID() == CSSValueID::kOpen) {
state.Style()->SetTextEmphasisFill(
identifier_value.ConvertTo<TextEmphasisFill>());
state.Style()->SetTextEmphasisMark(TextEmphasisMark::kAuto);
} else {
state.Style()->SetTextEmphasisFill(TextEmphasisFill::kFilled);
state.Style()->SetTextEmphasisMark(
identifier_value.ConvertTo<TextEmphasisMark>());
}
}
const CSSValue* WebkitTextFillColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color WebkitTextFillColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
StyleColor text_fill_color = style.TextFillColor();
if (style.ShouldForceColor(text_fill_color))
return style.GetInternalForcedCurrentColor();
return text_fill_color.Resolve(style.GetCurrentColor(),
style.UsedColorScheme());
}
const CSSValue* WebkitTextFillColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::CurrentColorOrValidColor(
style, style.TextFillColor(), CSSValuePhase::kComputedValue);
}
const CSSValue* WebkitTextOrientation::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.GetTextOrientation() == ETextOrientation::kMixed)
return CSSIdentifierValue::Create(CSSValueID::kVerticalRight);
return CSSIdentifierValue::Create(style.GetTextOrientation());
}
void WebkitTextOrientation::ApplyInitial(StyleResolverState& state) const {
state.SetTextOrientation(
ComputedStyleInitialValues::InitialTextOrientation());
}
void WebkitTextOrientation::ApplyInherit(StyleResolverState& state) const {
state.SetTextOrientation(state.ParentStyle()->GetTextOrientation());
}
void WebkitTextOrientation::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.SetTextOrientation(
To<CSSIdentifierValue>(value).ConvertTo<ETextOrientation>());
}
const CSSValue* WebkitTextSecurity::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.TextSecurity());
}
const CSSValue* WebkitTextStrokeColor::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeColor(range, context);
}
const blink::Color WebkitTextStrokeColor::ColorIncludingFallback(
bool visited_link,
const ComputedStyle& style) const {
DCHECK(!visited_link);
StyleColor text_stroke_color = style.TextStrokeColor();
if (style.ShouldForceColor(text_stroke_color))
return style.GetInternalForcedCurrentColor();
return text_stroke_color.Resolve(style.GetCurrentColor(),
style.UsedColorScheme());
}
const CSSValue* WebkitTextStrokeColor::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::CurrentColorOrValidColor(
style, style.TextStrokeColor(), CSSValuePhase::kComputedValue);
}
const CSSValue* WebkitTextStrokeWidth::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeLineWidth(
range, context, css_parsing_utils::UnitlessQuirk::kForbid);
}
const CSSValue* WebkitTextStrokeWidth::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.TextStrokeWidth(), style);
}
const CSSValue* WebkitTransformOriginX::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumePositionLonghand<CSSValueID::kLeft,
CSSValueID::kRight>(
range, context);
}
const CSSValue* WebkitTransformOriginY::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumePositionLonghand<CSSValueID::kTop,
CSSValueID::kBottom>(
range, context);
}
const CSSValue* WebkitTransformOriginZ::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeLength(range, context, kValueRangeAll);
}
const CSSValue* WebkitUserDrag::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.UserDrag());
}
const CSSValue* WebkitUserModify::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.UserModify());
}
const CSSValue* WebkitWritingMode::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetWritingMode());
}
void WebkitWritingMode::ApplyInitial(StyleResolverState& state) const {
state.SetWritingMode(ComputedStyleInitialValues::InitialWritingMode());
}
void WebkitWritingMode::ApplyInherit(StyleResolverState& state) const {
state.SetWritingMode(state.ParentStyle()->GetWritingMode());
}
void WebkitWritingMode::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.SetWritingMode(
To<CSSIdentifierValue>(value).ConvertTo<blink::WritingMode>());
}
const CSSValue* WhiteSpace::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.WhiteSpace());
}
const CSSValue* Widows::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumePositiveInteger(range, context);
}
const CSSValue* Widows::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.Widows(),
CSSPrimitiveValue::UnitType::kNumber);
}
const CSSValue* Width::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeWidthOrHeight(
range, context, css_parsing_utils::UnitlessQuirk::kAllow);
}
bool Width::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && (layout_object->IsBox() || layout_object->IsSVG());
}
const CSSValue* Width::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject* layout_object,
bool allow_visited_style) const {
if (ComputedStyleUtils::WidthOrHeightShouldReturnUsedValue(layout_object)) {
return ZoomAdjustedPixelValue(
ComputedStyleUtils::UsedBoxSize(*layout_object).Width(), style);
}
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(style.Width(),
style);
}
const CSSValue* WillChange::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
CSSValueList* values = CSSValueList::CreateCommaSeparated();
// Every comma-separated list of identifiers is a valid will-change value,
// unless the list includes an explicitly disallowed identifier.
while (true) {
if (range.Peek().GetType() != kIdentToken)
return nullptr;
CSSPropertyID unresolved_property = UnresolvedCSSPropertyID(
context.GetExecutionContext(), range.Peek().Value());
if (unresolved_property != CSSPropertyID::kInvalid &&
unresolved_property != CSSPropertyID::kVariable) {
#if DCHECK_IS_ON()
DCHECK(CSSProperty::Get(ResolveCSSPropertyID(unresolved_property))
.IsWebExposed(context.GetExecutionContext()));
#endif
// Now "all" is used by both CSSValue and CSSPropertyValue.
// Need to return nullptr when currentValue is CSSPropertyID::kAll.
if (unresolved_property == CSSPropertyID::kWillChange ||
unresolved_property == CSSPropertyID::kAll)
return nullptr;
values->Append(
*MakeGarbageCollected<CSSCustomIdentValue>(unresolved_property));
range.ConsumeIncludingWhitespace();
} else {
switch (range.Peek().Id()) {
case CSSValueID::kNone:
case CSSValueID::kAll:
case CSSValueID::kAuto:
case CSSValueID::kDefault:
case CSSValueID::kInitial:
case CSSValueID::kInherit:
case CSSValueID::kRevert:
return nullptr;
case CSSValueID::kContents:
case CSSValueID::kScrollPosition:
values->Append(*css_parsing_utils::ConsumeIdent(range));
break;
default:
range.ConsumeIncludingWhitespace();
break;
}
}
if (range.AtEnd())
break;
if (!css_parsing_utils::ConsumeCommaIncludingWhitespace(range))
return nullptr;
}
return values;
}
const CSSValue* WillChange::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForWillChange(
style.WillChangeProperties(), style.WillChangeContents(),
style.WillChangeScrollPosition());
}
void WillChange::ApplyInitial(StyleResolverState& state) const {
state.Style()->SetWillChangeContents(false);
state.Style()->SetWillChangeScrollPosition(false);
state.Style()->SetWillChangeProperties(Vector<CSSPropertyID>());
state.Style()->SetSubtreeWillChangeContents(
state.ParentStyle()->SubtreeWillChangeContents());
}
void WillChange::ApplyInherit(StyleResolverState& state) const {
state.Style()->SetWillChangeContents(
state.ParentStyle()->WillChangeContents());
state.Style()->SetWillChangeScrollPosition(
state.ParentStyle()->WillChangeScrollPosition());
state.Style()->SetWillChangeProperties(
state.ParentStyle()->WillChangeProperties());
state.Style()->SetSubtreeWillChangeContents(
state.ParentStyle()->SubtreeWillChangeContents());
}
void WillChange::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
bool will_change_contents = false;
bool will_change_scroll_position = false;
Vector<CSSPropertyID> will_change_properties;
if (auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) {
DCHECK_EQ(identifier_value->GetValueID(), CSSValueID::kAuto);
} else {
for (auto& will_change_value : To<CSSValueList>(value)) {
if (auto* ident_value =
DynamicTo<CSSCustomIdentValue>(will_change_value.Get())) {
will_change_properties.push_back(ident_value->ValueAsPropertyID());
} else if (To<CSSIdentifierValue>(*will_change_value).GetValueID() ==
CSSValueID::kContents) {
will_change_contents = true;
} else if (To<CSSIdentifierValue>(*will_change_value).GetValueID() ==
CSSValueID::kScrollPosition) {
will_change_scroll_position = true;
} else {
NOTREACHED();
}
}
}
state.Style()->SetWillChangeContents(will_change_contents);
state.Style()->SetWillChangeScrollPosition(will_change_scroll_position);
state.Style()->SetWillChangeProperties(will_change_properties);
state.Style()->SetSubtreeWillChangeContents(
will_change_contents || state.ParentStyle()->SubtreeWillChangeContents());
}
const CSSValue* WordBreak::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.WordBreak());
}
const CSSValue* WordSpacing::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ParseSpacing(range, context);
}
const CSSValue* WordSpacing::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ZoomAdjustedPixelValue(style.WordSpacing(), style);
}
const CSSValue* WritingMode::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.GetWritingMode());
}
void WritingMode::ApplyInitial(StyleResolverState& state) const {
state.SetWritingMode(ComputedStyleInitialValues::InitialWritingMode());
}
void WritingMode::ApplyInherit(StyleResolverState& state) const {
state.SetWritingMode(state.ParentStyle()->GetWritingMode());
}
void WritingMode::ApplyValue(StyleResolverState& state,
const CSSValue& value) const {
state.SetWritingMode(
To<CSSIdentifierValue>(value).ConvertTo<blink::WritingMode>());
}
const CSSValue* X::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeSVGGeometryPropertyLength(range, context,
kValueRangeAll);
}
const CSSValue* X::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(style.X(), style);
}
const CSSValue* Y::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeSVGGeometryPropertyLength(range, context,
kValueRangeAll);
}
const CSSValue* Y::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return ComputedStyleUtils::ZoomAdjustedPixelValueForLength(style.Y(), style);
}
const CSSValue* ZIndex::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto)
return css_parsing_utils::ConsumeIdent(range);
return css_parsing_utils::ConsumeInteger(range, context);
}
const CSSValue* ZIndex::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
if (style.HasAutoZIndex())
return CSSIdentifierValue::Create(CSSValueID::kAuto);
return CSSNumericLiteralValue::Create(style.ZIndex(),
CSSPrimitiveValue::UnitType::kInteger);
}
const CSSValue* Zoom::ParseSingleValue(CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext&) const {
const CSSParserToken& token = range.Peek();
CSSValue* zoom = nullptr;
if (token.GetType() == kIdentToken) {
zoom = css_parsing_utils::ConsumeIdent<CSSValueID::kNormal>(range);
} else {
zoom = css_parsing_utils::ConsumePercent(range, context,
kValueRangeNonNegative);
if (!zoom) {
zoom = css_parsing_utils::ConsumeNumber(range, context,
kValueRangeNonNegative);
}
}
if (zoom) {
if (!(token.Id() == CSSValueID::kNormal ||
(token.GetType() == kNumberToken &&
To<CSSPrimitiveValue>(zoom)->GetDoubleValue() == 1) ||
(token.GetType() == kPercentageToken &&
To<CSSPrimitiveValue>(zoom)->GetDoubleValue() == 100)))
context.Count(WebFeature::kCSSZoomNotEqualToOne);
}
return zoom;
}
const CSSValue* Zoom::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const LayoutObject*,
bool allow_visited_style) const {
return CSSNumericLiteralValue::Create(style.Zoom(),
CSSPrimitiveValue::UnitType::kNumber);
}
void Zoom::ApplyInitial(StyleResolverState& state) const {
state.SetZoom(ComputedStyleInitialValues::InitialZoom());
}
void Zoom::ApplyInherit(StyleResolverState& state) const {
state.SetZoom(state.ParentStyle()->Zoom());
}
void Zoom::ApplyValue(StyleResolverState& state, const CSSValue& value) const {
state.SetZoom(StyleBuilderConverter::ConvertZoom(state, value));
}
const CSSValue* InternalAlignSelfBlock::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeIdent<CSSValueID::kCenter,
CSSValueID::kNormal>(range);
}
const CSSValue* InternalEmptyLineHeight::ParseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext&,
const CSSParserLocalContext&) const {
return css_parsing_utils::ConsumeIdent<CSSValueID::kFabricated,
CSSValueID::kNone>(range);
}
} // namespace css_longhand
} // namespace blink
| 37.164377
| 86
| 0.722951
|
DamieFC
|
f57b60c102973381d996c3d370d2129ca4de5c5d
| 211
|
cpp
|
C++
|
src/arch/user_space/destroy.cpp
|
xhd2015/rsp3-armv8-baremetal
|
f7e2ac04abd3be20daa94ad9c7ad2c1bad5159b0
|
[
"MIT"
] | 21
|
2018-03-14T09:45:26.000Z
|
2021-09-13T01:13:27.000Z
|
src/arch/user_space/destroy.cpp
|
xhd2015/rsp3-armv8-baremetal
|
f7e2ac04abd3be20daa94ad9c7ad2c1bad5159b0
|
[
"MIT"
] | null | null | null |
src/arch/user_space/destroy.cpp
|
xhd2015/rsp3-armv8-baremetal
|
f7e2ac04abd3be20daa94ad9c7ad2c1bad5159b0
|
[
"MIT"
] | 4
|
2018-03-18T11:56:09.000Z
|
2021-02-04T16:26:52.000Z
|
/*
* exti.cpp
*
* Created on: Mar 13, 2018
* Author: 13774
*/
#include <interrupt/svc_call.h>
#include <schedule/PidManager.h>
void destroy(int i)
{
svc_call<SvcFunc::killProcess>(PID_CURRENT,i);
}
| 15.071429
| 47
| 0.663507
|
xhd2015
|
f58052c19e8ce9fb896998e3cc7b91608b4ec265
| 4,564
|
cpp
|
C++
|
legacy/galaxy/components/BatchSprite.cpp
|
reworks/rework
|
90508252c9a4c77e45a38e7ce63cfd99f533f42b
|
[
"Apache-2.0"
] | 19
|
2020-02-02T16:36:46.000Z
|
2021-12-25T07:02:28.000Z
|
legacy/galaxy/components/BatchSprite.cpp
|
reworks/rework
|
90508252c9a4c77e45a38e7ce63cfd99f533f42b
|
[
"Apache-2.0"
] | 103
|
2020-10-13T09:03:42.000Z
|
2022-03-26T03:41:50.000Z
|
legacy/galaxy/components/BatchSprite.cpp
|
reworks/rework
|
90508252c9a4c77e45a38e7ce63cfd99f533f42b
|
[
"Apache-2.0"
] | 5
|
2020-03-13T06:14:37.000Z
|
2021-12-12T02:13:46.000Z
|
///
/// BatchSprite.cpp
/// galaxy
///
/// Refer to LICENSE.txt for more details.
///
#include "galaxy/core/ServiceLocator.hpp"
#include "galaxy/resource/TextureBook.hpp"
#include "BatchSprite.hpp"
namespace galaxy
{
namespace components
{
BatchSprite::BatchSprite() noexcept
: Serializable {this}
, m_index {0}
, m_region {0.0f, 0.0f, 0.0f, 0.0f}
, m_clip {0.0f, 0.0f}
, m_opacity {255}
{
}
BatchSprite::BatchSprite(const nlohmann::json& json)
: Serializable {this}
, m_index {0}
, m_region {0.0f, 0.0f, 0.0f, 0.0f}
, m_clip {0.0f, 0.0f}
, m_opacity {255}
{
deserialize(json);
}
BatchSprite::BatchSprite(BatchSprite&& bs) noexcept
: Serializable {this}
{
this->m_clip = std::move(bs.m_clip);
this->m_key = std::move(bs.m_key);
this->m_region = std::move(bs.m_region);
this->m_index = bs.m_index;
this->m_layer = std::move(bs.m_layer);
this->m_opacity = bs.m_opacity;
}
BatchSprite& BatchSprite::operator=(BatchSprite&& bs) noexcept
{
if (this != &bs)
{
this->m_clip = std::move(bs.m_clip);
this->m_key = std::move(bs.m_key);
this->m_region = std::move(bs.m_region);
this->m_index = bs.m_index;
this->m_layer = std::move(bs.m_layer);
this->m_opacity = bs.m_opacity;
}
return *this;
}
BatchSprite::~BatchSprite() noexcept
{
}
void BatchSprite::create(const math::Rect<float>& region, std::string_view layer, std::size_t index) noexcept
{
m_region = region;
m_index = index;
m_clip = {0.0f, 0.0f};
m_layer = static_cast<std::string>(layer);
}
void BatchSprite::create(std::string_view texture_key, std::string_view layer) noexcept
{
auto info = SL_HANDLE.texturebook()->search(texture_key);
if (info != std::nullopt)
{
m_key = static_cast<std::string>(texture_key);
m_region = info.value().m_region;
m_index = info.value().m_index;
m_clip = {0.0f, 0.0f};
m_layer = static_cast<std::string>(layer);
}
else
{
GALAXY_LOG(GALAXY_ERROR, "Failed to get texture from textureatlas for batchsprite: {0}.", texture_key);
}
}
void BatchSprite::update_region(std::string_view texture_key) noexcept
{
create(texture_key, m_layer);
}
void BatchSprite::set_layer(std::string_view layer) noexcept
{
m_layer = static_cast<std::string>(layer);
}
void BatchSprite::set_opacity(const std::uint8_t opacity) noexcept
{
m_opacity = std::clamp<std::uint8_t>(opacity, 0, 255);
}
void BatchSprite::clip_width(const float width) noexcept
{
m_clip.x = width;
m_region.m_width = width;
}
void BatchSprite::clip_height(const float height) noexcept
{
m_clip.y = height;
m_region.m_height = height;
}
const glm::vec2& BatchSprite::get_clip() const noexcept
{
return m_clip;
}
const std::string& BatchSprite::get_layer() const noexcept
{
return m_layer;
}
const std::uint8_t BatchSprite::get_opacity() const noexcept
{
return m_opacity;
}
const math::Rect<float>& BatchSprite::get_region() const noexcept
{
return m_region;
}
const std::string& BatchSprite::get_key() const noexcept
{
return m_key;
}
const std::size_t BatchSprite::get_atlas_index() const noexcept
{
return m_index;
}
nlohmann::json BatchSprite::serialize()
{
nlohmann::json json = "{}"_json;
json["texture-key"] = m_key;
json["layer"] = m_layer;
json["opacity"] = m_opacity;
json["clip"] = nlohmann::json::object();
json["clip"]["w"] = m_clip.x;
json["clip"]["h"] = m_clip.y;
json["region"] = nlohmann::json::object();
json["region"]["x"] = m_region.m_x;
json["region"]["y"] = m_region.m_y;
json["region"]["w"] = m_region.m_width;
json["region"]["h"] = m_region.m_height;
return json;
}
void BatchSprite::deserialize(const nlohmann::json& json)
{
if (json.count("texture-key") > 0)
{
create(json.at("texture-key"), json.at("layer"));
}
else if (json.count("region") > 0)
{
const auto& region = json.at("region");
m_region.m_x = region.at("x");
m_region.m_y = region.at("y");
m_region.m_width = region.at("w");
m_region.m_height = region.at("h");
create(region, json.at("layer"));
}
set_opacity(json.at("opacity"));
if (json.count("clip") > 0)
{
const auto& clip = json.at("clip");
m_clip.x = clip.at("w");
m_clip.y = clip.at("h");
}
}
} // namespace components
} // namespace galaxy
| 23.050505
| 111
| 0.622699
|
reworks
|
f580630eea06ce8ba9b530ae7bc4a4449b7fc846
| 1,167
|
cpp
|
C++
|
Contest 1008/E.cpp
|
PC-DOS/SEUCPP-OJ-KEYS
|
073f97fb29a659abd25554330382f0a7149c2511
|
[
"MIT"
] | null | null | null |
Contest 1008/E.cpp
|
PC-DOS/SEUCPP-OJ-KEYS
|
073f97fb29a659abd25554330382f0a7149c2511
|
[
"MIT"
] | null | null | null |
Contest 1008/E.cpp
|
PC-DOS/SEUCPP-OJ-KEYS
|
073f97fb29a659abd25554330382f0a7149c2511
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
using namespace std;
long GetNonOddCount(long number){
string num;
long nCount = 0;
num = to_string(number);
long i;
int tmp;
for (i = 0; i <= num.length() - 1; ++i){
tmp = num[i] - '0';
if (tmp % 2 == 0)
++nCount;
}
return nCount;
}
void Process(int n){
n = abs(n);
int Num;
int Count_NotOdd;
int Count_Odd;
int i=0;
if (n == 321)
cout << 321;
else
if (n == 0){
cout << 101 << endl;
Process(101);
}
else{
Num = int(log10(n)) + 1;
Count_NotOdd = GetNonOddCount(n);
Count_Odd = Num - Count_NotOdd;
i += Count_NotOdd;
if (i == 0)
i += Count_Odd * 10;
else
i += Count_Odd*pow(10, int(log10(i)) + 1);
i +=Num*pow(10, int(log10(i)) + 1);
if (i != 321) cout << i << endl;
Process(i);
}
}
int main(){
long n;
cin >> n;
Process(n);
//system("pause > nul");
return 0;
}
| 21.611111
| 58
| 0.449871
|
PC-DOS
|
f5815785970c6447eadbd394e8317436b675aff9
| 847
|
cpp
|
C++
|
src/wallet/test/wallet_transaction_tests.cpp
|
wilofice/dahomey
|
5cbc2406a27e68bbe30f85a7162b86f4741effab
|
[
"MIT"
] | 1
|
2022-03-19T13:35:37.000Z
|
2022-03-19T13:35:37.000Z
|
src/wallet/test/wallet_transaction_tests.cpp
|
wilofice/danxome
|
5cbc2406a27e68bbe30f85a7162b86f4741effab
|
[
"MIT"
] | null | null | null |
src/wallet/test/wallet_transaction_tests.cpp
|
wilofice/danxome
|
5cbc2406a27e68bbe30f85a7162b86f4741effab
|
[
"MIT"
] | null | null | null |
// Copyright (c) 2021 The Danxome Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <wallet/transaction.h>
#include <wallet/test/wallet_test_fixture.h>
#include <boost/test/unit_test.hpp>
namespace wallet {
BOOST_FIXTURE_TEST_SUITE(wallet_transaction_tests, WalletTestingSetup)
BOOST_AUTO_TEST_CASE(roundtrip)
{
for (uint8_t hash = 0; hash < 5; ++hash) {
for (int index = -2; index < 3; ++index) {
TxState state = TxStateInterpretSerialized(TxStateUnrecognized{uint256{hash}, index});
BOOST_CHECK_EQUAL(TxStateSerializedBlockHash(state), uint256{hash});
BOOST_CHECK_EQUAL(TxStateSerializedIndex(state), index);
}
}
}
BOOST_AUTO_TEST_SUITE_END()
} // namespace wallet
| 31.37037
| 98
| 0.726092
|
wilofice
|
f5815e86c78f4b08b3a49c393e4218bf434c004e
| 2,314
|
cpp
|
C++
|
gui/tool-panel.cpp
|
lukas-ke/faint-graphics-editor
|
33eb9e6a3f2216fb2cf6ef9709a14f3d20b78fbf
|
[
"Apache-2.0"
] | 10
|
2016-12-28T22:06:31.000Z
|
2021-05-24T13:42:30.000Z
|
gui/tool-panel.cpp
|
lukas-ke/faint-graphics-editor
|
33eb9e6a3f2216fb2cf6ef9709a14f3d20b78fbf
|
[
"Apache-2.0"
] | 4
|
2015-10-09T23:55:10.000Z
|
2020-04-04T08:09:22.000Z
|
gui/tool-panel.cpp
|
lukas-ke/faint-graphics-editor
|
33eb9e6a3f2216fb2cf6ef9709a14f3d20b78fbf
|
[
"Apache-2.0"
] | null | null | null |
// -*- coding: us-ascii-unix -*-
// Copyright 2012 Lukas Kemmer
//
// 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 "wx/defs.h" // wxEXPAND etc
#include "gui/tool-bar.hh"
#include "gui/tool-panel.hh"
#include "gui/tool-setting-panel.hh"
#include "util-wx/fwd-wx.hh"
#include "util-wx/layout-wx.hh"
namespace faint{
ToolPanel::ToolPanel(wxWindow* parent,
StatusInterface& status,
Art& art,
DialogContext& dialogContext,
const StringSource& unitStrings)
{
m_panel = create_panel(parent);
m_toolbar = std::make_unique<Toolbar>(m_panel, status, art);
m_toolSettingPanel = std::make_unique<ToolSettingPanel>(m_panel,
status,
art,
dialogContext,
unitStrings);
const int borderSize = from_DIP(5, m_panel);
using namespace layout;
set_sizer(m_panel,
create_column(OuterSpacing(0), ItemSpacing(0), {
{m_toolbar->AsWindow(),
Proportion(0),
wxEXPAND|wxUP|wxLEFT|wxRIGHT, borderSize},
{m_toolSettingPanel->AsWindow(),
Proportion(1),
wxEXPAND|wxLEFT|wxRIGHT, borderSize}}));
}
ToolPanel::~ToolPanel(){
deleted_by_wx(m_panel);
}
wxWindow* ToolPanel::AsWindow(){
return m_panel;
}
bool ToolPanel::Visible() const{
return is_shown(m_panel);
}
void ToolPanel::Show(bool s){
show(m_panel, s);
}
void ToolPanel::Enable(bool e){
enable(m_panel, e);
}
void ToolPanel::Hide(){
hide(m_panel);
}
void ToolPanel::ShowSettings(const Settings& s){
m_toolSettingPanel->ShowSettings(s);
}
void ToolPanel::SelectTool(ToolId id){
// Fixme: Weird, IIRC, used to put all handling in a FaintWindow
// event-handler, and not duplicate button state...
m_toolbar->SendToolChoiceEvent(id);
}
void ToolPanel::SelectLayer(Layer layer){
// Fixme: See SelectTool note
m_toolbar->SendLayerChoiceEvent(layer);
}
} // namespace
| 24.88172
| 70
| 0.715644
|
lukas-ke
|
f584a645adc182c99c000b5ed7983a7d5d77dfb0
| 1,587
|
hpp
|
C++
|
Assignment6/BVH.hpp
|
Antares0982/GAMES101
|
d45cf6ad14fb633e64ecc5ef10e8637d27472f00
|
[
"MIT"
] | 1
|
2021-12-19T08:33:48.000Z
|
2021-12-19T08:33:48.000Z
|
Assignment6/BVH.hpp
|
Antares0982/GAMES101
|
d45cf6ad14fb633e64ecc5ef10e8637d27472f00
|
[
"MIT"
] | null | null | null |
Assignment6/BVH.hpp
|
Antares0982/GAMES101
|
d45cf6ad14fb633e64ecc5ef10e8637d27472f00
|
[
"MIT"
] | null | null | null |
//
// Created by LEI XU on 5/16/19.
//
#ifndef RAYTRACING_BVH_H
#define RAYTRACING_BVH_H
#include "Bounds3.hpp"
#include "Intersection.hpp"
#include "Object.hpp"
#include "Ray.hpp"
#include "Vector.hpp"
#include <atomic>
#include <ctime>
#include <memory>
#include <vector>
struct BVHBuildNode;
// BVHAccel Forward Declarations
struct BVHPrimitiveInfo;
// BVHAccel Declarations
inline int leafNodes, totalLeafNodes, totalPrimitives, interiorNodes;
class BVHAccel {
public:
// BVHAccel Public Types
enum class SplitMethod {
NAIVE,
SAH
};
// BVHAccel Public Methods
BVHAccel(std::vector<Object *> p, int maxPrimsInNode = 1, SplitMethod splitMethod = SplitMethod::NAIVE);
Bounds3 WorldBound() const;
~BVHAccel();
Intersection Intersect(const Ray &ray) const;
Intersection getIntersection(BVHBuildNode *node, const Ray &ray) const;
bool IntersectP(const Ray &ray) const;
BVHBuildNode *root;
// BVHAccel Private Methods
BVHBuildNode *recursiveBuild(std::vector<Object *> objects, Bounds3 totalbounds);
// BVHAccel Private Data
const int maxPrimsInNode;
const SplitMethod splitMethod;
std::vector<Object *> primitives;
};
struct BVHBuildNode {
Bounds3 bounds;
BVHBuildNode *left;
BVHBuildNode *right;
Object *object;
public:
int splitAxis = 0, firstPrimOffset = 0, nPrimitives = 0;
// BVHBuildNode Public Methods
BVHBuildNode() {
bounds = Bounds3();
left = nullptr;
right = nullptr;
object = nullptr;
}
};
#endif //RAYTRACING_BVH_H
| 22.352113
| 108
| 0.691241
|
Antares0982
|