text
string | size
int64 | token_count
int64 |
|---|---|---|
// Copyright 2020 CryptoGarage
#include "cfdcore/cfdcore_schnorrsig.h"
#include <cstring>
#include <string>
#include <vector>
#include "cfdcore/cfdcore_exception.h"
#include "cfdcore/cfdcore_util.h"
#include "secp256k1.h" // NOLINT
#include "secp256k1_schnorrsig.h" // NOLINT
#include "secp256k1_util.h" // NOLINT
#include "wally_core.h" // NOLINT
namespace cfd {
namespace core {
using cfd::core::ByteData;
using cfd::core::ByteData256;
using cfd::core::CfdError;
using cfd::core::CfdException;
using cfd::core::HashUtil;
// ----------------------------------------------------------------------------
// SchnorrSignature
// ----------------------------------------------------------------------------
SchnorrSignature::SchnorrSignature()
: data_(), sighash_type_(SigHashAlgorithm::kSigHashDefault) {}
SchnorrSignature::SchnorrSignature(const ByteData &data)
: data_(data), sighash_type_(SigHashAlgorithm::kSigHashDefault) {
if (data_.GetDataSize() == SchnorrSignature::kSchnorrSignatureSize + 1) {
auto bytes = data.GetBytes();
uint8_t sighash_type = bytes[SchnorrSignature::kSchnorrSignatureSize];
if ((sighash_type == 0) || (!IsValidSigHashType(sighash_type))) {
throw CfdException(
CfdError::kCfdIllegalArgumentError,
"Invalid Schnorr signature hash type.");
}
sighash_type_.SetFromSigHashFlag(sighash_type);
data_ = ByteData(bytes.data(), SchnorrSignature::kSchnorrSignatureSize);
} else if (data_.GetDataSize() != SchnorrSignature::kSchnorrSignatureSize) {
throw CfdException(
CfdError::kCfdIllegalArgumentError, "Invalid Schnorr signature data.");
}
}
SchnorrSignature::SchnorrSignature(const std::string &data)
: SchnorrSignature(ByteData(data)) {}
SchnorrSignature::SchnorrSignature(const SchnorrSignature &object) {
data_ = object.data_;
sighash_type_ = object.sighash_type_;
}
SchnorrSignature &SchnorrSignature::operator=(const SchnorrSignature &object) {
if (this != &object) {
data_ = object.data_;
sighash_type_ = object.sighash_type_;
}
return *this;
}
ByteData SchnorrSignature::GetData(bool append_sighash_type) const {
if ((!append_sighash_type) || (sighash_type_.GetSigHashFlag() == 0) ||
(data_.GetDataSize() != SchnorrSignature::kSchnorrSignatureSize)) {
return data_;
}
uint8_t sighash_type = static_cast<uint8_t>(sighash_type_.GetSigHashFlag());
return data_.Concat(ByteData(sighash_type));
}
std::string SchnorrSignature::GetHex(bool append_sighash_type) const {
if (sighash_type_.GetSigHashFlag() == 0) return data_.GetHex();
return GetData(append_sighash_type).GetHex();
}
SigHashType SchnorrSignature::GetSigHashType() const { return sighash_type_; }
SchnorrPubkey SchnorrSignature::GetNonce() const {
auto bytes = data_.GetBytes();
return SchnorrPubkey(ByteData(std::vector<uint8_t>(
bytes.begin(), bytes.begin() + SchnorrPubkey::kSchnorrPubkeySize)));
}
Privkey SchnorrSignature::GetPrivkey() const {
auto bytes = data_.GetBytes();
auto start = bytes.begin() + SchnorrPubkey::kSchnorrPubkeySize;
auto end = start + Privkey::kPrivkeySize;
return Privkey(ByteData(std::vector<uint8_t>(start, end)));
}
void SchnorrSignature::SetSigHashType(const SigHashType &sighash_type) {
if (!IsValidSigHashType(
static_cast<uint8_t>(sighash_type.GetSigHashFlag()))) {
throw CfdException(
CfdError::kCfdIllegalArgumentError,
"Invalid sighash type for schnorr signature.");
}
sighash_type_ = sighash_type;
}
bool SchnorrSignature::IsValidSigHashType(uint8_t sighash_type_value) {
bool is_anyone_can_pay = (sighash_type_value & 0x80) ? true : false;
if ((is_anyone_can_pay &&
((sighash_type_value <= 0x80) || (sighash_type_value > 0x83))) ||
((!is_anyone_can_pay) && (sighash_type_value > 0x03))) {
return false;
}
return true;
}
// ----------------------------------------------------------------------------
// SchnorrPubkey
// ----------------------------------------------------------------------------
SchnorrPubkey::SchnorrPubkey() : data_() {}
SchnorrPubkey::SchnorrPubkey(const ByteData &data) : data_() {
if (Pubkey::IsValid(data)) {
auto pk = SchnorrPubkey::FromPubkey(Pubkey(data));
data_ = pk.data_;
} else {
if (data.GetDataSize() != SchnorrPubkey::kSchnorrPubkeySize) {
throw CfdException(
CfdError::kCfdIllegalArgumentError,
"Invalid Schnorr pubkey length.");
}
data_ = ByteData256(data);
if (data_.IsEmpty()) {
throw CfdException(
CfdError::kCfdIllegalArgumentError, "Invalid Schnorr pubkey data.");
}
}
}
SchnorrPubkey::SchnorrPubkey(const ByteData256 &data) : data_(data) {
if (data.IsEmpty()) {
throw CfdException(
CfdError::kCfdIllegalArgumentError, "Invalid Schnorr pubkey data.");
}
}
SchnorrPubkey::SchnorrPubkey(const std::string &data)
: SchnorrPubkey(ByteData(data)) {}
SchnorrPubkey SchnorrPubkey::FromPrivkey(
const Privkey &privkey, bool *parity) {
auto ctx = wally_get_secp_context();
secp256k1_keypair keypair;
auto ret = secp256k1_keypair_create(
ctx, &keypair, privkey.GetData().GetBytes().data());
if (ret != 1) {
throw CfdException(
CfdError::kCfdIllegalArgumentError, "Invalid private key");
}
secp256k1_xonly_pubkey x_only_pubkey;
int pk_parity = 0;
ret = secp256k1_keypair_xonly_pub(ctx, &x_only_pubkey, &pk_parity, &keypair);
if (ret != 1) {
throw CfdException(CfdError::kCfdInternalError);
}
if (parity != nullptr) *parity = (pk_parity != 0);
return SchnorrPubkey(ConvertSchnorrPubkey(x_only_pubkey));
}
SchnorrPubkey SchnorrPubkey::FromPubkey(const Pubkey &pubkey, bool *parity) {
auto xpk = GetXOnlyPubkeyFromPubkey(ParsePubkey(pubkey), parity);
return SchnorrPubkey(ConvertSchnorrPubkey(xpk));
}
SchnorrPubkey SchnorrPubkey::CreateTweakAddFromPrivkey(
const Privkey &privkey, const ByteData256 &tweak, Privkey *tweaked_privkey,
bool *parity) {
std::vector<uint8_t> tweak_bytes = tweak.GetBytes();
auto ctx = wally_get_secp_context();
secp256k1_keypair keypair;
auto ret = secp256k1_keypair_create(
ctx, &keypair, privkey.GetData().GetBytes().data());
if (ret != 1) {
throw CfdException(
CfdError::kCfdIllegalArgumentError, "Invalid private key");
}
ret = secp256k1_keypair_xonly_tweak_add(ctx, &keypair, tweak_bytes.data());
if (ret != 1) {
throw CfdException(
CfdError::kCfdInternalError, "Could not tweak add key pair");
}
secp256k1_xonly_pubkey x_only_pubkey;
int pk_parity = 0;
ret = secp256k1_keypair_xonly_pub(ctx, &x_only_pubkey, &pk_parity, &keypair);
if (ret != 1) {
throw CfdException(CfdError::kCfdInternalError);
}
if (tweaked_privkey != nullptr) {
*tweaked_privkey = Privkey(ByteData(keypair.data, Privkey::kPrivkeySize));
}
if (parity != nullptr) *parity = (pk_parity != 0);
return SchnorrPubkey(ConvertSchnorrPubkey(x_only_pubkey));
}
ByteData SchnorrPubkey::GetData() const { return data_.GetData(); }
ByteData256 SchnorrPubkey::GetByteData256() const {
return ByteData256(data_);
}
std::string SchnorrPubkey::GetHex() const { return data_.GetHex(); }
bool SchnorrPubkey::Equals(const SchnorrPubkey &pubkey) const {
return data_.Equals(pubkey.data_);
}
bool SchnorrPubkey::IsValid() const { return !data_.IsEmpty(); }
SchnorrPubkey SchnorrPubkey::CreateTweakAdd(
const ByteData256 &tweak, bool *parity) const {
return SchnorrPubkey(TweakAddXonlyPubkey(*this, tweak, parity));
}
SchnorrPubkey SchnorrPubkey::CreateTweakAdd(
const SchnorrPubkey &tweak, bool *parity) const {
return CreateTweakAdd(tweak.data_, parity);
}
bool SchnorrPubkey::IsTweaked(
const SchnorrPubkey &base_pubkey, const ByteData256 &tweak,
bool parity) const {
return CheckTweakAddXonlyPubkey(*this, base_pubkey, tweak, parity);
}
bool SchnorrPubkey::Verify(
const SchnorrSignature &signature, const ByteData256 &msg) const {
return SchnorrUtil::Verify(signature, msg, *this);
}
Pubkey SchnorrPubkey::CreatePubkey(bool parity) const {
uint8_t head = (parity) ? 3 : 2;
ByteData data = ByteData(head).Concat(data_);
return Pubkey(data);
}
SchnorrPubkey SchnorrPubkey::operator+=(const ByteData256 &right) {
SchnorrPubkey key = CreateTweakAdd(right);
*this = key;
return *this;
}
SchnorrPubkey SchnorrPubkey::operator-=(const ByteData256 &right) {
Privkey sk(right);
auto neg = sk.CreateNegate();
SchnorrPubkey key = CreateTweakAdd(ByteData256(neg.GetData()));
*this = key;
return *this;
}
SchnorrPubkey operator+(const SchnorrPubkey &left, const ByteData256 &right) {
return left.CreateTweakAdd(right);
}
SchnorrPubkey operator-(const SchnorrPubkey &left, const ByteData256 &right) {
SchnorrPubkey key = left;
key -= right;
return key;
}
// ----------------------------------------------------------------------------
// SchnorrUtil
// ----------------------------------------------------------------------------
/**
* @brief A function that simply copies the data into the nonce.
*
* @param nonce32 the nonce
* @param msg32 unused
* @param key32 unused
* @param algo16 unused
* @param xonly_pk32 unused
* @param data the data (actually the nonce to use)
* @return int always returns 1
*/
int ConstantNonceFunction(
unsigned char *nonce32, const unsigned char *msg32,
const unsigned char *key32, const unsigned char *algo16,
const unsigned char *xonly_pk32, void *data) {
(void)msg32;
(void)key32;
(void)algo16;
(void)xonly_pk32;
std::memcpy(nonce32, (const unsigned char *)data, 32);
return 1;
}
/**
* @brief Constant nonce function instance to be passed to secp256k1.
*
*/
const secp256k1_nonce_function_hardened ConstantNonce = ConstantNonceFunction;
/**
* @brief Private function to both create a schnorr signature using the default
* bip340 nonce function (and passing aux_rand as ndata) or using the constant
* nonce function (and passing the nonce as ndata)
*
* @param msg the message to sign
* @param sk the private key to use
* @param nonce_fn the nonce function to use (if null uses bip 340 nonce function)
* @param ndata the ndata to pass
* @return SchnorrSignature the generated signature
*/
SchnorrSignature SignCommon(
const ByteData256 &msg, const Privkey &sk,
const secp256k1_nonce_function_hardened *nonce_fn, const ByteData ndata) {
auto ctx = wally_get_secp_context();
secp256k1_keypair keypair;
auto ret =
secp256k1_keypair_create(ctx, &keypair, sk.GetData().GetBytes().data());
if (ret != 1) {
throw CfdException(
CfdError::kCfdInternalError, "Could not create keypair.");
}
secp256k1_nonce_function_hardened nfn =
nonce_fn == nullptr ? nullptr : *nonce_fn;
std::vector<uint8_t> raw_sig(SchnorrSignature::kSchnorrSignatureSize);
ret = secp256k1_schnorrsig_sign(
ctx, raw_sig.data(), msg.GetBytes().data(), &keypair, nfn,
(ndata.IsEmpty()) ? nullptr : ndata.GetBytes().data());
if (ret != 1) {
throw CfdException(
CfdError::kCfdInternalError, "Could not create Schnorr signature.");
}
return SchnorrSignature(raw_sig);
}
SchnorrSignature SchnorrUtil::Sign(const ByteData256 &msg, const Privkey &sk) {
return SignCommon(msg, sk, nullptr, ByteData());
}
SchnorrSignature SchnorrUtil::Sign(
const ByteData256 &msg, const Privkey &sk, const ByteData256 &aux_rand) {
return SignCommon(msg, sk, nullptr, aux_rand.GetData());
}
SchnorrSignature SchnorrUtil::SignWithNonce(
const ByteData256 &msg, const Privkey &sk, const Privkey &nonce) {
return SignCommon(msg, sk, &ConstantNonce, nonce.GetData());
}
Pubkey SchnorrUtil::ComputeSigPoint(
const ByteData256 &msg, const SchnorrPubkey &nonce,
const SchnorrPubkey &pubkey) {
auto ctx = wally_get_secp_context();
secp256k1_xonly_pubkey xonly_pubkey = ParseXOnlyPubkey(pubkey);
secp256k1_xonly_pubkey secp_nonce = ParseXOnlyPubkey(nonce);
secp256k1_pubkey secp_sigpoint;
auto ret = secp256k1_schnorrsig_compute_sigpoint(
ctx, &secp_sigpoint, msg.GetBytes().data(), &secp_nonce, &xonly_pubkey);
if (ret != 1) {
throw CfdException(
CfdError::kCfdInternalError, "Could not compute sigpoint");
}
return ConvertSecpPubkey(secp_sigpoint);
}
Pubkey SchnorrUtil::ComputeSigPointBatch(
const std::vector<ByteData256> &msgs,
const std::vector<SchnorrPubkey> &nonces, const SchnorrPubkey &pubkey) {
if (msgs.size() != nonces.size() || msgs.empty()) {
throw CfdException(
CfdError::kCfdIllegalArgumentError,
"Expected same number of messages or nonces, and at least one "
"message.");
}
Pubkey rs;
if (msgs.size() == 1) {
rs = Pubkey(ByteData("02").Concat(nonces[0].GetData()));
} else {
std::vector<Pubkey> pub_nonces;
for (const auto &nonce : nonces) {
pub_nonces.push_back(Pubkey(ByteData("02").Concat(nonce.GetData())));
}
rs = Pubkey::CombinePubkey(pub_nonces);
}
auto bip340_challenge = ByteData(
"7bb52d7a9fef58323eb1bf7a407db382d2f3f2d81bb1224f49fe518f6d48d37c7bb52d7"
"a9fef58323eb1bf7a407db382d2f3f2d81bb1224f49fe518f6d48d37c");
Privkey res;
for (size_t i = 0; i < msgs.size(); i++) {
auto m_tagged_hash =
HashUtil::Sha256(bip340_challenge.Concat(nonces[i].GetData())
.Concat(pubkey.GetData())
.Concat(msgs[i]));
if (i == 0) {
res = Privkey(m_tagged_hash);
} else {
res = res.CreateTweakAdd(m_tagged_hash);
}
}
auto xe = Pubkey(ByteData("02").Concat(pubkey.GetData()))
.CreateTweakMul(ByteData256(res.GetData()));
return Pubkey::CombinePubkey({rs, xe});
}
bool SchnorrUtil::Verify(
const SchnorrSignature &signature, const ByteData256 &msg,
const SchnorrPubkey &pubkey) {
auto ctx = wally_get_secp_context();
secp256k1_xonly_pubkey xonly_pubkey = ParseXOnlyPubkey(pubkey);
return 1 == secp256k1_schnorrsig_verify(
ctx, signature.GetData().GetBytes().data(),
msg.GetBytes().data(), &xonly_pubkey);
}
} // namespace core
} // namespace cfd
| 14,174
| 5,343
|
//Copyright 2018 Husky Data Lab, CUHK
//Authors: Hongzhi Chen, Miao Liu
#ifndef SLAVE_COMMUN_HPP_
#define SLAVE_COMMUN_HPP_
#include <mpi.h>
#include "util/communication.hpp"
#include "util/global.hpp"
int slave_all_sum(int my_copy)
{
int tmp = my_copy;
if( _my_rank != SLAVE_LEADER)
{
send_data(my_copy, SLAVE_LEADER, MSCOMMUN_CHANNEL);
}
else
{
for (int i = 0; i < _num_workers - 2; i++)
{
tmp += recv_data<int>(MPI_ANY_SOURCE, MSCOMMUN_CHANNEL);
}
}
return tmp;
}
#endif /* SLAVE_COMMUN_HPP_ */
| 525
| 273
|
#pragma once
#include <algorithm>
#include <cmath>
#include <stdexcept>
#include <vector>
// LCA: Lowest Common Ancestor
// using Binary Lifting
//
// Space: O(V log V + E)
//
// NOTE:
// - undirected
// - non-loop
// - non-multi-edge
// - it can NOT handle a forest
//
// Verified:
// - https://onlinejudge.u-aizu.ac.jp/problems/GRL_5_C
//
class LCABinaryLifting {
private:
size_t N, L;
std::vector<size_t> tin, tout;
std::vector<std::vector<size_t>> up;
public:
// root = [0,N)
// Time: O(N logN)
LCABinaryLifting(
std::vector<std::vector<size_t>> const& adj = {},
size_t const root = 0
)
{
build(adj, root);
}
// root = [0,N)
// O(N logN)
void build(
std::vector<std::vector<size_t>> const& adj,
size_t const root = 0
)
{
N = adj.size();
L = std::ceil(std::log2(std::max(size_t(1),N))) + 1;
tin.assign(N, 2 * N);
tout.assign(N, 2 * N);
up.assign(N, std::vector<size_t>(L, 0));
if (N > 0) {
size_t timer = 0;
if (root >= N) throw std::out_of_range("root");
dfs_euler(adj, root, root, timer);
}
}
// A LCA node of both the node 'u' and the node 'v'
// Time: O(logN)
size_t query(size_t u, size_t v) const {
if (u >= N) throw std::out_of_range("u");
if (v >= N) throw std::out_of_range("v");
if (is_ancestor(u, v)) return u;
if (is_ancestor(v, u)) return v;
for (size_t i = 0; i < L; ++i) {
if (is_ancestor(up[u][L-1-i], v)) continue;
u = up[u][L-1-i];
}
return up[u][0];
}
// A highest ancestor node of the node 'u'
// where the ancestor is not an ancestor of the node 'v'.
// If 'u' is an ancestor of 'v', return 'N'.
// Time: O(logN)
size_t upper_bound(size_t u, size_t const v) const {
if (u >= N) throw std::out_of_range("u");
if (v >= N) throw std::out_of_range("v");
if (is_ancestor(u, v)) return N;
for (size_t i = 0; i < L; ++i) {
if (is_ancestor(up[u][L-1-i], v)) continue;
u = up[u][L-1-i];
}
return u;
}
// True if the node 'u' is an ancestor of the node 'v'
// u = [0,N), v = [0,N)
// Time: O(1)
bool is_ancestor(size_t const u, size_t const v) const {
if (u >= N) throw std::out_of_range("u");
if (v >= N) throw std::out_of_range("v");
return tin[u] <= tin[v] && tout[u] >= tout[v];
}
// The In Index of the Euler Tour
// u = [0,N)
// The In Index = [0,2*N)
size_t euler_in(size_t const u) const {
if (u >= N) throw std::out_of_range("u");
return tin[u];
}
// The Out Index of the Euler Tour
// u = [0,N)
// The Out Index = [0, 2*N)
size_t euler_out(size_t const u) const {
if (u >= N) throw std::out_of_range("u");
return tout[u];
}
// Time: O(1)
size_t size() const {
return N;
}
private:
// Time: O(N logN)
void dfs_euler(std::vector<std::vector<size_t>> const& adj, size_t v, size_t p, size_t& timer) {
tin[v] = timer++;
up[v][0] = p;
for (size_t i = 1; i < L; ++i) {
up[v][i] = up[up[v][i-1]][i-1];
}
for (auto const& u : adj[v]) {
if (u == p) continue;
dfs_euler(adj, u, v, timer);
}
tout[v] = timer++;
}
};
| 3,467
| 1,388
|
/*********************************************************************************
Copyright 2017 GlobalPlatform, Inc.
Licensed under the GlobalPlatform/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
https://github.com/GlobalPlatform/SE-test-IP-connector/blob/master/Charter%20and%20Rules%20for%20the%20SE%20IP%20connector.docx
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 "config/config_wrapper.hpp"
#include "nlohmann/json.hpp"
#include <fstream>
#include <iostream>
#include <string>
namespace server {
void ConfigWrapper::init(std::string path) {
std::ifstream i(path);
i >> config_;
i.close();
}
std::string ConfigWrapper::getValue(std::string key) {
return config_[key];
}
std::string ConfigWrapper::getValue(std::string key, std::string default_value) {
return config_[key].is_null() ? default_value : config_[key].get<std::string>();
}
} /* namespace server */
| 1,352
| 391
|
#ifndef DECISION_NODE_H
#define DECISION_NODE_H
#include "fconfig.hpp"
#include "fcontext.hpp"
#include <mcts/inner_node.hpp>
namespace freedom {
using mcts::INode;
using mcts::InnerNode;
// ----------------------------------------------------------------------
/// @brief Uses a selectionStrategy for nodes in which we (the bot)
/// has to make a move.
// ----------------------------------------------------------------------
class DecisionNode : public InnerNode<FContext, FConfig> {
typedef typename INode<FContext, FConfig>::node_t node_t;
public:
DecisionNode(const FContext &fcontext_, FConfig *fconfig_, node_t *parent_);
void expand();
virtual node_t *select_child();
virtual ~DecisionNode();
};
}
#endif
| 743
| 232
|
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD+Patents license found in the
* LICENSE file in the root directory of this source tree.
*/
// -*- c++ -*-
#include "IndexBinary.h"
#include "FaissAssert.h"
#include <cstring>
namespace faiss {
IndexBinary::~IndexBinary() {}
void IndexBinary::train(idx_t, const uint8_t *) {
// Does nothing by default.
}
void IndexBinary::range_search(idx_t, const uint8_t *, int,
RangeSearchResult *) const {
FAISS_THROW_MSG("range search not implemented");
}
void IndexBinary::assign(idx_t n, const uint8_t *x, idx_t *labels, idx_t k) {
int *distances = new int[n * k];
ScopeDeleter<int> del(distances);
search(n, x, k, distances, labels);
}
void IndexBinary::add_with_ids(idx_t, const uint8_t *, const long *) {
FAISS_THROW_MSG("add_with_ids not implemented for this type of index");
}
long IndexBinary::remove_ids(const IDSelector&) {
FAISS_THROW_MSG("remove_ids not implemented for this type of index");
return -1;
}
void IndexBinary::reconstruct(idx_t, uint8_t *) const {
FAISS_THROW_MSG("reconstruct not implemented for this type of index");
}
void IndexBinary::reconstruct_n(idx_t i0, idx_t ni, uint8_t *recons) const {
for (idx_t i = 0; i < ni; i++) {
reconstruct(i0 + i, recons + i * d);
}
}
void IndexBinary::search_and_reconstruct(idx_t n, const uint8_t *x, idx_t k,
int32_t *distances, idx_t *labels,
uint8_t *recons) const {
search(n, x, k, distances, labels);
for (idx_t i = 0; i < n; ++i) {
for (idx_t j = 0; j < k; ++j) {
idx_t ij = i * k + j;
idx_t key = labels[ij];
uint8_t *reconstructed = recons + ij * d;
if (key < 0) {
// Fill with NaNs
memset(reconstructed, -1, sizeof(*reconstructed) * d);
} else {
reconstruct(key, reconstructed);
}
}
}
}
void IndexBinary::display() const {
printf("Index: %s -> %ld elements\n", typeid (*this).name(), ntotal);
}
} // namespace faiss
| 2,134
| 773
|
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include "ppl/nn/models/onnx/model_parser.h"
#include "ppl/nn/models/onnx/graph_parser.h"
#include "ppl/nn/common/logger.h"
#include "ppl/common/file_mapping.h"
// large proto file support
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/zero_copy_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl.h"
using namespace std;
using namespace ppl::common;
namespace ppl { namespace nn { namespace onnx {
static bool ParseFromBinaryBuffer(const char* buf, uint64_t buf_len, google::protobuf::MessageLite* pb_model) {
if (!buf) {
LOG(ERROR) << "buf ptr is nullptr.";
return false;
}
if (buf_len == 0) {
LOG(ERROR) << "buf len is 0.";
return false;
}
google::protobuf::io::CodedInputStream cis((uint8_t*)buf, buf_len);
cis.SetTotalBytesLimit(INT_MAX);
return pb_model->ParseFromCodedStream(&cis);
}
static map<string, uint64_t> ParseOpSets(const ::onnx::ModelProto pb_model) {
map<string, uint64_t> res;
for (int i = 0; i < pb_model.opset_import_size(); ++i) {
const string& domain = pb_model.opset_import(i).domain();
uint64_t version = pb_model.opset_import(i).version();
auto ref = res.insert(make_pair(domain, 0));
if (version > ref.first->second) {
ref.first->second = version;
}
}
return res;
}
RetCode ModelParser::Parse(const char* buf, uint64_t buf_len, const char* model_file_dir, ir::Graph* graph) {
::onnx::ModelProto pb_model;
if (!ParseFromBinaryBuffer(buf, buf_len, &pb_model)) {
LOG(ERROR) << "load onnx model from model buffer failed.";
return RC_OTHER_ERROR;
}
if (pb_model.graph().quantization_annotation_size() > 0) {
LOG(ERROR) << "quantization in ONNX model is not supported now.";
return RC_UNSUPPORTED;
}
map<string, uint64_t> op_sets = ParseOpSets(pb_model);
GraphParser graph_parser;
auto status = graph_parser.Parse(pb_model.graph(), op_sets, model_file_dir, graph);
if (status != RC_SUCCESS) {
LOG(ERROR) << "parse graph failed: " << GetRetCodeStr(status);
return status;
}
if (graph->topo->GetExtraInputCount() > 0) {
auto topo = graph->topo.get();
LOG(ERROR) << "unresolved extra input of graph[" << topo->GetName() << "]:";
for (uint32_t i = 0; i < topo->GetExtraInputCount(); ++i) {
LOG(ERROR) << " -> " << topo->GetEdge(topo->GetExtraInput(i))->GetName();
}
return RC_NOT_FOUND;
}
return RC_SUCCESS;
}
}}} // namespace ppl::nn::onnx
| 3,394
| 1,138
|
#include <sstream>
#include <iostream>
#include <ydk/entity_util.hpp>
#include "bundle_info.hpp"
#include "generated_entity_lookup.hpp"
#include "Cisco_IOS_XR_mpls_te_oper_40.hpp"
#include "Cisco_IOS_XR_mpls_te_oper_41.hpp"
using namespace ydk;
namespace cisco_ios_xr {
namespace Cisco_IOS_XR_mpls_te_oper {
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::LabelRroSubObject()
:
label{YType::uint32, "label"},
is_label_variable_length{YType::boolean, "is-label-variable-length"}
,
flags(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags>())
, variable_length_label(this, {})
{
flags->parent = this;
yang_name = "label-rro-sub-object"; yang_parent_name = "resv-rro"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::~LabelRroSubObject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<variable_length_label.len(); index++)
{
if(variable_length_label[index]->has_data())
return true;
}
return label.is_set
|| is_label_variable_length.is_set
|| (flags != nullptr && flags->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::has_operation() const
{
for (std::size_t index=0; index<variable_length_label.len(); index++)
{
if(variable_length_label[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(label.yfilter)
|| ydk::is_set(is_label_variable_length.yfilter)
|| (flags != nullptr && flags->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "label-rro-sub-object";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (label.is_set || is_set(label.yfilter)) leaf_name_data.push_back(label.get_name_leafdata());
if (is_label_variable_length.is_set || is_set(is_label_variable_length.yfilter)) leaf_name_data.push_back(is_label_variable_length.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "flags")
{
if(flags == nullptr)
{
flags = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags>();
}
return flags;
}
if(child_yang_name == "variable-length-label")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel>();
ent_->parent = this;
variable_length_label.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(flags != nullptr)
{
_children["flags"] = flags;
}
count_ = 0;
for (auto ent_ : variable_length_label.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "label")
{
label = value;
label.value_namespace = name_space;
label.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-label-variable-length")
{
is_label_variable_length = value;
is_label_variable_length.value_namespace = name_space;
is_label_variable_length.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "label")
{
label.yfilter = yfilter;
}
if(value_path == "is-label-variable-length")
{
is_label_variable_length.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "flags" || name == "variable-length-label" || name == "label" || name == "is-label-variable-length")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::Flags()
:
is_global_label{YType::boolean, "is-global-label"}
{
yang_name = "flags"; yang_parent_name = "label-rro-sub-object"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::~Flags()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::has_data() const
{
if (is_presence_container) return true;
return is_global_label.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(is_global_label.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "flags";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (is_global_label.is_set || is_set(is_global_label.yfilter)) leaf_name_data.push_back(is_global_label.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "is-global-label")
{
is_global_label = value;
is_global_label.value_namespace = name_space;
is_global_label.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "is-global-label")
{
is_global_label.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "is-global-label")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::VariableLengthLabel()
:
entry{YType::uint32, "entry"}
{
yang_name = "variable-length-label"; yang_parent_name = "label-rro-sub-object"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::~VariableLengthLabel()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "variable-length-label";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::UnnumberedRroSubObject()
:
interface_address{YType::str, "interface-address"},
interface_id{YType::uint32, "interface-id"}
,
flags(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags>())
{
flags->parent = this;
yang_name = "unnumbered-rro-sub-object"; yang_parent_name = "resv-rro"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::~UnnumberedRroSubObject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::has_data() const
{
if (is_presence_container) return true;
return interface_address.is_set
|| interface_id.is_set
|| (flags != nullptr && flags->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(interface_address.yfilter)
|| ydk::is_set(interface_id.yfilter)
|| (flags != nullptr && flags->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "unnumbered-rro-sub-object";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (interface_address.is_set || is_set(interface_address.yfilter)) leaf_name_data.push_back(interface_address.get_name_leafdata());
if (interface_id.is_set || is_set(interface_id.yfilter)) leaf_name_data.push_back(interface_id.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "flags")
{
if(flags == nullptr)
{
flags = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags>();
}
return flags;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(flags != nullptr)
{
_children["flags"] = flags;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "interface-address")
{
interface_address = value;
interface_address.value_namespace = name_space;
interface_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "interface-id")
{
interface_id = value;
interface_id.value_namespace = name_space;
interface_id.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "interface-address")
{
interface_address.yfilter = yfilter;
}
if(value_path == "interface-id")
{
interface_id.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "flags" || name == "interface-address" || name == "interface-id")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::Flags()
:
is_protection_available{YType::boolean, "is-protection-available"},
is_protection_in_use{YType::boolean, "is-protection-in-use"},
is_bandwidth_protected{YType::boolean, "is-bandwidth-protected"},
is_node_protection_available{YType::boolean, "is-node-protection-available"},
is_node_id{YType::boolean, "is-node-id"}
{
yang_name = "flags"; yang_parent_name = "unnumbered-rro-sub-object"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::~Flags()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::has_data() const
{
if (is_presence_container) return true;
return is_protection_available.is_set
|| is_protection_in_use.is_set
|| is_bandwidth_protected.is_set
|| is_node_protection_available.is_set
|| is_node_id.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(is_protection_available.yfilter)
|| ydk::is_set(is_protection_in_use.yfilter)
|| ydk::is_set(is_bandwidth_protected.yfilter)
|| ydk::is_set(is_node_protection_available.yfilter)
|| ydk::is_set(is_node_id.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "flags";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (is_protection_available.is_set || is_set(is_protection_available.yfilter)) leaf_name_data.push_back(is_protection_available.get_name_leafdata());
if (is_protection_in_use.is_set || is_set(is_protection_in_use.yfilter)) leaf_name_data.push_back(is_protection_in_use.get_name_leafdata());
if (is_bandwidth_protected.is_set || is_set(is_bandwidth_protected.yfilter)) leaf_name_data.push_back(is_bandwidth_protected.get_name_leafdata());
if (is_node_protection_available.is_set || is_set(is_node_protection_available.yfilter)) leaf_name_data.push_back(is_node_protection_available.get_name_leafdata());
if (is_node_id.is_set || is_set(is_node_id.yfilter)) leaf_name_data.push_back(is_node_id.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "is-protection-available")
{
is_protection_available = value;
is_protection_available.value_namespace = name_space;
is_protection_available.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-protection-in-use")
{
is_protection_in_use = value;
is_protection_in_use.value_namespace = name_space;
is_protection_in_use.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-bandwidth-protected")
{
is_bandwidth_protected = value;
is_bandwidth_protected.value_namespace = name_space;
is_bandwidth_protected.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-node-protection-available")
{
is_node_protection_available = value;
is_node_protection_available.value_namespace = name_space;
is_node_protection_available.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-node-id")
{
is_node_id = value;
is_node_id.value_namespace = name_space;
is_node_id.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "is-protection-available")
{
is_protection_available.yfilter = yfilter;
}
if(value_path == "is-protection-in-use")
{
is_protection_in_use.yfilter = yfilter;
}
if(value_path == "is-bandwidth-protected")
{
is_bandwidth_protected.yfilter = yfilter;
}
if(value_path == "is-node-protection-available")
{
is_node_protection_available.yfilter = yfilter;
}
if(value_path == "is-node-id")
{
is_node_id.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "is-protection-available" || name == "is-protection-in-use" || name == "is-bandwidth-protected" || name == "is-node-protection-available" || name == "is-node-id")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlgRroSubObject()
:
srl_gs(this, {})
{
yang_name = "srlg-rro-sub-object"; yang_parent_name = "resv-rro"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::~SrlgRroSubObject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<srl_gs.len(); index++)
{
if(srl_gs[index]->has_data())
return true;
}
return false;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::has_operation() const
{
for (std::size_t index=0; index<srl_gs.len(); index++)
{
if(srl_gs[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "srlg-rro-sub-object";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "srl-gs")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs>();
ent_->parent = this;
srl_gs.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : srl_gs.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "srl-gs")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::SrlGs()
:
entry{YType::uint32, "entry"}
{
yang_name = "srl-gs"; yang_parent_name = "srlg-rro-sub-object"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::~SrlGs()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "srl-gs";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::PathAffinityArray()
:
hop_address{YType::str, "hop-address"},
hop_affinity{YType::uint32, "hop-affinity"}
,
hop_extended_affinity(this, {})
{
yang_name = "path-affinity-array"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::~PathAffinityArray()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<hop_extended_affinity.len(); index++)
{
if(hop_extended_affinity[index]->has_data())
return true;
}
return hop_address.is_set
|| hop_affinity.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::has_operation() const
{
for (std::size_t index=0; index<hop_extended_affinity.len(); index++)
{
if(hop_extended_affinity[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(hop_address.yfilter)
|| ydk::is_set(hop_affinity.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "path-affinity-array";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (hop_address.is_set || is_set(hop_address.yfilter)) leaf_name_data.push_back(hop_address.get_name_leafdata());
if (hop_affinity.is_set || is_set(hop_affinity.yfilter)) leaf_name_data.push_back(hop_affinity.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "hop-extended-affinity")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity>();
ent_->parent = this;
hop_extended_affinity.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : hop_extended_affinity.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "hop-address")
{
hop_address = value;
hop_address.value_namespace = name_space;
hop_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "hop-affinity")
{
hop_affinity = value;
hop_affinity.value_namespace = name_space;
hop_affinity.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "hop-address")
{
hop_address.yfilter = yfilter;
}
if(value_path == "hop-affinity")
{
hop_affinity.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "hop-extended-affinity" || name == "hop-address" || name == "hop-affinity")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::HopExtendedAffinity()
:
entry{YType::uint32, "entry"}
{
yang_name = "hop-extended-affinity"; yang_parent_name = "path-affinity-array"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::~HopExtendedAffinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "hop-extended-affinity";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::ReverseEroIn()
:
ero_type{YType::enumeration, "ero-type"}
,
ipv4ero_sub_object(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject>())
, unnumbered_ero_sub_object(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject>())
{
ipv4ero_sub_object->parent = this;
unnumbered_ero_sub_object->parent = this;
yang_name = "reverse-ero-in"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::~ReverseEroIn()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::has_data() const
{
if (is_presence_container) return true;
return ero_type.is_set
|| (ipv4ero_sub_object != nullptr && ipv4ero_sub_object->has_data())
|| (unnumbered_ero_sub_object != nullptr && unnumbered_ero_sub_object->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ero_type.yfilter)
|| (ipv4ero_sub_object != nullptr && ipv4ero_sub_object->has_operation())
|| (unnumbered_ero_sub_object != nullptr && unnumbered_ero_sub_object->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "reverse-ero-in";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ero_type.is_set || is_set(ero_type.yfilter)) leaf_name_data.push_back(ero_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ipv4ero-sub-object")
{
if(ipv4ero_sub_object == nullptr)
{
ipv4ero_sub_object = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject>();
}
return ipv4ero_sub_object;
}
if(child_yang_name == "unnumbered-ero-sub-object")
{
if(unnumbered_ero_sub_object == nullptr)
{
unnumbered_ero_sub_object = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject>();
}
return unnumbered_ero_sub_object;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(ipv4ero_sub_object != nullptr)
{
_children["ipv4ero-sub-object"] = ipv4ero_sub_object;
}
if(unnumbered_ero_sub_object != nullptr)
{
_children["unnumbered-ero-sub-object"] = unnumbered_ero_sub_object;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ero-type")
{
ero_type = value;
ero_type.value_namespace = name_space;
ero_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ero-type")
{
ero_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4ero-sub-object" || name == "unnumbered-ero-sub-object" || name == "ero-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::Ipv4eroSubObject()
:
is_strict_route{YType::boolean, "is-strict-route"},
ero_address{YType::str, "ero-address"},
prefix_length{YType::uint8, "prefix-length"}
{
yang_name = "ipv4ero-sub-object"; yang_parent_name = "reverse-ero-in"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::~Ipv4eroSubObject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::has_data() const
{
if (is_presence_container) return true;
return is_strict_route.is_set
|| ero_address.is_set
|| prefix_length.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(is_strict_route.yfilter)
|| ydk::is_set(ero_address.yfilter)
|| ydk::is_set(prefix_length.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv4ero-sub-object";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (is_strict_route.is_set || is_set(is_strict_route.yfilter)) leaf_name_data.push_back(is_strict_route.get_name_leafdata());
if (ero_address.is_set || is_set(ero_address.yfilter)) leaf_name_data.push_back(ero_address.get_name_leafdata());
if (prefix_length.is_set || is_set(prefix_length.yfilter)) leaf_name_data.push_back(prefix_length.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "is-strict-route")
{
is_strict_route = value;
is_strict_route.value_namespace = name_space;
is_strict_route.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ero-address")
{
ero_address = value;
ero_address.value_namespace = name_space;
ero_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-length")
{
prefix_length = value;
prefix_length.value_namespace = name_space;
prefix_length.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "is-strict-route")
{
is_strict_route.yfilter = yfilter;
}
if(value_path == "ero-address")
{
ero_address.yfilter = yfilter;
}
if(value_path == "prefix-length")
{
prefix_length.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "is-strict-route" || name == "ero-address" || name == "prefix-length")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::UnnumberedEroSubObject()
:
is_strict_route{YType::boolean, "is-strict-route"},
ero_interface_id{YType::uint32, "ero-interface-id"},
ero_router_id{YType::str, "ero-router-id"},
status{YType::enumeration, "status"}
{
yang_name = "unnumbered-ero-sub-object"; yang_parent_name = "reverse-ero-in"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::~UnnumberedEroSubObject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::has_data() const
{
if (is_presence_container) return true;
return is_strict_route.is_set
|| ero_interface_id.is_set
|| ero_router_id.is_set
|| status.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(is_strict_route.yfilter)
|| ydk::is_set(ero_interface_id.yfilter)
|| ydk::is_set(ero_router_id.yfilter)
|| ydk::is_set(status.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "unnumbered-ero-sub-object";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (is_strict_route.is_set || is_set(is_strict_route.yfilter)) leaf_name_data.push_back(is_strict_route.get_name_leafdata());
if (ero_interface_id.is_set || is_set(ero_interface_id.yfilter)) leaf_name_data.push_back(ero_interface_id.get_name_leafdata());
if (ero_router_id.is_set || is_set(ero_router_id.yfilter)) leaf_name_data.push_back(ero_router_id.get_name_leafdata());
if (status.is_set || is_set(status.yfilter)) leaf_name_data.push_back(status.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "is-strict-route")
{
is_strict_route = value;
is_strict_route.value_namespace = name_space;
is_strict_route.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ero-interface-id")
{
ero_interface_id = value;
ero_interface_id.value_namespace = name_space;
ero_interface_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ero-router-id")
{
ero_router_id = value;
ero_router_id.value_namespace = name_space;
ero_router_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "status")
{
status = value;
status.value_namespace = name_space;
status.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "is-strict-route")
{
is_strict_route.yfilter = yfilter;
}
if(value_path == "ero-interface-id")
{
ero_interface_id.yfilter = yfilter;
}
if(value_path == "ero-router-id")
{
ero_router_id.yfilter = yfilter;
}
if(value_path == "status")
{
status.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "is-strict-route" || name == "ero-interface-id" || name == "ero-router-id" || name == "status")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::S2lSegmentRoutingPath()
:
sid_type{YType::enumeration, "sid-type"},
has_ip_addresses{YType::boolean, "has-ip-addresses"},
local_addr{YType::str, "local-addr"},
remote_addr{YType::str, "remote-addr"},
has_mpls_label{YType::boolean, "has-mpls-label"},
mpls_label_value{YType::uint32, "mpls-label-value"},
has_entropy_label{YType::boolean, "has-entropy-label"}
{
yang_name = "s2l-segment-routing-path"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::~S2lSegmentRoutingPath()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::has_data() const
{
if (is_presence_container) return true;
return sid_type.is_set
|| has_ip_addresses.is_set
|| local_addr.is_set
|| remote_addr.is_set
|| has_mpls_label.is_set
|| mpls_label_value.is_set
|| has_entropy_label.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(sid_type.yfilter)
|| ydk::is_set(has_ip_addresses.yfilter)
|| ydk::is_set(local_addr.yfilter)
|| ydk::is_set(remote_addr.yfilter)
|| ydk::is_set(has_mpls_label.yfilter)
|| ydk::is_set(mpls_label_value.yfilter)
|| ydk::is_set(has_entropy_label.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "s2l-segment-routing-path";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (sid_type.is_set || is_set(sid_type.yfilter)) leaf_name_data.push_back(sid_type.get_name_leafdata());
if (has_ip_addresses.is_set || is_set(has_ip_addresses.yfilter)) leaf_name_data.push_back(has_ip_addresses.get_name_leafdata());
if (local_addr.is_set || is_set(local_addr.yfilter)) leaf_name_data.push_back(local_addr.get_name_leafdata());
if (remote_addr.is_set || is_set(remote_addr.yfilter)) leaf_name_data.push_back(remote_addr.get_name_leafdata());
if (has_mpls_label.is_set || is_set(has_mpls_label.yfilter)) leaf_name_data.push_back(has_mpls_label.get_name_leafdata());
if (mpls_label_value.is_set || is_set(mpls_label_value.yfilter)) leaf_name_data.push_back(mpls_label_value.get_name_leafdata());
if (has_entropy_label.is_set || is_set(has_entropy_label.yfilter)) leaf_name_data.push_back(has_entropy_label.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "sid-type")
{
sid_type = value;
sid_type.value_namespace = name_space;
sid_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "has-ip-addresses")
{
has_ip_addresses = value;
has_ip_addresses.value_namespace = name_space;
has_ip_addresses.value_namespace_prefix = name_space_prefix;
}
if(value_path == "local-addr")
{
local_addr = value;
local_addr.value_namespace = name_space;
local_addr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "remote-addr")
{
remote_addr = value;
remote_addr.value_namespace = name_space;
remote_addr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "has-mpls-label")
{
has_mpls_label = value;
has_mpls_label.value_namespace = name_space;
has_mpls_label.value_namespace_prefix = name_space_prefix;
}
if(value_path == "mpls-label-value")
{
mpls_label_value = value;
mpls_label_value.value_namespace = name_space;
mpls_label_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "has-entropy-label")
{
has_entropy_label = value;
has_entropy_label.value_namespace = name_space;
has_entropy_label.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "sid-type")
{
sid_type.yfilter = yfilter;
}
if(value_path == "has-ip-addresses")
{
has_ip_addresses.yfilter = yfilter;
}
if(value_path == "local-addr")
{
local_addr.yfilter = yfilter;
}
if(value_path == "remote-addr")
{
remote_addr.yfilter = yfilter;
}
if(value_path == "has-mpls-label")
{
has_mpls_label.yfilter = yfilter;
}
if(value_path == "mpls-label-value")
{
mpls_label_value.yfilter = yfilter;
}
if(value_path == "has-entropy-label")
{
has_entropy_label.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "sid-type" || name == "has-ip-addresses" || name == "local-addr" || name == "remote-addr" || name == "has-mpls-label" || name == "mpls-label-value" || name == "has-entropy-label")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::ReoptimizedP2mpLsp()
:
signaled_name{YType::str, "signaled-name"},
is_frr_failed{YType::boolean, "is-frr-failed"},
frr_active_reason{YType::uint32, "frr-active-reason"},
lsp_bandwidth{YType::uint32, "lsp-bandwidth"},
lsp_setup_priority{YType::uint8, "lsp-setup-priority"},
lsp_hold_priority{YType::uint8, "lsp-hold-priority"},
lsp_bandwidth_type{YType::enumeration, "lsp-bandwidth-type"},
dste_class_match{YType::boolean, "dste-class-match"},
dste_class_index{YType::uint8, "dste-class-index"},
type{YType::enumeration, "type"},
uptime{YType::uint32, "uptime"},
s2_ls_up{YType::uint32, "s2-ls-up"},
s2_ls_proceeding{YType::uint32, "s2-ls-proceeding"},
s2_ls_down{YType::uint32, "s2-ls-down"},
reoptimize_reason{YType::enumeration, "reoptimize-reason"},
reoptimize_trigger{YType::enumeration, "reoptimize-trigger"},
timer_left{YType::uint32, "timer-left"},
is_passive{YType::boolean, "is-passive"},
is_interface{YType::boolean, "is-interface"},
last_path_change{YType::uint32, "last-path-change"},
persistent_bytes{YType::uint64, "persistent-bytes"},
persistent_packets{YType::uint64, "persistent-packets"}
,
lsp_fec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec>())
, s2l(this, {})
{
lsp_fec->parent = this;
yang_name = "reoptimized-p2mp-lsp"; yang_parent_name = "nni-tunnel"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::~ReoptimizedP2mpLsp()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<s2l.len(); index++)
{
if(s2l[index]->has_data())
return true;
}
return signaled_name.is_set
|| is_frr_failed.is_set
|| frr_active_reason.is_set
|| lsp_bandwidth.is_set
|| lsp_setup_priority.is_set
|| lsp_hold_priority.is_set
|| lsp_bandwidth_type.is_set
|| dste_class_match.is_set
|| dste_class_index.is_set
|| type.is_set
|| uptime.is_set
|| s2_ls_up.is_set
|| s2_ls_proceeding.is_set
|| s2_ls_down.is_set
|| reoptimize_reason.is_set
|| reoptimize_trigger.is_set
|| timer_left.is_set
|| is_passive.is_set
|| is_interface.is_set
|| last_path_change.is_set
|| persistent_bytes.is_set
|| persistent_packets.is_set
|| (lsp_fec != nullptr && lsp_fec->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::has_operation() const
{
for (std::size_t index=0; index<s2l.len(); index++)
{
if(s2l[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(signaled_name.yfilter)
|| ydk::is_set(is_frr_failed.yfilter)
|| ydk::is_set(frr_active_reason.yfilter)
|| ydk::is_set(lsp_bandwidth.yfilter)
|| ydk::is_set(lsp_setup_priority.yfilter)
|| ydk::is_set(lsp_hold_priority.yfilter)
|| ydk::is_set(lsp_bandwidth_type.yfilter)
|| ydk::is_set(dste_class_match.yfilter)
|| ydk::is_set(dste_class_index.yfilter)
|| ydk::is_set(type.yfilter)
|| ydk::is_set(uptime.yfilter)
|| ydk::is_set(s2_ls_up.yfilter)
|| ydk::is_set(s2_ls_proceeding.yfilter)
|| ydk::is_set(s2_ls_down.yfilter)
|| ydk::is_set(reoptimize_reason.yfilter)
|| ydk::is_set(reoptimize_trigger.yfilter)
|| ydk::is_set(timer_left.yfilter)
|| ydk::is_set(is_passive.yfilter)
|| ydk::is_set(is_interface.yfilter)
|| ydk::is_set(last_path_change.yfilter)
|| ydk::is_set(persistent_bytes.yfilter)
|| ydk::is_set(persistent_packets.yfilter)
|| (lsp_fec != nullptr && lsp_fec->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "reoptimized-p2mp-lsp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (signaled_name.is_set || is_set(signaled_name.yfilter)) leaf_name_data.push_back(signaled_name.get_name_leafdata());
if (is_frr_failed.is_set || is_set(is_frr_failed.yfilter)) leaf_name_data.push_back(is_frr_failed.get_name_leafdata());
if (frr_active_reason.is_set || is_set(frr_active_reason.yfilter)) leaf_name_data.push_back(frr_active_reason.get_name_leafdata());
if (lsp_bandwidth.is_set || is_set(lsp_bandwidth.yfilter)) leaf_name_data.push_back(lsp_bandwidth.get_name_leafdata());
if (lsp_setup_priority.is_set || is_set(lsp_setup_priority.yfilter)) leaf_name_data.push_back(lsp_setup_priority.get_name_leafdata());
if (lsp_hold_priority.is_set || is_set(lsp_hold_priority.yfilter)) leaf_name_data.push_back(lsp_hold_priority.get_name_leafdata());
if (lsp_bandwidth_type.is_set || is_set(lsp_bandwidth_type.yfilter)) leaf_name_data.push_back(lsp_bandwidth_type.get_name_leafdata());
if (dste_class_match.is_set || is_set(dste_class_match.yfilter)) leaf_name_data.push_back(dste_class_match.get_name_leafdata());
if (dste_class_index.is_set || is_set(dste_class_index.yfilter)) leaf_name_data.push_back(dste_class_index.get_name_leafdata());
if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata());
if (uptime.is_set || is_set(uptime.yfilter)) leaf_name_data.push_back(uptime.get_name_leafdata());
if (s2_ls_up.is_set || is_set(s2_ls_up.yfilter)) leaf_name_data.push_back(s2_ls_up.get_name_leafdata());
if (s2_ls_proceeding.is_set || is_set(s2_ls_proceeding.yfilter)) leaf_name_data.push_back(s2_ls_proceeding.get_name_leafdata());
if (s2_ls_down.is_set || is_set(s2_ls_down.yfilter)) leaf_name_data.push_back(s2_ls_down.get_name_leafdata());
if (reoptimize_reason.is_set || is_set(reoptimize_reason.yfilter)) leaf_name_data.push_back(reoptimize_reason.get_name_leafdata());
if (reoptimize_trigger.is_set || is_set(reoptimize_trigger.yfilter)) leaf_name_data.push_back(reoptimize_trigger.get_name_leafdata());
if (timer_left.is_set || is_set(timer_left.yfilter)) leaf_name_data.push_back(timer_left.get_name_leafdata());
if (is_passive.is_set || is_set(is_passive.yfilter)) leaf_name_data.push_back(is_passive.get_name_leafdata());
if (is_interface.is_set || is_set(is_interface.yfilter)) leaf_name_data.push_back(is_interface.get_name_leafdata());
if (last_path_change.is_set || is_set(last_path_change.yfilter)) leaf_name_data.push_back(last_path_change.get_name_leafdata());
if (persistent_bytes.is_set || is_set(persistent_bytes.yfilter)) leaf_name_data.push_back(persistent_bytes.get_name_leafdata());
if (persistent_packets.is_set || is_set(persistent_packets.yfilter)) leaf_name_data.push_back(persistent_packets.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "lsp-fec")
{
if(lsp_fec == nullptr)
{
lsp_fec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec>();
}
return lsp_fec;
}
if(child_yang_name == "s2l")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l>();
ent_->parent = this;
s2l.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(lsp_fec != nullptr)
{
_children["lsp-fec"] = lsp_fec;
}
count_ = 0;
for (auto ent_ : s2l.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "signaled-name")
{
signaled_name = value;
signaled_name.value_namespace = name_space;
signaled_name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-frr-failed")
{
is_frr_failed = value;
is_frr_failed.value_namespace = name_space;
is_frr_failed.value_namespace_prefix = name_space_prefix;
}
if(value_path == "frr-active-reason")
{
frr_active_reason = value;
frr_active_reason.value_namespace = name_space;
frr_active_reason.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-bandwidth")
{
lsp_bandwidth = value;
lsp_bandwidth.value_namespace = name_space;
lsp_bandwidth.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-setup-priority")
{
lsp_setup_priority = value;
lsp_setup_priority.value_namespace = name_space;
lsp_setup_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-hold-priority")
{
lsp_hold_priority = value;
lsp_hold_priority.value_namespace = name_space;
lsp_hold_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-bandwidth-type")
{
lsp_bandwidth_type = value;
lsp_bandwidth_type.value_namespace = name_space;
lsp_bandwidth_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "dste-class-match")
{
dste_class_match = value;
dste_class_match.value_namespace = name_space;
dste_class_match.value_namespace_prefix = name_space_prefix;
}
if(value_path == "dste-class-index")
{
dste_class_index = value;
dste_class_index.value_namespace = name_space;
dste_class_index.value_namespace_prefix = name_space_prefix;
}
if(value_path == "type")
{
type = value;
type.value_namespace = name_space;
type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "uptime")
{
uptime = value;
uptime.value_namespace = name_space;
uptime.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2-ls-up")
{
s2_ls_up = value;
s2_ls_up.value_namespace = name_space;
s2_ls_up.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2-ls-proceeding")
{
s2_ls_proceeding = value;
s2_ls_proceeding.value_namespace = name_space;
s2_ls_proceeding.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2-ls-down")
{
s2_ls_down = value;
s2_ls_down.value_namespace = name_space;
s2_ls_down.value_namespace_prefix = name_space_prefix;
}
if(value_path == "reoptimize-reason")
{
reoptimize_reason = value;
reoptimize_reason.value_namespace = name_space;
reoptimize_reason.value_namespace_prefix = name_space_prefix;
}
if(value_path == "reoptimize-trigger")
{
reoptimize_trigger = value;
reoptimize_trigger.value_namespace = name_space;
reoptimize_trigger.value_namespace_prefix = name_space_prefix;
}
if(value_path == "timer-left")
{
timer_left = value;
timer_left.value_namespace = name_space;
timer_left.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-passive")
{
is_passive = value;
is_passive.value_namespace = name_space;
is_passive.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-interface")
{
is_interface = value;
is_interface.value_namespace = name_space;
is_interface.value_namespace_prefix = name_space_prefix;
}
if(value_path == "last-path-change")
{
last_path_change = value;
last_path_change.value_namespace = name_space;
last_path_change.value_namespace_prefix = name_space_prefix;
}
if(value_path == "persistent-bytes")
{
persistent_bytes = value;
persistent_bytes.value_namespace = name_space;
persistent_bytes.value_namespace_prefix = name_space_prefix;
}
if(value_path == "persistent-packets")
{
persistent_packets = value;
persistent_packets.value_namespace = name_space;
persistent_packets.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "signaled-name")
{
signaled_name.yfilter = yfilter;
}
if(value_path == "is-frr-failed")
{
is_frr_failed.yfilter = yfilter;
}
if(value_path == "frr-active-reason")
{
frr_active_reason.yfilter = yfilter;
}
if(value_path == "lsp-bandwidth")
{
lsp_bandwidth.yfilter = yfilter;
}
if(value_path == "lsp-setup-priority")
{
lsp_setup_priority.yfilter = yfilter;
}
if(value_path == "lsp-hold-priority")
{
lsp_hold_priority.yfilter = yfilter;
}
if(value_path == "lsp-bandwidth-type")
{
lsp_bandwidth_type.yfilter = yfilter;
}
if(value_path == "dste-class-match")
{
dste_class_match.yfilter = yfilter;
}
if(value_path == "dste-class-index")
{
dste_class_index.yfilter = yfilter;
}
if(value_path == "type")
{
type.yfilter = yfilter;
}
if(value_path == "uptime")
{
uptime.yfilter = yfilter;
}
if(value_path == "s2-ls-up")
{
s2_ls_up.yfilter = yfilter;
}
if(value_path == "s2-ls-proceeding")
{
s2_ls_proceeding.yfilter = yfilter;
}
if(value_path == "s2-ls-down")
{
s2_ls_down.yfilter = yfilter;
}
if(value_path == "reoptimize-reason")
{
reoptimize_reason.yfilter = yfilter;
}
if(value_path == "reoptimize-trigger")
{
reoptimize_trigger.yfilter = yfilter;
}
if(value_path == "timer-left")
{
timer_left.yfilter = yfilter;
}
if(value_path == "is-passive")
{
is_passive.yfilter = yfilter;
}
if(value_path == "is-interface")
{
is_interface.yfilter = yfilter;
}
if(value_path == "last-path-change")
{
last_path_change.yfilter = yfilter;
}
if(value_path == "persistent-bytes")
{
persistent_bytes.yfilter = yfilter;
}
if(value_path == "persistent-packets")
{
persistent_packets.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "lsp-fec" || name == "s2l" || name == "signaled-name" || name == "is-frr-failed" || name == "frr-active-reason" || name == "lsp-bandwidth" || name == "lsp-setup-priority" || name == "lsp-hold-priority" || name == "lsp-bandwidth-type" || name == "dste-class-match" || name == "dste-class-index" || name == "type" || name == "uptime" || name == "s2-ls-up" || name == "s2-ls-proceeding" || name == "s2-ls-down" || name == "reoptimize-reason" || name == "reoptimize-trigger" || name == "timer-left" || name == "is-passive" || name == "is-interface" || name == "last-path-change" || name == "persistent-bytes" || name == "persistent-packets")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::LspFec()
:
fec_lsp_id{YType::uint16, "fec-lsp-id"},
fec_tunnel_id{YType::uint16, "fec-tunnel-id"},
fec_extended_tunnel_id{YType::str, "fec-extended-tunnel-id"},
fec_source{YType::str, "fec-source"},
fec_vrf{YType::str, "fec-vrf"}
,
fec_destination_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo>())
{
fec_destination_info->parent = this;
yang_name = "lsp-fec"; yang_parent_name = "reoptimized-p2mp-lsp"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::~LspFec()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::has_data() const
{
if (is_presence_container) return true;
return fec_lsp_id.is_set
|| fec_tunnel_id.is_set
|| fec_extended_tunnel_id.is_set
|| fec_source.is_set
|| fec_vrf.is_set
|| (fec_destination_info != nullptr && fec_destination_info->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(fec_lsp_id.yfilter)
|| ydk::is_set(fec_tunnel_id.yfilter)
|| ydk::is_set(fec_extended_tunnel_id.yfilter)
|| ydk::is_set(fec_source.yfilter)
|| ydk::is_set(fec_vrf.yfilter)
|| (fec_destination_info != nullptr && fec_destination_info->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "lsp-fec";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (fec_lsp_id.is_set || is_set(fec_lsp_id.yfilter)) leaf_name_data.push_back(fec_lsp_id.get_name_leafdata());
if (fec_tunnel_id.is_set || is_set(fec_tunnel_id.yfilter)) leaf_name_data.push_back(fec_tunnel_id.get_name_leafdata());
if (fec_extended_tunnel_id.is_set || is_set(fec_extended_tunnel_id.yfilter)) leaf_name_data.push_back(fec_extended_tunnel_id.get_name_leafdata());
if (fec_source.is_set || is_set(fec_source.yfilter)) leaf_name_data.push_back(fec_source.get_name_leafdata());
if (fec_vrf.is_set || is_set(fec_vrf.yfilter)) leaf_name_data.push_back(fec_vrf.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "fec-destination-info")
{
if(fec_destination_info == nullptr)
{
fec_destination_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo>();
}
return fec_destination_info;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(fec_destination_info != nullptr)
{
_children["fec-destination-info"] = fec_destination_info;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "fec-lsp-id")
{
fec_lsp_id = value;
fec_lsp_id.value_namespace = name_space;
fec_lsp_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-tunnel-id")
{
fec_tunnel_id = value;
fec_tunnel_id.value_namespace = name_space;
fec_tunnel_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-extended-tunnel-id")
{
fec_extended_tunnel_id = value;
fec_extended_tunnel_id.value_namespace = name_space;
fec_extended_tunnel_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-source")
{
fec_source = value;
fec_source.value_namespace = name_space;
fec_source.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-vrf")
{
fec_vrf = value;
fec_vrf.value_namespace = name_space;
fec_vrf.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "fec-lsp-id")
{
fec_lsp_id.yfilter = yfilter;
}
if(value_path == "fec-tunnel-id")
{
fec_tunnel_id.yfilter = yfilter;
}
if(value_path == "fec-extended-tunnel-id")
{
fec_extended_tunnel_id.yfilter = yfilter;
}
if(value_path == "fec-source")
{
fec_source.yfilter = yfilter;
}
if(value_path == "fec-vrf")
{
fec_vrf.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "fec-destination-info" || name == "fec-lsp-id" || name == "fec-tunnel-id" || name == "fec-extended-tunnel-id" || name == "fec-source" || name == "fec-vrf")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::FecDestinationInfo()
:
fec_ctype{YType::enumeration, "fec-ctype"},
p2p_lsp_destination{YType::str, "p2p-lsp-destination"},
fec_destination_p2mp_id{YType::uint32, "fec-destination-p2mp-id"}
{
yang_name = "fec-destination-info"; yang_parent_name = "lsp-fec"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::~FecDestinationInfo()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::has_data() const
{
if (is_presence_container) return true;
return fec_ctype.is_set
|| p2p_lsp_destination.is_set
|| fec_destination_p2mp_id.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(fec_ctype.yfilter)
|| ydk::is_set(p2p_lsp_destination.yfilter)
|| ydk::is_set(fec_destination_p2mp_id.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "fec-destination-info";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (fec_ctype.is_set || is_set(fec_ctype.yfilter)) leaf_name_data.push_back(fec_ctype.get_name_leafdata());
if (p2p_lsp_destination.is_set || is_set(p2p_lsp_destination.yfilter)) leaf_name_data.push_back(p2p_lsp_destination.get_name_leafdata());
if (fec_destination_p2mp_id.is_set || is_set(fec_destination_p2mp_id.yfilter)) leaf_name_data.push_back(fec_destination_p2mp_id.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "fec-ctype")
{
fec_ctype = value;
fec_ctype.value_namespace = name_space;
fec_ctype.value_namespace_prefix = name_space_prefix;
}
if(value_path == "p2p-lsp-destination")
{
p2p_lsp_destination = value;
p2p_lsp_destination.value_namespace = name_space;
p2p_lsp_destination.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-destination-p2mp-id")
{
fec_destination_p2mp_id = value;
fec_destination_p2mp_id.value_namespace = name_space;
fec_destination_p2mp_id.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "fec-ctype")
{
fec_ctype.yfilter = yfilter;
}
if(value_path == "p2p-lsp-destination")
{
p2p_lsp_destination.yfilter = yfilter;
}
if(value_path == "fec-destination-p2mp-id")
{
fec_destination_p2mp_id.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "fec-ctype" || name == "p2p-lsp-destination" || name == "fec-destination-p2mp-id")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2l()
:
pcalc_area{YType::str, "pcalc-area"},
is_expanded_ero{YType::boolean, "is-expanded-ero"},
path_reeval_query_mid{YType::uint32, "path-reeval-query-mid"},
time_since_last_query_received_mid{YType::uint32, "time-since-last-query-received-mid"},
time_since_last_preferred_path_exists_send_mid{YType::uint32, "time-since-last-preferred-path-exists-send-mid"},
time_since_last_preferred_tree_exists_send_mid{YType::uint32, "time-since-last-preferred-tree-exists-send-mid"},
expanded_ero_area_id{YType::str, "expanded-ero-area-id"},
expanded_ero_affinity_bits{YType::uint32, "expanded-ero-affinity-bits"},
expanded_ero_affinity_mask{YType::uint32, "expanded-ero-affinity-mask"},
expanded_ero_metric_type{YType::enumeration, "expanded-ero-metric-type"},
expanded_ero_metric{YType::uint32, "expanded-ero-metric"},
abr_auto_discovered{YType::str, "abr-auto-discovered"},
is_frr_enabled{YType::boolean, "is-frr-enabled"},
is_node_protected{YType::boolean, "is-node-protected"},
is_bandwidth_protect{YType::boolean, "is-bandwidth-protect"},
path_rro_enabled{YType::boolean, "path-rro-enabled"},
weight{YType::uint64, "weight"},
reverse_weight{YType::uint64, "reverse-weight"},
uptime{YType::uint32, "uptime"},
egress_interface{YType::str, "egress-interface"},
egress_interface_state{YType::enumeration, "egress-interface-state"},
egress_interface_brief{YType::str, "egress-interface-brief"},
ingress_interface{YType::str, "ingress-interface"},
ingress_interface_state{YType::enumeration, "ingress-interface-state"},
ingress_interface_brief{YType::str, "ingress-interface-brief"},
s2l_local_label{YType::uint32, "s2l-local-label"},
s2l_out_label{YType::uint32, "s2l-out-label"},
outbound_frr_state{YType::enumeration, "outbound-frr-state"},
frr_out_tunnel_interface{YType::str, "frr-out-tunnel-interface"},
role{YType::enumeration, "role"},
signalling_status{YType::enumeration, "signalling-status"},
local_router_id{YType::str, "local-router-id"},
upstream_router_id{YType::str, "upstream-router-id"},
downstream_router_id{YType::str, "downstream-router-id"},
next_hop_address{YType::str, "next-hop-address"},
next_next_hop_address{YType::str, "next-next-hop-address"},
previous_hop_address{YType::str, "previous-hop-address"},
incoming_address{YType::str, "incoming-address"},
backup_tunnel_interface{YType::str, "backup-tunnel-interface"},
node_hop_count{YType::uint8, "node-hop-count"},
is_optical{YType::boolean, "is-optical"},
s2l_reverse_ero_obj_present{YType::boolean, "s2l-reverse-ero-obj-present"},
reverse_lsp_present{YType::boolean, "reverse-lsp-present"},
reverse_lsp_connected{YType::boolean, "reverse-lsp-connected"},
reverse_lsp_name{YType::str, "reverse-lsp-name"},
s2l_reverse_tspec_obj_present{YType::boolean, "s2l-reverse-tspec-obj-present"},
path_using_strict_spf{YType::boolean, "path-using-strict-spf"}
,
s2l_fec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec>())
, active_path_option(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption>())
, out_xro(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro>())
, in_xro(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro>())
, tspec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Tspec>())
, generic_tspec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::GenericTspec>())
, fspec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Fspec>())
, generic_fspec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::GenericFspec>())
, next_hop_address_generic(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::NextHopAddressGeneric>())
, previous_hop_address_generic(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::PreviousHopAddressGeneric>())
, incoming_address_generic(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::IncomingAddressGeneric>())
, s2l_convergence(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lConvergence>())
, soft_preemption(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::SoftPreemption>())
, gmpls_labels(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::GmplsLabels>())
, otn_s2l(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OtnS2l>())
, head_end_bfd_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::HeadEndBfdInfo>())
, tail_end_bfd_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::TailEndBfdInfo>())
, srlg_collection(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::SrlgCollection>())
, association(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Association>())
, protection(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Protection>())
, reverse_lsp_fec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ReverseLspFec>())
, reverse_tspec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ReverseTspec>())
, flex_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::FlexInfo>())
, lsp_wrap_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::LspWrapInfo>())
, diversity_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::DiversityInfo>())
, accumulated_path_metrics(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::AccumulatedPathMetrics>())
, accumulated_reverse_path_metrics(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::AccumulatedReversePathMetrics>())
, s2l_reverse_lsp_sub_obj(this, {})
, shared_risk_link_group(this, {})
, out_ero(this, {})
, in_ero(this, {})
, path_rro(this, {})
, resv_rro(this, {})
, path_affinity_array(this, {})
, reverse_ero_in(this, {})
, s2l_segment_routing_path(this, {})
{
s2l_fec->parent = this;
active_path_option->parent = this;
out_xro->parent = this;
in_xro->parent = this;
tspec->parent = this;
generic_tspec->parent = this;
fspec->parent = this;
generic_fspec->parent = this;
next_hop_address_generic->parent = this;
previous_hop_address_generic->parent = this;
incoming_address_generic->parent = this;
s2l_convergence->parent = this;
soft_preemption->parent = this;
gmpls_labels->parent = this;
otn_s2l->parent = this;
head_end_bfd_info->parent = this;
tail_end_bfd_info->parent = this;
srlg_collection->parent = this;
association->parent = this;
protection->parent = this;
reverse_lsp_fec->parent = this;
reverse_tspec->parent = this;
flex_info->parent = this;
lsp_wrap_info->parent = this;
diversity_info->parent = this;
accumulated_path_metrics->parent = this;
accumulated_reverse_path_metrics->parent = this;
yang_name = "s2l"; yang_parent_name = "reoptimized-p2mp-lsp"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::~S2l()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<s2l_reverse_lsp_sub_obj.len(); index++)
{
if(s2l_reverse_lsp_sub_obj[index]->has_data())
return true;
}
for (std::size_t index=0; index<shared_risk_link_group.len(); index++)
{
if(shared_risk_link_group[index]->has_data())
return true;
}
for (std::size_t index=0; index<out_ero.len(); index++)
{
if(out_ero[index]->has_data())
return true;
}
for (std::size_t index=0; index<in_ero.len(); index++)
{
if(in_ero[index]->has_data())
return true;
}
for (std::size_t index=0; index<path_rro.len(); index++)
{
if(path_rro[index]->has_data())
return true;
}
for (std::size_t index=0; index<resv_rro.len(); index++)
{
if(resv_rro[index]->has_data())
return true;
}
for (std::size_t index=0; index<path_affinity_array.len(); index++)
{
if(path_affinity_array[index]->has_data())
return true;
}
for (std::size_t index=0; index<reverse_ero_in.len(); index++)
{
if(reverse_ero_in[index]->has_data())
return true;
}
for (std::size_t index=0; index<s2l_segment_routing_path.len(); index++)
{
if(s2l_segment_routing_path[index]->has_data())
return true;
}
return pcalc_area.is_set
|| is_expanded_ero.is_set
|| path_reeval_query_mid.is_set
|| time_since_last_query_received_mid.is_set
|| time_since_last_preferred_path_exists_send_mid.is_set
|| time_since_last_preferred_tree_exists_send_mid.is_set
|| expanded_ero_area_id.is_set
|| expanded_ero_affinity_bits.is_set
|| expanded_ero_affinity_mask.is_set
|| expanded_ero_metric_type.is_set
|| expanded_ero_metric.is_set
|| abr_auto_discovered.is_set
|| is_frr_enabled.is_set
|| is_node_protected.is_set
|| is_bandwidth_protect.is_set
|| path_rro_enabled.is_set
|| weight.is_set
|| reverse_weight.is_set
|| uptime.is_set
|| egress_interface.is_set
|| egress_interface_state.is_set
|| egress_interface_brief.is_set
|| ingress_interface.is_set
|| ingress_interface_state.is_set
|| ingress_interface_brief.is_set
|| s2l_local_label.is_set
|| s2l_out_label.is_set
|| outbound_frr_state.is_set
|| frr_out_tunnel_interface.is_set
|| role.is_set
|| signalling_status.is_set
|| local_router_id.is_set
|| upstream_router_id.is_set
|| downstream_router_id.is_set
|| next_hop_address.is_set
|| next_next_hop_address.is_set
|| previous_hop_address.is_set
|| incoming_address.is_set
|| backup_tunnel_interface.is_set
|| node_hop_count.is_set
|| is_optical.is_set
|| s2l_reverse_ero_obj_present.is_set
|| reverse_lsp_present.is_set
|| reverse_lsp_connected.is_set
|| reverse_lsp_name.is_set
|| s2l_reverse_tspec_obj_present.is_set
|| path_using_strict_spf.is_set
|| (s2l_fec != nullptr && s2l_fec->has_data())
|| (active_path_option != nullptr && active_path_option->has_data())
|| (out_xro != nullptr && out_xro->has_data())
|| (in_xro != nullptr && in_xro->has_data())
|| (tspec != nullptr && tspec->has_data())
|| (generic_tspec != nullptr && generic_tspec->has_data())
|| (fspec != nullptr && fspec->has_data())
|| (generic_fspec != nullptr && generic_fspec->has_data())
|| (next_hop_address_generic != nullptr && next_hop_address_generic->has_data())
|| (previous_hop_address_generic != nullptr && previous_hop_address_generic->has_data())
|| (incoming_address_generic != nullptr && incoming_address_generic->has_data())
|| (s2l_convergence != nullptr && s2l_convergence->has_data())
|| (soft_preemption != nullptr && soft_preemption->has_data())
|| (gmpls_labels != nullptr && gmpls_labels->has_data())
|| (otn_s2l != nullptr && otn_s2l->has_data())
|| (head_end_bfd_info != nullptr && head_end_bfd_info->has_data())
|| (tail_end_bfd_info != nullptr && tail_end_bfd_info->has_data())
|| (srlg_collection != nullptr && srlg_collection->has_data())
|| (association != nullptr && association->has_data())
|| (protection != nullptr && protection->has_data())
|| (reverse_lsp_fec != nullptr && reverse_lsp_fec->has_data())
|| (reverse_tspec != nullptr && reverse_tspec->has_data())
|| (flex_info != nullptr && flex_info->has_data())
|| (lsp_wrap_info != nullptr && lsp_wrap_info->has_data())
|| (diversity_info != nullptr && diversity_info->has_data())
|| (accumulated_path_metrics != nullptr && accumulated_path_metrics->has_data())
|| (accumulated_reverse_path_metrics != nullptr && accumulated_reverse_path_metrics->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::has_operation() const
{
for (std::size_t index=0; index<s2l_reverse_lsp_sub_obj.len(); index++)
{
if(s2l_reverse_lsp_sub_obj[index]->has_operation())
return true;
}
for (std::size_t index=0; index<shared_risk_link_group.len(); index++)
{
if(shared_risk_link_group[index]->has_operation())
return true;
}
for (std::size_t index=0; index<out_ero.len(); index++)
{
if(out_ero[index]->has_operation())
return true;
}
for (std::size_t index=0; index<in_ero.len(); index++)
{
if(in_ero[index]->has_operation())
return true;
}
for (std::size_t index=0; index<path_rro.len(); index++)
{
if(path_rro[index]->has_operation())
return true;
}
for (std::size_t index=0; index<resv_rro.len(); index++)
{
if(resv_rro[index]->has_operation())
return true;
}
for (std::size_t index=0; index<path_affinity_array.len(); index++)
{
if(path_affinity_array[index]->has_operation())
return true;
}
for (std::size_t index=0; index<reverse_ero_in.len(); index++)
{
if(reverse_ero_in[index]->has_operation())
return true;
}
for (std::size_t index=0; index<s2l_segment_routing_path.len(); index++)
{
if(s2l_segment_routing_path[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(pcalc_area.yfilter)
|| ydk::is_set(is_expanded_ero.yfilter)
|| ydk::is_set(path_reeval_query_mid.yfilter)
|| ydk::is_set(time_since_last_query_received_mid.yfilter)
|| ydk::is_set(time_since_last_preferred_path_exists_send_mid.yfilter)
|| ydk::is_set(time_since_last_preferred_tree_exists_send_mid.yfilter)
|| ydk::is_set(expanded_ero_area_id.yfilter)
|| ydk::is_set(expanded_ero_affinity_bits.yfilter)
|| ydk::is_set(expanded_ero_affinity_mask.yfilter)
|| ydk::is_set(expanded_ero_metric_type.yfilter)
|| ydk::is_set(expanded_ero_metric.yfilter)
|| ydk::is_set(abr_auto_discovered.yfilter)
|| ydk::is_set(is_frr_enabled.yfilter)
|| ydk::is_set(is_node_protected.yfilter)
|| ydk::is_set(is_bandwidth_protect.yfilter)
|| ydk::is_set(path_rro_enabled.yfilter)
|| ydk::is_set(weight.yfilter)
|| ydk::is_set(reverse_weight.yfilter)
|| ydk::is_set(uptime.yfilter)
|| ydk::is_set(egress_interface.yfilter)
|| ydk::is_set(egress_interface_state.yfilter)
|| ydk::is_set(egress_interface_brief.yfilter)
|| ydk::is_set(ingress_interface.yfilter)
|| ydk::is_set(ingress_interface_state.yfilter)
|| ydk::is_set(ingress_interface_brief.yfilter)
|| ydk::is_set(s2l_local_label.yfilter)
|| ydk::is_set(s2l_out_label.yfilter)
|| ydk::is_set(outbound_frr_state.yfilter)
|| ydk::is_set(frr_out_tunnel_interface.yfilter)
|| ydk::is_set(role.yfilter)
|| ydk::is_set(signalling_status.yfilter)
|| ydk::is_set(local_router_id.yfilter)
|| ydk::is_set(upstream_router_id.yfilter)
|| ydk::is_set(downstream_router_id.yfilter)
|| ydk::is_set(next_hop_address.yfilter)
|| ydk::is_set(next_next_hop_address.yfilter)
|| ydk::is_set(previous_hop_address.yfilter)
|| ydk::is_set(incoming_address.yfilter)
|| ydk::is_set(backup_tunnel_interface.yfilter)
|| ydk::is_set(node_hop_count.yfilter)
|| ydk::is_set(is_optical.yfilter)
|| ydk::is_set(s2l_reverse_ero_obj_present.yfilter)
|| ydk::is_set(reverse_lsp_present.yfilter)
|| ydk::is_set(reverse_lsp_connected.yfilter)
|| ydk::is_set(reverse_lsp_name.yfilter)
|| ydk::is_set(s2l_reverse_tspec_obj_present.yfilter)
|| ydk::is_set(path_using_strict_spf.yfilter)
|| (s2l_fec != nullptr && s2l_fec->has_operation())
|| (active_path_option != nullptr && active_path_option->has_operation())
|| (out_xro != nullptr && out_xro->has_operation())
|| (in_xro != nullptr && in_xro->has_operation())
|| (tspec != nullptr && tspec->has_operation())
|| (generic_tspec != nullptr && generic_tspec->has_operation())
|| (fspec != nullptr && fspec->has_operation())
|| (generic_fspec != nullptr && generic_fspec->has_operation())
|| (next_hop_address_generic != nullptr && next_hop_address_generic->has_operation())
|| (previous_hop_address_generic != nullptr && previous_hop_address_generic->has_operation())
|| (incoming_address_generic != nullptr && incoming_address_generic->has_operation())
|| (s2l_convergence != nullptr && s2l_convergence->has_operation())
|| (soft_preemption != nullptr && soft_preemption->has_operation())
|| (gmpls_labels != nullptr && gmpls_labels->has_operation())
|| (otn_s2l != nullptr && otn_s2l->has_operation())
|| (head_end_bfd_info != nullptr && head_end_bfd_info->has_operation())
|| (tail_end_bfd_info != nullptr && tail_end_bfd_info->has_operation())
|| (srlg_collection != nullptr && srlg_collection->has_operation())
|| (association != nullptr && association->has_operation())
|| (protection != nullptr && protection->has_operation())
|| (reverse_lsp_fec != nullptr && reverse_lsp_fec->has_operation())
|| (reverse_tspec != nullptr && reverse_tspec->has_operation())
|| (flex_info != nullptr && flex_info->has_operation())
|| (lsp_wrap_info != nullptr && lsp_wrap_info->has_operation())
|| (diversity_info != nullptr && diversity_info->has_operation())
|| (accumulated_path_metrics != nullptr && accumulated_path_metrics->has_operation())
|| (accumulated_reverse_path_metrics != nullptr && accumulated_reverse_path_metrics->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "s2l";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (pcalc_area.is_set || is_set(pcalc_area.yfilter)) leaf_name_data.push_back(pcalc_area.get_name_leafdata());
if (is_expanded_ero.is_set || is_set(is_expanded_ero.yfilter)) leaf_name_data.push_back(is_expanded_ero.get_name_leafdata());
if (path_reeval_query_mid.is_set || is_set(path_reeval_query_mid.yfilter)) leaf_name_data.push_back(path_reeval_query_mid.get_name_leafdata());
if (time_since_last_query_received_mid.is_set || is_set(time_since_last_query_received_mid.yfilter)) leaf_name_data.push_back(time_since_last_query_received_mid.get_name_leafdata());
if (time_since_last_preferred_path_exists_send_mid.is_set || is_set(time_since_last_preferred_path_exists_send_mid.yfilter)) leaf_name_data.push_back(time_since_last_preferred_path_exists_send_mid.get_name_leafdata());
if (time_since_last_preferred_tree_exists_send_mid.is_set || is_set(time_since_last_preferred_tree_exists_send_mid.yfilter)) leaf_name_data.push_back(time_since_last_preferred_tree_exists_send_mid.get_name_leafdata());
if (expanded_ero_area_id.is_set || is_set(expanded_ero_area_id.yfilter)) leaf_name_data.push_back(expanded_ero_area_id.get_name_leafdata());
if (expanded_ero_affinity_bits.is_set || is_set(expanded_ero_affinity_bits.yfilter)) leaf_name_data.push_back(expanded_ero_affinity_bits.get_name_leafdata());
if (expanded_ero_affinity_mask.is_set || is_set(expanded_ero_affinity_mask.yfilter)) leaf_name_data.push_back(expanded_ero_affinity_mask.get_name_leafdata());
if (expanded_ero_metric_type.is_set || is_set(expanded_ero_metric_type.yfilter)) leaf_name_data.push_back(expanded_ero_metric_type.get_name_leafdata());
if (expanded_ero_metric.is_set || is_set(expanded_ero_metric.yfilter)) leaf_name_data.push_back(expanded_ero_metric.get_name_leafdata());
if (abr_auto_discovered.is_set || is_set(abr_auto_discovered.yfilter)) leaf_name_data.push_back(abr_auto_discovered.get_name_leafdata());
if (is_frr_enabled.is_set || is_set(is_frr_enabled.yfilter)) leaf_name_data.push_back(is_frr_enabled.get_name_leafdata());
if (is_node_protected.is_set || is_set(is_node_protected.yfilter)) leaf_name_data.push_back(is_node_protected.get_name_leafdata());
if (is_bandwidth_protect.is_set || is_set(is_bandwidth_protect.yfilter)) leaf_name_data.push_back(is_bandwidth_protect.get_name_leafdata());
if (path_rro_enabled.is_set || is_set(path_rro_enabled.yfilter)) leaf_name_data.push_back(path_rro_enabled.get_name_leafdata());
if (weight.is_set || is_set(weight.yfilter)) leaf_name_data.push_back(weight.get_name_leafdata());
if (reverse_weight.is_set || is_set(reverse_weight.yfilter)) leaf_name_data.push_back(reverse_weight.get_name_leafdata());
if (uptime.is_set || is_set(uptime.yfilter)) leaf_name_data.push_back(uptime.get_name_leafdata());
if (egress_interface.is_set || is_set(egress_interface.yfilter)) leaf_name_data.push_back(egress_interface.get_name_leafdata());
if (egress_interface_state.is_set || is_set(egress_interface_state.yfilter)) leaf_name_data.push_back(egress_interface_state.get_name_leafdata());
if (egress_interface_brief.is_set || is_set(egress_interface_brief.yfilter)) leaf_name_data.push_back(egress_interface_brief.get_name_leafdata());
if (ingress_interface.is_set || is_set(ingress_interface.yfilter)) leaf_name_data.push_back(ingress_interface.get_name_leafdata());
if (ingress_interface_state.is_set || is_set(ingress_interface_state.yfilter)) leaf_name_data.push_back(ingress_interface_state.get_name_leafdata());
if (ingress_interface_brief.is_set || is_set(ingress_interface_brief.yfilter)) leaf_name_data.push_back(ingress_interface_brief.get_name_leafdata());
if (s2l_local_label.is_set || is_set(s2l_local_label.yfilter)) leaf_name_data.push_back(s2l_local_label.get_name_leafdata());
if (s2l_out_label.is_set || is_set(s2l_out_label.yfilter)) leaf_name_data.push_back(s2l_out_label.get_name_leafdata());
if (outbound_frr_state.is_set || is_set(outbound_frr_state.yfilter)) leaf_name_data.push_back(outbound_frr_state.get_name_leafdata());
if (frr_out_tunnel_interface.is_set || is_set(frr_out_tunnel_interface.yfilter)) leaf_name_data.push_back(frr_out_tunnel_interface.get_name_leafdata());
if (role.is_set || is_set(role.yfilter)) leaf_name_data.push_back(role.get_name_leafdata());
if (signalling_status.is_set || is_set(signalling_status.yfilter)) leaf_name_data.push_back(signalling_status.get_name_leafdata());
if (local_router_id.is_set || is_set(local_router_id.yfilter)) leaf_name_data.push_back(local_router_id.get_name_leafdata());
if (upstream_router_id.is_set || is_set(upstream_router_id.yfilter)) leaf_name_data.push_back(upstream_router_id.get_name_leafdata());
if (downstream_router_id.is_set || is_set(downstream_router_id.yfilter)) leaf_name_data.push_back(downstream_router_id.get_name_leafdata());
if (next_hop_address.is_set || is_set(next_hop_address.yfilter)) leaf_name_data.push_back(next_hop_address.get_name_leafdata());
if (next_next_hop_address.is_set || is_set(next_next_hop_address.yfilter)) leaf_name_data.push_back(next_next_hop_address.get_name_leafdata());
if (previous_hop_address.is_set || is_set(previous_hop_address.yfilter)) leaf_name_data.push_back(previous_hop_address.get_name_leafdata());
if (incoming_address.is_set || is_set(incoming_address.yfilter)) leaf_name_data.push_back(incoming_address.get_name_leafdata());
if (backup_tunnel_interface.is_set || is_set(backup_tunnel_interface.yfilter)) leaf_name_data.push_back(backup_tunnel_interface.get_name_leafdata());
if (node_hop_count.is_set || is_set(node_hop_count.yfilter)) leaf_name_data.push_back(node_hop_count.get_name_leafdata());
if (is_optical.is_set || is_set(is_optical.yfilter)) leaf_name_data.push_back(is_optical.get_name_leafdata());
if (s2l_reverse_ero_obj_present.is_set || is_set(s2l_reverse_ero_obj_present.yfilter)) leaf_name_data.push_back(s2l_reverse_ero_obj_present.get_name_leafdata());
if (reverse_lsp_present.is_set || is_set(reverse_lsp_present.yfilter)) leaf_name_data.push_back(reverse_lsp_present.get_name_leafdata());
if (reverse_lsp_connected.is_set || is_set(reverse_lsp_connected.yfilter)) leaf_name_data.push_back(reverse_lsp_connected.get_name_leafdata());
if (reverse_lsp_name.is_set || is_set(reverse_lsp_name.yfilter)) leaf_name_data.push_back(reverse_lsp_name.get_name_leafdata());
if (s2l_reverse_tspec_obj_present.is_set || is_set(s2l_reverse_tspec_obj_present.yfilter)) leaf_name_data.push_back(s2l_reverse_tspec_obj_present.get_name_leafdata());
if (path_using_strict_spf.is_set || is_set(path_using_strict_spf.yfilter)) leaf_name_data.push_back(path_using_strict_spf.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "s2l-fec")
{
if(s2l_fec == nullptr)
{
s2l_fec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec>();
}
return s2l_fec;
}
if(child_yang_name == "active-path-option")
{
if(active_path_option == nullptr)
{
active_path_option = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption>();
}
return active_path_option;
}
if(child_yang_name == "out-xro")
{
if(out_xro == nullptr)
{
out_xro = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro>();
}
return out_xro;
}
if(child_yang_name == "in-xro")
{
if(in_xro == nullptr)
{
in_xro = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro>();
}
return in_xro;
}
if(child_yang_name == "tspec")
{
if(tspec == nullptr)
{
tspec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Tspec>();
}
return tspec;
}
if(child_yang_name == "generic-tspec")
{
if(generic_tspec == nullptr)
{
generic_tspec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::GenericTspec>();
}
return generic_tspec;
}
if(child_yang_name == "fspec")
{
if(fspec == nullptr)
{
fspec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Fspec>();
}
return fspec;
}
if(child_yang_name == "generic-fspec")
{
if(generic_fspec == nullptr)
{
generic_fspec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::GenericFspec>();
}
return generic_fspec;
}
if(child_yang_name == "next-hop-address-generic")
{
if(next_hop_address_generic == nullptr)
{
next_hop_address_generic = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::NextHopAddressGeneric>();
}
return next_hop_address_generic;
}
if(child_yang_name == "previous-hop-address-generic")
{
if(previous_hop_address_generic == nullptr)
{
previous_hop_address_generic = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::PreviousHopAddressGeneric>();
}
return previous_hop_address_generic;
}
if(child_yang_name == "incoming-address-generic")
{
if(incoming_address_generic == nullptr)
{
incoming_address_generic = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::IncomingAddressGeneric>();
}
return incoming_address_generic;
}
if(child_yang_name == "s2l-convergence")
{
if(s2l_convergence == nullptr)
{
s2l_convergence = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lConvergence>();
}
return s2l_convergence;
}
if(child_yang_name == "soft-preemption")
{
if(soft_preemption == nullptr)
{
soft_preemption = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::SoftPreemption>();
}
return soft_preemption;
}
if(child_yang_name == "gmpls-labels")
{
if(gmpls_labels == nullptr)
{
gmpls_labels = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::GmplsLabels>();
}
return gmpls_labels;
}
if(child_yang_name == "otn-s2l")
{
if(otn_s2l == nullptr)
{
otn_s2l = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OtnS2l>();
}
return otn_s2l;
}
if(child_yang_name == "head-end-bfd-info")
{
if(head_end_bfd_info == nullptr)
{
head_end_bfd_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::HeadEndBfdInfo>();
}
return head_end_bfd_info;
}
if(child_yang_name == "tail-end-bfd-info")
{
if(tail_end_bfd_info == nullptr)
{
tail_end_bfd_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::TailEndBfdInfo>();
}
return tail_end_bfd_info;
}
if(child_yang_name == "srlg-collection")
{
if(srlg_collection == nullptr)
{
srlg_collection = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::SrlgCollection>();
}
return srlg_collection;
}
if(child_yang_name == "association")
{
if(association == nullptr)
{
association = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Association>();
}
return association;
}
if(child_yang_name == "protection")
{
if(protection == nullptr)
{
protection = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Protection>();
}
return protection;
}
if(child_yang_name == "reverse-lsp-fec")
{
if(reverse_lsp_fec == nullptr)
{
reverse_lsp_fec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ReverseLspFec>();
}
return reverse_lsp_fec;
}
if(child_yang_name == "reverse-tspec")
{
if(reverse_tspec == nullptr)
{
reverse_tspec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ReverseTspec>();
}
return reverse_tspec;
}
if(child_yang_name == "flex-info")
{
if(flex_info == nullptr)
{
flex_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::FlexInfo>();
}
return flex_info;
}
if(child_yang_name == "lsp-wrap-info")
{
if(lsp_wrap_info == nullptr)
{
lsp_wrap_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::LspWrapInfo>();
}
return lsp_wrap_info;
}
if(child_yang_name == "diversity-info")
{
if(diversity_info == nullptr)
{
diversity_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::DiversityInfo>();
}
return diversity_info;
}
if(child_yang_name == "accumulated-path-metrics")
{
if(accumulated_path_metrics == nullptr)
{
accumulated_path_metrics = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::AccumulatedPathMetrics>();
}
return accumulated_path_metrics;
}
if(child_yang_name == "accumulated-reverse-path-metrics")
{
if(accumulated_reverse_path_metrics == nullptr)
{
accumulated_reverse_path_metrics = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::AccumulatedReversePathMetrics>();
}
return accumulated_reverse_path_metrics;
}
if(child_yang_name == "s2l-reverse-lsp-sub-obj")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lReverseLspSubObj>();
ent_->parent = this;
s2l_reverse_lsp_sub_obj.append(ent_);
return ent_;
}
if(child_yang_name == "shared-risk-link-group")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::SharedRiskLinkGroup>();
ent_->parent = this;
shared_risk_link_group.append(ent_);
return ent_;
}
if(child_yang_name == "out-ero")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutEro>();
ent_->parent = this;
out_ero.append(ent_);
return ent_;
}
if(child_yang_name == "in-ero")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InEro>();
ent_->parent = this;
in_ero.append(ent_);
return ent_;
}
if(child_yang_name == "path-rro")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::PathRro>();
ent_->parent = this;
path_rro.append(ent_);
return ent_;
}
if(child_yang_name == "resv-rro")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ResvRro>();
ent_->parent = this;
resv_rro.append(ent_);
return ent_;
}
if(child_yang_name == "path-affinity-array")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::PathAffinityArray>();
ent_->parent = this;
path_affinity_array.append(ent_);
return ent_;
}
if(child_yang_name == "reverse-ero-in")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ReverseEroIn>();
ent_->parent = this;
reverse_ero_in.append(ent_);
return ent_;
}
if(child_yang_name == "s2l-segment-routing-path")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lSegmentRoutingPath>();
ent_->parent = this;
s2l_segment_routing_path.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(s2l_fec != nullptr)
{
_children["s2l-fec"] = s2l_fec;
}
if(active_path_option != nullptr)
{
_children["active-path-option"] = active_path_option;
}
if(out_xro != nullptr)
{
_children["out-xro"] = out_xro;
}
if(in_xro != nullptr)
{
_children["in-xro"] = in_xro;
}
if(tspec != nullptr)
{
_children["tspec"] = tspec;
}
if(generic_tspec != nullptr)
{
_children["generic-tspec"] = generic_tspec;
}
if(fspec != nullptr)
{
_children["fspec"] = fspec;
}
if(generic_fspec != nullptr)
{
_children["generic-fspec"] = generic_fspec;
}
if(next_hop_address_generic != nullptr)
{
_children["next-hop-address-generic"] = next_hop_address_generic;
}
if(previous_hop_address_generic != nullptr)
{
_children["previous-hop-address-generic"] = previous_hop_address_generic;
}
if(incoming_address_generic != nullptr)
{
_children["incoming-address-generic"] = incoming_address_generic;
}
if(s2l_convergence != nullptr)
{
_children["s2l-convergence"] = s2l_convergence;
}
if(soft_preemption != nullptr)
{
_children["soft-preemption"] = soft_preemption;
}
if(gmpls_labels != nullptr)
{
_children["gmpls-labels"] = gmpls_labels;
}
if(otn_s2l != nullptr)
{
_children["otn-s2l"] = otn_s2l;
}
if(head_end_bfd_info != nullptr)
{
_children["head-end-bfd-info"] = head_end_bfd_info;
}
if(tail_end_bfd_info != nullptr)
{
_children["tail-end-bfd-info"] = tail_end_bfd_info;
}
if(srlg_collection != nullptr)
{
_children["srlg-collection"] = srlg_collection;
}
if(association != nullptr)
{
_children["association"] = association;
}
if(protection != nullptr)
{
_children["protection"] = protection;
}
if(reverse_lsp_fec != nullptr)
{
_children["reverse-lsp-fec"] = reverse_lsp_fec;
}
if(reverse_tspec != nullptr)
{
_children["reverse-tspec"] = reverse_tspec;
}
if(flex_info != nullptr)
{
_children["flex-info"] = flex_info;
}
if(lsp_wrap_info != nullptr)
{
_children["lsp-wrap-info"] = lsp_wrap_info;
}
if(diversity_info != nullptr)
{
_children["diversity-info"] = diversity_info;
}
if(accumulated_path_metrics != nullptr)
{
_children["accumulated-path-metrics"] = accumulated_path_metrics;
}
if(accumulated_reverse_path_metrics != nullptr)
{
_children["accumulated-reverse-path-metrics"] = accumulated_reverse_path_metrics;
}
count_ = 0;
for (auto ent_ : s2l_reverse_lsp_sub_obj.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : shared_risk_link_group.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : out_ero.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : in_ero.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : path_rro.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : resv_rro.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : path_affinity_array.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : reverse_ero_in.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : s2l_segment_routing_path.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "pcalc-area")
{
pcalc_area = value;
pcalc_area.value_namespace = name_space;
pcalc_area.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-expanded-ero")
{
is_expanded_ero = value;
is_expanded_ero.value_namespace = name_space;
is_expanded_ero.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-reeval-query-mid")
{
path_reeval_query_mid = value;
path_reeval_query_mid.value_namespace = name_space;
path_reeval_query_mid.value_namespace_prefix = name_space_prefix;
}
if(value_path == "time-since-last-query-received-mid")
{
time_since_last_query_received_mid = value;
time_since_last_query_received_mid.value_namespace = name_space;
time_since_last_query_received_mid.value_namespace_prefix = name_space_prefix;
}
if(value_path == "time-since-last-preferred-path-exists-send-mid")
{
time_since_last_preferred_path_exists_send_mid = value;
time_since_last_preferred_path_exists_send_mid.value_namespace = name_space;
time_since_last_preferred_path_exists_send_mid.value_namespace_prefix = name_space_prefix;
}
if(value_path == "time-since-last-preferred-tree-exists-send-mid")
{
time_since_last_preferred_tree_exists_send_mid = value;
time_since_last_preferred_tree_exists_send_mid.value_namespace = name_space;
time_since_last_preferred_tree_exists_send_mid.value_namespace_prefix = name_space_prefix;
}
if(value_path == "expanded-ero-area-id")
{
expanded_ero_area_id = value;
expanded_ero_area_id.value_namespace = name_space;
expanded_ero_area_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "expanded-ero-affinity-bits")
{
expanded_ero_affinity_bits = value;
expanded_ero_affinity_bits.value_namespace = name_space;
expanded_ero_affinity_bits.value_namespace_prefix = name_space_prefix;
}
if(value_path == "expanded-ero-affinity-mask")
{
expanded_ero_affinity_mask = value;
expanded_ero_affinity_mask.value_namespace = name_space;
expanded_ero_affinity_mask.value_namespace_prefix = name_space_prefix;
}
if(value_path == "expanded-ero-metric-type")
{
expanded_ero_metric_type = value;
expanded_ero_metric_type.value_namespace = name_space;
expanded_ero_metric_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "expanded-ero-metric")
{
expanded_ero_metric = value;
expanded_ero_metric.value_namespace = name_space;
expanded_ero_metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "abr-auto-discovered")
{
abr_auto_discovered = value;
abr_auto_discovered.value_namespace = name_space;
abr_auto_discovered.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-frr-enabled")
{
is_frr_enabled = value;
is_frr_enabled.value_namespace = name_space;
is_frr_enabled.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-node-protected")
{
is_node_protected = value;
is_node_protected.value_namespace = name_space;
is_node_protected.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-bandwidth-protect")
{
is_bandwidth_protect = value;
is_bandwidth_protect.value_namespace = name_space;
is_bandwidth_protect.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-rro-enabled")
{
path_rro_enabled = value;
path_rro_enabled.value_namespace = name_space;
path_rro_enabled.value_namespace_prefix = name_space_prefix;
}
if(value_path == "weight")
{
weight = value;
weight.value_namespace = name_space;
weight.value_namespace_prefix = name_space_prefix;
}
if(value_path == "reverse-weight")
{
reverse_weight = value;
reverse_weight.value_namespace = name_space;
reverse_weight.value_namespace_prefix = name_space_prefix;
}
if(value_path == "uptime")
{
uptime = value;
uptime.value_namespace = name_space;
uptime.value_namespace_prefix = name_space_prefix;
}
if(value_path == "egress-interface")
{
egress_interface = value;
egress_interface.value_namespace = name_space;
egress_interface.value_namespace_prefix = name_space_prefix;
}
if(value_path == "egress-interface-state")
{
egress_interface_state = value;
egress_interface_state.value_namespace = name_space;
egress_interface_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "egress-interface-brief")
{
egress_interface_brief = value;
egress_interface_brief.value_namespace = name_space;
egress_interface_brief.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ingress-interface")
{
ingress_interface = value;
ingress_interface.value_namespace = name_space;
ingress_interface.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ingress-interface-state")
{
ingress_interface_state = value;
ingress_interface_state.value_namespace = name_space;
ingress_interface_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ingress-interface-brief")
{
ingress_interface_brief = value;
ingress_interface_brief.value_namespace = name_space;
ingress_interface_brief.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-local-label")
{
s2l_local_label = value;
s2l_local_label.value_namespace = name_space;
s2l_local_label.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-out-label")
{
s2l_out_label = value;
s2l_out_label.value_namespace = name_space;
s2l_out_label.value_namespace_prefix = name_space_prefix;
}
if(value_path == "outbound-frr-state")
{
outbound_frr_state = value;
outbound_frr_state.value_namespace = name_space;
outbound_frr_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "frr-out-tunnel-interface")
{
frr_out_tunnel_interface = value;
frr_out_tunnel_interface.value_namespace = name_space;
frr_out_tunnel_interface.value_namespace_prefix = name_space_prefix;
}
if(value_path == "role")
{
role = value;
role.value_namespace = name_space;
role.value_namespace_prefix = name_space_prefix;
}
if(value_path == "signalling-status")
{
signalling_status = value;
signalling_status.value_namespace = name_space;
signalling_status.value_namespace_prefix = name_space_prefix;
}
if(value_path == "local-router-id")
{
local_router_id = value;
local_router_id.value_namespace = name_space;
local_router_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "upstream-router-id")
{
upstream_router_id = value;
upstream_router_id.value_namespace = name_space;
upstream_router_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "downstream-router-id")
{
downstream_router_id = value;
downstream_router_id.value_namespace = name_space;
downstream_router_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "next-hop-address")
{
next_hop_address = value;
next_hop_address.value_namespace = name_space;
next_hop_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "next-next-hop-address")
{
next_next_hop_address = value;
next_next_hop_address.value_namespace = name_space;
next_next_hop_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "previous-hop-address")
{
previous_hop_address = value;
previous_hop_address.value_namespace = name_space;
previous_hop_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "incoming-address")
{
incoming_address = value;
incoming_address.value_namespace = name_space;
incoming_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "backup-tunnel-interface")
{
backup_tunnel_interface = value;
backup_tunnel_interface.value_namespace = name_space;
backup_tunnel_interface.value_namespace_prefix = name_space_prefix;
}
if(value_path == "node-hop-count")
{
node_hop_count = value;
node_hop_count.value_namespace = name_space;
node_hop_count.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-optical")
{
is_optical = value;
is_optical.value_namespace = name_space;
is_optical.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-reverse-ero-obj-present")
{
s2l_reverse_ero_obj_present = value;
s2l_reverse_ero_obj_present.value_namespace = name_space;
s2l_reverse_ero_obj_present.value_namespace_prefix = name_space_prefix;
}
if(value_path == "reverse-lsp-present")
{
reverse_lsp_present = value;
reverse_lsp_present.value_namespace = name_space;
reverse_lsp_present.value_namespace_prefix = name_space_prefix;
}
if(value_path == "reverse-lsp-connected")
{
reverse_lsp_connected = value;
reverse_lsp_connected.value_namespace = name_space;
reverse_lsp_connected.value_namespace_prefix = name_space_prefix;
}
if(value_path == "reverse-lsp-name")
{
reverse_lsp_name = value;
reverse_lsp_name.value_namespace = name_space;
reverse_lsp_name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-reverse-tspec-obj-present")
{
s2l_reverse_tspec_obj_present = value;
s2l_reverse_tspec_obj_present.value_namespace = name_space;
s2l_reverse_tspec_obj_present.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-using-strict-spf")
{
path_using_strict_spf = value;
path_using_strict_spf.value_namespace = name_space;
path_using_strict_spf.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "pcalc-area")
{
pcalc_area.yfilter = yfilter;
}
if(value_path == "is-expanded-ero")
{
is_expanded_ero.yfilter = yfilter;
}
if(value_path == "path-reeval-query-mid")
{
path_reeval_query_mid.yfilter = yfilter;
}
if(value_path == "time-since-last-query-received-mid")
{
time_since_last_query_received_mid.yfilter = yfilter;
}
if(value_path == "time-since-last-preferred-path-exists-send-mid")
{
time_since_last_preferred_path_exists_send_mid.yfilter = yfilter;
}
if(value_path == "time-since-last-preferred-tree-exists-send-mid")
{
time_since_last_preferred_tree_exists_send_mid.yfilter = yfilter;
}
if(value_path == "expanded-ero-area-id")
{
expanded_ero_area_id.yfilter = yfilter;
}
if(value_path == "expanded-ero-affinity-bits")
{
expanded_ero_affinity_bits.yfilter = yfilter;
}
if(value_path == "expanded-ero-affinity-mask")
{
expanded_ero_affinity_mask.yfilter = yfilter;
}
if(value_path == "expanded-ero-metric-type")
{
expanded_ero_metric_type.yfilter = yfilter;
}
if(value_path == "expanded-ero-metric")
{
expanded_ero_metric.yfilter = yfilter;
}
if(value_path == "abr-auto-discovered")
{
abr_auto_discovered.yfilter = yfilter;
}
if(value_path == "is-frr-enabled")
{
is_frr_enabled.yfilter = yfilter;
}
if(value_path == "is-node-protected")
{
is_node_protected.yfilter = yfilter;
}
if(value_path == "is-bandwidth-protect")
{
is_bandwidth_protect.yfilter = yfilter;
}
if(value_path == "path-rro-enabled")
{
path_rro_enabled.yfilter = yfilter;
}
if(value_path == "weight")
{
weight.yfilter = yfilter;
}
if(value_path == "reverse-weight")
{
reverse_weight.yfilter = yfilter;
}
if(value_path == "uptime")
{
uptime.yfilter = yfilter;
}
if(value_path == "egress-interface")
{
egress_interface.yfilter = yfilter;
}
if(value_path == "egress-interface-state")
{
egress_interface_state.yfilter = yfilter;
}
if(value_path == "egress-interface-brief")
{
egress_interface_brief.yfilter = yfilter;
}
if(value_path == "ingress-interface")
{
ingress_interface.yfilter = yfilter;
}
if(value_path == "ingress-interface-state")
{
ingress_interface_state.yfilter = yfilter;
}
if(value_path == "ingress-interface-brief")
{
ingress_interface_brief.yfilter = yfilter;
}
if(value_path == "s2l-local-label")
{
s2l_local_label.yfilter = yfilter;
}
if(value_path == "s2l-out-label")
{
s2l_out_label.yfilter = yfilter;
}
if(value_path == "outbound-frr-state")
{
outbound_frr_state.yfilter = yfilter;
}
if(value_path == "frr-out-tunnel-interface")
{
frr_out_tunnel_interface.yfilter = yfilter;
}
if(value_path == "role")
{
role.yfilter = yfilter;
}
if(value_path == "signalling-status")
{
signalling_status.yfilter = yfilter;
}
if(value_path == "local-router-id")
{
local_router_id.yfilter = yfilter;
}
if(value_path == "upstream-router-id")
{
upstream_router_id.yfilter = yfilter;
}
if(value_path == "downstream-router-id")
{
downstream_router_id.yfilter = yfilter;
}
if(value_path == "next-hop-address")
{
next_hop_address.yfilter = yfilter;
}
if(value_path == "next-next-hop-address")
{
next_next_hop_address.yfilter = yfilter;
}
if(value_path == "previous-hop-address")
{
previous_hop_address.yfilter = yfilter;
}
if(value_path == "incoming-address")
{
incoming_address.yfilter = yfilter;
}
if(value_path == "backup-tunnel-interface")
{
backup_tunnel_interface.yfilter = yfilter;
}
if(value_path == "node-hop-count")
{
node_hop_count.yfilter = yfilter;
}
if(value_path == "is-optical")
{
is_optical.yfilter = yfilter;
}
if(value_path == "s2l-reverse-ero-obj-present")
{
s2l_reverse_ero_obj_present.yfilter = yfilter;
}
if(value_path == "reverse-lsp-present")
{
reverse_lsp_present.yfilter = yfilter;
}
if(value_path == "reverse-lsp-connected")
{
reverse_lsp_connected.yfilter = yfilter;
}
if(value_path == "reverse-lsp-name")
{
reverse_lsp_name.yfilter = yfilter;
}
if(value_path == "s2l-reverse-tspec-obj-present")
{
s2l_reverse_tspec_obj_present.yfilter = yfilter;
}
if(value_path == "path-using-strict-spf")
{
path_using_strict_spf.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "s2l-fec" || name == "active-path-option" || name == "out-xro" || name == "in-xro" || name == "tspec" || name == "generic-tspec" || name == "fspec" || name == "generic-fspec" || name == "next-hop-address-generic" || name == "previous-hop-address-generic" || name == "incoming-address-generic" || name == "s2l-convergence" || name == "soft-preemption" || name == "gmpls-labels" || name == "otn-s2l" || name == "head-end-bfd-info" || name == "tail-end-bfd-info" || name == "srlg-collection" || name == "association" || name == "protection" || name == "reverse-lsp-fec" || name == "reverse-tspec" || name == "flex-info" || name == "lsp-wrap-info" || name == "diversity-info" || name == "accumulated-path-metrics" || name == "accumulated-reverse-path-metrics" || name == "s2l-reverse-lsp-sub-obj" || name == "shared-risk-link-group" || name == "out-ero" || name == "in-ero" || name == "path-rro" || name == "resv-rro" || name == "path-affinity-array" || name == "reverse-ero-in" || name == "s2l-segment-routing-path" || name == "pcalc-area" || name == "is-expanded-ero" || name == "path-reeval-query-mid" || name == "time-since-last-query-received-mid" || name == "time-since-last-preferred-path-exists-send-mid" || name == "time-since-last-preferred-tree-exists-send-mid" || name == "expanded-ero-area-id" || name == "expanded-ero-affinity-bits" || name == "expanded-ero-affinity-mask" || name == "expanded-ero-metric-type" || name == "expanded-ero-metric" || name == "abr-auto-discovered" || name == "is-frr-enabled" || name == "is-node-protected" || name == "is-bandwidth-protect" || name == "path-rro-enabled" || name == "weight" || name == "reverse-weight" || name == "uptime" || name == "egress-interface" || name == "egress-interface-state" || name == "egress-interface-brief" || name == "ingress-interface" || name == "ingress-interface-state" || name == "ingress-interface-brief" || name == "s2l-local-label" || name == "s2l-out-label" || name == "outbound-frr-state" || name == "frr-out-tunnel-interface" || name == "role" || name == "signalling-status" || name == "local-router-id" || name == "upstream-router-id" || name == "downstream-router-id" || name == "next-hop-address" || name == "next-next-hop-address" || name == "previous-hop-address" || name == "incoming-address" || name == "backup-tunnel-interface" || name == "node-hop-count" || name == "is-optical" || name == "s2l-reverse-ero-obj-present" || name == "reverse-lsp-present" || name == "reverse-lsp-connected" || name == "reverse-lsp-name" || name == "s2l-reverse-tspec-obj-present" || name == "path-using-strict-spf")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::S2lFec()
:
s2l_fec_subgroup_id{YType::uint16, "s2l-fec-subgroup-id"},
s2l_fec_lsp_id{YType::uint16, "s2l-fec-lsp-id"},
s2l_fec_tunnel_id{YType::uint16, "s2l-fec-tunnel-id"},
s2l_fec_extended_tunnel_id{YType::str, "s2l-fec-extended-tunnel-id"},
s2l_fec_source{YType::str, "s2l-fec-source"},
s2l_fec_dest{YType::str, "s2l-fec-dest"},
s2l_fec_p2mp_id{YType::uint32, "s2l-fec-p2mp-id"},
s2l_fec_subgroup_originator{YType::str, "s2l-fec-subgroup-originator"},
s2l_fec_ctype{YType::enumeration, "s2l-fec-ctype"},
s2l_fec_vrf{YType::str, "s2l-fec-vrf"}
{
yang_name = "s2l-fec"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::~S2lFec()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::has_data() const
{
if (is_presence_container) return true;
return s2l_fec_subgroup_id.is_set
|| s2l_fec_lsp_id.is_set
|| s2l_fec_tunnel_id.is_set
|| s2l_fec_extended_tunnel_id.is_set
|| s2l_fec_source.is_set
|| s2l_fec_dest.is_set
|| s2l_fec_p2mp_id.is_set
|| s2l_fec_subgroup_originator.is_set
|| s2l_fec_ctype.is_set
|| s2l_fec_vrf.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(s2l_fec_subgroup_id.yfilter)
|| ydk::is_set(s2l_fec_lsp_id.yfilter)
|| ydk::is_set(s2l_fec_tunnel_id.yfilter)
|| ydk::is_set(s2l_fec_extended_tunnel_id.yfilter)
|| ydk::is_set(s2l_fec_source.yfilter)
|| ydk::is_set(s2l_fec_dest.yfilter)
|| ydk::is_set(s2l_fec_p2mp_id.yfilter)
|| ydk::is_set(s2l_fec_subgroup_originator.yfilter)
|| ydk::is_set(s2l_fec_ctype.yfilter)
|| ydk::is_set(s2l_fec_vrf.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "s2l-fec";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (s2l_fec_subgroup_id.is_set || is_set(s2l_fec_subgroup_id.yfilter)) leaf_name_data.push_back(s2l_fec_subgroup_id.get_name_leafdata());
if (s2l_fec_lsp_id.is_set || is_set(s2l_fec_lsp_id.yfilter)) leaf_name_data.push_back(s2l_fec_lsp_id.get_name_leafdata());
if (s2l_fec_tunnel_id.is_set || is_set(s2l_fec_tunnel_id.yfilter)) leaf_name_data.push_back(s2l_fec_tunnel_id.get_name_leafdata());
if (s2l_fec_extended_tunnel_id.is_set || is_set(s2l_fec_extended_tunnel_id.yfilter)) leaf_name_data.push_back(s2l_fec_extended_tunnel_id.get_name_leafdata());
if (s2l_fec_source.is_set || is_set(s2l_fec_source.yfilter)) leaf_name_data.push_back(s2l_fec_source.get_name_leafdata());
if (s2l_fec_dest.is_set || is_set(s2l_fec_dest.yfilter)) leaf_name_data.push_back(s2l_fec_dest.get_name_leafdata());
if (s2l_fec_p2mp_id.is_set || is_set(s2l_fec_p2mp_id.yfilter)) leaf_name_data.push_back(s2l_fec_p2mp_id.get_name_leafdata());
if (s2l_fec_subgroup_originator.is_set || is_set(s2l_fec_subgroup_originator.yfilter)) leaf_name_data.push_back(s2l_fec_subgroup_originator.get_name_leafdata());
if (s2l_fec_ctype.is_set || is_set(s2l_fec_ctype.yfilter)) leaf_name_data.push_back(s2l_fec_ctype.get_name_leafdata());
if (s2l_fec_vrf.is_set || is_set(s2l_fec_vrf.yfilter)) leaf_name_data.push_back(s2l_fec_vrf.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "s2l-fec-subgroup-id")
{
s2l_fec_subgroup_id = value;
s2l_fec_subgroup_id.value_namespace = name_space;
s2l_fec_subgroup_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-fec-lsp-id")
{
s2l_fec_lsp_id = value;
s2l_fec_lsp_id.value_namespace = name_space;
s2l_fec_lsp_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-fec-tunnel-id")
{
s2l_fec_tunnel_id = value;
s2l_fec_tunnel_id.value_namespace = name_space;
s2l_fec_tunnel_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-fec-extended-tunnel-id")
{
s2l_fec_extended_tunnel_id = value;
s2l_fec_extended_tunnel_id.value_namespace = name_space;
s2l_fec_extended_tunnel_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-fec-source")
{
s2l_fec_source = value;
s2l_fec_source.value_namespace = name_space;
s2l_fec_source.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-fec-dest")
{
s2l_fec_dest = value;
s2l_fec_dest.value_namespace = name_space;
s2l_fec_dest.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-fec-p2mp-id")
{
s2l_fec_p2mp_id = value;
s2l_fec_p2mp_id.value_namespace = name_space;
s2l_fec_p2mp_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-fec-subgroup-originator")
{
s2l_fec_subgroup_originator = value;
s2l_fec_subgroup_originator.value_namespace = name_space;
s2l_fec_subgroup_originator.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-fec-ctype")
{
s2l_fec_ctype = value;
s2l_fec_ctype.value_namespace = name_space;
s2l_fec_ctype.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-fec-vrf")
{
s2l_fec_vrf = value;
s2l_fec_vrf.value_namespace = name_space;
s2l_fec_vrf.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "s2l-fec-subgroup-id")
{
s2l_fec_subgroup_id.yfilter = yfilter;
}
if(value_path == "s2l-fec-lsp-id")
{
s2l_fec_lsp_id.yfilter = yfilter;
}
if(value_path == "s2l-fec-tunnel-id")
{
s2l_fec_tunnel_id.yfilter = yfilter;
}
if(value_path == "s2l-fec-extended-tunnel-id")
{
s2l_fec_extended_tunnel_id.yfilter = yfilter;
}
if(value_path == "s2l-fec-source")
{
s2l_fec_source.yfilter = yfilter;
}
if(value_path == "s2l-fec-dest")
{
s2l_fec_dest.yfilter = yfilter;
}
if(value_path == "s2l-fec-p2mp-id")
{
s2l_fec_p2mp_id.yfilter = yfilter;
}
if(value_path == "s2l-fec-subgroup-originator")
{
s2l_fec_subgroup_originator.yfilter = yfilter;
}
if(value_path == "s2l-fec-ctype")
{
s2l_fec_ctype.yfilter = yfilter;
}
if(value_path == "s2l-fec-vrf")
{
s2l_fec_vrf.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "s2l-fec-subgroup-id" || name == "s2l-fec-lsp-id" || name == "s2l-fec-tunnel-id" || name == "s2l-fec-extended-tunnel-id" || name == "s2l-fec-source" || name == "s2l-fec-dest" || name == "s2l-fec-p2mp-id" || name == "s2l-fec-subgroup-originator" || name == "s2l-fec-ctype" || name == "s2l-fec-vrf")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::ActivePathOption()
:
option_index_is_valid{YType::boolean, "option-index-is-valid"},
option_index{YType::uint32, "option-index"},
path_option_name{YType::str, "path-option-name"},
path_option_type{YType::enumeration, "path-option-type"},
explicit_path_name{YType::str, "explicit-path-name"},
explicit_path_id{YType::uint16, "explicit-path-id"},
holddown_duration{YType::uint16, "holddown-duration"},
pce_address{YType::str, "pce-address"},
path_option_area_id{YType::str, "path-option-area-id"},
is_strict_explicit_path{YType::boolean, "is-strict-explicit-path"},
is_helddown{YType::boolean, "is-helddown"},
is_lockdown{YType::boolean, "is-lockdown"},
is_verbatim{YType::boolean, "is-verbatim"},
is_disabled{YType::boolean, "is-disabled"},
has_attribute_set{YType::boolean, "has-attribute-set"},
attribute_set_found{YType::boolean, "attribute-set-found"},
has_xro_attribute_set{YType::boolean, "has-xro-attribute-set"},
xro_attribute_set_found{YType::boolean, "xro-attribute-set-found"},
is_segment_routing{YType::boolean, "is-segment-routing"},
protected_by_path_option_index{YType::uint32, "protected-by-path-option-index"},
restored_from_path_option_index{YType::uint32, "restored-from-path-option-index"}
,
attribute_set(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet>())
, xro_attribute_set(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet>())
, path_calculation_error(this, {})
, remerge_error(this, {})
, signalling_error(this, {})
{
attribute_set->parent = this;
xro_attribute_set->parent = this;
yang_name = "active-path-option"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::~ActivePathOption()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<path_calculation_error.len(); index++)
{
if(path_calculation_error[index]->has_data())
return true;
}
for (std::size_t index=0; index<remerge_error.len(); index++)
{
if(remerge_error[index]->has_data())
return true;
}
for (std::size_t index=0; index<signalling_error.len(); index++)
{
if(signalling_error[index]->has_data())
return true;
}
return option_index_is_valid.is_set
|| option_index.is_set
|| path_option_name.is_set
|| path_option_type.is_set
|| explicit_path_name.is_set
|| explicit_path_id.is_set
|| holddown_duration.is_set
|| pce_address.is_set
|| path_option_area_id.is_set
|| is_strict_explicit_path.is_set
|| is_helddown.is_set
|| is_lockdown.is_set
|| is_verbatim.is_set
|| is_disabled.is_set
|| has_attribute_set.is_set
|| attribute_set_found.is_set
|| has_xro_attribute_set.is_set
|| xro_attribute_set_found.is_set
|| is_segment_routing.is_set
|| protected_by_path_option_index.is_set
|| restored_from_path_option_index.is_set
|| (attribute_set != nullptr && attribute_set->has_data())
|| (xro_attribute_set != nullptr && xro_attribute_set->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::has_operation() const
{
for (std::size_t index=0; index<path_calculation_error.len(); index++)
{
if(path_calculation_error[index]->has_operation())
return true;
}
for (std::size_t index=0; index<remerge_error.len(); index++)
{
if(remerge_error[index]->has_operation())
return true;
}
for (std::size_t index=0; index<signalling_error.len(); index++)
{
if(signalling_error[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(option_index_is_valid.yfilter)
|| ydk::is_set(option_index.yfilter)
|| ydk::is_set(path_option_name.yfilter)
|| ydk::is_set(path_option_type.yfilter)
|| ydk::is_set(explicit_path_name.yfilter)
|| ydk::is_set(explicit_path_id.yfilter)
|| ydk::is_set(holddown_duration.yfilter)
|| ydk::is_set(pce_address.yfilter)
|| ydk::is_set(path_option_area_id.yfilter)
|| ydk::is_set(is_strict_explicit_path.yfilter)
|| ydk::is_set(is_helddown.yfilter)
|| ydk::is_set(is_lockdown.yfilter)
|| ydk::is_set(is_verbatim.yfilter)
|| ydk::is_set(is_disabled.yfilter)
|| ydk::is_set(has_attribute_set.yfilter)
|| ydk::is_set(attribute_set_found.yfilter)
|| ydk::is_set(has_xro_attribute_set.yfilter)
|| ydk::is_set(xro_attribute_set_found.yfilter)
|| ydk::is_set(is_segment_routing.yfilter)
|| ydk::is_set(protected_by_path_option_index.yfilter)
|| ydk::is_set(restored_from_path_option_index.yfilter)
|| (attribute_set != nullptr && attribute_set->has_operation())
|| (xro_attribute_set != nullptr && xro_attribute_set->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "active-path-option";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (option_index_is_valid.is_set || is_set(option_index_is_valid.yfilter)) leaf_name_data.push_back(option_index_is_valid.get_name_leafdata());
if (option_index.is_set || is_set(option_index.yfilter)) leaf_name_data.push_back(option_index.get_name_leafdata());
if (path_option_name.is_set || is_set(path_option_name.yfilter)) leaf_name_data.push_back(path_option_name.get_name_leafdata());
if (path_option_type.is_set || is_set(path_option_type.yfilter)) leaf_name_data.push_back(path_option_type.get_name_leafdata());
if (explicit_path_name.is_set || is_set(explicit_path_name.yfilter)) leaf_name_data.push_back(explicit_path_name.get_name_leafdata());
if (explicit_path_id.is_set || is_set(explicit_path_id.yfilter)) leaf_name_data.push_back(explicit_path_id.get_name_leafdata());
if (holddown_duration.is_set || is_set(holddown_duration.yfilter)) leaf_name_data.push_back(holddown_duration.get_name_leafdata());
if (pce_address.is_set || is_set(pce_address.yfilter)) leaf_name_data.push_back(pce_address.get_name_leafdata());
if (path_option_area_id.is_set || is_set(path_option_area_id.yfilter)) leaf_name_data.push_back(path_option_area_id.get_name_leafdata());
if (is_strict_explicit_path.is_set || is_set(is_strict_explicit_path.yfilter)) leaf_name_data.push_back(is_strict_explicit_path.get_name_leafdata());
if (is_helddown.is_set || is_set(is_helddown.yfilter)) leaf_name_data.push_back(is_helddown.get_name_leafdata());
if (is_lockdown.is_set || is_set(is_lockdown.yfilter)) leaf_name_data.push_back(is_lockdown.get_name_leafdata());
if (is_verbatim.is_set || is_set(is_verbatim.yfilter)) leaf_name_data.push_back(is_verbatim.get_name_leafdata());
if (is_disabled.is_set || is_set(is_disabled.yfilter)) leaf_name_data.push_back(is_disabled.get_name_leafdata());
if (has_attribute_set.is_set || is_set(has_attribute_set.yfilter)) leaf_name_data.push_back(has_attribute_set.get_name_leafdata());
if (attribute_set_found.is_set || is_set(attribute_set_found.yfilter)) leaf_name_data.push_back(attribute_set_found.get_name_leafdata());
if (has_xro_attribute_set.is_set || is_set(has_xro_attribute_set.yfilter)) leaf_name_data.push_back(has_xro_attribute_set.get_name_leafdata());
if (xro_attribute_set_found.is_set || is_set(xro_attribute_set_found.yfilter)) leaf_name_data.push_back(xro_attribute_set_found.get_name_leafdata());
if (is_segment_routing.is_set || is_set(is_segment_routing.yfilter)) leaf_name_data.push_back(is_segment_routing.get_name_leafdata());
if (protected_by_path_option_index.is_set || is_set(protected_by_path_option_index.yfilter)) leaf_name_data.push_back(protected_by_path_option_index.get_name_leafdata());
if (restored_from_path_option_index.is_set || is_set(restored_from_path_option_index.yfilter)) leaf_name_data.push_back(restored_from_path_option_index.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "attribute-set")
{
if(attribute_set == nullptr)
{
attribute_set = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet>();
}
return attribute_set;
}
if(child_yang_name == "xro-attribute-set")
{
if(xro_attribute_set == nullptr)
{
xro_attribute_set = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet>();
}
return xro_attribute_set;
}
if(child_yang_name == "path-calculation-error")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError>();
ent_->parent = this;
path_calculation_error.append(ent_);
return ent_;
}
if(child_yang_name == "remerge-error")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError>();
ent_->parent = this;
remerge_error.append(ent_);
return ent_;
}
if(child_yang_name == "signalling-error")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError>();
ent_->parent = this;
signalling_error.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(attribute_set != nullptr)
{
_children["attribute-set"] = attribute_set;
}
if(xro_attribute_set != nullptr)
{
_children["xro-attribute-set"] = xro_attribute_set;
}
count_ = 0;
for (auto ent_ : path_calculation_error.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : remerge_error.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : signalling_error.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "option-index-is-valid")
{
option_index_is_valid = value;
option_index_is_valid.value_namespace = name_space;
option_index_is_valid.value_namespace_prefix = name_space_prefix;
}
if(value_path == "option-index")
{
option_index = value;
option_index.value_namespace = name_space;
option_index.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-option-name")
{
path_option_name = value;
path_option_name.value_namespace = name_space;
path_option_name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-option-type")
{
path_option_type = value;
path_option_type.value_namespace = name_space;
path_option_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "explicit-path-name")
{
explicit_path_name = value;
explicit_path_name.value_namespace = name_space;
explicit_path_name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "explicit-path-id")
{
explicit_path_id = value;
explicit_path_id.value_namespace = name_space;
explicit_path_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "holddown-duration")
{
holddown_duration = value;
holddown_duration.value_namespace = name_space;
holddown_duration.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pce-address")
{
pce_address = value;
pce_address.value_namespace = name_space;
pce_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-option-area-id")
{
path_option_area_id = value;
path_option_area_id.value_namespace = name_space;
path_option_area_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-strict-explicit-path")
{
is_strict_explicit_path = value;
is_strict_explicit_path.value_namespace = name_space;
is_strict_explicit_path.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-helddown")
{
is_helddown = value;
is_helddown.value_namespace = name_space;
is_helddown.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-lockdown")
{
is_lockdown = value;
is_lockdown.value_namespace = name_space;
is_lockdown.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-verbatim")
{
is_verbatim = value;
is_verbatim.value_namespace = name_space;
is_verbatim.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-disabled")
{
is_disabled = value;
is_disabled.value_namespace = name_space;
is_disabled.value_namespace_prefix = name_space_prefix;
}
if(value_path == "has-attribute-set")
{
has_attribute_set = value;
has_attribute_set.value_namespace = name_space;
has_attribute_set.value_namespace_prefix = name_space_prefix;
}
if(value_path == "attribute-set-found")
{
attribute_set_found = value;
attribute_set_found.value_namespace = name_space;
attribute_set_found.value_namespace_prefix = name_space_prefix;
}
if(value_path == "has-xro-attribute-set")
{
has_xro_attribute_set = value;
has_xro_attribute_set.value_namespace = name_space;
has_xro_attribute_set.value_namespace_prefix = name_space_prefix;
}
if(value_path == "xro-attribute-set-found")
{
xro_attribute_set_found = value;
xro_attribute_set_found.value_namespace = name_space;
xro_attribute_set_found.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-segment-routing")
{
is_segment_routing = value;
is_segment_routing.value_namespace = name_space;
is_segment_routing.value_namespace_prefix = name_space_prefix;
}
if(value_path == "protected-by-path-option-index")
{
protected_by_path_option_index = value;
protected_by_path_option_index.value_namespace = name_space;
protected_by_path_option_index.value_namespace_prefix = name_space_prefix;
}
if(value_path == "restored-from-path-option-index")
{
restored_from_path_option_index = value;
restored_from_path_option_index.value_namespace = name_space;
restored_from_path_option_index.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "option-index-is-valid")
{
option_index_is_valid.yfilter = yfilter;
}
if(value_path == "option-index")
{
option_index.yfilter = yfilter;
}
if(value_path == "path-option-name")
{
path_option_name.yfilter = yfilter;
}
if(value_path == "path-option-type")
{
path_option_type.yfilter = yfilter;
}
if(value_path == "explicit-path-name")
{
explicit_path_name.yfilter = yfilter;
}
if(value_path == "explicit-path-id")
{
explicit_path_id.yfilter = yfilter;
}
if(value_path == "holddown-duration")
{
holddown_duration.yfilter = yfilter;
}
if(value_path == "pce-address")
{
pce_address.yfilter = yfilter;
}
if(value_path == "path-option-area-id")
{
path_option_area_id.yfilter = yfilter;
}
if(value_path == "is-strict-explicit-path")
{
is_strict_explicit_path.yfilter = yfilter;
}
if(value_path == "is-helddown")
{
is_helddown.yfilter = yfilter;
}
if(value_path == "is-lockdown")
{
is_lockdown.yfilter = yfilter;
}
if(value_path == "is-verbatim")
{
is_verbatim.yfilter = yfilter;
}
if(value_path == "is-disabled")
{
is_disabled.yfilter = yfilter;
}
if(value_path == "has-attribute-set")
{
has_attribute_set.yfilter = yfilter;
}
if(value_path == "attribute-set-found")
{
attribute_set_found.yfilter = yfilter;
}
if(value_path == "has-xro-attribute-set")
{
has_xro_attribute_set.yfilter = yfilter;
}
if(value_path == "xro-attribute-set-found")
{
xro_attribute_set_found.yfilter = yfilter;
}
if(value_path == "is-segment-routing")
{
is_segment_routing.yfilter = yfilter;
}
if(value_path == "protected-by-path-option-index")
{
protected_by_path_option_index.yfilter = yfilter;
}
if(value_path == "restored-from-path-option-index")
{
restored_from_path_option_index.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "attribute-set" || name == "xro-attribute-set" || name == "path-calculation-error" || name == "remerge-error" || name == "signalling-error" || name == "option-index-is-valid" || name == "option-index" || name == "path-option-name" || name == "path-option-type" || name == "explicit-path-name" || name == "explicit-path-id" || name == "holddown-duration" || name == "pce-address" || name == "path-option-area-id" || name == "is-strict-explicit-path" || name == "is-helddown" || name == "is-lockdown" || name == "is-verbatim" || name == "is-disabled" || name == "has-attribute-set" || name == "attribute-set-found" || name == "has-xro-attribute-set" || name == "xro-attribute-set-found" || name == "is-segment-routing" || name == "protected-by-path-option-index" || name == "restored-from-path-option-index")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSet()
:
tunnel_attribute_set_name{YType::str, "tunnel-attribute-set-name"},
tunnel_attribute_set_name_crc32{YType::uint32, "tunnel-attribute-set-name-crc32"}
,
attribute_set_union(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion>())
{
attribute_set_union->parent = this;
yang_name = "attribute-set"; yang_parent_name = "active-path-option"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::~AttributeSet()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::has_data() const
{
if (is_presence_container) return true;
return tunnel_attribute_set_name.is_set
|| tunnel_attribute_set_name_crc32.is_set
|| (attribute_set_union != nullptr && attribute_set_union->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(tunnel_attribute_set_name.yfilter)
|| ydk::is_set(tunnel_attribute_set_name_crc32.yfilter)
|| (attribute_set_union != nullptr && attribute_set_union->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (tunnel_attribute_set_name.is_set || is_set(tunnel_attribute_set_name.yfilter)) leaf_name_data.push_back(tunnel_attribute_set_name.get_name_leafdata());
if (tunnel_attribute_set_name_crc32.is_set || is_set(tunnel_attribute_set_name_crc32.yfilter)) leaf_name_data.push_back(tunnel_attribute_set_name_crc32.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "attribute-set-union")
{
if(attribute_set_union == nullptr)
{
attribute_set_union = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion>();
}
return attribute_set_union;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(attribute_set_union != nullptr)
{
_children["attribute-set-union"] = attribute_set_union;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "tunnel-attribute-set-name")
{
tunnel_attribute_set_name = value;
tunnel_attribute_set_name.value_namespace = name_space;
tunnel_attribute_set_name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "tunnel-attribute-set-name-crc32")
{
tunnel_attribute_set_name_crc32 = value;
tunnel_attribute_set_name_crc32.value_namespace = name_space;
tunnel_attribute_set_name_crc32.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "tunnel-attribute-set-name")
{
tunnel_attribute_set_name.yfilter = yfilter;
}
if(value_path == "tunnel-attribute-set-name-crc32")
{
tunnel_attribute_set_name_crc32.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "attribute-set-union" || name == "tunnel-attribute-set-name" || name == "tunnel-attribute-set-name-crc32")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetUnion()
:
tunnel_attribute_set_type{YType::enumeration, "tunnel-attribute-set-type"}
,
attribute_set_path_option(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption>())
, attribute_set_autobackup(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup>())
, attribute_set_automesh(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh>())
, attribute_set_xro(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro>())
, attribute_set_p2mpte(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte>())
, attribute_set_aps_pp(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp>())
, attribute_set_p2p_te(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe>())
{
attribute_set_path_option->parent = this;
attribute_set_autobackup->parent = this;
attribute_set_automesh->parent = this;
attribute_set_xro->parent = this;
attribute_set_p2mpte->parent = this;
attribute_set_aps_pp->parent = this;
attribute_set_p2p_te->parent = this;
yang_name = "attribute-set-union"; yang_parent_name = "attribute-set"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::~AttributeSetUnion()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::has_data() const
{
if (is_presence_container) return true;
return tunnel_attribute_set_type.is_set
|| (attribute_set_path_option != nullptr && attribute_set_path_option->has_data())
|| (attribute_set_autobackup != nullptr && attribute_set_autobackup->has_data())
|| (attribute_set_automesh != nullptr && attribute_set_automesh->has_data())
|| (attribute_set_xro != nullptr && attribute_set_xro->has_data())
|| (attribute_set_p2mpte != nullptr && attribute_set_p2mpte->has_data())
|| (attribute_set_aps_pp != nullptr && attribute_set_aps_pp->has_data())
|| (attribute_set_p2p_te != nullptr && attribute_set_p2p_te->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(tunnel_attribute_set_type.yfilter)
|| (attribute_set_path_option != nullptr && attribute_set_path_option->has_operation())
|| (attribute_set_autobackup != nullptr && attribute_set_autobackup->has_operation())
|| (attribute_set_automesh != nullptr && attribute_set_automesh->has_operation())
|| (attribute_set_xro != nullptr && attribute_set_xro->has_operation())
|| (attribute_set_p2mpte != nullptr && attribute_set_p2mpte->has_operation())
|| (attribute_set_aps_pp != nullptr && attribute_set_aps_pp->has_operation())
|| (attribute_set_p2p_te != nullptr && attribute_set_p2p_te->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-union";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (tunnel_attribute_set_type.is_set || is_set(tunnel_attribute_set_type.yfilter)) leaf_name_data.push_back(tunnel_attribute_set_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "attribute-set-path-option")
{
if(attribute_set_path_option == nullptr)
{
attribute_set_path_option = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption>();
}
return attribute_set_path_option;
}
if(child_yang_name == "attribute-set-autobackup")
{
if(attribute_set_autobackup == nullptr)
{
attribute_set_autobackup = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup>();
}
return attribute_set_autobackup;
}
if(child_yang_name == "attribute-set-automesh")
{
if(attribute_set_automesh == nullptr)
{
attribute_set_automesh = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh>();
}
return attribute_set_automesh;
}
if(child_yang_name == "attribute-set-xro")
{
if(attribute_set_xro == nullptr)
{
attribute_set_xro = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro>();
}
return attribute_set_xro;
}
if(child_yang_name == "attribute-set-p2mpte")
{
if(attribute_set_p2mpte == nullptr)
{
attribute_set_p2mpte = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte>();
}
return attribute_set_p2mpte;
}
if(child_yang_name == "attribute-set-aps-pp")
{
if(attribute_set_aps_pp == nullptr)
{
attribute_set_aps_pp = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp>();
}
return attribute_set_aps_pp;
}
if(child_yang_name == "attribute-set-p2p-te")
{
if(attribute_set_p2p_te == nullptr)
{
attribute_set_p2p_te = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe>();
}
return attribute_set_p2p_te;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(attribute_set_path_option != nullptr)
{
_children["attribute-set-path-option"] = attribute_set_path_option;
}
if(attribute_set_autobackup != nullptr)
{
_children["attribute-set-autobackup"] = attribute_set_autobackup;
}
if(attribute_set_automesh != nullptr)
{
_children["attribute-set-automesh"] = attribute_set_automesh;
}
if(attribute_set_xro != nullptr)
{
_children["attribute-set-xro"] = attribute_set_xro;
}
if(attribute_set_p2mpte != nullptr)
{
_children["attribute-set-p2mpte"] = attribute_set_p2mpte;
}
if(attribute_set_aps_pp != nullptr)
{
_children["attribute-set-aps-pp"] = attribute_set_aps_pp;
}
if(attribute_set_p2p_te != nullptr)
{
_children["attribute-set-p2p-te"] = attribute_set_p2p_te;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "tunnel-attribute-set-type")
{
tunnel_attribute_set_type = value;
tunnel_attribute_set_type.value_namespace = name_space;
tunnel_attribute_set_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "tunnel-attribute-set-type")
{
tunnel_attribute_set_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "attribute-set-path-option" || name == "attribute-set-autobackup" || name == "attribute-set-automesh" || name == "attribute-set-xro" || name == "attribute-set-p2mpte" || name == "attribute-set-aps-pp" || name == "attribute-set-p2p-te" || name == "tunnel-attribute-set-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::AttributeSetPathOption()
:
configured_bandwidth{YType::uint32, "configured-bandwidth"},
cost_limit{YType::uint32, "cost-limit"},
dste_class_type{YType::uint8, "dste-class-type"},
bandwidth_type{YType::enumeration, "bandwidth-type"},
is_bandwidth_configured{YType::boolean, "is-bandwidth-configured"},
is_cost_limit_configured{YType::boolean, "is-cost-limit-configured"},
is_affinity_configured{YType::boolean, "is-affinity-configured"},
generation{YType::uint32, "generation"},
path_invalidation_timeout{YType::uint32, "path-invalidation-timeout"},
path_invalidation_action{YType::uint32, "path-invalidation-action"},
is_path_invalidation_timeout_configured{YType::boolean, "is-path-invalidation-timeout-configured"},
is_path_invalidation_action_configured{YType::boolean, "is-path-invalidation-action-configured"},
exclude_list_name{YType::str, "exclude-list-name"},
is_exclude_list_name_configured{YType::boolean, "is-exclude-list-name-configured"},
is_pce_configured{YType::boolean, "is-pce-configured"},
is_pce_disj_source_configured{YType::boolean, "is-pce-disj-source-configured"},
is_pce_disj_type_configured{YType::boolean, "is-pce-disj-type-configured"},
is_pce_disj_group_id_configured{YType::boolean, "is-pce-disj-group-id-configured"},
pcedp_source_address{YType::uint32, "pcedp-source-address"},
pcedp_type{YType::enumeration, "pcedp-type"},
pcedp_group_id{YType::uint32, "pcedp-group-id"},
is_pceb_dj_source_configured{YType::boolean, "is-pceb-dj-source-configured"},
is_pcebd_group_id_configured{YType::boolean, "is-pcebd-group-id-configured"},
pcebd_source_address{YType::uint32, "pcebd-source-address"},
pcebd_group_id{YType::uint32, "pcebd-group-id"},
is_bfd_reverse_pat_configured{YType::boolean, "is-bfd-reverse-pat-configured"},
is_delay_limit_configured{YType::boolean, "is-delay-limit-configured"},
delay_limit{YType::uint32, "delay-limit"}
,
affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity>())
, bfd_reverse_path(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath>())
, tunnel_id(this, {})
, version_info(this, {})
{
affinity->parent = this;
bfd_reverse_path->parent = this;
yang_name = "attribute-set-path-option"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::~AttributeSetPathOption()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_data())
return true;
}
for (std::size_t index=0; index<version_info.len(); index++)
{
if(version_info[index]->has_data())
return true;
}
return configured_bandwidth.is_set
|| cost_limit.is_set
|| dste_class_type.is_set
|| bandwidth_type.is_set
|| is_bandwidth_configured.is_set
|| is_cost_limit_configured.is_set
|| is_affinity_configured.is_set
|| generation.is_set
|| path_invalidation_timeout.is_set
|| path_invalidation_action.is_set
|| is_path_invalidation_timeout_configured.is_set
|| is_path_invalidation_action_configured.is_set
|| exclude_list_name.is_set
|| is_exclude_list_name_configured.is_set
|| is_pce_configured.is_set
|| is_pce_disj_source_configured.is_set
|| is_pce_disj_type_configured.is_set
|| is_pce_disj_group_id_configured.is_set
|| pcedp_source_address.is_set
|| pcedp_type.is_set
|| pcedp_group_id.is_set
|| is_pceb_dj_source_configured.is_set
|| is_pcebd_group_id_configured.is_set
|| pcebd_source_address.is_set
|| pcebd_group_id.is_set
|| is_bfd_reverse_pat_configured.is_set
|| is_delay_limit_configured.is_set
|| delay_limit.is_set
|| (affinity != nullptr && affinity->has_data())
|| (bfd_reverse_path != nullptr && bfd_reverse_path->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::has_operation() const
{
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_operation())
return true;
}
for (std::size_t index=0; index<version_info.len(); index++)
{
if(version_info[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(configured_bandwidth.yfilter)
|| ydk::is_set(cost_limit.yfilter)
|| ydk::is_set(dste_class_type.yfilter)
|| ydk::is_set(bandwidth_type.yfilter)
|| ydk::is_set(is_bandwidth_configured.yfilter)
|| ydk::is_set(is_cost_limit_configured.yfilter)
|| ydk::is_set(is_affinity_configured.yfilter)
|| ydk::is_set(generation.yfilter)
|| ydk::is_set(path_invalidation_timeout.yfilter)
|| ydk::is_set(path_invalidation_action.yfilter)
|| ydk::is_set(is_path_invalidation_timeout_configured.yfilter)
|| ydk::is_set(is_path_invalidation_action_configured.yfilter)
|| ydk::is_set(exclude_list_name.yfilter)
|| ydk::is_set(is_exclude_list_name_configured.yfilter)
|| ydk::is_set(is_pce_configured.yfilter)
|| ydk::is_set(is_pce_disj_source_configured.yfilter)
|| ydk::is_set(is_pce_disj_type_configured.yfilter)
|| ydk::is_set(is_pce_disj_group_id_configured.yfilter)
|| ydk::is_set(pcedp_source_address.yfilter)
|| ydk::is_set(pcedp_type.yfilter)
|| ydk::is_set(pcedp_group_id.yfilter)
|| ydk::is_set(is_pceb_dj_source_configured.yfilter)
|| ydk::is_set(is_pcebd_group_id_configured.yfilter)
|| ydk::is_set(pcebd_source_address.yfilter)
|| ydk::is_set(pcebd_group_id.yfilter)
|| ydk::is_set(is_bfd_reverse_pat_configured.yfilter)
|| ydk::is_set(is_delay_limit_configured.yfilter)
|| ydk::is_set(delay_limit.yfilter)
|| (affinity != nullptr && affinity->has_operation())
|| (bfd_reverse_path != nullptr && bfd_reverse_path->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-path-option";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (configured_bandwidth.is_set || is_set(configured_bandwidth.yfilter)) leaf_name_data.push_back(configured_bandwidth.get_name_leafdata());
if (cost_limit.is_set || is_set(cost_limit.yfilter)) leaf_name_data.push_back(cost_limit.get_name_leafdata());
if (dste_class_type.is_set || is_set(dste_class_type.yfilter)) leaf_name_data.push_back(dste_class_type.get_name_leafdata());
if (bandwidth_type.is_set || is_set(bandwidth_type.yfilter)) leaf_name_data.push_back(bandwidth_type.get_name_leafdata());
if (is_bandwidth_configured.is_set || is_set(is_bandwidth_configured.yfilter)) leaf_name_data.push_back(is_bandwidth_configured.get_name_leafdata());
if (is_cost_limit_configured.is_set || is_set(is_cost_limit_configured.yfilter)) leaf_name_data.push_back(is_cost_limit_configured.get_name_leafdata());
if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata());
if (generation.is_set || is_set(generation.yfilter)) leaf_name_data.push_back(generation.get_name_leafdata());
if (path_invalidation_timeout.is_set || is_set(path_invalidation_timeout.yfilter)) leaf_name_data.push_back(path_invalidation_timeout.get_name_leafdata());
if (path_invalidation_action.is_set || is_set(path_invalidation_action.yfilter)) leaf_name_data.push_back(path_invalidation_action.get_name_leafdata());
if (is_path_invalidation_timeout_configured.is_set || is_set(is_path_invalidation_timeout_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_timeout_configured.get_name_leafdata());
if (is_path_invalidation_action_configured.is_set || is_set(is_path_invalidation_action_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_action_configured.get_name_leafdata());
if (exclude_list_name.is_set || is_set(exclude_list_name.yfilter)) leaf_name_data.push_back(exclude_list_name.get_name_leafdata());
if (is_exclude_list_name_configured.is_set || is_set(is_exclude_list_name_configured.yfilter)) leaf_name_data.push_back(is_exclude_list_name_configured.get_name_leafdata());
if (is_pce_configured.is_set || is_set(is_pce_configured.yfilter)) leaf_name_data.push_back(is_pce_configured.get_name_leafdata());
if (is_pce_disj_source_configured.is_set || is_set(is_pce_disj_source_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_source_configured.get_name_leafdata());
if (is_pce_disj_type_configured.is_set || is_set(is_pce_disj_type_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_type_configured.get_name_leafdata());
if (is_pce_disj_group_id_configured.is_set || is_set(is_pce_disj_group_id_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_group_id_configured.get_name_leafdata());
if (pcedp_source_address.is_set || is_set(pcedp_source_address.yfilter)) leaf_name_data.push_back(pcedp_source_address.get_name_leafdata());
if (pcedp_type.is_set || is_set(pcedp_type.yfilter)) leaf_name_data.push_back(pcedp_type.get_name_leafdata());
if (pcedp_group_id.is_set || is_set(pcedp_group_id.yfilter)) leaf_name_data.push_back(pcedp_group_id.get_name_leafdata());
if (is_pceb_dj_source_configured.is_set || is_set(is_pceb_dj_source_configured.yfilter)) leaf_name_data.push_back(is_pceb_dj_source_configured.get_name_leafdata());
if (is_pcebd_group_id_configured.is_set || is_set(is_pcebd_group_id_configured.yfilter)) leaf_name_data.push_back(is_pcebd_group_id_configured.get_name_leafdata());
if (pcebd_source_address.is_set || is_set(pcebd_source_address.yfilter)) leaf_name_data.push_back(pcebd_source_address.get_name_leafdata());
if (pcebd_group_id.is_set || is_set(pcebd_group_id.yfilter)) leaf_name_data.push_back(pcebd_group_id.get_name_leafdata());
if (is_bfd_reverse_pat_configured.is_set || is_set(is_bfd_reverse_pat_configured.yfilter)) leaf_name_data.push_back(is_bfd_reverse_pat_configured.get_name_leafdata());
if (is_delay_limit_configured.is_set || is_set(is_delay_limit_configured.yfilter)) leaf_name_data.push_back(is_delay_limit_configured.get_name_leafdata());
if (delay_limit.is_set || is_set(delay_limit.yfilter)) leaf_name_data.push_back(delay_limit.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "affinity")
{
if(affinity == nullptr)
{
affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity>();
}
return affinity;
}
if(child_yang_name == "bfd-reverse-path")
{
if(bfd_reverse_path == nullptr)
{
bfd_reverse_path = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath>();
}
return bfd_reverse_path;
}
if(child_yang_name == "tunnel-id")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId>();
ent_->parent = this;
tunnel_id.append(ent_);
return ent_;
}
if(child_yang_name == "version-info")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo>();
ent_->parent = this;
version_info.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(affinity != nullptr)
{
_children["affinity"] = affinity;
}
if(bfd_reverse_path != nullptr)
{
_children["bfd-reverse-path"] = bfd_reverse_path;
}
count_ = 0;
for (auto ent_ : tunnel_id.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : version_info.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "configured-bandwidth")
{
configured_bandwidth = value;
configured_bandwidth.value_namespace = name_space;
configured_bandwidth.value_namespace_prefix = name_space_prefix;
}
if(value_path == "cost-limit")
{
cost_limit = value;
cost_limit.value_namespace = name_space;
cost_limit.value_namespace_prefix = name_space_prefix;
}
if(value_path == "dste-class-type")
{
dste_class_type = value;
dste_class_type.value_namespace = name_space;
dste_class_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "bandwidth-type")
{
bandwidth_type = value;
bandwidth_type.value_namespace = name_space;
bandwidth_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-bandwidth-configured")
{
is_bandwidth_configured = value;
is_bandwidth_configured.value_namespace = name_space;
is_bandwidth_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-cost-limit-configured")
{
is_cost_limit_configured = value;
is_cost_limit_configured.value_namespace = name_space;
is_cost_limit_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured = value;
is_affinity_configured.value_namespace = name_space;
is_affinity_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "generation")
{
generation = value;
generation.value_namespace = name_space;
generation.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-invalidation-timeout")
{
path_invalidation_timeout = value;
path_invalidation_timeout.value_namespace = name_space;
path_invalidation_timeout.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-invalidation-action")
{
path_invalidation_action = value;
path_invalidation_action.value_namespace = name_space;
path_invalidation_action.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-invalidation-timeout-configured")
{
is_path_invalidation_timeout_configured = value;
is_path_invalidation_timeout_configured.value_namespace = name_space;
is_path_invalidation_timeout_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-invalidation-action-configured")
{
is_path_invalidation_action_configured = value;
is_path_invalidation_action_configured.value_namespace = name_space;
is_path_invalidation_action_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclude-list-name")
{
exclude_list_name = value;
exclude_list_name.value_namespace = name_space;
exclude_list_name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-exclude-list-name-configured")
{
is_exclude_list_name_configured = value;
is_exclude_list_name_configured.value_namespace = name_space;
is_exclude_list_name_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-configured")
{
is_pce_configured = value;
is_pce_configured.value_namespace = name_space;
is_pce_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-disj-source-configured")
{
is_pce_disj_source_configured = value;
is_pce_disj_source_configured.value_namespace = name_space;
is_pce_disj_source_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-disj-type-configured")
{
is_pce_disj_type_configured = value;
is_pce_disj_type_configured.value_namespace = name_space;
is_pce_disj_type_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-disj-group-id-configured")
{
is_pce_disj_group_id_configured = value;
is_pce_disj_group_id_configured.value_namespace = name_space;
is_pce_disj_group_id_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcedp-source-address")
{
pcedp_source_address = value;
pcedp_source_address.value_namespace = name_space;
pcedp_source_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcedp-type")
{
pcedp_type = value;
pcedp_type.value_namespace = name_space;
pcedp_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcedp-group-id")
{
pcedp_group_id = value;
pcedp_group_id.value_namespace = name_space;
pcedp_group_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pceb-dj-source-configured")
{
is_pceb_dj_source_configured = value;
is_pceb_dj_source_configured.value_namespace = name_space;
is_pceb_dj_source_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pcebd-group-id-configured")
{
is_pcebd_group_id_configured = value;
is_pcebd_group_id_configured.value_namespace = name_space;
is_pcebd_group_id_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcebd-source-address")
{
pcebd_source_address = value;
pcebd_source_address.value_namespace = name_space;
pcebd_source_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcebd-group-id")
{
pcebd_group_id = value;
pcebd_group_id.value_namespace = name_space;
pcebd_group_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-bfd-reverse-pat-configured")
{
is_bfd_reverse_pat_configured = value;
is_bfd_reverse_pat_configured.value_namespace = name_space;
is_bfd_reverse_pat_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-delay-limit-configured")
{
is_delay_limit_configured = value;
is_delay_limit_configured.value_namespace = name_space;
is_delay_limit_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "delay-limit")
{
delay_limit = value;
delay_limit.value_namespace = name_space;
delay_limit.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "configured-bandwidth")
{
configured_bandwidth.yfilter = yfilter;
}
if(value_path == "cost-limit")
{
cost_limit.yfilter = yfilter;
}
if(value_path == "dste-class-type")
{
dste_class_type.yfilter = yfilter;
}
if(value_path == "bandwidth-type")
{
bandwidth_type.yfilter = yfilter;
}
if(value_path == "is-bandwidth-configured")
{
is_bandwidth_configured.yfilter = yfilter;
}
if(value_path == "is-cost-limit-configured")
{
is_cost_limit_configured.yfilter = yfilter;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured.yfilter = yfilter;
}
if(value_path == "generation")
{
generation.yfilter = yfilter;
}
if(value_path == "path-invalidation-timeout")
{
path_invalidation_timeout.yfilter = yfilter;
}
if(value_path == "path-invalidation-action")
{
path_invalidation_action.yfilter = yfilter;
}
if(value_path == "is-path-invalidation-timeout-configured")
{
is_path_invalidation_timeout_configured.yfilter = yfilter;
}
if(value_path == "is-path-invalidation-action-configured")
{
is_path_invalidation_action_configured.yfilter = yfilter;
}
if(value_path == "exclude-list-name")
{
exclude_list_name.yfilter = yfilter;
}
if(value_path == "is-exclude-list-name-configured")
{
is_exclude_list_name_configured.yfilter = yfilter;
}
if(value_path == "is-pce-configured")
{
is_pce_configured.yfilter = yfilter;
}
if(value_path == "is-pce-disj-source-configured")
{
is_pce_disj_source_configured.yfilter = yfilter;
}
if(value_path == "is-pce-disj-type-configured")
{
is_pce_disj_type_configured.yfilter = yfilter;
}
if(value_path == "is-pce-disj-group-id-configured")
{
is_pce_disj_group_id_configured.yfilter = yfilter;
}
if(value_path == "pcedp-source-address")
{
pcedp_source_address.yfilter = yfilter;
}
if(value_path == "pcedp-type")
{
pcedp_type.yfilter = yfilter;
}
if(value_path == "pcedp-group-id")
{
pcedp_group_id.yfilter = yfilter;
}
if(value_path == "is-pceb-dj-source-configured")
{
is_pceb_dj_source_configured.yfilter = yfilter;
}
if(value_path == "is-pcebd-group-id-configured")
{
is_pcebd_group_id_configured.yfilter = yfilter;
}
if(value_path == "pcebd-source-address")
{
pcebd_source_address.yfilter = yfilter;
}
if(value_path == "pcebd-group-id")
{
pcebd_group_id.yfilter = yfilter;
}
if(value_path == "is-bfd-reverse-pat-configured")
{
is_bfd_reverse_pat_configured.yfilter = yfilter;
}
if(value_path == "is-delay-limit-configured")
{
is_delay_limit_configured.yfilter = yfilter;
}
if(value_path == "delay-limit")
{
delay_limit.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "affinity" || name == "bfd-reverse-path" || name == "tunnel-id" || name == "version-info" || name == "configured-bandwidth" || name == "cost-limit" || name == "dste-class-type" || name == "bandwidth-type" || name == "is-bandwidth-configured" || name == "is-cost-limit-configured" || name == "is-affinity-configured" || name == "generation" || name == "path-invalidation-timeout" || name == "path-invalidation-action" || name == "is-path-invalidation-timeout-configured" || name == "is-path-invalidation-action-configured" || name == "exclude-list-name" || name == "is-exclude-list-name-configured" || name == "is-pce-configured" || name == "is-pce-disj-source-configured" || name == "is-pce-disj-type-configured" || name == "is-pce-disj-group-id-configured" || name == "pcedp-source-address" || name == "pcedp-type" || name == "pcedp-group-id" || name == "is-pceb-dj-source-configured" || name == "is-pcebd-group-id-configured" || name == "pcebd-source-address" || name == "pcebd-group-id" || name == "is-bfd-reverse-pat-configured" || name == "is-delay-limit-configured" || name == "delay-limit")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::Affinity()
:
affinity_bits{YType::uint32, "affinity-bits"},
affinity_mask{YType::uint32, "affinity-mask"}
,
named_affinity(this, {})
{
yang_name = "affinity"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::~Affinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_data())
return true;
}
return affinity_bits.is_set
|| affinity_mask.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::has_operation() const
{
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(affinity_bits.yfilter)
|| ydk::is_set(affinity_mask.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "affinity";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata());
if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "named-affinity")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity>();
ent_->parent = this;
named_affinity.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : named_affinity.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "affinity-bits")
{
affinity_bits = value;
affinity_bits.value_namespace = name_space;
affinity_bits.value_namespace_prefix = name_space_prefix;
}
if(value_path == "affinity-mask")
{
affinity_mask = value;
affinity_mask.value_namespace = name_space;
affinity_mask.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "affinity-bits")
{
affinity_bits.yfilter = yfilter;
}
if(value_path == "affinity-mask")
{
affinity_mask.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::NamedAffinity()
:
constraint_type{YType::uint8, "constraint-type"},
constraint_value{YType::uint32, "constraint-value"},
forward_ref_value{YType::uint32, "forward-ref-value"}
,
constraint_extended_value(this, {})
, extended_forward_ref_value(this, {})
{
yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::~NamedAffinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_data())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_data())
return true;
}
return constraint_type.is_set
|| constraint_value.is_set
|| forward_ref_value.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::has_operation() const
{
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_operation())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(constraint_type.yfilter)
|| ydk::is_set(constraint_value.yfilter)
|| ydk::is_set(forward_ref_value.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "named-affinity";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata());
if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata());
if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "constraint-extended-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue>();
ent_->parent = this;
constraint_extended_value.append(ent_);
return ent_;
}
if(child_yang_name == "extended-forward-ref-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue>();
ent_->parent = this;
extended_forward_ref_value.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : constraint_extended_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : extended_forward_ref_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "constraint-type")
{
constraint_type = value;
constraint_type.value_namespace = name_space;
constraint_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "constraint-value")
{
constraint_value = value;
constraint_value.value_namespace = name_space;
constraint_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "forward-ref-value")
{
forward_ref_value = value;
forward_ref_value.value_namespace = name_space;
forward_ref_value.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "constraint-type")
{
constraint_type.yfilter = yfilter;
}
if(value_path == "constraint-value")
{
constraint_value.yfilter = yfilter;
}
if(value_path == "forward-ref-value")
{
forward_ref_value.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "constraint-extended-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "extended-forward-ref-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::BfdReversePath()
:
path_type{YType::enumeration, "path-type"},
binding_label{YType::uint32, "binding-label"}
{
yang_name = "bfd-reverse-path"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::~BfdReversePath()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::has_data() const
{
if (is_presence_container) return true;
return path_type.is_set
|| binding_label.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(path_type.yfilter)
|| ydk::is_set(binding_label.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "bfd-reverse-path";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (path_type.is_set || is_set(path_type.yfilter)) leaf_name_data.push_back(path_type.get_name_leafdata());
if (binding_label.is_set || is_set(binding_label.yfilter)) leaf_name_data.push_back(binding_label.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "path-type")
{
path_type = value;
path_type.value_namespace = name_space;
path_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "binding-label")
{
binding_label = value;
binding_label.value_namespace = name_space;
binding_label.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "path-type")
{
path_type.yfilter = yfilter;
}
if(value_path == "binding-label")
{
binding_label.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "path-type" || name == "binding-label")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::TunnelId()
:
entry{YType::uint16, "entry"}
{
yang_name = "tunnel-id"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::~TunnelId()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tunnel-id";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::VersionInfo()
:
attribute_type{YType::str, "attribute-type"},
generation{YType::uint32, "generation"},
is_default{YType::boolean, "is-default"}
{
yang_name = "version-info"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::~VersionInfo()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::has_data() const
{
if (is_presence_container) return true;
return attribute_type.is_set
|| generation.is_set
|| is_default.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(attribute_type.yfilter)
|| ydk::is_set(generation.yfilter)
|| ydk::is_set(is_default.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "version-info";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (attribute_type.is_set || is_set(attribute_type.yfilter)) leaf_name_data.push_back(attribute_type.get_name_leafdata());
if (generation.is_set || is_set(generation.yfilter)) leaf_name_data.push_back(generation.get_name_leafdata());
if (is_default.is_set || is_set(is_default.yfilter)) leaf_name_data.push_back(is_default.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "attribute-type")
{
attribute_type = value;
attribute_type.value_namespace = name_space;
attribute_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "generation")
{
generation = value;
generation.value_namespace = name_space;
generation.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-default")
{
is_default = value;
is_default.value_namespace = name_space;
is_default.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "attribute-type")
{
attribute_type.yfilter = yfilter;
}
if(value_path == "generation")
{
generation.yfilter = yfilter;
}
if(value_path == "is-default")
{
is_default.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "attribute-type" || name == "generation" || name == "is-default")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::AttributeSetAutobackup()
:
is_signalled_name_configured{YType::boolean, "is-signalled-name-configured"},
setup_priority{YType::uint8, "setup-priority"},
hold_priority{YType::uint8, "hold-priority"},
is_priority_configured{YType::boolean, "is-priority-configured"},
policy_class{YType::uint8, "policy-class"},
is_policyclass_configured{YType::boolean, "is-policyclass-configured"},
is_affinity_configured{YType::boolean, "is-affinity-configured"},
record_route{YType::boolean, "record-route"}
,
signalled_name(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName>())
, affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity>())
, logging(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging>())
, policy_class_entry(this, {})
, tunnel_id(this, {})
, protected_interface(this, {})
{
signalled_name->parent = this;
affinity->parent = this;
logging->parent = this;
yang_name = "attribute-set-autobackup"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::~AttributeSetAutobackup()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<policy_class_entry.len(); index++)
{
if(policy_class_entry[index]->has_data())
return true;
}
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_data())
return true;
}
for (std::size_t index=0; index<protected_interface.len(); index++)
{
if(protected_interface[index]->has_data())
return true;
}
return is_signalled_name_configured.is_set
|| setup_priority.is_set
|| hold_priority.is_set
|| is_priority_configured.is_set
|| policy_class.is_set
|| is_policyclass_configured.is_set
|| is_affinity_configured.is_set
|| record_route.is_set
|| (signalled_name != nullptr && signalled_name->has_data())
|| (affinity != nullptr && affinity->has_data())
|| (logging != nullptr && logging->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::has_operation() const
{
for (std::size_t index=0; index<policy_class_entry.len(); index++)
{
if(policy_class_entry[index]->has_operation())
return true;
}
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_operation())
return true;
}
for (std::size_t index=0; index<protected_interface.len(); index++)
{
if(protected_interface[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(is_signalled_name_configured.yfilter)
|| ydk::is_set(setup_priority.yfilter)
|| ydk::is_set(hold_priority.yfilter)
|| ydk::is_set(is_priority_configured.yfilter)
|| ydk::is_set(policy_class.yfilter)
|| ydk::is_set(is_policyclass_configured.yfilter)
|| ydk::is_set(is_affinity_configured.yfilter)
|| ydk::is_set(record_route.yfilter)
|| (signalled_name != nullptr && signalled_name->has_operation())
|| (affinity != nullptr && affinity->has_operation())
|| (logging != nullptr && logging->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-autobackup";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (is_signalled_name_configured.is_set || is_set(is_signalled_name_configured.yfilter)) leaf_name_data.push_back(is_signalled_name_configured.get_name_leafdata());
if (setup_priority.is_set || is_set(setup_priority.yfilter)) leaf_name_data.push_back(setup_priority.get_name_leafdata());
if (hold_priority.is_set || is_set(hold_priority.yfilter)) leaf_name_data.push_back(hold_priority.get_name_leafdata());
if (is_priority_configured.is_set || is_set(is_priority_configured.yfilter)) leaf_name_data.push_back(is_priority_configured.get_name_leafdata());
if (policy_class.is_set || is_set(policy_class.yfilter)) leaf_name_data.push_back(policy_class.get_name_leafdata());
if (is_policyclass_configured.is_set || is_set(is_policyclass_configured.yfilter)) leaf_name_data.push_back(is_policyclass_configured.get_name_leafdata());
if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata());
if (record_route.is_set || is_set(record_route.yfilter)) leaf_name_data.push_back(record_route.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "signalled-name")
{
if(signalled_name == nullptr)
{
signalled_name = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName>();
}
return signalled_name;
}
if(child_yang_name == "affinity")
{
if(affinity == nullptr)
{
affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity>();
}
return affinity;
}
if(child_yang_name == "logging")
{
if(logging == nullptr)
{
logging = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging>();
}
return logging;
}
if(child_yang_name == "policy-class-entry")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry>();
ent_->parent = this;
policy_class_entry.append(ent_);
return ent_;
}
if(child_yang_name == "tunnel-id")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId>();
ent_->parent = this;
tunnel_id.append(ent_);
return ent_;
}
if(child_yang_name == "protected-interface")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface>();
ent_->parent = this;
protected_interface.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(signalled_name != nullptr)
{
_children["signalled-name"] = signalled_name;
}
if(affinity != nullptr)
{
_children["affinity"] = affinity;
}
if(logging != nullptr)
{
_children["logging"] = logging;
}
count_ = 0;
for (auto ent_ : policy_class_entry.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : tunnel_id.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : protected_interface.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "is-signalled-name-configured")
{
is_signalled_name_configured = value;
is_signalled_name_configured.value_namespace = name_space;
is_signalled_name_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "setup-priority")
{
setup_priority = value;
setup_priority.value_namespace = name_space;
setup_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "hold-priority")
{
hold_priority = value;
hold_priority.value_namespace = name_space;
hold_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-priority-configured")
{
is_priority_configured = value;
is_priority_configured.value_namespace = name_space;
is_priority_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "policy-class")
{
policy_class = value;
policy_class.value_namespace = name_space;
policy_class.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-policyclass-configured")
{
is_policyclass_configured = value;
is_policyclass_configured.value_namespace = name_space;
is_policyclass_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured = value;
is_affinity_configured.value_namespace = name_space;
is_affinity_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "record-route")
{
record_route = value;
record_route.value_namespace = name_space;
record_route.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "is-signalled-name-configured")
{
is_signalled_name_configured.yfilter = yfilter;
}
if(value_path == "setup-priority")
{
setup_priority.yfilter = yfilter;
}
if(value_path == "hold-priority")
{
hold_priority.yfilter = yfilter;
}
if(value_path == "is-priority-configured")
{
is_priority_configured.yfilter = yfilter;
}
if(value_path == "policy-class")
{
policy_class.yfilter = yfilter;
}
if(value_path == "is-policyclass-configured")
{
is_policyclass_configured.yfilter = yfilter;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured.yfilter = yfilter;
}
if(value_path == "record-route")
{
record_route.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "signalled-name" || name == "affinity" || name == "logging" || name == "policy-class-entry" || name == "tunnel-id" || name == "protected-interface" || name == "is-signalled-name-configured" || name == "setup-priority" || name == "hold-priority" || name == "is-priority-configured" || name == "policy-class" || name == "is-policyclass-configured" || name == "is-affinity-configured" || name == "record-route")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::SignalledName()
:
name{YType::str, "name"},
source_type{YType::enumeration, "source-type"},
protected_interface_type{YType::enumeration, "protected-interface-type"},
is_mp_addresses{YType::boolean, "is-mp-addresses"}
{
yang_name = "signalled-name"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::~SignalledName()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::has_data() const
{
if (is_presence_container) return true;
return name.is_set
|| source_type.is_set
|| protected_interface_type.is_set
|| is_mp_addresses.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(name.yfilter)
|| ydk::is_set(source_type.yfilter)
|| ydk::is_set(protected_interface_type.yfilter)
|| ydk::is_set(is_mp_addresses.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "signalled-name";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (name.is_set || is_set(name.yfilter)) leaf_name_data.push_back(name.get_name_leafdata());
if (source_type.is_set || is_set(source_type.yfilter)) leaf_name_data.push_back(source_type.get_name_leafdata());
if (protected_interface_type.is_set || is_set(protected_interface_type.yfilter)) leaf_name_data.push_back(protected_interface_type.get_name_leafdata());
if (is_mp_addresses.is_set || is_set(is_mp_addresses.yfilter)) leaf_name_data.push_back(is_mp_addresses.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "name")
{
name = value;
name.value_namespace = name_space;
name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "source-type")
{
source_type = value;
source_type.value_namespace = name_space;
source_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "protected-interface-type")
{
protected_interface_type = value;
protected_interface_type.value_namespace = name_space;
protected_interface_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-mp-addresses")
{
is_mp_addresses = value;
is_mp_addresses.value_namespace = name_space;
is_mp_addresses.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "name")
{
name.yfilter = yfilter;
}
if(value_path == "source-type")
{
source_type.yfilter = yfilter;
}
if(value_path == "protected-interface-type")
{
protected_interface_type.yfilter = yfilter;
}
if(value_path == "is-mp-addresses")
{
is_mp_addresses.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "name" || name == "source-type" || name == "protected-interface-type" || name == "is-mp-addresses")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::Affinity()
:
affinity_bits{YType::uint32, "affinity-bits"},
affinity_mask{YType::uint32, "affinity-mask"}
,
named_affinity(this, {})
{
yang_name = "affinity"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::~Affinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_data())
return true;
}
return affinity_bits.is_set
|| affinity_mask.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::has_operation() const
{
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(affinity_bits.yfilter)
|| ydk::is_set(affinity_mask.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "affinity";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata());
if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "named-affinity")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity>();
ent_->parent = this;
named_affinity.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : named_affinity.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "affinity-bits")
{
affinity_bits = value;
affinity_bits.value_namespace = name_space;
affinity_bits.value_namespace_prefix = name_space_prefix;
}
if(value_path == "affinity-mask")
{
affinity_mask = value;
affinity_mask.value_namespace = name_space;
affinity_mask.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "affinity-bits")
{
affinity_bits.yfilter = yfilter;
}
if(value_path == "affinity-mask")
{
affinity_mask.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::NamedAffinity()
:
constraint_type{YType::uint8, "constraint-type"},
constraint_value{YType::uint32, "constraint-value"},
forward_ref_value{YType::uint32, "forward-ref-value"}
,
constraint_extended_value(this, {})
, extended_forward_ref_value(this, {})
{
yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::~NamedAffinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_data())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_data())
return true;
}
return constraint_type.is_set
|| constraint_value.is_set
|| forward_ref_value.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::has_operation() const
{
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_operation())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(constraint_type.yfilter)
|| ydk::is_set(constraint_value.yfilter)
|| ydk::is_set(forward_ref_value.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "named-affinity";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata());
if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata());
if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "constraint-extended-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue>();
ent_->parent = this;
constraint_extended_value.append(ent_);
return ent_;
}
if(child_yang_name == "extended-forward-ref-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue>();
ent_->parent = this;
extended_forward_ref_value.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : constraint_extended_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : extended_forward_ref_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "constraint-type")
{
constraint_type = value;
constraint_type.value_namespace = name_space;
constraint_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "constraint-value")
{
constraint_value = value;
constraint_value.value_namespace = name_space;
constraint_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "forward-ref-value")
{
forward_ref_value = value;
forward_ref_value.value_namespace = name_space;
forward_ref_value.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "constraint-type")
{
constraint_type.yfilter = yfilter;
}
if(value_path == "constraint-value")
{
constraint_value.yfilter = yfilter;
}
if(value_path == "forward-ref-value")
{
forward_ref_value.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "constraint-extended-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "extended-forward-ref-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::Logging()
:
lsp_state{YType::boolean, "lsp-state"},
s2l_state{YType::boolean, "s2l-state"},
lsp_re_route{YType::boolean, "lsp-re-route"},
lsp_re_opt{YType::boolean, "lsp-re-opt"},
lsp_insufficient_bw{YType::boolean, "lsp-insufficient-bw"},
lsp_bandwidth_change{YType::boolean, "lsp-bandwidth-change"},
lsp_pcalc_failure_logging_enabled{YType::boolean, "lsp-pcalc-failure-logging-enabled"},
all_logging_enabled{YType::boolean, "all-logging-enabled"}
{
yang_name = "logging"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::~Logging()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::has_data() const
{
if (is_presence_container) return true;
return lsp_state.is_set
|| s2l_state.is_set
|| lsp_re_route.is_set
|| lsp_re_opt.is_set
|| lsp_insufficient_bw.is_set
|| lsp_bandwidth_change.is_set
|| lsp_pcalc_failure_logging_enabled.is_set
|| all_logging_enabled.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lsp_state.yfilter)
|| ydk::is_set(s2l_state.yfilter)
|| ydk::is_set(lsp_re_route.yfilter)
|| ydk::is_set(lsp_re_opt.yfilter)
|| ydk::is_set(lsp_insufficient_bw.yfilter)
|| ydk::is_set(lsp_bandwidth_change.yfilter)
|| ydk::is_set(lsp_pcalc_failure_logging_enabled.yfilter)
|| ydk::is_set(all_logging_enabled.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "logging";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lsp_state.is_set || is_set(lsp_state.yfilter)) leaf_name_data.push_back(lsp_state.get_name_leafdata());
if (s2l_state.is_set || is_set(s2l_state.yfilter)) leaf_name_data.push_back(s2l_state.get_name_leafdata());
if (lsp_re_route.is_set || is_set(lsp_re_route.yfilter)) leaf_name_data.push_back(lsp_re_route.get_name_leafdata());
if (lsp_re_opt.is_set || is_set(lsp_re_opt.yfilter)) leaf_name_data.push_back(lsp_re_opt.get_name_leafdata());
if (lsp_insufficient_bw.is_set || is_set(lsp_insufficient_bw.yfilter)) leaf_name_data.push_back(lsp_insufficient_bw.get_name_leafdata());
if (lsp_bandwidth_change.is_set || is_set(lsp_bandwidth_change.yfilter)) leaf_name_data.push_back(lsp_bandwidth_change.get_name_leafdata());
if (lsp_pcalc_failure_logging_enabled.is_set || is_set(lsp_pcalc_failure_logging_enabled.yfilter)) leaf_name_data.push_back(lsp_pcalc_failure_logging_enabled.get_name_leafdata());
if (all_logging_enabled.is_set || is_set(all_logging_enabled.yfilter)) leaf_name_data.push_back(all_logging_enabled.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "lsp-state")
{
lsp_state = value;
lsp_state.value_namespace = name_space;
lsp_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-state")
{
s2l_state = value;
s2l_state.value_namespace = name_space;
s2l_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-re-route")
{
lsp_re_route = value;
lsp_re_route.value_namespace = name_space;
lsp_re_route.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-re-opt")
{
lsp_re_opt = value;
lsp_re_opt.value_namespace = name_space;
lsp_re_opt.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-insufficient-bw")
{
lsp_insufficient_bw = value;
lsp_insufficient_bw.value_namespace = name_space;
lsp_insufficient_bw.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-bandwidth-change")
{
lsp_bandwidth_change = value;
lsp_bandwidth_change.value_namespace = name_space;
lsp_bandwidth_change.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-pcalc-failure-logging-enabled")
{
lsp_pcalc_failure_logging_enabled = value;
lsp_pcalc_failure_logging_enabled.value_namespace = name_space;
lsp_pcalc_failure_logging_enabled.value_namespace_prefix = name_space_prefix;
}
if(value_path == "all-logging-enabled")
{
all_logging_enabled = value;
all_logging_enabled.value_namespace = name_space;
all_logging_enabled.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "lsp-state")
{
lsp_state.yfilter = yfilter;
}
if(value_path == "s2l-state")
{
s2l_state.yfilter = yfilter;
}
if(value_path == "lsp-re-route")
{
lsp_re_route.yfilter = yfilter;
}
if(value_path == "lsp-re-opt")
{
lsp_re_opt.yfilter = yfilter;
}
if(value_path == "lsp-insufficient-bw")
{
lsp_insufficient_bw.yfilter = yfilter;
}
if(value_path == "lsp-bandwidth-change")
{
lsp_bandwidth_change.yfilter = yfilter;
}
if(value_path == "lsp-pcalc-failure-logging-enabled")
{
lsp_pcalc_failure_logging_enabled.yfilter = yfilter;
}
if(value_path == "all-logging-enabled")
{
all_logging_enabled.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "lsp-state" || name == "s2l-state" || name == "lsp-re-route" || name == "lsp-re-opt" || name == "lsp-insufficient-bw" || name == "lsp-bandwidth-change" || name == "lsp-pcalc-failure-logging-enabled" || name == "all-logging-enabled")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::PolicyClassEntry()
:
entry{YType::uint8, "entry"}
{
yang_name = "policy-class-entry"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::~PolicyClassEntry()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "policy-class-entry";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::TunnelId()
:
entry{YType::uint16, "entry"}
{
yang_name = "tunnel-id"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::~TunnelId()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tunnel-id";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::ProtectedInterface()
:
protected_interface{YType::str, "protected-interface"}
{
yang_name = "protected-interface"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::~ProtectedInterface()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::has_data() const
{
if (is_presence_container) return true;
return protected_interface.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(protected_interface.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "protected-interface";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (protected_interface.is_set || is_set(protected_interface.yfilter)) leaf_name_data.push_back(protected_interface.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "protected-interface")
{
protected_interface = value;
protected_interface.value_namespace = name_space;
protected_interface.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "protected-interface")
{
protected_interface.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "protected-interface")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::AttributeSetAutomesh()
:
configured_bandwidth{YType::uint32, "configured-bandwidth"},
dste_class_type{YType::uint8, "dste-class-type"},
is_bandwidth_configured{YType::boolean, "is-bandwidth-configured"},
setup_priority{YType::uint8, "setup-priority"},
hold_priority{YType::uint8, "hold-priority"},
is_priority_configured{YType::boolean, "is-priority-configured"},
policy_class{YType::uint8, "policy-class"},
is_policyclass_configured{YType::boolean, "is-policyclass-configured"},
forward_class{YType::uint32, "forward-class"},
is_forward_class_configured{YType::boolean, "is-forward-class-configured"},
is_affinity_configured{YType::boolean, "is-affinity-configured"},
fast_reroute{YType::boolean, "fast-reroute"},
frr_node_protection{YType::boolean, "frr-node-protection"},
frr_bandwidth_protection{YType::boolean, "frr-bandwidth-protection"},
record_route{YType::boolean, "record-route"},
auto_bandwidth_collect{YType::boolean, "auto-bandwidth-collect"},
auto_route_announce{YType::boolean, "auto-route-announce"},
soft_preemption_configured{YType::boolean, "soft-preemption-configured"},
bandwidth{YType::uint32, "bandwidth"},
load_share{YType::uint32, "load-share"},
is_interface_bw_configured{YType::boolean, "is-interface-bw-configured"}
,
affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity>())
, logging(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging>())
, policy_class_entry(this, {})
, mesh_group_id(this, {})
, tunnel_id(this, {})
{
affinity->parent = this;
logging->parent = this;
yang_name = "attribute-set-automesh"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::~AttributeSetAutomesh()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<policy_class_entry.len(); index++)
{
if(policy_class_entry[index]->has_data())
return true;
}
for (std::size_t index=0; index<mesh_group_id.len(); index++)
{
if(mesh_group_id[index]->has_data())
return true;
}
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_data())
return true;
}
return configured_bandwidth.is_set
|| dste_class_type.is_set
|| is_bandwidth_configured.is_set
|| setup_priority.is_set
|| hold_priority.is_set
|| is_priority_configured.is_set
|| policy_class.is_set
|| is_policyclass_configured.is_set
|| forward_class.is_set
|| is_forward_class_configured.is_set
|| is_affinity_configured.is_set
|| fast_reroute.is_set
|| frr_node_protection.is_set
|| frr_bandwidth_protection.is_set
|| record_route.is_set
|| auto_bandwidth_collect.is_set
|| auto_route_announce.is_set
|| soft_preemption_configured.is_set
|| bandwidth.is_set
|| load_share.is_set
|| is_interface_bw_configured.is_set
|| (affinity != nullptr && affinity->has_data())
|| (logging != nullptr && logging->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::has_operation() const
{
for (std::size_t index=0; index<policy_class_entry.len(); index++)
{
if(policy_class_entry[index]->has_operation())
return true;
}
for (std::size_t index=0; index<mesh_group_id.len(); index++)
{
if(mesh_group_id[index]->has_operation())
return true;
}
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(configured_bandwidth.yfilter)
|| ydk::is_set(dste_class_type.yfilter)
|| ydk::is_set(is_bandwidth_configured.yfilter)
|| ydk::is_set(setup_priority.yfilter)
|| ydk::is_set(hold_priority.yfilter)
|| ydk::is_set(is_priority_configured.yfilter)
|| ydk::is_set(policy_class.yfilter)
|| ydk::is_set(is_policyclass_configured.yfilter)
|| ydk::is_set(forward_class.yfilter)
|| ydk::is_set(is_forward_class_configured.yfilter)
|| ydk::is_set(is_affinity_configured.yfilter)
|| ydk::is_set(fast_reroute.yfilter)
|| ydk::is_set(frr_node_protection.yfilter)
|| ydk::is_set(frr_bandwidth_protection.yfilter)
|| ydk::is_set(record_route.yfilter)
|| ydk::is_set(auto_bandwidth_collect.yfilter)
|| ydk::is_set(auto_route_announce.yfilter)
|| ydk::is_set(soft_preemption_configured.yfilter)
|| ydk::is_set(bandwidth.yfilter)
|| ydk::is_set(load_share.yfilter)
|| ydk::is_set(is_interface_bw_configured.yfilter)
|| (affinity != nullptr && affinity->has_operation())
|| (logging != nullptr && logging->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-automesh";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (configured_bandwidth.is_set || is_set(configured_bandwidth.yfilter)) leaf_name_data.push_back(configured_bandwidth.get_name_leafdata());
if (dste_class_type.is_set || is_set(dste_class_type.yfilter)) leaf_name_data.push_back(dste_class_type.get_name_leafdata());
if (is_bandwidth_configured.is_set || is_set(is_bandwidth_configured.yfilter)) leaf_name_data.push_back(is_bandwidth_configured.get_name_leafdata());
if (setup_priority.is_set || is_set(setup_priority.yfilter)) leaf_name_data.push_back(setup_priority.get_name_leafdata());
if (hold_priority.is_set || is_set(hold_priority.yfilter)) leaf_name_data.push_back(hold_priority.get_name_leafdata());
if (is_priority_configured.is_set || is_set(is_priority_configured.yfilter)) leaf_name_data.push_back(is_priority_configured.get_name_leafdata());
if (policy_class.is_set || is_set(policy_class.yfilter)) leaf_name_data.push_back(policy_class.get_name_leafdata());
if (is_policyclass_configured.is_set || is_set(is_policyclass_configured.yfilter)) leaf_name_data.push_back(is_policyclass_configured.get_name_leafdata());
if (forward_class.is_set || is_set(forward_class.yfilter)) leaf_name_data.push_back(forward_class.get_name_leafdata());
if (is_forward_class_configured.is_set || is_set(is_forward_class_configured.yfilter)) leaf_name_data.push_back(is_forward_class_configured.get_name_leafdata());
if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata());
if (fast_reroute.is_set || is_set(fast_reroute.yfilter)) leaf_name_data.push_back(fast_reroute.get_name_leafdata());
if (frr_node_protection.is_set || is_set(frr_node_protection.yfilter)) leaf_name_data.push_back(frr_node_protection.get_name_leafdata());
if (frr_bandwidth_protection.is_set || is_set(frr_bandwidth_protection.yfilter)) leaf_name_data.push_back(frr_bandwidth_protection.get_name_leafdata());
if (record_route.is_set || is_set(record_route.yfilter)) leaf_name_data.push_back(record_route.get_name_leafdata());
if (auto_bandwidth_collect.is_set || is_set(auto_bandwidth_collect.yfilter)) leaf_name_data.push_back(auto_bandwidth_collect.get_name_leafdata());
if (auto_route_announce.is_set || is_set(auto_route_announce.yfilter)) leaf_name_data.push_back(auto_route_announce.get_name_leafdata());
if (soft_preemption_configured.is_set || is_set(soft_preemption_configured.yfilter)) leaf_name_data.push_back(soft_preemption_configured.get_name_leafdata());
if (bandwidth.is_set || is_set(bandwidth.yfilter)) leaf_name_data.push_back(bandwidth.get_name_leafdata());
if (load_share.is_set || is_set(load_share.yfilter)) leaf_name_data.push_back(load_share.get_name_leafdata());
if (is_interface_bw_configured.is_set || is_set(is_interface_bw_configured.yfilter)) leaf_name_data.push_back(is_interface_bw_configured.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "affinity")
{
if(affinity == nullptr)
{
affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity>();
}
return affinity;
}
if(child_yang_name == "logging")
{
if(logging == nullptr)
{
logging = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging>();
}
return logging;
}
if(child_yang_name == "policy-class-entry")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry>();
ent_->parent = this;
policy_class_entry.append(ent_);
return ent_;
}
if(child_yang_name == "mesh-group-id")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId>();
ent_->parent = this;
mesh_group_id.append(ent_);
return ent_;
}
if(child_yang_name == "tunnel-id")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId>();
ent_->parent = this;
tunnel_id.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(affinity != nullptr)
{
_children["affinity"] = affinity;
}
if(logging != nullptr)
{
_children["logging"] = logging;
}
count_ = 0;
for (auto ent_ : policy_class_entry.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : mesh_group_id.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : tunnel_id.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "configured-bandwidth")
{
configured_bandwidth = value;
configured_bandwidth.value_namespace = name_space;
configured_bandwidth.value_namespace_prefix = name_space_prefix;
}
if(value_path == "dste-class-type")
{
dste_class_type = value;
dste_class_type.value_namespace = name_space;
dste_class_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-bandwidth-configured")
{
is_bandwidth_configured = value;
is_bandwidth_configured.value_namespace = name_space;
is_bandwidth_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "setup-priority")
{
setup_priority = value;
setup_priority.value_namespace = name_space;
setup_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "hold-priority")
{
hold_priority = value;
hold_priority.value_namespace = name_space;
hold_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-priority-configured")
{
is_priority_configured = value;
is_priority_configured.value_namespace = name_space;
is_priority_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "policy-class")
{
policy_class = value;
policy_class.value_namespace = name_space;
policy_class.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-policyclass-configured")
{
is_policyclass_configured = value;
is_policyclass_configured.value_namespace = name_space;
is_policyclass_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "forward-class")
{
forward_class = value;
forward_class.value_namespace = name_space;
forward_class.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-forward-class-configured")
{
is_forward_class_configured = value;
is_forward_class_configured.value_namespace = name_space;
is_forward_class_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured = value;
is_affinity_configured.value_namespace = name_space;
is_affinity_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fast-reroute")
{
fast_reroute = value;
fast_reroute.value_namespace = name_space;
fast_reroute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "frr-node-protection")
{
frr_node_protection = value;
frr_node_protection.value_namespace = name_space;
frr_node_protection.value_namespace_prefix = name_space_prefix;
}
if(value_path == "frr-bandwidth-protection")
{
frr_bandwidth_protection = value;
frr_bandwidth_protection.value_namespace = name_space;
frr_bandwidth_protection.value_namespace_prefix = name_space_prefix;
}
if(value_path == "record-route")
{
record_route = value;
record_route.value_namespace = name_space;
record_route.value_namespace_prefix = name_space_prefix;
}
if(value_path == "auto-bandwidth-collect")
{
auto_bandwidth_collect = value;
auto_bandwidth_collect.value_namespace = name_space;
auto_bandwidth_collect.value_namespace_prefix = name_space_prefix;
}
if(value_path == "auto-route-announce")
{
auto_route_announce = value;
auto_route_announce.value_namespace = name_space;
auto_route_announce.value_namespace_prefix = name_space_prefix;
}
if(value_path == "soft-preemption-configured")
{
soft_preemption_configured = value;
soft_preemption_configured.value_namespace = name_space;
soft_preemption_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "bandwidth")
{
bandwidth = value;
bandwidth.value_namespace = name_space;
bandwidth.value_namespace_prefix = name_space_prefix;
}
if(value_path == "load-share")
{
load_share = value;
load_share.value_namespace = name_space;
load_share.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-interface-bw-configured")
{
is_interface_bw_configured = value;
is_interface_bw_configured.value_namespace = name_space;
is_interface_bw_configured.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "configured-bandwidth")
{
configured_bandwidth.yfilter = yfilter;
}
if(value_path == "dste-class-type")
{
dste_class_type.yfilter = yfilter;
}
if(value_path == "is-bandwidth-configured")
{
is_bandwidth_configured.yfilter = yfilter;
}
if(value_path == "setup-priority")
{
setup_priority.yfilter = yfilter;
}
if(value_path == "hold-priority")
{
hold_priority.yfilter = yfilter;
}
if(value_path == "is-priority-configured")
{
is_priority_configured.yfilter = yfilter;
}
if(value_path == "policy-class")
{
policy_class.yfilter = yfilter;
}
if(value_path == "is-policyclass-configured")
{
is_policyclass_configured.yfilter = yfilter;
}
if(value_path == "forward-class")
{
forward_class.yfilter = yfilter;
}
if(value_path == "is-forward-class-configured")
{
is_forward_class_configured.yfilter = yfilter;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured.yfilter = yfilter;
}
if(value_path == "fast-reroute")
{
fast_reroute.yfilter = yfilter;
}
if(value_path == "frr-node-protection")
{
frr_node_protection.yfilter = yfilter;
}
if(value_path == "frr-bandwidth-protection")
{
frr_bandwidth_protection.yfilter = yfilter;
}
if(value_path == "record-route")
{
record_route.yfilter = yfilter;
}
if(value_path == "auto-bandwidth-collect")
{
auto_bandwidth_collect.yfilter = yfilter;
}
if(value_path == "auto-route-announce")
{
auto_route_announce.yfilter = yfilter;
}
if(value_path == "soft-preemption-configured")
{
soft_preemption_configured.yfilter = yfilter;
}
if(value_path == "bandwidth")
{
bandwidth.yfilter = yfilter;
}
if(value_path == "load-share")
{
load_share.yfilter = yfilter;
}
if(value_path == "is-interface-bw-configured")
{
is_interface_bw_configured.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "affinity" || name == "logging" || name == "policy-class-entry" || name == "mesh-group-id" || name == "tunnel-id" || name == "configured-bandwidth" || name == "dste-class-type" || name == "is-bandwidth-configured" || name == "setup-priority" || name == "hold-priority" || name == "is-priority-configured" || name == "policy-class" || name == "is-policyclass-configured" || name == "forward-class" || name == "is-forward-class-configured" || name == "is-affinity-configured" || name == "fast-reroute" || name == "frr-node-protection" || name == "frr-bandwidth-protection" || name == "record-route" || name == "auto-bandwidth-collect" || name == "auto-route-announce" || name == "soft-preemption-configured" || name == "bandwidth" || name == "load-share" || name == "is-interface-bw-configured")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::Affinity()
:
affinity_bits{YType::uint32, "affinity-bits"},
affinity_mask{YType::uint32, "affinity-mask"}
,
named_affinity(this, {})
{
yang_name = "affinity"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::~Affinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_data())
return true;
}
return affinity_bits.is_set
|| affinity_mask.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::has_operation() const
{
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(affinity_bits.yfilter)
|| ydk::is_set(affinity_mask.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "affinity";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata());
if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "named-affinity")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity>();
ent_->parent = this;
named_affinity.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : named_affinity.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "affinity-bits")
{
affinity_bits = value;
affinity_bits.value_namespace = name_space;
affinity_bits.value_namespace_prefix = name_space_prefix;
}
if(value_path == "affinity-mask")
{
affinity_mask = value;
affinity_mask.value_namespace = name_space;
affinity_mask.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "affinity-bits")
{
affinity_bits.yfilter = yfilter;
}
if(value_path == "affinity-mask")
{
affinity_mask.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::NamedAffinity()
:
constraint_type{YType::uint8, "constraint-type"},
constraint_value{YType::uint32, "constraint-value"},
forward_ref_value{YType::uint32, "forward-ref-value"}
,
constraint_extended_value(this, {})
, extended_forward_ref_value(this, {})
{
yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::~NamedAffinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_data())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_data())
return true;
}
return constraint_type.is_set
|| constraint_value.is_set
|| forward_ref_value.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::has_operation() const
{
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_operation())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(constraint_type.yfilter)
|| ydk::is_set(constraint_value.yfilter)
|| ydk::is_set(forward_ref_value.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "named-affinity";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata());
if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata());
if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "constraint-extended-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue>();
ent_->parent = this;
constraint_extended_value.append(ent_);
return ent_;
}
if(child_yang_name == "extended-forward-ref-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue>();
ent_->parent = this;
extended_forward_ref_value.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : constraint_extended_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : extended_forward_ref_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "constraint-type")
{
constraint_type = value;
constraint_type.value_namespace = name_space;
constraint_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "constraint-value")
{
constraint_value = value;
constraint_value.value_namespace = name_space;
constraint_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "forward-ref-value")
{
forward_ref_value = value;
forward_ref_value.value_namespace = name_space;
forward_ref_value.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "constraint-type")
{
constraint_type.yfilter = yfilter;
}
if(value_path == "constraint-value")
{
constraint_value.yfilter = yfilter;
}
if(value_path == "forward-ref-value")
{
forward_ref_value.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "constraint-extended-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "extended-forward-ref-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::Logging()
:
lsp_state{YType::boolean, "lsp-state"},
s2l_state{YType::boolean, "s2l-state"},
lsp_re_route{YType::boolean, "lsp-re-route"},
lsp_re_opt{YType::boolean, "lsp-re-opt"},
lsp_insufficient_bw{YType::boolean, "lsp-insufficient-bw"},
lsp_bandwidth_change{YType::boolean, "lsp-bandwidth-change"},
lsp_pcalc_failure_logging_enabled{YType::boolean, "lsp-pcalc-failure-logging-enabled"},
all_logging_enabled{YType::boolean, "all-logging-enabled"}
{
yang_name = "logging"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::~Logging()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::has_data() const
{
if (is_presence_container) return true;
return lsp_state.is_set
|| s2l_state.is_set
|| lsp_re_route.is_set
|| lsp_re_opt.is_set
|| lsp_insufficient_bw.is_set
|| lsp_bandwidth_change.is_set
|| lsp_pcalc_failure_logging_enabled.is_set
|| all_logging_enabled.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lsp_state.yfilter)
|| ydk::is_set(s2l_state.yfilter)
|| ydk::is_set(lsp_re_route.yfilter)
|| ydk::is_set(lsp_re_opt.yfilter)
|| ydk::is_set(lsp_insufficient_bw.yfilter)
|| ydk::is_set(lsp_bandwidth_change.yfilter)
|| ydk::is_set(lsp_pcalc_failure_logging_enabled.yfilter)
|| ydk::is_set(all_logging_enabled.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "logging";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lsp_state.is_set || is_set(lsp_state.yfilter)) leaf_name_data.push_back(lsp_state.get_name_leafdata());
if (s2l_state.is_set || is_set(s2l_state.yfilter)) leaf_name_data.push_back(s2l_state.get_name_leafdata());
if (lsp_re_route.is_set || is_set(lsp_re_route.yfilter)) leaf_name_data.push_back(lsp_re_route.get_name_leafdata());
if (lsp_re_opt.is_set || is_set(lsp_re_opt.yfilter)) leaf_name_data.push_back(lsp_re_opt.get_name_leafdata());
if (lsp_insufficient_bw.is_set || is_set(lsp_insufficient_bw.yfilter)) leaf_name_data.push_back(lsp_insufficient_bw.get_name_leafdata());
if (lsp_bandwidth_change.is_set || is_set(lsp_bandwidth_change.yfilter)) leaf_name_data.push_back(lsp_bandwidth_change.get_name_leafdata());
if (lsp_pcalc_failure_logging_enabled.is_set || is_set(lsp_pcalc_failure_logging_enabled.yfilter)) leaf_name_data.push_back(lsp_pcalc_failure_logging_enabled.get_name_leafdata());
if (all_logging_enabled.is_set || is_set(all_logging_enabled.yfilter)) leaf_name_data.push_back(all_logging_enabled.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "lsp-state")
{
lsp_state = value;
lsp_state.value_namespace = name_space;
lsp_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-state")
{
s2l_state = value;
s2l_state.value_namespace = name_space;
s2l_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-re-route")
{
lsp_re_route = value;
lsp_re_route.value_namespace = name_space;
lsp_re_route.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-re-opt")
{
lsp_re_opt = value;
lsp_re_opt.value_namespace = name_space;
lsp_re_opt.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-insufficient-bw")
{
lsp_insufficient_bw = value;
lsp_insufficient_bw.value_namespace = name_space;
lsp_insufficient_bw.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-bandwidth-change")
{
lsp_bandwidth_change = value;
lsp_bandwidth_change.value_namespace = name_space;
lsp_bandwidth_change.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-pcalc-failure-logging-enabled")
{
lsp_pcalc_failure_logging_enabled = value;
lsp_pcalc_failure_logging_enabled.value_namespace = name_space;
lsp_pcalc_failure_logging_enabled.value_namespace_prefix = name_space_prefix;
}
if(value_path == "all-logging-enabled")
{
all_logging_enabled = value;
all_logging_enabled.value_namespace = name_space;
all_logging_enabled.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "lsp-state")
{
lsp_state.yfilter = yfilter;
}
if(value_path == "s2l-state")
{
s2l_state.yfilter = yfilter;
}
if(value_path == "lsp-re-route")
{
lsp_re_route.yfilter = yfilter;
}
if(value_path == "lsp-re-opt")
{
lsp_re_opt.yfilter = yfilter;
}
if(value_path == "lsp-insufficient-bw")
{
lsp_insufficient_bw.yfilter = yfilter;
}
if(value_path == "lsp-bandwidth-change")
{
lsp_bandwidth_change.yfilter = yfilter;
}
if(value_path == "lsp-pcalc-failure-logging-enabled")
{
lsp_pcalc_failure_logging_enabled.yfilter = yfilter;
}
if(value_path == "all-logging-enabled")
{
all_logging_enabled.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "lsp-state" || name == "s2l-state" || name == "lsp-re-route" || name == "lsp-re-opt" || name == "lsp-insufficient-bw" || name == "lsp-bandwidth-change" || name == "lsp-pcalc-failure-logging-enabled" || name == "all-logging-enabled")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::PolicyClassEntry()
:
entry{YType::uint8, "entry"}
{
yang_name = "policy-class-entry"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::~PolicyClassEntry()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "policy-class-entry";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::MeshGroupId()
:
entry{YType::uint32, "entry"}
{
yang_name = "mesh-group-id"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::~MeshGroupId()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "mesh-group-id";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::TunnelId()
:
entry{YType::uint16, "entry"}
{
yang_name = "tunnel-id"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::~TunnelId()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tunnel-id";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::AttributeSetXro()
:
xro(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro>())
{
xro->parent = this;
yang_name = "attribute-set-xro"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::~AttributeSetXro()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::has_data() const
{
if (is_presence_container) return true;
return (xro != nullptr && xro->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::has_operation() const
{
return is_set(yfilter)
|| (xro != nullptr && xro->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-xro";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "xro")
{
if(xro == nullptr)
{
xro = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro>();
}
return xro;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(xro != nullptr)
{
_children["xro"] = xro;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "xro")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::Xro()
:
mutual_diversity_flag{YType::boolean, "mutual-diversity-flag"}
,
xro_subobject(this, {})
{
yang_name = "xro"; yang_parent_name = "attribute-set-xro"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::~Xro()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<xro_subobject.len(); index++)
{
if(xro_subobject[index]->has_data())
return true;
}
return mutual_diversity_flag.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::has_operation() const
{
for (std::size_t index=0; index<xro_subobject.len(); index++)
{
if(xro_subobject[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(mutual_diversity_flag.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "xro";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (mutual_diversity_flag.is_set || is_set(mutual_diversity_flag.yfilter)) leaf_name_data.push_back(mutual_diversity_flag.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "xro-subobject")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject>();
ent_->parent = this;
xro_subobject.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : xro_subobject.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "mutual-diversity-flag")
{
mutual_diversity_flag = value;
mutual_diversity_flag.value_namespace = name_space;
mutual_diversity_flag.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "mutual-diversity-flag")
{
mutual_diversity_flag.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "xro-subobject" || name == "mutual-diversity-flag")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::XroSubobject()
:
type{YType::enumeration, "type"}
,
ipv4_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject>())
, ipv6_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject>())
, unnumbered_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject>())
, as_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject>())
, srlg_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject>())
, lsp_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject>())
{
ipv4_subobject->parent = this;
ipv6_subobject->parent = this;
unnumbered_subobject->parent = this;
as_subobject->parent = this;
srlg_subobject->parent = this;
lsp_subobject->parent = this;
yang_name = "xro-subobject"; yang_parent_name = "xro"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::~XroSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::has_data() const
{
if (is_presence_container) return true;
return type.is_set
|| (ipv4_subobject != nullptr && ipv4_subobject->has_data())
|| (ipv6_subobject != nullptr && ipv6_subobject->has_data())
|| (unnumbered_subobject != nullptr && unnumbered_subobject->has_data())
|| (as_subobject != nullptr && as_subobject->has_data())
|| (srlg_subobject != nullptr && srlg_subobject->has_data())
|| (lsp_subobject != nullptr && lsp_subobject->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(type.yfilter)
|| (ipv4_subobject != nullptr && ipv4_subobject->has_operation())
|| (ipv6_subobject != nullptr && ipv6_subobject->has_operation())
|| (unnumbered_subobject != nullptr && unnumbered_subobject->has_operation())
|| (as_subobject != nullptr && as_subobject->has_operation())
|| (srlg_subobject != nullptr && srlg_subobject->has_operation())
|| (lsp_subobject != nullptr && lsp_subobject->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "xro-subobject";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ipv4-subobject")
{
if(ipv4_subobject == nullptr)
{
ipv4_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject>();
}
return ipv4_subobject;
}
if(child_yang_name == "ipv6-subobject")
{
if(ipv6_subobject == nullptr)
{
ipv6_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject>();
}
return ipv6_subobject;
}
if(child_yang_name == "unnumbered-subobject")
{
if(unnumbered_subobject == nullptr)
{
unnumbered_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject>();
}
return unnumbered_subobject;
}
if(child_yang_name == "as-subobject")
{
if(as_subobject == nullptr)
{
as_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject>();
}
return as_subobject;
}
if(child_yang_name == "srlg-subobject")
{
if(srlg_subobject == nullptr)
{
srlg_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject>();
}
return srlg_subobject;
}
if(child_yang_name == "lsp-subobject")
{
if(lsp_subobject == nullptr)
{
lsp_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject>();
}
return lsp_subobject;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(ipv4_subobject != nullptr)
{
_children["ipv4-subobject"] = ipv4_subobject;
}
if(ipv6_subobject != nullptr)
{
_children["ipv6-subobject"] = ipv6_subobject;
}
if(unnumbered_subobject != nullptr)
{
_children["unnumbered-subobject"] = unnumbered_subobject;
}
if(as_subobject != nullptr)
{
_children["as-subobject"] = as_subobject;
}
if(srlg_subobject != nullptr)
{
_children["srlg-subobject"] = srlg_subobject;
}
if(lsp_subobject != nullptr)
{
_children["lsp-subobject"] = lsp_subobject;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "type")
{
type = value;
type.value_namespace = name_space;
type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "type")
{
type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4-subobject" || name == "ipv6-subobject" || name == "unnumbered-subobject" || name == "as-subobject" || name == "srlg-subobject" || name == "lsp-subobject" || name == "type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::Ipv4Subobject()
:
address{YType::str, "address"},
prefix_len{YType::uint8, "prefix-len"},
attribute{YType::enumeration, "attribute"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "ipv4-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::~Ipv4Subobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::has_data() const
{
if (is_presence_container) return true;
return address.is_set
|| prefix_len.is_set
|| attribute.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(address.yfilter)
|| ydk::is_set(prefix_len.yfilter)
|| ydk::is_set(attribute.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv4-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata());
if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata());
if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address = value;
address.value_namespace = name_space;
address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-len")
{
prefix_len = value;
prefix_len.value_namespace = name_space;
prefix_len.value_namespace_prefix = name_space_prefix;
}
if(value_path == "attribute")
{
attribute = value;
attribute.value_namespace = name_space;
attribute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
if(value_path == "prefix-len")
{
prefix_len.yfilter = yfilter;
}
if(value_path == "attribute")
{
attribute.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::Ipv6Subobject()
:
address{YType::str, "address"},
prefix_len{YType::uint8, "prefix-len"},
attribute{YType::enumeration, "attribute"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "ipv6-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::~Ipv6Subobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::has_data() const
{
if (is_presence_container) return true;
return address.is_set
|| prefix_len.is_set
|| attribute.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(address.yfilter)
|| ydk::is_set(prefix_len.yfilter)
|| ydk::is_set(attribute.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv6-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata());
if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata());
if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address = value;
address.value_namespace = name_space;
address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-len")
{
prefix_len = value;
prefix_len.value_namespace = name_space;
prefix_len.value_namespace_prefix = name_space_prefix;
}
if(value_path == "attribute")
{
attribute = value;
attribute.value_namespace = name_space;
attribute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
if(value_path == "prefix-len")
{
prefix_len.yfilter = yfilter;
}
if(value_path == "attribute")
{
attribute.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::UnnumberedSubobject()
:
te_router_id{YType::str, "te-router-id"},
interface_id{YType::uint32, "interface-id"},
attribute{YType::enumeration, "attribute"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "unnumbered-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::~UnnumberedSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::has_data() const
{
if (is_presence_container) return true;
return te_router_id.is_set
|| interface_id.is_set
|| attribute.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(te_router_id.yfilter)
|| ydk::is_set(interface_id.yfilter)
|| ydk::is_set(attribute.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "unnumbered-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (te_router_id.is_set || is_set(te_router_id.yfilter)) leaf_name_data.push_back(te_router_id.get_name_leafdata());
if (interface_id.is_set || is_set(interface_id.yfilter)) leaf_name_data.push_back(interface_id.get_name_leafdata());
if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "te-router-id")
{
te_router_id = value;
te_router_id.value_namespace = name_space;
te_router_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "interface-id")
{
interface_id = value;
interface_id.value_namespace = name_space;
interface_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "attribute")
{
attribute = value;
attribute.value_namespace = name_space;
attribute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "te-router-id")
{
te_router_id.yfilter = yfilter;
}
if(value_path == "interface-id")
{
interface_id.yfilter = yfilter;
}
if(value_path == "attribute")
{
attribute.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "te-router-id" || name == "interface-id" || name == "attribute" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::AsSubobject()
:
as_number{YType::uint16, "as-number"}
{
yang_name = "as-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::~AsSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::has_data() const
{
if (is_presence_container) return true;
return as_number.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(as_number.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "as-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (as_number.is_set || is_set(as_number.yfilter)) leaf_name_data.push_back(as_number.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "as-number")
{
as_number = value;
as_number.value_namespace = name_space;
as_number.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "as-number")
{
as_number.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "as-number")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::SrlgSubobject()
:
srlg_id{YType::uint32, "srlg-id"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "srlg-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::~SrlgSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::has_data() const
{
if (is_presence_container) return true;
return srlg_id.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(srlg_id.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "srlg-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (srlg_id.is_set || is_set(srlg_id.yfilter)) leaf_name_data.push_back(srlg_id.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "srlg-id")
{
srlg_id = value;
srlg_id.value_namespace = name_space;
srlg_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "srlg-id")
{
srlg_id.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "srlg-id" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::LspSubobject()
:
ignore_lsp_id{YType::boolean, "ignore-lsp-id"},
processing_node_exception{YType::boolean, "processing-node-exception"},
penultimate_node_exception{YType::boolean, "penultimate-node-exception"},
destination_node_exception{YType::boolean, "destination-node-exception"},
exclusion_type{YType::enumeration, "exclusion-type"}
,
fec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec>())
{
fec->parent = this;
yang_name = "lsp-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::~LspSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::has_data() const
{
if (is_presence_container) return true;
return ignore_lsp_id.is_set
|| processing_node_exception.is_set
|| penultimate_node_exception.is_set
|| destination_node_exception.is_set
|| exclusion_type.is_set
|| (fec != nullptr && fec->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ignore_lsp_id.yfilter)
|| ydk::is_set(processing_node_exception.yfilter)
|| ydk::is_set(penultimate_node_exception.yfilter)
|| ydk::is_set(destination_node_exception.yfilter)
|| ydk::is_set(exclusion_type.yfilter)
|| (fec != nullptr && fec->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "lsp-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ignore_lsp_id.is_set || is_set(ignore_lsp_id.yfilter)) leaf_name_data.push_back(ignore_lsp_id.get_name_leafdata());
if (processing_node_exception.is_set || is_set(processing_node_exception.yfilter)) leaf_name_data.push_back(processing_node_exception.get_name_leafdata());
if (penultimate_node_exception.is_set || is_set(penultimate_node_exception.yfilter)) leaf_name_data.push_back(penultimate_node_exception.get_name_leafdata());
if (destination_node_exception.is_set || is_set(destination_node_exception.yfilter)) leaf_name_data.push_back(destination_node_exception.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "fec")
{
if(fec == nullptr)
{
fec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec>();
}
return fec;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(fec != nullptr)
{
_children["fec"] = fec;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ignore-lsp-id")
{
ignore_lsp_id = value;
ignore_lsp_id.value_namespace = name_space;
ignore_lsp_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "processing-node-exception")
{
processing_node_exception = value;
processing_node_exception.value_namespace = name_space;
processing_node_exception.value_namespace_prefix = name_space_prefix;
}
if(value_path == "penultimate-node-exception")
{
penultimate_node_exception = value;
penultimate_node_exception.value_namespace = name_space;
penultimate_node_exception.value_namespace_prefix = name_space_prefix;
}
if(value_path == "destination-node-exception")
{
destination_node_exception = value;
destination_node_exception.value_namespace = name_space;
destination_node_exception.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ignore-lsp-id")
{
ignore_lsp_id.yfilter = yfilter;
}
if(value_path == "processing-node-exception")
{
processing_node_exception.yfilter = yfilter;
}
if(value_path == "penultimate-node-exception")
{
penultimate_node_exception.yfilter = yfilter;
}
if(value_path == "destination-node-exception")
{
destination_node_exception.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "fec" || name == "ignore-lsp-id" || name == "processing-node-exception" || name == "penultimate-node-exception" || name == "destination-node-exception" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::Fec()
:
fec_lsp_id{YType::uint16, "fec-lsp-id"},
fec_tunnel_id{YType::uint16, "fec-tunnel-id"},
fec_extended_tunnel_id{YType::str, "fec-extended-tunnel-id"},
fec_source{YType::str, "fec-source"},
fec_vrf{YType::str, "fec-vrf"}
,
fec_destination_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo>())
{
fec_destination_info->parent = this;
yang_name = "fec"; yang_parent_name = "lsp-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::~Fec()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::has_data() const
{
if (is_presence_container) return true;
return fec_lsp_id.is_set
|| fec_tunnel_id.is_set
|| fec_extended_tunnel_id.is_set
|| fec_source.is_set
|| fec_vrf.is_set
|| (fec_destination_info != nullptr && fec_destination_info->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(fec_lsp_id.yfilter)
|| ydk::is_set(fec_tunnel_id.yfilter)
|| ydk::is_set(fec_extended_tunnel_id.yfilter)
|| ydk::is_set(fec_source.yfilter)
|| ydk::is_set(fec_vrf.yfilter)
|| (fec_destination_info != nullptr && fec_destination_info->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "fec";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (fec_lsp_id.is_set || is_set(fec_lsp_id.yfilter)) leaf_name_data.push_back(fec_lsp_id.get_name_leafdata());
if (fec_tunnel_id.is_set || is_set(fec_tunnel_id.yfilter)) leaf_name_data.push_back(fec_tunnel_id.get_name_leafdata());
if (fec_extended_tunnel_id.is_set || is_set(fec_extended_tunnel_id.yfilter)) leaf_name_data.push_back(fec_extended_tunnel_id.get_name_leafdata());
if (fec_source.is_set || is_set(fec_source.yfilter)) leaf_name_data.push_back(fec_source.get_name_leafdata());
if (fec_vrf.is_set || is_set(fec_vrf.yfilter)) leaf_name_data.push_back(fec_vrf.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "fec-destination-info")
{
if(fec_destination_info == nullptr)
{
fec_destination_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo>();
}
return fec_destination_info;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(fec_destination_info != nullptr)
{
_children["fec-destination-info"] = fec_destination_info;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "fec-lsp-id")
{
fec_lsp_id = value;
fec_lsp_id.value_namespace = name_space;
fec_lsp_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-tunnel-id")
{
fec_tunnel_id = value;
fec_tunnel_id.value_namespace = name_space;
fec_tunnel_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-extended-tunnel-id")
{
fec_extended_tunnel_id = value;
fec_extended_tunnel_id.value_namespace = name_space;
fec_extended_tunnel_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-source")
{
fec_source = value;
fec_source.value_namespace = name_space;
fec_source.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-vrf")
{
fec_vrf = value;
fec_vrf.value_namespace = name_space;
fec_vrf.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "fec-lsp-id")
{
fec_lsp_id.yfilter = yfilter;
}
if(value_path == "fec-tunnel-id")
{
fec_tunnel_id.yfilter = yfilter;
}
if(value_path == "fec-extended-tunnel-id")
{
fec_extended_tunnel_id.yfilter = yfilter;
}
if(value_path == "fec-source")
{
fec_source.yfilter = yfilter;
}
if(value_path == "fec-vrf")
{
fec_vrf.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "fec-destination-info" || name == "fec-lsp-id" || name == "fec-tunnel-id" || name == "fec-extended-tunnel-id" || name == "fec-source" || name == "fec-vrf")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::FecDestinationInfo()
:
fec_ctype{YType::enumeration, "fec-ctype"},
p2p_lsp_destination{YType::str, "p2p-lsp-destination"},
fec_destination_p2mp_id{YType::uint32, "fec-destination-p2mp-id"}
{
yang_name = "fec-destination-info"; yang_parent_name = "fec"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::~FecDestinationInfo()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_data() const
{
if (is_presence_container) return true;
return fec_ctype.is_set
|| p2p_lsp_destination.is_set
|| fec_destination_p2mp_id.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(fec_ctype.yfilter)
|| ydk::is_set(p2p_lsp_destination.yfilter)
|| ydk::is_set(fec_destination_p2mp_id.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "fec-destination-info";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (fec_ctype.is_set || is_set(fec_ctype.yfilter)) leaf_name_data.push_back(fec_ctype.get_name_leafdata());
if (p2p_lsp_destination.is_set || is_set(p2p_lsp_destination.yfilter)) leaf_name_data.push_back(p2p_lsp_destination.get_name_leafdata());
if (fec_destination_p2mp_id.is_set || is_set(fec_destination_p2mp_id.yfilter)) leaf_name_data.push_back(fec_destination_p2mp_id.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "fec-ctype")
{
fec_ctype = value;
fec_ctype.value_namespace = name_space;
fec_ctype.value_namespace_prefix = name_space_prefix;
}
if(value_path == "p2p-lsp-destination")
{
p2p_lsp_destination = value;
p2p_lsp_destination.value_namespace = name_space;
p2p_lsp_destination.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-destination-p2mp-id")
{
fec_destination_p2mp_id = value;
fec_destination_p2mp_id.value_namespace = name_space;
fec_destination_p2mp_id.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "fec-ctype")
{
fec_ctype.yfilter = yfilter;
}
if(value_path == "p2p-lsp-destination")
{
p2p_lsp_destination.yfilter = yfilter;
}
if(value_path == "fec-destination-p2mp-id")
{
fec_destination_p2mp_id.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "fec-ctype" || name == "p2p-lsp-destination" || name == "fec-destination-p2mp-id")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::AttributeSetP2mpte()
:
fast_reroute{YType::boolean, "fast-reroute"},
frr_bandwidth_protection{YType::boolean, "frr-bandwidth-protection"},
setup_priority{YType::uint8, "setup-priority"},
hold_priority{YType::uint8, "hold-priority"},
is_priority_configured{YType::boolean, "is-priority-configured"},
configured_bandwidth{YType::uint32, "configured-bandwidth"},
dste_class_type{YType::uint8, "dste-class-type"},
is_bandwidth_configured{YType::boolean, "is-bandwidth-configured"},
is_affinity_configured{YType::boolean, "is-affinity-configured"}
,
affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity>())
, tunnel_id(this, {})
{
affinity->parent = this;
yang_name = "attribute-set-p2mpte"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::~AttributeSetP2mpte()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_data())
return true;
}
return fast_reroute.is_set
|| frr_bandwidth_protection.is_set
|| setup_priority.is_set
|| hold_priority.is_set
|| is_priority_configured.is_set
|| configured_bandwidth.is_set
|| dste_class_type.is_set
|| is_bandwidth_configured.is_set
|| is_affinity_configured.is_set
|| (affinity != nullptr && affinity->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::has_operation() const
{
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(fast_reroute.yfilter)
|| ydk::is_set(frr_bandwidth_protection.yfilter)
|| ydk::is_set(setup_priority.yfilter)
|| ydk::is_set(hold_priority.yfilter)
|| ydk::is_set(is_priority_configured.yfilter)
|| ydk::is_set(configured_bandwidth.yfilter)
|| ydk::is_set(dste_class_type.yfilter)
|| ydk::is_set(is_bandwidth_configured.yfilter)
|| ydk::is_set(is_affinity_configured.yfilter)
|| (affinity != nullptr && affinity->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-p2mpte";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (fast_reroute.is_set || is_set(fast_reroute.yfilter)) leaf_name_data.push_back(fast_reroute.get_name_leafdata());
if (frr_bandwidth_protection.is_set || is_set(frr_bandwidth_protection.yfilter)) leaf_name_data.push_back(frr_bandwidth_protection.get_name_leafdata());
if (setup_priority.is_set || is_set(setup_priority.yfilter)) leaf_name_data.push_back(setup_priority.get_name_leafdata());
if (hold_priority.is_set || is_set(hold_priority.yfilter)) leaf_name_data.push_back(hold_priority.get_name_leafdata());
if (is_priority_configured.is_set || is_set(is_priority_configured.yfilter)) leaf_name_data.push_back(is_priority_configured.get_name_leafdata());
if (configured_bandwidth.is_set || is_set(configured_bandwidth.yfilter)) leaf_name_data.push_back(configured_bandwidth.get_name_leafdata());
if (dste_class_type.is_set || is_set(dste_class_type.yfilter)) leaf_name_data.push_back(dste_class_type.get_name_leafdata());
if (is_bandwidth_configured.is_set || is_set(is_bandwidth_configured.yfilter)) leaf_name_data.push_back(is_bandwidth_configured.get_name_leafdata());
if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "affinity")
{
if(affinity == nullptr)
{
affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity>();
}
return affinity;
}
if(child_yang_name == "tunnel-id")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId>();
ent_->parent = this;
tunnel_id.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(affinity != nullptr)
{
_children["affinity"] = affinity;
}
count_ = 0;
for (auto ent_ : tunnel_id.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "fast-reroute")
{
fast_reroute = value;
fast_reroute.value_namespace = name_space;
fast_reroute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "frr-bandwidth-protection")
{
frr_bandwidth_protection = value;
frr_bandwidth_protection.value_namespace = name_space;
frr_bandwidth_protection.value_namespace_prefix = name_space_prefix;
}
if(value_path == "setup-priority")
{
setup_priority = value;
setup_priority.value_namespace = name_space;
setup_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "hold-priority")
{
hold_priority = value;
hold_priority.value_namespace = name_space;
hold_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-priority-configured")
{
is_priority_configured = value;
is_priority_configured.value_namespace = name_space;
is_priority_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "configured-bandwidth")
{
configured_bandwidth = value;
configured_bandwidth.value_namespace = name_space;
configured_bandwidth.value_namespace_prefix = name_space_prefix;
}
if(value_path == "dste-class-type")
{
dste_class_type = value;
dste_class_type.value_namespace = name_space;
dste_class_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-bandwidth-configured")
{
is_bandwidth_configured = value;
is_bandwidth_configured.value_namespace = name_space;
is_bandwidth_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured = value;
is_affinity_configured.value_namespace = name_space;
is_affinity_configured.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "fast-reroute")
{
fast_reroute.yfilter = yfilter;
}
if(value_path == "frr-bandwidth-protection")
{
frr_bandwidth_protection.yfilter = yfilter;
}
if(value_path == "setup-priority")
{
setup_priority.yfilter = yfilter;
}
if(value_path == "hold-priority")
{
hold_priority.yfilter = yfilter;
}
if(value_path == "is-priority-configured")
{
is_priority_configured.yfilter = yfilter;
}
if(value_path == "configured-bandwidth")
{
configured_bandwidth.yfilter = yfilter;
}
if(value_path == "dste-class-type")
{
dste_class_type.yfilter = yfilter;
}
if(value_path == "is-bandwidth-configured")
{
is_bandwidth_configured.yfilter = yfilter;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "affinity" || name == "tunnel-id" || name == "fast-reroute" || name == "frr-bandwidth-protection" || name == "setup-priority" || name == "hold-priority" || name == "is-priority-configured" || name == "configured-bandwidth" || name == "dste-class-type" || name == "is-bandwidth-configured" || name == "is-affinity-configured")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::Affinity()
:
affinity_bits{YType::uint32, "affinity-bits"},
affinity_mask{YType::uint32, "affinity-mask"}
,
named_affinity(this, {})
{
yang_name = "affinity"; yang_parent_name = "attribute-set-p2mpte"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::~Affinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_data())
return true;
}
return affinity_bits.is_set
|| affinity_mask.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::has_operation() const
{
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(affinity_bits.yfilter)
|| ydk::is_set(affinity_mask.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "affinity";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata());
if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "named-affinity")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity>();
ent_->parent = this;
named_affinity.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : named_affinity.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "affinity-bits")
{
affinity_bits = value;
affinity_bits.value_namespace = name_space;
affinity_bits.value_namespace_prefix = name_space_prefix;
}
if(value_path == "affinity-mask")
{
affinity_mask = value;
affinity_mask.value_namespace = name_space;
affinity_mask.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "affinity-bits")
{
affinity_bits.yfilter = yfilter;
}
if(value_path == "affinity-mask")
{
affinity_mask.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::NamedAffinity()
:
constraint_type{YType::uint8, "constraint-type"},
constraint_value{YType::uint32, "constraint-value"},
forward_ref_value{YType::uint32, "forward-ref-value"}
,
constraint_extended_value(this, {})
, extended_forward_ref_value(this, {})
{
yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::~NamedAffinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_data())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_data())
return true;
}
return constraint_type.is_set
|| constraint_value.is_set
|| forward_ref_value.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::has_operation() const
{
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_operation())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(constraint_type.yfilter)
|| ydk::is_set(constraint_value.yfilter)
|| ydk::is_set(forward_ref_value.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "named-affinity";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata());
if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata());
if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "constraint-extended-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue>();
ent_->parent = this;
constraint_extended_value.append(ent_);
return ent_;
}
if(child_yang_name == "extended-forward-ref-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue>();
ent_->parent = this;
extended_forward_ref_value.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : constraint_extended_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : extended_forward_ref_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "constraint-type")
{
constraint_type = value;
constraint_type.value_namespace = name_space;
constraint_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "constraint-value")
{
constraint_value = value;
constraint_value.value_namespace = name_space;
constraint_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "forward-ref-value")
{
forward_ref_value = value;
forward_ref_value.value_namespace = name_space;
forward_ref_value.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "constraint-type")
{
constraint_type.yfilter = yfilter;
}
if(value_path == "constraint-value")
{
constraint_value.yfilter = yfilter;
}
if(value_path == "forward-ref-value")
{
forward_ref_value.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "constraint-extended-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "extended-forward-ref-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::TunnelId()
:
entry{YType::uint16, "entry"}
{
yang_name = "tunnel-id"; yang_parent_name = "attribute-set-p2mpte"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::~TunnelId()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tunnel-id";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::AttributeSetApsPp()
:
snc_mode{YType::enumeration, "snc-mode"},
tcm_id{YType::uint32, "tcm-id"},
protection_type{YType::enumeration, "protection-type"},
protection_mode{YType::enumeration, "protection-mode"},
wait_to_restore_time{YType::uint32, "wait-to-restore-time"},
hold_off_time{YType::uint32, "hold-off-time"},
path_prot_profile_type{YType::enumeration, "path-prot-profile-type"},
restoration_style{YType::enumeration, "restoration-style"}
,
revert_schedule(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule>())
{
revert_schedule->parent = this;
yang_name = "attribute-set-aps-pp"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::~AttributeSetApsPp()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::has_data() const
{
if (is_presence_container) return true;
return snc_mode.is_set
|| tcm_id.is_set
|| protection_type.is_set
|| protection_mode.is_set
|| wait_to_restore_time.is_set
|| hold_off_time.is_set
|| path_prot_profile_type.is_set
|| restoration_style.is_set
|| (revert_schedule != nullptr && revert_schedule->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(snc_mode.yfilter)
|| ydk::is_set(tcm_id.yfilter)
|| ydk::is_set(protection_type.yfilter)
|| ydk::is_set(protection_mode.yfilter)
|| ydk::is_set(wait_to_restore_time.yfilter)
|| ydk::is_set(hold_off_time.yfilter)
|| ydk::is_set(path_prot_profile_type.yfilter)
|| ydk::is_set(restoration_style.yfilter)
|| (revert_schedule != nullptr && revert_schedule->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-aps-pp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (snc_mode.is_set || is_set(snc_mode.yfilter)) leaf_name_data.push_back(snc_mode.get_name_leafdata());
if (tcm_id.is_set || is_set(tcm_id.yfilter)) leaf_name_data.push_back(tcm_id.get_name_leafdata());
if (protection_type.is_set || is_set(protection_type.yfilter)) leaf_name_data.push_back(protection_type.get_name_leafdata());
if (protection_mode.is_set || is_set(protection_mode.yfilter)) leaf_name_data.push_back(protection_mode.get_name_leafdata());
if (wait_to_restore_time.is_set || is_set(wait_to_restore_time.yfilter)) leaf_name_data.push_back(wait_to_restore_time.get_name_leafdata());
if (hold_off_time.is_set || is_set(hold_off_time.yfilter)) leaf_name_data.push_back(hold_off_time.get_name_leafdata());
if (path_prot_profile_type.is_set || is_set(path_prot_profile_type.yfilter)) leaf_name_data.push_back(path_prot_profile_type.get_name_leafdata());
if (restoration_style.is_set || is_set(restoration_style.yfilter)) leaf_name_data.push_back(restoration_style.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "revert-schedule")
{
if(revert_schedule == nullptr)
{
revert_schedule = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule>();
}
return revert_schedule;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(revert_schedule != nullptr)
{
_children["revert-schedule"] = revert_schedule;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "snc-mode")
{
snc_mode = value;
snc_mode.value_namespace = name_space;
snc_mode.value_namespace_prefix = name_space_prefix;
}
if(value_path == "tcm-id")
{
tcm_id = value;
tcm_id.value_namespace = name_space;
tcm_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "protection-type")
{
protection_type = value;
protection_type.value_namespace = name_space;
protection_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "protection-mode")
{
protection_mode = value;
protection_mode.value_namespace = name_space;
protection_mode.value_namespace_prefix = name_space_prefix;
}
if(value_path == "wait-to-restore-time")
{
wait_to_restore_time = value;
wait_to_restore_time.value_namespace = name_space;
wait_to_restore_time.value_namespace_prefix = name_space_prefix;
}
if(value_path == "hold-off-time")
{
hold_off_time = value;
hold_off_time.value_namespace = name_space;
hold_off_time.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-prot-profile-type")
{
path_prot_profile_type = value;
path_prot_profile_type.value_namespace = name_space;
path_prot_profile_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "restoration-style")
{
restoration_style = value;
restoration_style.value_namespace = name_space;
restoration_style.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "snc-mode")
{
snc_mode.yfilter = yfilter;
}
if(value_path == "tcm-id")
{
tcm_id.yfilter = yfilter;
}
if(value_path == "protection-type")
{
protection_type.yfilter = yfilter;
}
if(value_path == "protection-mode")
{
protection_mode.yfilter = yfilter;
}
if(value_path == "wait-to-restore-time")
{
wait_to_restore_time.yfilter = yfilter;
}
if(value_path == "hold-off-time")
{
hold_off_time.yfilter = yfilter;
}
if(value_path == "path-prot-profile-type")
{
path_prot_profile_type.yfilter = yfilter;
}
if(value_path == "restoration-style")
{
restoration_style.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "revert-schedule" || name == "snc-mode" || name == "tcm-id" || name == "protection-type" || name == "protection-mode" || name == "wait-to-restore-time" || name == "hold-off-time" || name == "path-prot-profile-type" || name == "restoration-style")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::RevertSchedule()
:
schedulename{YType::str, "schedulename"},
schedule_date{YType::uint32, "schedule-date"},
schedule_frequency{YType::enumeration, "schedule-frequency"},
duration{YType::uint32, "duration"},
max_tries{YType::uint32, "max-tries"}
{
yang_name = "revert-schedule"; yang_parent_name = "attribute-set-aps-pp"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::~RevertSchedule()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::has_data() const
{
if (is_presence_container) return true;
return schedulename.is_set
|| schedule_date.is_set
|| schedule_frequency.is_set
|| duration.is_set
|| max_tries.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(schedulename.yfilter)
|| ydk::is_set(schedule_date.yfilter)
|| ydk::is_set(schedule_frequency.yfilter)
|| ydk::is_set(duration.yfilter)
|| ydk::is_set(max_tries.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "revert-schedule";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (schedulename.is_set || is_set(schedulename.yfilter)) leaf_name_data.push_back(schedulename.get_name_leafdata());
if (schedule_date.is_set || is_set(schedule_date.yfilter)) leaf_name_data.push_back(schedule_date.get_name_leafdata());
if (schedule_frequency.is_set || is_set(schedule_frequency.yfilter)) leaf_name_data.push_back(schedule_frequency.get_name_leafdata());
if (duration.is_set || is_set(duration.yfilter)) leaf_name_data.push_back(duration.get_name_leafdata());
if (max_tries.is_set || is_set(max_tries.yfilter)) leaf_name_data.push_back(max_tries.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "schedulename")
{
schedulename = value;
schedulename.value_namespace = name_space;
schedulename.value_namespace_prefix = name_space_prefix;
}
if(value_path == "schedule-date")
{
schedule_date = value;
schedule_date.value_namespace = name_space;
schedule_date.value_namespace_prefix = name_space_prefix;
}
if(value_path == "schedule-frequency")
{
schedule_frequency = value;
schedule_frequency.value_namespace = name_space;
schedule_frequency.value_namespace_prefix = name_space_prefix;
}
if(value_path == "duration")
{
duration = value;
duration.value_namespace = name_space;
duration.value_namespace_prefix = name_space_prefix;
}
if(value_path == "max-tries")
{
max_tries = value;
max_tries.value_namespace = name_space;
max_tries.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "schedulename")
{
schedulename.yfilter = yfilter;
}
if(value_path == "schedule-date")
{
schedule_date.yfilter = yfilter;
}
if(value_path == "schedule-frequency")
{
schedule_frequency.yfilter = yfilter;
}
if(value_path == "duration")
{
duration.yfilter = yfilter;
}
if(value_path == "max-tries")
{
max_tries.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "schedulename" || name == "schedule-date" || name == "schedule-frequency" || name == "duration" || name == "max-tries")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::AttributeSetP2pTe()
:
is_affinity_configured{YType::boolean, "is-affinity-configured"},
path_selection_segment_routing_adjacency_protection{YType::enumeration, "path-selection-segment-routing-adjacency-protection"},
is_path_selection_segment_routing_adjacency_protection_configured{YType::boolean, "is-path-selection-segment-routing-adjacency-protection-configured"},
path_invalidation_timeout{YType::uint32, "path-invalidation-timeout"},
path_selection_invalidation_action{YType::enumeration, "path-selection-invalidation-action"},
is_path_invalidation_timeout_configured{YType::boolean, "is-path-invalidation-timeout-configured"},
is_path_invalidation_action_configured{YType::boolean, "is-path-invalidation-action-configured"},
path_selection_metric{YType::enumeration, "path-selection-metric"},
is_path_selection_metric_configured{YType::boolean, "is-path-selection-metric-configured"},
path_selection_segment_routing_margin{YType::uint32, "path-selection-segment-routing-margin"},
is_path_selection_segment_routing_margin_relative{YType::boolean, "is-path-selection-segment-routing-margin-relative"},
is_path_selection_segment_routing_margin_configured{YType::boolean, "is-path-selection-segment-routing-margin-configured"},
path_selection_segment_routing_segment_limit{YType::uint32, "path-selection-segment-routing-segment-limit"},
is_path_selection_segment_routing_segment_limit_configured{YType::boolean, "is-path-selection-segment-routing-segment-limit-configured"},
is_path_select_configured{YType::boolean, "is-path-select-configured"},
is_prepend_list_configured{YType::boolean, "is-prepend-list-configured"},
is_pce_configured{YType::boolean, "is-pce-configured"},
is_pce_disj_source_configured{YType::boolean, "is-pce-disj-source-configured"},
is_pce_disj_type_configured{YType::boolean, "is-pce-disj-type-configured"},
is_pce_disj_group_id_configured{YType::boolean, "is-pce-disj-group-id-configured"},
pcedp_source_address{YType::uint32, "pcedp-source-address"},
pcedp_type{YType::enumeration, "pcedp-type"},
pcedp_group_id{YType::uint32, "pcedp-group-id"},
is_pceb_dj_source_configured{YType::boolean, "is-pceb-dj-source-configured"},
is_pcebd_group_id_configured{YType::boolean, "is-pcebd-group-id-configured"},
pcebd_source_address{YType::uint32, "pcebd-source-address"},
pcebd_group_id{YType::uint32, "pcebd-group-id"}
,
affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity>())
, logging(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging>())
, prepend_list(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList>())
, tunnel_id(this, {})
{
affinity->parent = this;
logging->parent = this;
prepend_list->parent = this;
yang_name = "attribute-set-p2p-te"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::~AttributeSetP2pTe()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_data())
return true;
}
return is_affinity_configured.is_set
|| path_selection_segment_routing_adjacency_protection.is_set
|| is_path_selection_segment_routing_adjacency_protection_configured.is_set
|| path_invalidation_timeout.is_set
|| path_selection_invalidation_action.is_set
|| is_path_invalidation_timeout_configured.is_set
|| is_path_invalidation_action_configured.is_set
|| path_selection_metric.is_set
|| is_path_selection_metric_configured.is_set
|| path_selection_segment_routing_margin.is_set
|| is_path_selection_segment_routing_margin_relative.is_set
|| is_path_selection_segment_routing_margin_configured.is_set
|| path_selection_segment_routing_segment_limit.is_set
|| is_path_selection_segment_routing_segment_limit_configured.is_set
|| is_path_select_configured.is_set
|| is_prepend_list_configured.is_set
|| is_pce_configured.is_set
|| is_pce_disj_source_configured.is_set
|| is_pce_disj_type_configured.is_set
|| is_pce_disj_group_id_configured.is_set
|| pcedp_source_address.is_set
|| pcedp_type.is_set
|| pcedp_group_id.is_set
|| is_pceb_dj_source_configured.is_set
|| is_pcebd_group_id_configured.is_set
|| pcebd_source_address.is_set
|| pcebd_group_id.is_set
|| (affinity != nullptr && affinity->has_data())
|| (logging != nullptr && logging->has_data())
|| (prepend_list != nullptr && prepend_list->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::has_operation() const
{
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(is_affinity_configured.yfilter)
|| ydk::is_set(path_selection_segment_routing_adjacency_protection.yfilter)
|| ydk::is_set(is_path_selection_segment_routing_adjacency_protection_configured.yfilter)
|| ydk::is_set(path_invalidation_timeout.yfilter)
|| ydk::is_set(path_selection_invalidation_action.yfilter)
|| ydk::is_set(is_path_invalidation_timeout_configured.yfilter)
|| ydk::is_set(is_path_invalidation_action_configured.yfilter)
|| ydk::is_set(path_selection_metric.yfilter)
|| ydk::is_set(is_path_selection_metric_configured.yfilter)
|| ydk::is_set(path_selection_segment_routing_margin.yfilter)
|| ydk::is_set(is_path_selection_segment_routing_margin_relative.yfilter)
|| ydk::is_set(is_path_selection_segment_routing_margin_configured.yfilter)
|| ydk::is_set(path_selection_segment_routing_segment_limit.yfilter)
|| ydk::is_set(is_path_selection_segment_routing_segment_limit_configured.yfilter)
|| ydk::is_set(is_path_select_configured.yfilter)
|| ydk::is_set(is_prepend_list_configured.yfilter)
|| ydk::is_set(is_pce_configured.yfilter)
|| ydk::is_set(is_pce_disj_source_configured.yfilter)
|| ydk::is_set(is_pce_disj_type_configured.yfilter)
|| ydk::is_set(is_pce_disj_group_id_configured.yfilter)
|| ydk::is_set(pcedp_source_address.yfilter)
|| ydk::is_set(pcedp_type.yfilter)
|| ydk::is_set(pcedp_group_id.yfilter)
|| ydk::is_set(is_pceb_dj_source_configured.yfilter)
|| ydk::is_set(is_pcebd_group_id_configured.yfilter)
|| ydk::is_set(pcebd_source_address.yfilter)
|| ydk::is_set(pcebd_group_id.yfilter)
|| (affinity != nullptr && affinity->has_operation())
|| (logging != nullptr && logging->has_operation())
|| (prepend_list != nullptr && prepend_list->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-p2p-te";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata());
if (path_selection_segment_routing_adjacency_protection.is_set || is_set(path_selection_segment_routing_adjacency_protection.yfilter)) leaf_name_data.push_back(path_selection_segment_routing_adjacency_protection.get_name_leafdata());
if (is_path_selection_segment_routing_adjacency_protection_configured.is_set || is_set(is_path_selection_segment_routing_adjacency_protection_configured.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_adjacency_protection_configured.get_name_leafdata());
if (path_invalidation_timeout.is_set || is_set(path_invalidation_timeout.yfilter)) leaf_name_data.push_back(path_invalidation_timeout.get_name_leafdata());
if (path_selection_invalidation_action.is_set || is_set(path_selection_invalidation_action.yfilter)) leaf_name_data.push_back(path_selection_invalidation_action.get_name_leafdata());
if (is_path_invalidation_timeout_configured.is_set || is_set(is_path_invalidation_timeout_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_timeout_configured.get_name_leafdata());
if (is_path_invalidation_action_configured.is_set || is_set(is_path_invalidation_action_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_action_configured.get_name_leafdata());
if (path_selection_metric.is_set || is_set(path_selection_metric.yfilter)) leaf_name_data.push_back(path_selection_metric.get_name_leafdata());
if (is_path_selection_metric_configured.is_set || is_set(is_path_selection_metric_configured.yfilter)) leaf_name_data.push_back(is_path_selection_metric_configured.get_name_leafdata());
if (path_selection_segment_routing_margin.is_set || is_set(path_selection_segment_routing_margin.yfilter)) leaf_name_data.push_back(path_selection_segment_routing_margin.get_name_leafdata());
if (is_path_selection_segment_routing_margin_relative.is_set || is_set(is_path_selection_segment_routing_margin_relative.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_margin_relative.get_name_leafdata());
if (is_path_selection_segment_routing_margin_configured.is_set || is_set(is_path_selection_segment_routing_margin_configured.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_margin_configured.get_name_leafdata());
if (path_selection_segment_routing_segment_limit.is_set || is_set(path_selection_segment_routing_segment_limit.yfilter)) leaf_name_data.push_back(path_selection_segment_routing_segment_limit.get_name_leafdata());
if (is_path_selection_segment_routing_segment_limit_configured.is_set || is_set(is_path_selection_segment_routing_segment_limit_configured.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_segment_limit_configured.get_name_leafdata());
if (is_path_select_configured.is_set || is_set(is_path_select_configured.yfilter)) leaf_name_data.push_back(is_path_select_configured.get_name_leafdata());
if (is_prepend_list_configured.is_set || is_set(is_prepend_list_configured.yfilter)) leaf_name_data.push_back(is_prepend_list_configured.get_name_leafdata());
if (is_pce_configured.is_set || is_set(is_pce_configured.yfilter)) leaf_name_data.push_back(is_pce_configured.get_name_leafdata());
if (is_pce_disj_source_configured.is_set || is_set(is_pce_disj_source_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_source_configured.get_name_leafdata());
if (is_pce_disj_type_configured.is_set || is_set(is_pce_disj_type_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_type_configured.get_name_leafdata());
if (is_pce_disj_group_id_configured.is_set || is_set(is_pce_disj_group_id_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_group_id_configured.get_name_leafdata());
if (pcedp_source_address.is_set || is_set(pcedp_source_address.yfilter)) leaf_name_data.push_back(pcedp_source_address.get_name_leafdata());
if (pcedp_type.is_set || is_set(pcedp_type.yfilter)) leaf_name_data.push_back(pcedp_type.get_name_leafdata());
if (pcedp_group_id.is_set || is_set(pcedp_group_id.yfilter)) leaf_name_data.push_back(pcedp_group_id.get_name_leafdata());
if (is_pceb_dj_source_configured.is_set || is_set(is_pceb_dj_source_configured.yfilter)) leaf_name_data.push_back(is_pceb_dj_source_configured.get_name_leafdata());
if (is_pcebd_group_id_configured.is_set || is_set(is_pcebd_group_id_configured.yfilter)) leaf_name_data.push_back(is_pcebd_group_id_configured.get_name_leafdata());
if (pcebd_source_address.is_set || is_set(pcebd_source_address.yfilter)) leaf_name_data.push_back(pcebd_source_address.get_name_leafdata());
if (pcebd_group_id.is_set || is_set(pcebd_group_id.yfilter)) leaf_name_data.push_back(pcebd_group_id.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "affinity")
{
if(affinity == nullptr)
{
affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity>();
}
return affinity;
}
if(child_yang_name == "logging")
{
if(logging == nullptr)
{
logging = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging>();
}
return logging;
}
if(child_yang_name == "prepend-list")
{
if(prepend_list == nullptr)
{
prepend_list = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList>();
}
return prepend_list;
}
if(child_yang_name == "tunnel-id")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId>();
ent_->parent = this;
tunnel_id.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(affinity != nullptr)
{
_children["affinity"] = affinity;
}
if(logging != nullptr)
{
_children["logging"] = logging;
}
if(prepend_list != nullptr)
{
_children["prepend-list"] = prepend_list;
}
count_ = 0;
for (auto ent_ : tunnel_id.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "is-affinity-configured")
{
is_affinity_configured = value;
is_affinity_configured.value_namespace = name_space;
is_affinity_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-selection-segment-routing-adjacency-protection")
{
path_selection_segment_routing_adjacency_protection = value;
path_selection_segment_routing_adjacency_protection.value_namespace = name_space;
path_selection_segment_routing_adjacency_protection.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-selection-segment-routing-adjacency-protection-configured")
{
is_path_selection_segment_routing_adjacency_protection_configured = value;
is_path_selection_segment_routing_adjacency_protection_configured.value_namespace = name_space;
is_path_selection_segment_routing_adjacency_protection_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-invalidation-timeout")
{
path_invalidation_timeout = value;
path_invalidation_timeout.value_namespace = name_space;
path_invalidation_timeout.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-selection-invalidation-action")
{
path_selection_invalidation_action = value;
path_selection_invalidation_action.value_namespace = name_space;
path_selection_invalidation_action.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-invalidation-timeout-configured")
{
is_path_invalidation_timeout_configured = value;
is_path_invalidation_timeout_configured.value_namespace = name_space;
is_path_invalidation_timeout_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-invalidation-action-configured")
{
is_path_invalidation_action_configured = value;
is_path_invalidation_action_configured.value_namespace = name_space;
is_path_invalidation_action_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-selection-metric")
{
path_selection_metric = value;
path_selection_metric.value_namespace = name_space;
path_selection_metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-selection-metric-configured")
{
is_path_selection_metric_configured = value;
is_path_selection_metric_configured.value_namespace = name_space;
is_path_selection_metric_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-selection-segment-routing-margin")
{
path_selection_segment_routing_margin = value;
path_selection_segment_routing_margin.value_namespace = name_space;
path_selection_segment_routing_margin.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-selection-segment-routing-margin-relative")
{
is_path_selection_segment_routing_margin_relative = value;
is_path_selection_segment_routing_margin_relative.value_namespace = name_space;
is_path_selection_segment_routing_margin_relative.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-selection-segment-routing-margin-configured")
{
is_path_selection_segment_routing_margin_configured = value;
is_path_selection_segment_routing_margin_configured.value_namespace = name_space;
is_path_selection_segment_routing_margin_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-selection-segment-routing-segment-limit")
{
path_selection_segment_routing_segment_limit = value;
path_selection_segment_routing_segment_limit.value_namespace = name_space;
path_selection_segment_routing_segment_limit.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-selection-segment-routing-segment-limit-configured")
{
is_path_selection_segment_routing_segment_limit_configured = value;
is_path_selection_segment_routing_segment_limit_configured.value_namespace = name_space;
is_path_selection_segment_routing_segment_limit_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-select-configured")
{
is_path_select_configured = value;
is_path_select_configured.value_namespace = name_space;
is_path_select_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-prepend-list-configured")
{
is_prepend_list_configured = value;
is_prepend_list_configured.value_namespace = name_space;
is_prepend_list_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-configured")
{
is_pce_configured = value;
is_pce_configured.value_namespace = name_space;
is_pce_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-disj-source-configured")
{
is_pce_disj_source_configured = value;
is_pce_disj_source_configured.value_namespace = name_space;
is_pce_disj_source_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-disj-type-configured")
{
is_pce_disj_type_configured = value;
is_pce_disj_type_configured.value_namespace = name_space;
is_pce_disj_type_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-disj-group-id-configured")
{
is_pce_disj_group_id_configured = value;
is_pce_disj_group_id_configured.value_namespace = name_space;
is_pce_disj_group_id_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcedp-source-address")
{
pcedp_source_address = value;
pcedp_source_address.value_namespace = name_space;
pcedp_source_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcedp-type")
{
pcedp_type = value;
pcedp_type.value_namespace = name_space;
pcedp_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcedp-group-id")
{
pcedp_group_id = value;
pcedp_group_id.value_namespace = name_space;
pcedp_group_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pceb-dj-source-configured")
{
is_pceb_dj_source_configured = value;
is_pceb_dj_source_configured.value_namespace = name_space;
is_pceb_dj_source_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pcebd-group-id-configured")
{
is_pcebd_group_id_configured = value;
is_pcebd_group_id_configured.value_namespace = name_space;
is_pcebd_group_id_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcebd-source-address")
{
pcebd_source_address = value;
pcebd_source_address.value_namespace = name_space;
pcebd_source_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcebd-group-id")
{
pcebd_group_id = value;
pcebd_group_id.value_namespace = name_space;
pcebd_group_id.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "is-affinity-configured")
{
is_affinity_configured.yfilter = yfilter;
}
if(value_path == "path-selection-segment-routing-adjacency-protection")
{
path_selection_segment_routing_adjacency_protection.yfilter = yfilter;
}
if(value_path == "is-path-selection-segment-routing-adjacency-protection-configured")
{
is_path_selection_segment_routing_adjacency_protection_configured.yfilter = yfilter;
}
if(value_path == "path-invalidation-timeout")
{
path_invalidation_timeout.yfilter = yfilter;
}
if(value_path == "path-selection-invalidation-action")
{
path_selection_invalidation_action.yfilter = yfilter;
}
if(value_path == "is-path-invalidation-timeout-configured")
{
is_path_invalidation_timeout_configured.yfilter = yfilter;
}
if(value_path == "is-path-invalidation-action-configured")
{
is_path_invalidation_action_configured.yfilter = yfilter;
}
if(value_path == "path-selection-metric")
{
path_selection_metric.yfilter = yfilter;
}
if(value_path == "is-path-selection-metric-configured")
{
is_path_selection_metric_configured.yfilter = yfilter;
}
if(value_path == "path-selection-segment-routing-margin")
{
path_selection_segment_routing_margin.yfilter = yfilter;
}
if(value_path == "is-path-selection-segment-routing-margin-relative")
{
is_path_selection_segment_routing_margin_relative.yfilter = yfilter;
}
if(value_path == "is-path-selection-segment-routing-margin-configured")
{
is_path_selection_segment_routing_margin_configured.yfilter = yfilter;
}
if(value_path == "path-selection-segment-routing-segment-limit")
{
path_selection_segment_routing_segment_limit.yfilter = yfilter;
}
if(value_path == "is-path-selection-segment-routing-segment-limit-configured")
{
is_path_selection_segment_routing_segment_limit_configured.yfilter = yfilter;
}
if(value_path == "is-path-select-configured")
{
is_path_select_configured.yfilter = yfilter;
}
if(value_path == "is-prepend-list-configured")
{
is_prepend_list_configured.yfilter = yfilter;
}
if(value_path == "is-pce-configured")
{
is_pce_configured.yfilter = yfilter;
}
if(value_path == "is-pce-disj-source-configured")
{
is_pce_disj_source_configured.yfilter = yfilter;
}
if(value_path == "is-pce-disj-type-configured")
{
is_pce_disj_type_configured.yfilter = yfilter;
}
if(value_path == "is-pce-disj-group-id-configured")
{
is_pce_disj_group_id_configured.yfilter = yfilter;
}
if(value_path == "pcedp-source-address")
{
pcedp_source_address.yfilter = yfilter;
}
if(value_path == "pcedp-type")
{
pcedp_type.yfilter = yfilter;
}
if(value_path == "pcedp-group-id")
{
pcedp_group_id.yfilter = yfilter;
}
if(value_path == "is-pceb-dj-source-configured")
{
is_pceb_dj_source_configured.yfilter = yfilter;
}
if(value_path == "is-pcebd-group-id-configured")
{
is_pcebd_group_id_configured.yfilter = yfilter;
}
if(value_path == "pcebd-source-address")
{
pcebd_source_address.yfilter = yfilter;
}
if(value_path == "pcebd-group-id")
{
pcebd_group_id.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "affinity" || name == "logging" || name == "prepend-list" || name == "tunnel-id" || name == "is-affinity-configured" || name == "path-selection-segment-routing-adjacency-protection" || name == "is-path-selection-segment-routing-adjacency-protection-configured" || name == "path-invalidation-timeout" || name == "path-selection-invalidation-action" || name == "is-path-invalidation-timeout-configured" || name == "is-path-invalidation-action-configured" || name == "path-selection-metric" || name == "is-path-selection-metric-configured" || name == "path-selection-segment-routing-margin" || name == "is-path-selection-segment-routing-margin-relative" || name == "is-path-selection-segment-routing-margin-configured" || name == "path-selection-segment-routing-segment-limit" || name == "is-path-selection-segment-routing-segment-limit-configured" || name == "is-path-select-configured" || name == "is-prepend-list-configured" || name == "is-pce-configured" || name == "is-pce-disj-source-configured" || name == "is-pce-disj-type-configured" || name == "is-pce-disj-group-id-configured" || name == "pcedp-source-address" || name == "pcedp-type" || name == "pcedp-group-id" || name == "is-pceb-dj-source-configured" || name == "is-pcebd-group-id-configured" || name == "pcebd-source-address" || name == "pcebd-group-id")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::Affinity()
:
affinity_bits{YType::uint32, "affinity-bits"},
affinity_mask{YType::uint32, "affinity-mask"}
,
named_affinity(this, {})
{
yang_name = "affinity"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::~Affinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_data())
return true;
}
return affinity_bits.is_set
|| affinity_mask.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::has_operation() const
{
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(affinity_bits.yfilter)
|| ydk::is_set(affinity_mask.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "affinity";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata());
if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "named-affinity")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity>();
ent_->parent = this;
named_affinity.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : named_affinity.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "affinity-bits")
{
affinity_bits = value;
affinity_bits.value_namespace = name_space;
affinity_bits.value_namespace_prefix = name_space_prefix;
}
if(value_path == "affinity-mask")
{
affinity_mask = value;
affinity_mask.value_namespace = name_space;
affinity_mask.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "affinity-bits")
{
affinity_bits.yfilter = yfilter;
}
if(value_path == "affinity-mask")
{
affinity_mask.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::NamedAffinity()
:
constraint_type{YType::uint8, "constraint-type"},
constraint_value{YType::uint32, "constraint-value"},
forward_ref_value{YType::uint32, "forward-ref-value"}
,
constraint_extended_value(this, {})
, extended_forward_ref_value(this, {})
{
yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::~NamedAffinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_data())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_data())
return true;
}
return constraint_type.is_set
|| constraint_value.is_set
|| forward_ref_value.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::has_operation() const
{
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_operation())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(constraint_type.yfilter)
|| ydk::is_set(constraint_value.yfilter)
|| ydk::is_set(forward_ref_value.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "named-affinity";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata());
if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata());
if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "constraint-extended-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue>();
ent_->parent = this;
constraint_extended_value.append(ent_);
return ent_;
}
if(child_yang_name == "extended-forward-ref-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue>();
ent_->parent = this;
extended_forward_ref_value.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : constraint_extended_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : extended_forward_ref_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "constraint-type")
{
constraint_type = value;
constraint_type.value_namespace = name_space;
constraint_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "constraint-value")
{
constraint_value = value;
constraint_value.value_namespace = name_space;
constraint_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "forward-ref-value")
{
forward_ref_value = value;
forward_ref_value.value_namespace = name_space;
forward_ref_value.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "constraint-type")
{
constraint_type.yfilter = yfilter;
}
if(value_path == "constraint-value")
{
constraint_value.yfilter = yfilter;
}
if(value_path == "forward-ref-value")
{
forward_ref_value.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "constraint-extended-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "extended-forward-ref-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::Logging()
:
lsp_state{YType::boolean, "lsp-state"},
s2l_state{YType::boolean, "s2l-state"},
lsp_re_route{YType::boolean, "lsp-re-route"},
lsp_re_opt{YType::boolean, "lsp-re-opt"},
lsp_insufficient_bw{YType::boolean, "lsp-insufficient-bw"},
lsp_bandwidth_change{YType::boolean, "lsp-bandwidth-change"},
lsp_pcalc_failure_logging_enabled{YType::boolean, "lsp-pcalc-failure-logging-enabled"},
all_logging_enabled{YType::boolean, "all-logging-enabled"}
{
yang_name = "logging"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::~Logging()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::has_data() const
{
if (is_presence_container) return true;
return lsp_state.is_set
|| s2l_state.is_set
|| lsp_re_route.is_set
|| lsp_re_opt.is_set
|| lsp_insufficient_bw.is_set
|| lsp_bandwidth_change.is_set
|| lsp_pcalc_failure_logging_enabled.is_set
|| all_logging_enabled.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lsp_state.yfilter)
|| ydk::is_set(s2l_state.yfilter)
|| ydk::is_set(lsp_re_route.yfilter)
|| ydk::is_set(lsp_re_opt.yfilter)
|| ydk::is_set(lsp_insufficient_bw.yfilter)
|| ydk::is_set(lsp_bandwidth_change.yfilter)
|| ydk::is_set(lsp_pcalc_failure_logging_enabled.yfilter)
|| ydk::is_set(all_logging_enabled.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "logging";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lsp_state.is_set || is_set(lsp_state.yfilter)) leaf_name_data.push_back(lsp_state.get_name_leafdata());
if (s2l_state.is_set || is_set(s2l_state.yfilter)) leaf_name_data.push_back(s2l_state.get_name_leafdata());
if (lsp_re_route.is_set || is_set(lsp_re_route.yfilter)) leaf_name_data.push_back(lsp_re_route.get_name_leafdata());
if (lsp_re_opt.is_set || is_set(lsp_re_opt.yfilter)) leaf_name_data.push_back(lsp_re_opt.get_name_leafdata());
if (lsp_insufficient_bw.is_set || is_set(lsp_insufficient_bw.yfilter)) leaf_name_data.push_back(lsp_insufficient_bw.get_name_leafdata());
if (lsp_bandwidth_change.is_set || is_set(lsp_bandwidth_change.yfilter)) leaf_name_data.push_back(lsp_bandwidth_change.get_name_leafdata());
if (lsp_pcalc_failure_logging_enabled.is_set || is_set(lsp_pcalc_failure_logging_enabled.yfilter)) leaf_name_data.push_back(lsp_pcalc_failure_logging_enabled.get_name_leafdata());
if (all_logging_enabled.is_set || is_set(all_logging_enabled.yfilter)) leaf_name_data.push_back(all_logging_enabled.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "lsp-state")
{
lsp_state = value;
lsp_state.value_namespace = name_space;
lsp_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-state")
{
s2l_state = value;
s2l_state.value_namespace = name_space;
s2l_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-re-route")
{
lsp_re_route = value;
lsp_re_route.value_namespace = name_space;
lsp_re_route.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-re-opt")
{
lsp_re_opt = value;
lsp_re_opt.value_namespace = name_space;
lsp_re_opt.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-insufficient-bw")
{
lsp_insufficient_bw = value;
lsp_insufficient_bw.value_namespace = name_space;
lsp_insufficient_bw.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-bandwidth-change")
{
lsp_bandwidth_change = value;
lsp_bandwidth_change.value_namespace = name_space;
lsp_bandwidth_change.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-pcalc-failure-logging-enabled")
{
lsp_pcalc_failure_logging_enabled = value;
lsp_pcalc_failure_logging_enabled.value_namespace = name_space;
lsp_pcalc_failure_logging_enabled.value_namespace_prefix = name_space_prefix;
}
if(value_path == "all-logging-enabled")
{
all_logging_enabled = value;
all_logging_enabled.value_namespace = name_space;
all_logging_enabled.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "lsp-state")
{
lsp_state.yfilter = yfilter;
}
if(value_path == "s2l-state")
{
s2l_state.yfilter = yfilter;
}
if(value_path == "lsp-re-route")
{
lsp_re_route.yfilter = yfilter;
}
if(value_path == "lsp-re-opt")
{
lsp_re_opt.yfilter = yfilter;
}
if(value_path == "lsp-insufficient-bw")
{
lsp_insufficient_bw.yfilter = yfilter;
}
if(value_path == "lsp-bandwidth-change")
{
lsp_bandwidth_change.yfilter = yfilter;
}
if(value_path == "lsp-pcalc-failure-logging-enabled")
{
lsp_pcalc_failure_logging_enabled.yfilter = yfilter;
}
if(value_path == "all-logging-enabled")
{
all_logging_enabled.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "lsp-state" || name == "s2l-state" || name == "lsp-re-route" || name == "lsp-re-opt" || name == "lsp-insufficient-bw" || name == "lsp-bandwidth-change" || name == "lsp-pcalc-failure-logging-enabled" || name == "all-logging-enabled")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependList()
:
prepend_entry(this, {})
{
yang_name = "prepend-list"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::~PrependList()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<prepend_entry.len(); index++)
{
if(prepend_entry[index]->has_data())
return true;
}
return false;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::has_operation() const
{
for (std::size_t index=0; index<prepend_entry.len(); index++)
{
if(prepend_entry[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "prepend-list";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "prepend-entry")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry>();
ent_->parent = this;
prepend_entry.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : prepend_entry.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "prepend-entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::PrependEntry()
:
type{YType::enumeration, "type"},
index_{YType::uint32, "index"},
next_label{YType::uint32, "next-label"}
{
yang_name = "prepend-entry"; yang_parent_name = "prepend-list"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::~PrependEntry()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::has_data() const
{
if (is_presence_container) return true;
return type.is_set
|| index_.is_set
|| next_label.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(type.yfilter)
|| ydk::is_set(index_.yfilter)
|| ydk::is_set(next_label.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "prepend-entry";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata());
if (index_.is_set || is_set(index_.yfilter)) leaf_name_data.push_back(index_.get_name_leafdata());
if (next_label.is_set || is_set(next_label.yfilter)) leaf_name_data.push_back(next_label.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "type")
{
type = value;
type.value_namespace = name_space;
type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "index")
{
index_ = value;
index_.value_namespace = name_space;
index_.value_namespace_prefix = name_space_prefix;
}
if(value_path == "next-label")
{
next_label = value;
next_label.value_namespace = name_space;
next_label.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "type")
{
type.yfilter = yfilter;
}
if(value_path == "index")
{
index_.yfilter = yfilter;
}
if(value_path == "next-label")
{
next_label.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "type" || name == "index" || name == "next-label")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::TunnelId()
:
entry{YType::uint16, "entry"}
{
yang_name = "tunnel-id"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::~TunnelId()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tunnel-id";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::XroAttributeSet()
:
tunnel_attribute_set_name{YType::str, "tunnel-attribute-set-name"},
tunnel_attribute_set_name_crc32{YType::uint32, "tunnel-attribute-set-name-crc32"}
,
attribute_set_union(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion>())
{
attribute_set_union->parent = this;
yang_name = "xro-attribute-set"; yang_parent_name = "active-path-option"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::~XroAttributeSet()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::has_data() const
{
if (is_presence_container) return true;
return tunnel_attribute_set_name.is_set
|| tunnel_attribute_set_name_crc32.is_set
|| (attribute_set_union != nullptr && attribute_set_union->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(tunnel_attribute_set_name.yfilter)
|| ydk::is_set(tunnel_attribute_set_name_crc32.yfilter)
|| (attribute_set_union != nullptr && attribute_set_union->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "xro-attribute-set";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (tunnel_attribute_set_name.is_set || is_set(tunnel_attribute_set_name.yfilter)) leaf_name_data.push_back(tunnel_attribute_set_name.get_name_leafdata());
if (tunnel_attribute_set_name_crc32.is_set || is_set(tunnel_attribute_set_name_crc32.yfilter)) leaf_name_data.push_back(tunnel_attribute_set_name_crc32.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "attribute-set-union")
{
if(attribute_set_union == nullptr)
{
attribute_set_union = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion>();
}
return attribute_set_union;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(attribute_set_union != nullptr)
{
_children["attribute-set-union"] = attribute_set_union;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "tunnel-attribute-set-name")
{
tunnel_attribute_set_name = value;
tunnel_attribute_set_name.value_namespace = name_space;
tunnel_attribute_set_name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "tunnel-attribute-set-name-crc32")
{
tunnel_attribute_set_name_crc32 = value;
tunnel_attribute_set_name_crc32.value_namespace = name_space;
tunnel_attribute_set_name_crc32.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "tunnel-attribute-set-name")
{
tunnel_attribute_set_name.yfilter = yfilter;
}
if(value_path == "tunnel-attribute-set-name-crc32")
{
tunnel_attribute_set_name_crc32.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "attribute-set-union" || name == "tunnel-attribute-set-name" || name == "tunnel-attribute-set-name-crc32")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetUnion()
:
tunnel_attribute_set_type{YType::enumeration, "tunnel-attribute-set-type"}
,
attribute_set_path_option(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption>())
, attribute_set_autobackup(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup>())
, attribute_set_automesh(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh>())
, attribute_set_xro(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro>())
, attribute_set_p2mpte(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte>())
, attribute_set_aps_pp(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp>())
, attribute_set_p2p_te(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe>())
{
attribute_set_path_option->parent = this;
attribute_set_autobackup->parent = this;
attribute_set_automesh->parent = this;
attribute_set_xro->parent = this;
attribute_set_p2mpte->parent = this;
attribute_set_aps_pp->parent = this;
attribute_set_p2p_te->parent = this;
yang_name = "attribute-set-union"; yang_parent_name = "xro-attribute-set"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::~AttributeSetUnion()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::has_data() const
{
if (is_presence_container) return true;
return tunnel_attribute_set_type.is_set
|| (attribute_set_path_option != nullptr && attribute_set_path_option->has_data())
|| (attribute_set_autobackup != nullptr && attribute_set_autobackup->has_data())
|| (attribute_set_automesh != nullptr && attribute_set_automesh->has_data())
|| (attribute_set_xro != nullptr && attribute_set_xro->has_data())
|| (attribute_set_p2mpte != nullptr && attribute_set_p2mpte->has_data())
|| (attribute_set_aps_pp != nullptr && attribute_set_aps_pp->has_data())
|| (attribute_set_p2p_te != nullptr && attribute_set_p2p_te->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(tunnel_attribute_set_type.yfilter)
|| (attribute_set_path_option != nullptr && attribute_set_path_option->has_operation())
|| (attribute_set_autobackup != nullptr && attribute_set_autobackup->has_operation())
|| (attribute_set_automesh != nullptr && attribute_set_automesh->has_operation())
|| (attribute_set_xro != nullptr && attribute_set_xro->has_operation())
|| (attribute_set_p2mpte != nullptr && attribute_set_p2mpte->has_operation())
|| (attribute_set_aps_pp != nullptr && attribute_set_aps_pp->has_operation())
|| (attribute_set_p2p_te != nullptr && attribute_set_p2p_te->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-union";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (tunnel_attribute_set_type.is_set || is_set(tunnel_attribute_set_type.yfilter)) leaf_name_data.push_back(tunnel_attribute_set_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "attribute-set-path-option")
{
if(attribute_set_path_option == nullptr)
{
attribute_set_path_option = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption>();
}
return attribute_set_path_option;
}
if(child_yang_name == "attribute-set-autobackup")
{
if(attribute_set_autobackup == nullptr)
{
attribute_set_autobackup = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup>();
}
return attribute_set_autobackup;
}
if(child_yang_name == "attribute-set-automesh")
{
if(attribute_set_automesh == nullptr)
{
attribute_set_automesh = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh>();
}
return attribute_set_automesh;
}
if(child_yang_name == "attribute-set-xro")
{
if(attribute_set_xro == nullptr)
{
attribute_set_xro = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro>();
}
return attribute_set_xro;
}
if(child_yang_name == "attribute-set-p2mpte")
{
if(attribute_set_p2mpte == nullptr)
{
attribute_set_p2mpte = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte>();
}
return attribute_set_p2mpte;
}
if(child_yang_name == "attribute-set-aps-pp")
{
if(attribute_set_aps_pp == nullptr)
{
attribute_set_aps_pp = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp>();
}
return attribute_set_aps_pp;
}
if(child_yang_name == "attribute-set-p2p-te")
{
if(attribute_set_p2p_te == nullptr)
{
attribute_set_p2p_te = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe>();
}
return attribute_set_p2p_te;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(attribute_set_path_option != nullptr)
{
_children["attribute-set-path-option"] = attribute_set_path_option;
}
if(attribute_set_autobackup != nullptr)
{
_children["attribute-set-autobackup"] = attribute_set_autobackup;
}
if(attribute_set_automesh != nullptr)
{
_children["attribute-set-automesh"] = attribute_set_automesh;
}
if(attribute_set_xro != nullptr)
{
_children["attribute-set-xro"] = attribute_set_xro;
}
if(attribute_set_p2mpte != nullptr)
{
_children["attribute-set-p2mpte"] = attribute_set_p2mpte;
}
if(attribute_set_aps_pp != nullptr)
{
_children["attribute-set-aps-pp"] = attribute_set_aps_pp;
}
if(attribute_set_p2p_te != nullptr)
{
_children["attribute-set-p2p-te"] = attribute_set_p2p_te;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "tunnel-attribute-set-type")
{
tunnel_attribute_set_type = value;
tunnel_attribute_set_type.value_namespace = name_space;
tunnel_attribute_set_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "tunnel-attribute-set-type")
{
tunnel_attribute_set_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "attribute-set-path-option" || name == "attribute-set-autobackup" || name == "attribute-set-automesh" || name == "attribute-set-xro" || name == "attribute-set-p2mpte" || name == "attribute-set-aps-pp" || name == "attribute-set-p2p-te" || name == "tunnel-attribute-set-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::AttributeSetPathOption()
:
configured_bandwidth{YType::uint32, "configured-bandwidth"},
cost_limit{YType::uint32, "cost-limit"},
dste_class_type{YType::uint8, "dste-class-type"},
bandwidth_type{YType::enumeration, "bandwidth-type"},
is_bandwidth_configured{YType::boolean, "is-bandwidth-configured"},
is_cost_limit_configured{YType::boolean, "is-cost-limit-configured"},
is_affinity_configured{YType::boolean, "is-affinity-configured"},
generation{YType::uint32, "generation"},
path_invalidation_timeout{YType::uint32, "path-invalidation-timeout"},
path_invalidation_action{YType::uint32, "path-invalidation-action"},
is_path_invalidation_timeout_configured{YType::boolean, "is-path-invalidation-timeout-configured"},
is_path_invalidation_action_configured{YType::boolean, "is-path-invalidation-action-configured"},
exclude_list_name{YType::str, "exclude-list-name"},
is_exclude_list_name_configured{YType::boolean, "is-exclude-list-name-configured"},
is_pce_configured{YType::boolean, "is-pce-configured"},
is_pce_disj_source_configured{YType::boolean, "is-pce-disj-source-configured"},
is_pce_disj_type_configured{YType::boolean, "is-pce-disj-type-configured"},
is_pce_disj_group_id_configured{YType::boolean, "is-pce-disj-group-id-configured"},
pcedp_source_address{YType::uint32, "pcedp-source-address"},
pcedp_type{YType::enumeration, "pcedp-type"},
pcedp_group_id{YType::uint32, "pcedp-group-id"},
is_pceb_dj_source_configured{YType::boolean, "is-pceb-dj-source-configured"},
is_pcebd_group_id_configured{YType::boolean, "is-pcebd-group-id-configured"},
pcebd_source_address{YType::uint32, "pcebd-source-address"},
pcebd_group_id{YType::uint32, "pcebd-group-id"},
is_bfd_reverse_pat_configured{YType::boolean, "is-bfd-reverse-pat-configured"},
is_delay_limit_configured{YType::boolean, "is-delay-limit-configured"},
delay_limit{YType::uint32, "delay-limit"}
,
affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity>())
, bfd_reverse_path(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath>())
, tunnel_id(this, {})
, version_info(this, {})
{
affinity->parent = this;
bfd_reverse_path->parent = this;
yang_name = "attribute-set-path-option"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::~AttributeSetPathOption()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_data())
return true;
}
for (std::size_t index=0; index<version_info.len(); index++)
{
if(version_info[index]->has_data())
return true;
}
return configured_bandwidth.is_set
|| cost_limit.is_set
|| dste_class_type.is_set
|| bandwidth_type.is_set
|| is_bandwidth_configured.is_set
|| is_cost_limit_configured.is_set
|| is_affinity_configured.is_set
|| generation.is_set
|| path_invalidation_timeout.is_set
|| path_invalidation_action.is_set
|| is_path_invalidation_timeout_configured.is_set
|| is_path_invalidation_action_configured.is_set
|| exclude_list_name.is_set
|| is_exclude_list_name_configured.is_set
|| is_pce_configured.is_set
|| is_pce_disj_source_configured.is_set
|| is_pce_disj_type_configured.is_set
|| is_pce_disj_group_id_configured.is_set
|| pcedp_source_address.is_set
|| pcedp_type.is_set
|| pcedp_group_id.is_set
|| is_pceb_dj_source_configured.is_set
|| is_pcebd_group_id_configured.is_set
|| pcebd_source_address.is_set
|| pcebd_group_id.is_set
|| is_bfd_reverse_pat_configured.is_set
|| is_delay_limit_configured.is_set
|| delay_limit.is_set
|| (affinity != nullptr && affinity->has_data())
|| (bfd_reverse_path != nullptr && bfd_reverse_path->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::has_operation() const
{
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_operation())
return true;
}
for (std::size_t index=0; index<version_info.len(); index++)
{
if(version_info[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(configured_bandwidth.yfilter)
|| ydk::is_set(cost_limit.yfilter)
|| ydk::is_set(dste_class_type.yfilter)
|| ydk::is_set(bandwidth_type.yfilter)
|| ydk::is_set(is_bandwidth_configured.yfilter)
|| ydk::is_set(is_cost_limit_configured.yfilter)
|| ydk::is_set(is_affinity_configured.yfilter)
|| ydk::is_set(generation.yfilter)
|| ydk::is_set(path_invalidation_timeout.yfilter)
|| ydk::is_set(path_invalidation_action.yfilter)
|| ydk::is_set(is_path_invalidation_timeout_configured.yfilter)
|| ydk::is_set(is_path_invalidation_action_configured.yfilter)
|| ydk::is_set(exclude_list_name.yfilter)
|| ydk::is_set(is_exclude_list_name_configured.yfilter)
|| ydk::is_set(is_pce_configured.yfilter)
|| ydk::is_set(is_pce_disj_source_configured.yfilter)
|| ydk::is_set(is_pce_disj_type_configured.yfilter)
|| ydk::is_set(is_pce_disj_group_id_configured.yfilter)
|| ydk::is_set(pcedp_source_address.yfilter)
|| ydk::is_set(pcedp_type.yfilter)
|| ydk::is_set(pcedp_group_id.yfilter)
|| ydk::is_set(is_pceb_dj_source_configured.yfilter)
|| ydk::is_set(is_pcebd_group_id_configured.yfilter)
|| ydk::is_set(pcebd_source_address.yfilter)
|| ydk::is_set(pcebd_group_id.yfilter)
|| ydk::is_set(is_bfd_reverse_pat_configured.yfilter)
|| ydk::is_set(is_delay_limit_configured.yfilter)
|| ydk::is_set(delay_limit.yfilter)
|| (affinity != nullptr && affinity->has_operation())
|| (bfd_reverse_path != nullptr && bfd_reverse_path->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-path-option";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (configured_bandwidth.is_set || is_set(configured_bandwidth.yfilter)) leaf_name_data.push_back(configured_bandwidth.get_name_leafdata());
if (cost_limit.is_set || is_set(cost_limit.yfilter)) leaf_name_data.push_back(cost_limit.get_name_leafdata());
if (dste_class_type.is_set || is_set(dste_class_type.yfilter)) leaf_name_data.push_back(dste_class_type.get_name_leafdata());
if (bandwidth_type.is_set || is_set(bandwidth_type.yfilter)) leaf_name_data.push_back(bandwidth_type.get_name_leafdata());
if (is_bandwidth_configured.is_set || is_set(is_bandwidth_configured.yfilter)) leaf_name_data.push_back(is_bandwidth_configured.get_name_leafdata());
if (is_cost_limit_configured.is_set || is_set(is_cost_limit_configured.yfilter)) leaf_name_data.push_back(is_cost_limit_configured.get_name_leafdata());
if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata());
if (generation.is_set || is_set(generation.yfilter)) leaf_name_data.push_back(generation.get_name_leafdata());
if (path_invalidation_timeout.is_set || is_set(path_invalidation_timeout.yfilter)) leaf_name_data.push_back(path_invalidation_timeout.get_name_leafdata());
if (path_invalidation_action.is_set || is_set(path_invalidation_action.yfilter)) leaf_name_data.push_back(path_invalidation_action.get_name_leafdata());
if (is_path_invalidation_timeout_configured.is_set || is_set(is_path_invalidation_timeout_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_timeout_configured.get_name_leafdata());
if (is_path_invalidation_action_configured.is_set || is_set(is_path_invalidation_action_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_action_configured.get_name_leafdata());
if (exclude_list_name.is_set || is_set(exclude_list_name.yfilter)) leaf_name_data.push_back(exclude_list_name.get_name_leafdata());
if (is_exclude_list_name_configured.is_set || is_set(is_exclude_list_name_configured.yfilter)) leaf_name_data.push_back(is_exclude_list_name_configured.get_name_leafdata());
if (is_pce_configured.is_set || is_set(is_pce_configured.yfilter)) leaf_name_data.push_back(is_pce_configured.get_name_leafdata());
if (is_pce_disj_source_configured.is_set || is_set(is_pce_disj_source_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_source_configured.get_name_leafdata());
if (is_pce_disj_type_configured.is_set || is_set(is_pce_disj_type_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_type_configured.get_name_leafdata());
if (is_pce_disj_group_id_configured.is_set || is_set(is_pce_disj_group_id_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_group_id_configured.get_name_leafdata());
if (pcedp_source_address.is_set || is_set(pcedp_source_address.yfilter)) leaf_name_data.push_back(pcedp_source_address.get_name_leafdata());
if (pcedp_type.is_set || is_set(pcedp_type.yfilter)) leaf_name_data.push_back(pcedp_type.get_name_leafdata());
if (pcedp_group_id.is_set || is_set(pcedp_group_id.yfilter)) leaf_name_data.push_back(pcedp_group_id.get_name_leafdata());
if (is_pceb_dj_source_configured.is_set || is_set(is_pceb_dj_source_configured.yfilter)) leaf_name_data.push_back(is_pceb_dj_source_configured.get_name_leafdata());
if (is_pcebd_group_id_configured.is_set || is_set(is_pcebd_group_id_configured.yfilter)) leaf_name_data.push_back(is_pcebd_group_id_configured.get_name_leafdata());
if (pcebd_source_address.is_set || is_set(pcebd_source_address.yfilter)) leaf_name_data.push_back(pcebd_source_address.get_name_leafdata());
if (pcebd_group_id.is_set || is_set(pcebd_group_id.yfilter)) leaf_name_data.push_back(pcebd_group_id.get_name_leafdata());
if (is_bfd_reverse_pat_configured.is_set || is_set(is_bfd_reverse_pat_configured.yfilter)) leaf_name_data.push_back(is_bfd_reverse_pat_configured.get_name_leafdata());
if (is_delay_limit_configured.is_set || is_set(is_delay_limit_configured.yfilter)) leaf_name_data.push_back(is_delay_limit_configured.get_name_leafdata());
if (delay_limit.is_set || is_set(delay_limit.yfilter)) leaf_name_data.push_back(delay_limit.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "affinity")
{
if(affinity == nullptr)
{
affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity>();
}
return affinity;
}
if(child_yang_name == "bfd-reverse-path")
{
if(bfd_reverse_path == nullptr)
{
bfd_reverse_path = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath>();
}
return bfd_reverse_path;
}
if(child_yang_name == "tunnel-id")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId>();
ent_->parent = this;
tunnel_id.append(ent_);
return ent_;
}
if(child_yang_name == "version-info")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo>();
ent_->parent = this;
version_info.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(affinity != nullptr)
{
_children["affinity"] = affinity;
}
if(bfd_reverse_path != nullptr)
{
_children["bfd-reverse-path"] = bfd_reverse_path;
}
count_ = 0;
for (auto ent_ : tunnel_id.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : version_info.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "configured-bandwidth")
{
configured_bandwidth = value;
configured_bandwidth.value_namespace = name_space;
configured_bandwidth.value_namespace_prefix = name_space_prefix;
}
if(value_path == "cost-limit")
{
cost_limit = value;
cost_limit.value_namespace = name_space;
cost_limit.value_namespace_prefix = name_space_prefix;
}
if(value_path == "dste-class-type")
{
dste_class_type = value;
dste_class_type.value_namespace = name_space;
dste_class_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "bandwidth-type")
{
bandwidth_type = value;
bandwidth_type.value_namespace = name_space;
bandwidth_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-bandwidth-configured")
{
is_bandwidth_configured = value;
is_bandwidth_configured.value_namespace = name_space;
is_bandwidth_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-cost-limit-configured")
{
is_cost_limit_configured = value;
is_cost_limit_configured.value_namespace = name_space;
is_cost_limit_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured = value;
is_affinity_configured.value_namespace = name_space;
is_affinity_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "generation")
{
generation = value;
generation.value_namespace = name_space;
generation.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-invalidation-timeout")
{
path_invalidation_timeout = value;
path_invalidation_timeout.value_namespace = name_space;
path_invalidation_timeout.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-invalidation-action")
{
path_invalidation_action = value;
path_invalidation_action.value_namespace = name_space;
path_invalidation_action.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-invalidation-timeout-configured")
{
is_path_invalidation_timeout_configured = value;
is_path_invalidation_timeout_configured.value_namespace = name_space;
is_path_invalidation_timeout_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-invalidation-action-configured")
{
is_path_invalidation_action_configured = value;
is_path_invalidation_action_configured.value_namespace = name_space;
is_path_invalidation_action_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclude-list-name")
{
exclude_list_name = value;
exclude_list_name.value_namespace = name_space;
exclude_list_name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-exclude-list-name-configured")
{
is_exclude_list_name_configured = value;
is_exclude_list_name_configured.value_namespace = name_space;
is_exclude_list_name_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-configured")
{
is_pce_configured = value;
is_pce_configured.value_namespace = name_space;
is_pce_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-disj-source-configured")
{
is_pce_disj_source_configured = value;
is_pce_disj_source_configured.value_namespace = name_space;
is_pce_disj_source_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-disj-type-configured")
{
is_pce_disj_type_configured = value;
is_pce_disj_type_configured.value_namespace = name_space;
is_pce_disj_type_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-disj-group-id-configured")
{
is_pce_disj_group_id_configured = value;
is_pce_disj_group_id_configured.value_namespace = name_space;
is_pce_disj_group_id_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcedp-source-address")
{
pcedp_source_address = value;
pcedp_source_address.value_namespace = name_space;
pcedp_source_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcedp-type")
{
pcedp_type = value;
pcedp_type.value_namespace = name_space;
pcedp_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcedp-group-id")
{
pcedp_group_id = value;
pcedp_group_id.value_namespace = name_space;
pcedp_group_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pceb-dj-source-configured")
{
is_pceb_dj_source_configured = value;
is_pceb_dj_source_configured.value_namespace = name_space;
is_pceb_dj_source_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pcebd-group-id-configured")
{
is_pcebd_group_id_configured = value;
is_pcebd_group_id_configured.value_namespace = name_space;
is_pcebd_group_id_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcebd-source-address")
{
pcebd_source_address = value;
pcebd_source_address.value_namespace = name_space;
pcebd_source_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcebd-group-id")
{
pcebd_group_id = value;
pcebd_group_id.value_namespace = name_space;
pcebd_group_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-bfd-reverse-pat-configured")
{
is_bfd_reverse_pat_configured = value;
is_bfd_reverse_pat_configured.value_namespace = name_space;
is_bfd_reverse_pat_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-delay-limit-configured")
{
is_delay_limit_configured = value;
is_delay_limit_configured.value_namespace = name_space;
is_delay_limit_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "delay-limit")
{
delay_limit = value;
delay_limit.value_namespace = name_space;
delay_limit.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "configured-bandwidth")
{
configured_bandwidth.yfilter = yfilter;
}
if(value_path == "cost-limit")
{
cost_limit.yfilter = yfilter;
}
if(value_path == "dste-class-type")
{
dste_class_type.yfilter = yfilter;
}
if(value_path == "bandwidth-type")
{
bandwidth_type.yfilter = yfilter;
}
if(value_path == "is-bandwidth-configured")
{
is_bandwidth_configured.yfilter = yfilter;
}
if(value_path == "is-cost-limit-configured")
{
is_cost_limit_configured.yfilter = yfilter;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured.yfilter = yfilter;
}
if(value_path == "generation")
{
generation.yfilter = yfilter;
}
if(value_path == "path-invalidation-timeout")
{
path_invalidation_timeout.yfilter = yfilter;
}
if(value_path == "path-invalidation-action")
{
path_invalidation_action.yfilter = yfilter;
}
if(value_path == "is-path-invalidation-timeout-configured")
{
is_path_invalidation_timeout_configured.yfilter = yfilter;
}
if(value_path == "is-path-invalidation-action-configured")
{
is_path_invalidation_action_configured.yfilter = yfilter;
}
if(value_path == "exclude-list-name")
{
exclude_list_name.yfilter = yfilter;
}
if(value_path == "is-exclude-list-name-configured")
{
is_exclude_list_name_configured.yfilter = yfilter;
}
if(value_path == "is-pce-configured")
{
is_pce_configured.yfilter = yfilter;
}
if(value_path == "is-pce-disj-source-configured")
{
is_pce_disj_source_configured.yfilter = yfilter;
}
if(value_path == "is-pce-disj-type-configured")
{
is_pce_disj_type_configured.yfilter = yfilter;
}
if(value_path == "is-pce-disj-group-id-configured")
{
is_pce_disj_group_id_configured.yfilter = yfilter;
}
if(value_path == "pcedp-source-address")
{
pcedp_source_address.yfilter = yfilter;
}
if(value_path == "pcedp-type")
{
pcedp_type.yfilter = yfilter;
}
if(value_path == "pcedp-group-id")
{
pcedp_group_id.yfilter = yfilter;
}
if(value_path == "is-pceb-dj-source-configured")
{
is_pceb_dj_source_configured.yfilter = yfilter;
}
if(value_path == "is-pcebd-group-id-configured")
{
is_pcebd_group_id_configured.yfilter = yfilter;
}
if(value_path == "pcebd-source-address")
{
pcebd_source_address.yfilter = yfilter;
}
if(value_path == "pcebd-group-id")
{
pcebd_group_id.yfilter = yfilter;
}
if(value_path == "is-bfd-reverse-pat-configured")
{
is_bfd_reverse_pat_configured.yfilter = yfilter;
}
if(value_path == "is-delay-limit-configured")
{
is_delay_limit_configured.yfilter = yfilter;
}
if(value_path == "delay-limit")
{
delay_limit.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "affinity" || name == "bfd-reverse-path" || name == "tunnel-id" || name == "version-info" || name == "configured-bandwidth" || name == "cost-limit" || name == "dste-class-type" || name == "bandwidth-type" || name == "is-bandwidth-configured" || name == "is-cost-limit-configured" || name == "is-affinity-configured" || name == "generation" || name == "path-invalidation-timeout" || name == "path-invalidation-action" || name == "is-path-invalidation-timeout-configured" || name == "is-path-invalidation-action-configured" || name == "exclude-list-name" || name == "is-exclude-list-name-configured" || name == "is-pce-configured" || name == "is-pce-disj-source-configured" || name == "is-pce-disj-type-configured" || name == "is-pce-disj-group-id-configured" || name == "pcedp-source-address" || name == "pcedp-type" || name == "pcedp-group-id" || name == "is-pceb-dj-source-configured" || name == "is-pcebd-group-id-configured" || name == "pcebd-source-address" || name == "pcebd-group-id" || name == "is-bfd-reverse-pat-configured" || name == "is-delay-limit-configured" || name == "delay-limit")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::Affinity()
:
affinity_bits{YType::uint32, "affinity-bits"},
affinity_mask{YType::uint32, "affinity-mask"}
,
named_affinity(this, {})
{
yang_name = "affinity"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::~Affinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_data())
return true;
}
return affinity_bits.is_set
|| affinity_mask.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::has_operation() const
{
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(affinity_bits.yfilter)
|| ydk::is_set(affinity_mask.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "affinity";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata());
if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "named-affinity")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity>();
ent_->parent = this;
named_affinity.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : named_affinity.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "affinity-bits")
{
affinity_bits = value;
affinity_bits.value_namespace = name_space;
affinity_bits.value_namespace_prefix = name_space_prefix;
}
if(value_path == "affinity-mask")
{
affinity_mask = value;
affinity_mask.value_namespace = name_space;
affinity_mask.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "affinity-bits")
{
affinity_bits.yfilter = yfilter;
}
if(value_path == "affinity-mask")
{
affinity_mask.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::NamedAffinity()
:
constraint_type{YType::uint8, "constraint-type"},
constraint_value{YType::uint32, "constraint-value"},
forward_ref_value{YType::uint32, "forward-ref-value"}
,
constraint_extended_value(this, {})
, extended_forward_ref_value(this, {})
{
yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::~NamedAffinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_data())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_data())
return true;
}
return constraint_type.is_set
|| constraint_value.is_set
|| forward_ref_value.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::has_operation() const
{
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_operation())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(constraint_type.yfilter)
|| ydk::is_set(constraint_value.yfilter)
|| ydk::is_set(forward_ref_value.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "named-affinity";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata());
if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata());
if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "constraint-extended-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue>();
ent_->parent = this;
constraint_extended_value.append(ent_);
return ent_;
}
if(child_yang_name == "extended-forward-ref-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue>();
ent_->parent = this;
extended_forward_ref_value.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : constraint_extended_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : extended_forward_ref_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "constraint-type")
{
constraint_type = value;
constraint_type.value_namespace = name_space;
constraint_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "constraint-value")
{
constraint_value = value;
constraint_value.value_namespace = name_space;
constraint_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "forward-ref-value")
{
forward_ref_value = value;
forward_ref_value.value_namespace = name_space;
forward_ref_value.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "constraint-type")
{
constraint_type.yfilter = yfilter;
}
if(value_path == "constraint-value")
{
constraint_value.yfilter = yfilter;
}
if(value_path == "forward-ref-value")
{
forward_ref_value.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "constraint-extended-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "extended-forward-ref-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::BfdReversePath()
:
path_type{YType::enumeration, "path-type"},
binding_label{YType::uint32, "binding-label"}
{
yang_name = "bfd-reverse-path"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::~BfdReversePath()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::has_data() const
{
if (is_presence_container) return true;
return path_type.is_set
|| binding_label.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(path_type.yfilter)
|| ydk::is_set(binding_label.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "bfd-reverse-path";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (path_type.is_set || is_set(path_type.yfilter)) leaf_name_data.push_back(path_type.get_name_leafdata());
if (binding_label.is_set || is_set(binding_label.yfilter)) leaf_name_data.push_back(binding_label.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "path-type")
{
path_type = value;
path_type.value_namespace = name_space;
path_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "binding-label")
{
binding_label = value;
binding_label.value_namespace = name_space;
binding_label.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "path-type")
{
path_type.yfilter = yfilter;
}
if(value_path == "binding-label")
{
binding_label.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "path-type" || name == "binding-label")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::TunnelId()
:
entry{YType::uint16, "entry"}
{
yang_name = "tunnel-id"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::~TunnelId()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tunnel-id";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::VersionInfo()
:
attribute_type{YType::str, "attribute-type"},
generation{YType::uint32, "generation"},
is_default{YType::boolean, "is-default"}
{
yang_name = "version-info"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::~VersionInfo()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::has_data() const
{
if (is_presence_container) return true;
return attribute_type.is_set
|| generation.is_set
|| is_default.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(attribute_type.yfilter)
|| ydk::is_set(generation.yfilter)
|| ydk::is_set(is_default.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "version-info";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (attribute_type.is_set || is_set(attribute_type.yfilter)) leaf_name_data.push_back(attribute_type.get_name_leafdata());
if (generation.is_set || is_set(generation.yfilter)) leaf_name_data.push_back(generation.get_name_leafdata());
if (is_default.is_set || is_set(is_default.yfilter)) leaf_name_data.push_back(is_default.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "attribute-type")
{
attribute_type = value;
attribute_type.value_namespace = name_space;
attribute_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "generation")
{
generation = value;
generation.value_namespace = name_space;
generation.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-default")
{
is_default = value;
is_default.value_namespace = name_space;
is_default.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "attribute-type")
{
attribute_type.yfilter = yfilter;
}
if(value_path == "generation")
{
generation.yfilter = yfilter;
}
if(value_path == "is-default")
{
is_default.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "attribute-type" || name == "generation" || name == "is-default")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::AttributeSetAutobackup()
:
is_signalled_name_configured{YType::boolean, "is-signalled-name-configured"},
setup_priority{YType::uint8, "setup-priority"},
hold_priority{YType::uint8, "hold-priority"},
is_priority_configured{YType::boolean, "is-priority-configured"},
policy_class{YType::uint8, "policy-class"},
is_policyclass_configured{YType::boolean, "is-policyclass-configured"},
is_affinity_configured{YType::boolean, "is-affinity-configured"},
record_route{YType::boolean, "record-route"}
,
signalled_name(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName>())
, affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity>())
, logging(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging>())
, policy_class_entry(this, {})
, tunnel_id(this, {})
, protected_interface(this, {})
{
signalled_name->parent = this;
affinity->parent = this;
logging->parent = this;
yang_name = "attribute-set-autobackup"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::~AttributeSetAutobackup()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<policy_class_entry.len(); index++)
{
if(policy_class_entry[index]->has_data())
return true;
}
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_data())
return true;
}
for (std::size_t index=0; index<protected_interface.len(); index++)
{
if(protected_interface[index]->has_data())
return true;
}
return is_signalled_name_configured.is_set
|| setup_priority.is_set
|| hold_priority.is_set
|| is_priority_configured.is_set
|| policy_class.is_set
|| is_policyclass_configured.is_set
|| is_affinity_configured.is_set
|| record_route.is_set
|| (signalled_name != nullptr && signalled_name->has_data())
|| (affinity != nullptr && affinity->has_data())
|| (logging != nullptr && logging->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::has_operation() const
{
for (std::size_t index=0; index<policy_class_entry.len(); index++)
{
if(policy_class_entry[index]->has_operation())
return true;
}
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_operation())
return true;
}
for (std::size_t index=0; index<protected_interface.len(); index++)
{
if(protected_interface[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(is_signalled_name_configured.yfilter)
|| ydk::is_set(setup_priority.yfilter)
|| ydk::is_set(hold_priority.yfilter)
|| ydk::is_set(is_priority_configured.yfilter)
|| ydk::is_set(policy_class.yfilter)
|| ydk::is_set(is_policyclass_configured.yfilter)
|| ydk::is_set(is_affinity_configured.yfilter)
|| ydk::is_set(record_route.yfilter)
|| (signalled_name != nullptr && signalled_name->has_operation())
|| (affinity != nullptr && affinity->has_operation())
|| (logging != nullptr && logging->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-autobackup";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (is_signalled_name_configured.is_set || is_set(is_signalled_name_configured.yfilter)) leaf_name_data.push_back(is_signalled_name_configured.get_name_leafdata());
if (setup_priority.is_set || is_set(setup_priority.yfilter)) leaf_name_data.push_back(setup_priority.get_name_leafdata());
if (hold_priority.is_set || is_set(hold_priority.yfilter)) leaf_name_data.push_back(hold_priority.get_name_leafdata());
if (is_priority_configured.is_set || is_set(is_priority_configured.yfilter)) leaf_name_data.push_back(is_priority_configured.get_name_leafdata());
if (policy_class.is_set || is_set(policy_class.yfilter)) leaf_name_data.push_back(policy_class.get_name_leafdata());
if (is_policyclass_configured.is_set || is_set(is_policyclass_configured.yfilter)) leaf_name_data.push_back(is_policyclass_configured.get_name_leafdata());
if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata());
if (record_route.is_set || is_set(record_route.yfilter)) leaf_name_data.push_back(record_route.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "signalled-name")
{
if(signalled_name == nullptr)
{
signalled_name = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName>();
}
return signalled_name;
}
if(child_yang_name == "affinity")
{
if(affinity == nullptr)
{
affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity>();
}
return affinity;
}
if(child_yang_name == "logging")
{
if(logging == nullptr)
{
logging = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging>();
}
return logging;
}
if(child_yang_name == "policy-class-entry")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry>();
ent_->parent = this;
policy_class_entry.append(ent_);
return ent_;
}
if(child_yang_name == "tunnel-id")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId>();
ent_->parent = this;
tunnel_id.append(ent_);
return ent_;
}
if(child_yang_name == "protected-interface")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface>();
ent_->parent = this;
protected_interface.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(signalled_name != nullptr)
{
_children["signalled-name"] = signalled_name;
}
if(affinity != nullptr)
{
_children["affinity"] = affinity;
}
if(logging != nullptr)
{
_children["logging"] = logging;
}
count_ = 0;
for (auto ent_ : policy_class_entry.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : tunnel_id.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : protected_interface.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "is-signalled-name-configured")
{
is_signalled_name_configured = value;
is_signalled_name_configured.value_namespace = name_space;
is_signalled_name_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "setup-priority")
{
setup_priority = value;
setup_priority.value_namespace = name_space;
setup_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "hold-priority")
{
hold_priority = value;
hold_priority.value_namespace = name_space;
hold_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-priority-configured")
{
is_priority_configured = value;
is_priority_configured.value_namespace = name_space;
is_priority_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "policy-class")
{
policy_class = value;
policy_class.value_namespace = name_space;
policy_class.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-policyclass-configured")
{
is_policyclass_configured = value;
is_policyclass_configured.value_namespace = name_space;
is_policyclass_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured = value;
is_affinity_configured.value_namespace = name_space;
is_affinity_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "record-route")
{
record_route = value;
record_route.value_namespace = name_space;
record_route.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "is-signalled-name-configured")
{
is_signalled_name_configured.yfilter = yfilter;
}
if(value_path == "setup-priority")
{
setup_priority.yfilter = yfilter;
}
if(value_path == "hold-priority")
{
hold_priority.yfilter = yfilter;
}
if(value_path == "is-priority-configured")
{
is_priority_configured.yfilter = yfilter;
}
if(value_path == "policy-class")
{
policy_class.yfilter = yfilter;
}
if(value_path == "is-policyclass-configured")
{
is_policyclass_configured.yfilter = yfilter;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured.yfilter = yfilter;
}
if(value_path == "record-route")
{
record_route.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "signalled-name" || name == "affinity" || name == "logging" || name == "policy-class-entry" || name == "tunnel-id" || name == "protected-interface" || name == "is-signalled-name-configured" || name == "setup-priority" || name == "hold-priority" || name == "is-priority-configured" || name == "policy-class" || name == "is-policyclass-configured" || name == "is-affinity-configured" || name == "record-route")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::SignalledName()
:
name{YType::str, "name"},
source_type{YType::enumeration, "source-type"},
protected_interface_type{YType::enumeration, "protected-interface-type"},
is_mp_addresses{YType::boolean, "is-mp-addresses"}
{
yang_name = "signalled-name"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::~SignalledName()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::has_data() const
{
if (is_presence_container) return true;
return name.is_set
|| source_type.is_set
|| protected_interface_type.is_set
|| is_mp_addresses.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(name.yfilter)
|| ydk::is_set(source_type.yfilter)
|| ydk::is_set(protected_interface_type.yfilter)
|| ydk::is_set(is_mp_addresses.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "signalled-name";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (name.is_set || is_set(name.yfilter)) leaf_name_data.push_back(name.get_name_leafdata());
if (source_type.is_set || is_set(source_type.yfilter)) leaf_name_data.push_back(source_type.get_name_leafdata());
if (protected_interface_type.is_set || is_set(protected_interface_type.yfilter)) leaf_name_data.push_back(protected_interface_type.get_name_leafdata());
if (is_mp_addresses.is_set || is_set(is_mp_addresses.yfilter)) leaf_name_data.push_back(is_mp_addresses.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "name")
{
name = value;
name.value_namespace = name_space;
name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "source-type")
{
source_type = value;
source_type.value_namespace = name_space;
source_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "protected-interface-type")
{
protected_interface_type = value;
protected_interface_type.value_namespace = name_space;
protected_interface_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-mp-addresses")
{
is_mp_addresses = value;
is_mp_addresses.value_namespace = name_space;
is_mp_addresses.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "name")
{
name.yfilter = yfilter;
}
if(value_path == "source-type")
{
source_type.yfilter = yfilter;
}
if(value_path == "protected-interface-type")
{
protected_interface_type.yfilter = yfilter;
}
if(value_path == "is-mp-addresses")
{
is_mp_addresses.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "name" || name == "source-type" || name == "protected-interface-type" || name == "is-mp-addresses")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::Affinity()
:
affinity_bits{YType::uint32, "affinity-bits"},
affinity_mask{YType::uint32, "affinity-mask"}
,
named_affinity(this, {})
{
yang_name = "affinity"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::~Affinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_data())
return true;
}
return affinity_bits.is_set
|| affinity_mask.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::has_operation() const
{
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(affinity_bits.yfilter)
|| ydk::is_set(affinity_mask.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "affinity";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata());
if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "named-affinity")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity>();
ent_->parent = this;
named_affinity.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : named_affinity.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "affinity-bits")
{
affinity_bits = value;
affinity_bits.value_namespace = name_space;
affinity_bits.value_namespace_prefix = name_space_prefix;
}
if(value_path == "affinity-mask")
{
affinity_mask = value;
affinity_mask.value_namespace = name_space;
affinity_mask.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "affinity-bits")
{
affinity_bits.yfilter = yfilter;
}
if(value_path == "affinity-mask")
{
affinity_mask.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::NamedAffinity()
:
constraint_type{YType::uint8, "constraint-type"},
constraint_value{YType::uint32, "constraint-value"},
forward_ref_value{YType::uint32, "forward-ref-value"}
,
constraint_extended_value(this, {})
, extended_forward_ref_value(this, {})
{
yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::~NamedAffinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_data())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_data())
return true;
}
return constraint_type.is_set
|| constraint_value.is_set
|| forward_ref_value.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::has_operation() const
{
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_operation())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(constraint_type.yfilter)
|| ydk::is_set(constraint_value.yfilter)
|| ydk::is_set(forward_ref_value.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "named-affinity";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata());
if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata());
if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "constraint-extended-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue>();
ent_->parent = this;
constraint_extended_value.append(ent_);
return ent_;
}
if(child_yang_name == "extended-forward-ref-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue>();
ent_->parent = this;
extended_forward_ref_value.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : constraint_extended_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : extended_forward_ref_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "constraint-type")
{
constraint_type = value;
constraint_type.value_namespace = name_space;
constraint_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "constraint-value")
{
constraint_value = value;
constraint_value.value_namespace = name_space;
constraint_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "forward-ref-value")
{
forward_ref_value = value;
forward_ref_value.value_namespace = name_space;
forward_ref_value.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "constraint-type")
{
constraint_type.yfilter = yfilter;
}
if(value_path == "constraint-value")
{
constraint_value.yfilter = yfilter;
}
if(value_path == "forward-ref-value")
{
forward_ref_value.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "constraint-extended-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "extended-forward-ref-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::Logging()
:
lsp_state{YType::boolean, "lsp-state"},
s2l_state{YType::boolean, "s2l-state"},
lsp_re_route{YType::boolean, "lsp-re-route"},
lsp_re_opt{YType::boolean, "lsp-re-opt"},
lsp_insufficient_bw{YType::boolean, "lsp-insufficient-bw"},
lsp_bandwidth_change{YType::boolean, "lsp-bandwidth-change"},
lsp_pcalc_failure_logging_enabled{YType::boolean, "lsp-pcalc-failure-logging-enabled"},
all_logging_enabled{YType::boolean, "all-logging-enabled"}
{
yang_name = "logging"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::~Logging()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::has_data() const
{
if (is_presence_container) return true;
return lsp_state.is_set
|| s2l_state.is_set
|| lsp_re_route.is_set
|| lsp_re_opt.is_set
|| lsp_insufficient_bw.is_set
|| lsp_bandwidth_change.is_set
|| lsp_pcalc_failure_logging_enabled.is_set
|| all_logging_enabled.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lsp_state.yfilter)
|| ydk::is_set(s2l_state.yfilter)
|| ydk::is_set(lsp_re_route.yfilter)
|| ydk::is_set(lsp_re_opt.yfilter)
|| ydk::is_set(lsp_insufficient_bw.yfilter)
|| ydk::is_set(lsp_bandwidth_change.yfilter)
|| ydk::is_set(lsp_pcalc_failure_logging_enabled.yfilter)
|| ydk::is_set(all_logging_enabled.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "logging";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lsp_state.is_set || is_set(lsp_state.yfilter)) leaf_name_data.push_back(lsp_state.get_name_leafdata());
if (s2l_state.is_set || is_set(s2l_state.yfilter)) leaf_name_data.push_back(s2l_state.get_name_leafdata());
if (lsp_re_route.is_set || is_set(lsp_re_route.yfilter)) leaf_name_data.push_back(lsp_re_route.get_name_leafdata());
if (lsp_re_opt.is_set || is_set(lsp_re_opt.yfilter)) leaf_name_data.push_back(lsp_re_opt.get_name_leafdata());
if (lsp_insufficient_bw.is_set || is_set(lsp_insufficient_bw.yfilter)) leaf_name_data.push_back(lsp_insufficient_bw.get_name_leafdata());
if (lsp_bandwidth_change.is_set || is_set(lsp_bandwidth_change.yfilter)) leaf_name_data.push_back(lsp_bandwidth_change.get_name_leafdata());
if (lsp_pcalc_failure_logging_enabled.is_set || is_set(lsp_pcalc_failure_logging_enabled.yfilter)) leaf_name_data.push_back(lsp_pcalc_failure_logging_enabled.get_name_leafdata());
if (all_logging_enabled.is_set || is_set(all_logging_enabled.yfilter)) leaf_name_data.push_back(all_logging_enabled.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "lsp-state")
{
lsp_state = value;
lsp_state.value_namespace = name_space;
lsp_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-state")
{
s2l_state = value;
s2l_state.value_namespace = name_space;
s2l_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-re-route")
{
lsp_re_route = value;
lsp_re_route.value_namespace = name_space;
lsp_re_route.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-re-opt")
{
lsp_re_opt = value;
lsp_re_opt.value_namespace = name_space;
lsp_re_opt.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-insufficient-bw")
{
lsp_insufficient_bw = value;
lsp_insufficient_bw.value_namespace = name_space;
lsp_insufficient_bw.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-bandwidth-change")
{
lsp_bandwidth_change = value;
lsp_bandwidth_change.value_namespace = name_space;
lsp_bandwidth_change.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-pcalc-failure-logging-enabled")
{
lsp_pcalc_failure_logging_enabled = value;
lsp_pcalc_failure_logging_enabled.value_namespace = name_space;
lsp_pcalc_failure_logging_enabled.value_namespace_prefix = name_space_prefix;
}
if(value_path == "all-logging-enabled")
{
all_logging_enabled = value;
all_logging_enabled.value_namespace = name_space;
all_logging_enabled.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "lsp-state")
{
lsp_state.yfilter = yfilter;
}
if(value_path == "s2l-state")
{
s2l_state.yfilter = yfilter;
}
if(value_path == "lsp-re-route")
{
lsp_re_route.yfilter = yfilter;
}
if(value_path == "lsp-re-opt")
{
lsp_re_opt.yfilter = yfilter;
}
if(value_path == "lsp-insufficient-bw")
{
lsp_insufficient_bw.yfilter = yfilter;
}
if(value_path == "lsp-bandwidth-change")
{
lsp_bandwidth_change.yfilter = yfilter;
}
if(value_path == "lsp-pcalc-failure-logging-enabled")
{
lsp_pcalc_failure_logging_enabled.yfilter = yfilter;
}
if(value_path == "all-logging-enabled")
{
all_logging_enabled.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "lsp-state" || name == "s2l-state" || name == "lsp-re-route" || name == "lsp-re-opt" || name == "lsp-insufficient-bw" || name == "lsp-bandwidth-change" || name == "lsp-pcalc-failure-logging-enabled" || name == "all-logging-enabled")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::PolicyClassEntry()
:
entry{YType::uint8, "entry"}
{
yang_name = "policy-class-entry"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::~PolicyClassEntry()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "policy-class-entry";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::TunnelId()
:
entry{YType::uint16, "entry"}
{
yang_name = "tunnel-id"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::~TunnelId()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tunnel-id";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::ProtectedInterface()
:
protected_interface{YType::str, "protected-interface"}
{
yang_name = "protected-interface"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::~ProtectedInterface()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::has_data() const
{
if (is_presence_container) return true;
return protected_interface.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(protected_interface.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "protected-interface";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (protected_interface.is_set || is_set(protected_interface.yfilter)) leaf_name_data.push_back(protected_interface.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "protected-interface")
{
protected_interface = value;
protected_interface.value_namespace = name_space;
protected_interface.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "protected-interface")
{
protected_interface.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "protected-interface")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::AttributeSetAutomesh()
:
configured_bandwidth{YType::uint32, "configured-bandwidth"},
dste_class_type{YType::uint8, "dste-class-type"},
is_bandwidth_configured{YType::boolean, "is-bandwidth-configured"},
setup_priority{YType::uint8, "setup-priority"},
hold_priority{YType::uint8, "hold-priority"},
is_priority_configured{YType::boolean, "is-priority-configured"},
policy_class{YType::uint8, "policy-class"},
is_policyclass_configured{YType::boolean, "is-policyclass-configured"},
forward_class{YType::uint32, "forward-class"},
is_forward_class_configured{YType::boolean, "is-forward-class-configured"},
is_affinity_configured{YType::boolean, "is-affinity-configured"},
fast_reroute{YType::boolean, "fast-reroute"},
frr_node_protection{YType::boolean, "frr-node-protection"},
frr_bandwidth_protection{YType::boolean, "frr-bandwidth-protection"},
record_route{YType::boolean, "record-route"},
auto_bandwidth_collect{YType::boolean, "auto-bandwidth-collect"},
auto_route_announce{YType::boolean, "auto-route-announce"},
soft_preemption_configured{YType::boolean, "soft-preemption-configured"},
bandwidth{YType::uint32, "bandwidth"},
load_share{YType::uint32, "load-share"},
is_interface_bw_configured{YType::boolean, "is-interface-bw-configured"}
,
affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity>())
, logging(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging>())
, policy_class_entry(this, {})
, mesh_group_id(this, {})
, tunnel_id(this, {})
{
affinity->parent = this;
logging->parent = this;
yang_name = "attribute-set-automesh"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::~AttributeSetAutomesh()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<policy_class_entry.len(); index++)
{
if(policy_class_entry[index]->has_data())
return true;
}
for (std::size_t index=0; index<mesh_group_id.len(); index++)
{
if(mesh_group_id[index]->has_data())
return true;
}
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_data())
return true;
}
return configured_bandwidth.is_set
|| dste_class_type.is_set
|| is_bandwidth_configured.is_set
|| setup_priority.is_set
|| hold_priority.is_set
|| is_priority_configured.is_set
|| policy_class.is_set
|| is_policyclass_configured.is_set
|| forward_class.is_set
|| is_forward_class_configured.is_set
|| is_affinity_configured.is_set
|| fast_reroute.is_set
|| frr_node_protection.is_set
|| frr_bandwidth_protection.is_set
|| record_route.is_set
|| auto_bandwidth_collect.is_set
|| auto_route_announce.is_set
|| soft_preemption_configured.is_set
|| bandwidth.is_set
|| load_share.is_set
|| is_interface_bw_configured.is_set
|| (affinity != nullptr && affinity->has_data())
|| (logging != nullptr && logging->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::has_operation() const
{
for (std::size_t index=0; index<policy_class_entry.len(); index++)
{
if(policy_class_entry[index]->has_operation())
return true;
}
for (std::size_t index=0; index<mesh_group_id.len(); index++)
{
if(mesh_group_id[index]->has_operation())
return true;
}
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(configured_bandwidth.yfilter)
|| ydk::is_set(dste_class_type.yfilter)
|| ydk::is_set(is_bandwidth_configured.yfilter)
|| ydk::is_set(setup_priority.yfilter)
|| ydk::is_set(hold_priority.yfilter)
|| ydk::is_set(is_priority_configured.yfilter)
|| ydk::is_set(policy_class.yfilter)
|| ydk::is_set(is_policyclass_configured.yfilter)
|| ydk::is_set(forward_class.yfilter)
|| ydk::is_set(is_forward_class_configured.yfilter)
|| ydk::is_set(is_affinity_configured.yfilter)
|| ydk::is_set(fast_reroute.yfilter)
|| ydk::is_set(frr_node_protection.yfilter)
|| ydk::is_set(frr_bandwidth_protection.yfilter)
|| ydk::is_set(record_route.yfilter)
|| ydk::is_set(auto_bandwidth_collect.yfilter)
|| ydk::is_set(auto_route_announce.yfilter)
|| ydk::is_set(soft_preemption_configured.yfilter)
|| ydk::is_set(bandwidth.yfilter)
|| ydk::is_set(load_share.yfilter)
|| ydk::is_set(is_interface_bw_configured.yfilter)
|| (affinity != nullptr && affinity->has_operation())
|| (logging != nullptr && logging->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-automesh";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (configured_bandwidth.is_set || is_set(configured_bandwidth.yfilter)) leaf_name_data.push_back(configured_bandwidth.get_name_leafdata());
if (dste_class_type.is_set || is_set(dste_class_type.yfilter)) leaf_name_data.push_back(dste_class_type.get_name_leafdata());
if (is_bandwidth_configured.is_set || is_set(is_bandwidth_configured.yfilter)) leaf_name_data.push_back(is_bandwidth_configured.get_name_leafdata());
if (setup_priority.is_set || is_set(setup_priority.yfilter)) leaf_name_data.push_back(setup_priority.get_name_leafdata());
if (hold_priority.is_set || is_set(hold_priority.yfilter)) leaf_name_data.push_back(hold_priority.get_name_leafdata());
if (is_priority_configured.is_set || is_set(is_priority_configured.yfilter)) leaf_name_data.push_back(is_priority_configured.get_name_leafdata());
if (policy_class.is_set || is_set(policy_class.yfilter)) leaf_name_data.push_back(policy_class.get_name_leafdata());
if (is_policyclass_configured.is_set || is_set(is_policyclass_configured.yfilter)) leaf_name_data.push_back(is_policyclass_configured.get_name_leafdata());
if (forward_class.is_set || is_set(forward_class.yfilter)) leaf_name_data.push_back(forward_class.get_name_leafdata());
if (is_forward_class_configured.is_set || is_set(is_forward_class_configured.yfilter)) leaf_name_data.push_back(is_forward_class_configured.get_name_leafdata());
if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata());
if (fast_reroute.is_set || is_set(fast_reroute.yfilter)) leaf_name_data.push_back(fast_reroute.get_name_leafdata());
if (frr_node_protection.is_set || is_set(frr_node_protection.yfilter)) leaf_name_data.push_back(frr_node_protection.get_name_leafdata());
if (frr_bandwidth_protection.is_set || is_set(frr_bandwidth_protection.yfilter)) leaf_name_data.push_back(frr_bandwidth_protection.get_name_leafdata());
if (record_route.is_set || is_set(record_route.yfilter)) leaf_name_data.push_back(record_route.get_name_leafdata());
if (auto_bandwidth_collect.is_set || is_set(auto_bandwidth_collect.yfilter)) leaf_name_data.push_back(auto_bandwidth_collect.get_name_leafdata());
if (auto_route_announce.is_set || is_set(auto_route_announce.yfilter)) leaf_name_data.push_back(auto_route_announce.get_name_leafdata());
if (soft_preemption_configured.is_set || is_set(soft_preemption_configured.yfilter)) leaf_name_data.push_back(soft_preemption_configured.get_name_leafdata());
if (bandwidth.is_set || is_set(bandwidth.yfilter)) leaf_name_data.push_back(bandwidth.get_name_leafdata());
if (load_share.is_set || is_set(load_share.yfilter)) leaf_name_data.push_back(load_share.get_name_leafdata());
if (is_interface_bw_configured.is_set || is_set(is_interface_bw_configured.yfilter)) leaf_name_data.push_back(is_interface_bw_configured.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "affinity")
{
if(affinity == nullptr)
{
affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity>();
}
return affinity;
}
if(child_yang_name == "logging")
{
if(logging == nullptr)
{
logging = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging>();
}
return logging;
}
if(child_yang_name == "policy-class-entry")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry>();
ent_->parent = this;
policy_class_entry.append(ent_);
return ent_;
}
if(child_yang_name == "mesh-group-id")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId>();
ent_->parent = this;
mesh_group_id.append(ent_);
return ent_;
}
if(child_yang_name == "tunnel-id")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId>();
ent_->parent = this;
tunnel_id.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(affinity != nullptr)
{
_children["affinity"] = affinity;
}
if(logging != nullptr)
{
_children["logging"] = logging;
}
count_ = 0;
for (auto ent_ : policy_class_entry.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : mesh_group_id.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : tunnel_id.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "configured-bandwidth")
{
configured_bandwidth = value;
configured_bandwidth.value_namespace = name_space;
configured_bandwidth.value_namespace_prefix = name_space_prefix;
}
if(value_path == "dste-class-type")
{
dste_class_type = value;
dste_class_type.value_namespace = name_space;
dste_class_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-bandwidth-configured")
{
is_bandwidth_configured = value;
is_bandwidth_configured.value_namespace = name_space;
is_bandwidth_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "setup-priority")
{
setup_priority = value;
setup_priority.value_namespace = name_space;
setup_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "hold-priority")
{
hold_priority = value;
hold_priority.value_namespace = name_space;
hold_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-priority-configured")
{
is_priority_configured = value;
is_priority_configured.value_namespace = name_space;
is_priority_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "policy-class")
{
policy_class = value;
policy_class.value_namespace = name_space;
policy_class.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-policyclass-configured")
{
is_policyclass_configured = value;
is_policyclass_configured.value_namespace = name_space;
is_policyclass_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "forward-class")
{
forward_class = value;
forward_class.value_namespace = name_space;
forward_class.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-forward-class-configured")
{
is_forward_class_configured = value;
is_forward_class_configured.value_namespace = name_space;
is_forward_class_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured = value;
is_affinity_configured.value_namespace = name_space;
is_affinity_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fast-reroute")
{
fast_reroute = value;
fast_reroute.value_namespace = name_space;
fast_reroute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "frr-node-protection")
{
frr_node_protection = value;
frr_node_protection.value_namespace = name_space;
frr_node_protection.value_namespace_prefix = name_space_prefix;
}
if(value_path == "frr-bandwidth-protection")
{
frr_bandwidth_protection = value;
frr_bandwidth_protection.value_namespace = name_space;
frr_bandwidth_protection.value_namespace_prefix = name_space_prefix;
}
if(value_path == "record-route")
{
record_route = value;
record_route.value_namespace = name_space;
record_route.value_namespace_prefix = name_space_prefix;
}
if(value_path == "auto-bandwidth-collect")
{
auto_bandwidth_collect = value;
auto_bandwidth_collect.value_namespace = name_space;
auto_bandwidth_collect.value_namespace_prefix = name_space_prefix;
}
if(value_path == "auto-route-announce")
{
auto_route_announce = value;
auto_route_announce.value_namespace = name_space;
auto_route_announce.value_namespace_prefix = name_space_prefix;
}
if(value_path == "soft-preemption-configured")
{
soft_preemption_configured = value;
soft_preemption_configured.value_namespace = name_space;
soft_preemption_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "bandwidth")
{
bandwidth = value;
bandwidth.value_namespace = name_space;
bandwidth.value_namespace_prefix = name_space_prefix;
}
if(value_path == "load-share")
{
load_share = value;
load_share.value_namespace = name_space;
load_share.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-interface-bw-configured")
{
is_interface_bw_configured = value;
is_interface_bw_configured.value_namespace = name_space;
is_interface_bw_configured.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "configured-bandwidth")
{
configured_bandwidth.yfilter = yfilter;
}
if(value_path == "dste-class-type")
{
dste_class_type.yfilter = yfilter;
}
if(value_path == "is-bandwidth-configured")
{
is_bandwidth_configured.yfilter = yfilter;
}
if(value_path == "setup-priority")
{
setup_priority.yfilter = yfilter;
}
if(value_path == "hold-priority")
{
hold_priority.yfilter = yfilter;
}
if(value_path == "is-priority-configured")
{
is_priority_configured.yfilter = yfilter;
}
if(value_path == "policy-class")
{
policy_class.yfilter = yfilter;
}
if(value_path == "is-policyclass-configured")
{
is_policyclass_configured.yfilter = yfilter;
}
if(value_path == "forward-class")
{
forward_class.yfilter = yfilter;
}
if(value_path == "is-forward-class-configured")
{
is_forward_class_configured.yfilter = yfilter;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured.yfilter = yfilter;
}
if(value_path == "fast-reroute")
{
fast_reroute.yfilter = yfilter;
}
if(value_path == "frr-node-protection")
{
frr_node_protection.yfilter = yfilter;
}
if(value_path == "frr-bandwidth-protection")
{
frr_bandwidth_protection.yfilter = yfilter;
}
if(value_path == "record-route")
{
record_route.yfilter = yfilter;
}
if(value_path == "auto-bandwidth-collect")
{
auto_bandwidth_collect.yfilter = yfilter;
}
if(value_path == "auto-route-announce")
{
auto_route_announce.yfilter = yfilter;
}
if(value_path == "soft-preemption-configured")
{
soft_preemption_configured.yfilter = yfilter;
}
if(value_path == "bandwidth")
{
bandwidth.yfilter = yfilter;
}
if(value_path == "load-share")
{
load_share.yfilter = yfilter;
}
if(value_path == "is-interface-bw-configured")
{
is_interface_bw_configured.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "affinity" || name == "logging" || name == "policy-class-entry" || name == "mesh-group-id" || name == "tunnel-id" || name == "configured-bandwidth" || name == "dste-class-type" || name == "is-bandwidth-configured" || name == "setup-priority" || name == "hold-priority" || name == "is-priority-configured" || name == "policy-class" || name == "is-policyclass-configured" || name == "forward-class" || name == "is-forward-class-configured" || name == "is-affinity-configured" || name == "fast-reroute" || name == "frr-node-protection" || name == "frr-bandwidth-protection" || name == "record-route" || name == "auto-bandwidth-collect" || name == "auto-route-announce" || name == "soft-preemption-configured" || name == "bandwidth" || name == "load-share" || name == "is-interface-bw-configured")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::Affinity()
:
affinity_bits{YType::uint32, "affinity-bits"},
affinity_mask{YType::uint32, "affinity-mask"}
,
named_affinity(this, {})
{
yang_name = "affinity"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::~Affinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_data())
return true;
}
return affinity_bits.is_set
|| affinity_mask.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::has_operation() const
{
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(affinity_bits.yfilter)
|| ydk::is_set(affinity_mask.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "affinity";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata());
if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "named-affinity")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity>();
ent_->parent = this;
named_affinity.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : named_affinity.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "affinity-bits")
{
affinity_bits = value;
affinity_bits.value_namespace = name_space;
affinity_bits.value_namespace_prefix = name_space_prefix;
}
if(value_path == "affinity-mask")
{
affinity_mask = value;
affinity_mask.value_namespace = name_space;
affinity_mask.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "affinity-bits")
{
affinity_bits.yfilter = yfilter;
}
if(value_path == "affinity-mask")
{
affinity_mask.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::NamedAffinity()
:
constraint_type{YType::uint8, "constraint-type"},
constraint_value{YType::uint32, "constraint-value"},
forward_ref_value{YType::uint32, "forward-ref-value"}
,
constraint_extended_value(this, {})
, extended_forward_ref_value(this, {})
{
yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::~NamedAffinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_data())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_data())
return true;
}
return constraint_type.is_set
|| constraint_value.is_set
|| forward_ref_value.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::has_operation() const
{
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_operation())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(constraint_type.yfilter)
|| ydk::is_set(constraint_value.yfilter)
|| ydk::is_set(forward_ref_value.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "named-affinity";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata());
if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata());
if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "constraint-extended-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue>();
ent_->parent = this;
constraint_extended_value.append(ent_);
return ent_;
}
if(child_yang_name == "extended-forward-ref-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue>();
ent_->parent = this;
extended_forward_ref_value.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : constraint_extended_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : extended_forward_ref_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "constraint-type")
{
constraint_type = value;
constraint_type.value_namespace = name_space;
constraint_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "constraint-value")
{
constraint_value = value;
constraint_value.value_namespace = name_space;
constraint_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "forward-ref-value")
{
forward_ref_value = value;
forward_ref_value.value_namespace = name_space;
forward_ref_value.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "constraint-type")
{
constraint_type.yfilter = yfilter;
}
if(value_path == "constraint-value")
{
constraint_value.yfilter = yfilter;
}
if(value_path == "forward-ref-value")
{
forward_ref_value.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "constraint-extended-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "extended-forward-ref-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::Logging()
:
lsp_state{YType::boolean, "lsp-state"},
s2l_state{YType::boolean, "s2l-state"},
lsp_re_route{YType::boolean, "lsp-re-route"},
lsp_re_opt{YType::boolean, "lsp-re-opt"},
lsp_insufficient_bw{YType::boolean, "lsp-insufficient-bw"},
lsp_bandwidth_change{YType::boolean, "lsp-bandwidth-change"},
lsp_pcalc_failure_logging_enabled{YType::boolean, "lsp-pcalc-failure-logging-enabled"},
all_logging_enabled{YType::boolean, "all-logging-enabled"}
{
yang_name = "logging"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::~Logging()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::has_data() const
{
if (is_presence_container) return true;
return lsp_state.is_set
|| s2l_state.is_set
|| lsp_re_route.is_set
|| lsp_re_opt.is_set
|| lsp_insufficient_bw.is_set
|| lsp_bandwidth_change.is_set
|| lsp_pcalc_failure_logging_enabled.is_set
|| all_logging_enabled.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lsp_state.yfilter)
|| ydk::is_set(s2l_state.yfilter)
|| ydk::is_set(lsp_re_route.yfilter)
|| ydk::is_set(lsp_re_opt.yfilter)
|| ydk::is_set(lsp_insufficient_bw.yfilter)
|| ydk::is_set(lsp_bandwidth_change.yfilter)
|| ydk::is_set(lsp_pcalc_failure_logging_enabled.yfilter)
|| ydk::is_set(all_logging_enabled.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "logging";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lsp_state.is_set || is_set(lsp_state.yfilter)) leaf_name_data.push_back(lsp_state.get_name_leafdata());
if (s2l_state.is_set || is_set(s2l_state.yfilter)) leaf_name_data.push_back(s2l_state.get_name_leafdata());
if (lsp_re_route.is_set || is_set(lsp_re_route.yfilter)) leaf_name_data.push_back(lsp_re_route.get_name_leafdata());
if (lsp_re_opt.is_set || is_set(lsp_re_opt.yfilter)) leaf_name_data.push_back(lsp_re_opt.get_name_leafdata());
if (lsp_insufficient_bw.is_set || is_set(lsp_insufficient_bw.yfilter)) leaf_name_data.push_back(lsp_insufficient_bw.get_name_leafdata());
if (lsp_bandwidth_change.is_set || is_set(lsp_bandwidth_change.yfilter)) leaf_name_data.push_back(lsp_bandwidth_change.get_name_leafdata());
if (lsp_pcalc_failure_logging_enabled.is_set || is_set(lsp_pcalc_failure_logging_enabled.yfilter)) leaf_name_data.push_back(lsp_pcalc_failure_logging_enabled.get_name_leafdata());
if (all_logging_enabled.is_set || is_set(all_logging_enabled.yfilter)) leaf_name_data.push_back(all_logging_enabled.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "lsp-state")
{
lsp_state = value;
lsp_state.value_namespace = name_space;
lsp_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-state")
{
s2l_state = value;
s2l_state.value_namespace = name_space;
s2l_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-re-route")
{
lsp_re_route = value;
lsp_re_route.value_namespace = name_space;
lsp_re_route.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-re-opt")
{
lsp_re_opt = value;
lsp_re_opt.value_namespace = name_space;
lsp_re_opt.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-insufficient-bw")
{
lsp_insufficient_bw = value;
lsp_insufficient_bw.value_namespace = name_space;
lsp_insufficient_bw.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-bandwidth-change")
{
lsp_bandwidth_change = value;
lsp_bandwidth_change.value_namespace = name_space;
lsp_bandwidth_change.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-pcalc-failure-logging-enabled")
{
lsp_pcalc_failure_logging_enabled = value;
lsp_pcalc_failure_logging_enabled.value_namespace = name_space;
lsp_pcalc_failure_logging_enabled.value_namespace_prefix = name_space_prefix;
}
if(value_path == "all-logging-enabled")
{
all_logging_enabled = value;
all_logging_enabled.value_namespace = name_space;
all_logging_enabled.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "lsp-state")
{
lsp_state.yfilter = yfilter;
}
if(value_path == "s2l-state")
{
s2l_state.yfilter = yfilter;
}
if(value_path == "lsp-re-route")
{
lsp_re_route.yfilter = yfilter;
}
if(value_path == "lsp-re-opt")
{
lsp_re_opt.yfilter = yfilter;
}
if(value_path == "lsp-insufficient-bw")
{
lsp_insufficient_bw.yfilter = yfilter;
}
if(value_path == "lsp-bandwidth-change")
{
lsp_bandwidth_change.yfilter = yfilter;
}
if(value_path == "lsp-pcalc-failure-logging-enabled")
{
lsp_pcalc_failure_logging_enabled.yfilter = yfilter;
}
if(value_path == "all-logging-enabled")
{
all_logging_enabled.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "lsp-state" || name == "s2l-state" || name == "lsp-re-route" || name == "lsp-re-opt" || name == "lsp-insufficient-bw" || name == "lsp-bandwidth-change" || name == "lsp-pcalc-failure-logging-enabled" || name == "all-logging-enabled")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::PolicyClassEntry()
:
entry{YType::uint8, "entry"}
{
yang_name = "policy-class-entry"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::~PolicyClassEntry()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "policy-class-entry";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::MeshGroupId()
:
entry{YType::uint32, "entry"}
{
yang_name = "mesh-group-id"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::~MeshGroupId()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "mesh-group-id";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::TunnelId()
:
entry{YType::uint16, "entry"}
{
yang_name = "tunnel-id"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::~TunnelId()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tunnel-id";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::AttributeSetXro()
:
xro(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro>())
{
xro->parent = this;
yang_name = "attribute-set-xro"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::~AttributeSetXro()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::has_data() const
{
if (is_presence_container) return true;
return (xro != nullptr && xro->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::has_operation() const
{
return is_set(yfilter)
|| (xro != nullptr && xro->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-xro";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "xro")
{
if(xro == nullptr)
{
xro = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro>();
}
return xro;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(xro != nullptr)
{
_children["xro"] = xro;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "xro")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::Xro()
:
mutual_diversity_flag{YType::boolean, "mutual-diversity-flag"}
,
xro_subobject(this, {})
{
yang_name = "xro"; yang_parent_name = "attribute-set-xro"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::~Xro()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<xro_subobject.len(); index++)
{
if(xro_subobject[index]->has_data())
return true;
}
return mutual_diversity_flag.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::has_operation() const
{
for (std::size_t index=0; index<xro_subobject.len(); index++)
{
if(xro_subobject[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(mutual_diversity_flag.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "xro";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (mutual_diversity_flag.is_set || is_set(mutual_diversity_flag.yfilter)) leaf_name_data.push_back(mutual_diversity_flag.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "xro-subobject")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject>();
ent_->parent = this;
xro_subobject.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : xro_subobject.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "mutual-diversity-flag")
{
mutual_diversity_flag = value;
mutual_diversity_flag.value_namespace = name_space;
mutual_diversity_flag.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "mutual-diversity-flag")
{
mutual_diversity_flag.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "xro-subobject" || name == "mutual-diversity-flag")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::XroSubobject()
:
type{YType::enumeration, "type"}
,
ipv4_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject>())
, ipv6_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject>())
, unnumbered_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject>())
, as_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject>())
, srlg_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject>())
, lsp_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject>())
{
ipv4_subobject->parent = this;
ipv6_subobject->parent = this;
unnumbered_subobject->parent = this;
as_subobject->parent = this;
srlg_subobject->parent = this;
lsp_subobject->parent = this;
yang_name = "xro-subobject"; yang_parent_name = "xro"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::~XroSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::has_data() const
{
if (is_presence_container) return true;
return type.is_set
|| (ipv4_subobject != nullptr && ipv4_subobject->has_data())
|| (ipv6_subobject != nullptr && ipv6_subobject->has_data())
|| (unnumbered_subobject != nullptr && unnumbered_subobject->has_data())
|| (as_subobject != nullptr && as_subobject->has_data())
|| (srlg_subobject != nullptr && srlg_subobject->has_data())
|| (lsp_subobject != nullptr && lsp_subobject->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(type.yfilter)
|| (ipv4_subobject != nullptr && ipv4_subobject->has_operation())
|| (ipv6_subobject != nullptr && ipv6_subobject->has_operation())
|| (unnumbered_subobject != nullptr && unnumbered_subobject->has_operation())
|| (as_subobject != nullptr && as_subobject->has_operation())
|| (srlg_subobject != nullptr && srlg_subobject->has_operation())
|| (lsp_subobject != nullptr && lsp_subobject->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "xro-subobject";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ipv4-subobject")
{
if(ipv4_subobject == nullptr)
{
ipv4_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject>();
}
return ipv4_subobject;
}
if(child_yang_name == "ipv6-subobject")
{
if(ipv6_subobject == nullptr)
{
ipv6_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject>();
}
return ipv6_subobject;
}
if(child_yang_name == "unnumbered-subobject")
{
if(unnumbered_subobject == nullptr)
{
unnumbered_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject>();
}
return unnumbered_subobject;
}
if(child_yang_name == "as-subobject")
{
if(as_subobject == nullptr)
{
as_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject>();
}
return as_subobject;
}
if(child_yang_name == "srlg-subobject")
{
if(srlg_subobject == nullptr)
{
srlg_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject>();
}
return srlg_subobject;
}
if(child_yang_name == "lsp-subobject")
{
if(lsp_subobject == nullptr)
{
lsp_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject>();
}
return lsp_subobject;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(ipv4_subobject != nullptr)
{
_children["ipv4-subobject"] = ipv4_subobject;
}
if(ipv6_subobject != nullptr)
{
_children["ipv6-subobject"] = ipv6_subobject;
}
if(unnumbered_subobject != nullptr)
{
_children["unnumbered-subobject"] = unnumbered_subobject;
}
if(as_subobject != nullptr)
{
_children["as-subobject"] = as_subobject;
}
if(srlg_subobject != nullptr)
{
_children["srlg-subobject"] = srlg_subobject;
}
if(lsp_subobject != nullptr)
{
_children["lsp-subobject"] = lsp_subobject;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "type")
{
type = value;
type.value_namespace = name_space;
type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "type")
{
type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4-subobject" || name == "ipv6-subobject" || name == "unnumbered-subobject" || name == "as-subobject" || name == "srlg-subobject" || name == "lsp-subobject" || name == "type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::Ipv4Subobject()
:
address{YType::str, "address"},
prefix_len{YType::uint8, "prefix-len"},
attribute{YType::enumeration, "attribute"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "ipv4-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::~Ipv4Subobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::has_data() const
{
if (is_presence_container) return true;
return address.is_set
|| prefix_len.is_set
|| attribute.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(address.yfilter)
|| ydk::is_set(prefix_len.yfilter)
|| ydk::is_set(attribute.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv4-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata());
if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata());
if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address = value;
address.value_namespace = name_space;
address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-len")
{
prefix_len = value;
prefix_len.value_namespace = name_space;
prefix_len.value_namespace_prefix = name_space_prefix;
}
if(value_path == "attribute")
{
attribute = value;
attribute.value_namespace = name_space;
attribute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
if(value_path == "prefix-len")
{
prefix_len.yfilter = yfilter;
}
if(value_path == "attribute")
{
attribute.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::Ipv6Subobject()
:
address{YType::str, "address"},
prefix_len{YType::uint8, "prefix-len"},
attribute{YType::enumeration, "attribute"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "ipv6-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::~Ipv6Subobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::has_data() const
{
if (is_presence_container) return true;
return address.is_set
|| prefix_len.is_set
|| attribute.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(address.yfilter)
|| ydk::is_set(prefix_len.yfilter)
|| ydk::is_set(attribute.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv6-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata());
if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata());
if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address = value;
address.value_namespace = name_space;
address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-len")
{
prefix_len = value;
prefix_len.value_namespace = name_space;
prefix_len.value_namespace_prefix = name_space_prefix;
}
if(value_path == "attribute")
{
attribute = value;
attribute.value_namespace = name_space;
attribute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
if(value_path == "prefix-len")
{
prefix_len.yfilter = yfilter;
}
if(value_path == "attribute")
{
attribute.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::UnnumberedSubobject()
:
te_router_id{YType::str, "te-router-id"},
interface_id{YType::uint32, "interface-id"},
attribute{YType::enumeration, "attribute"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "unnumbered-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::~UnnumberedSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::has_data() const
{
if (is_presence_container) return true;
return te_router_id.is_set
|| interface_id.is_set
|| attribute.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(te_router_id.yfilter)
|| ydk::is_set(interface_id.yfilter)
|| ydk::is_set(attribute.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "unnumbered-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (te_router_id.is_set || is_set(te_router_id.yfilter)) leaf_name_data.push_back(te_router_id.get_name_leafdata());
if (interface_id.is_set || is_set(interface_id.yfilter)) leaf_name_data.push_back(interface_id.get_name_leafdata());
if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "te-router-id")
{
te_router_id = value;
te_router_id.value_namespace = name_space;
te_router_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "interface-id")
{
interface_id = value;
interface_id.value_namespace = name_space;
interface_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "attribute")
{
attribute = value;
attribute.value_namespace = name_space;
attribute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "te-router-id")
{
te_router_id.yfilter = yfilter;
}
if(value_path == "interface-id")
{
interface_id.yfilter = yfilter;
}
if(value_path == "attribute")
{
attribute.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "te-router-id" || name == "interface-id" || name == "attribute" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::AsSubobject()
:
as_number{YType::uint16, "as-number"}
{
yang_name = "as-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::~AsSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::has_data() const
{
if (is_presence_container) return true;
return as_number.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(as_number.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "as-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (as_number.is_set || is_set(as_number.yfilter)) leaf_name_data.push_back(as_number.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "as-number")
{
as_number = value;
as_number.value_namespace = name_space;
as_number.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "as-number")
{
as_number.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "as-number")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::SrlgSubobject()
:
srlg_id{YType::uint32, "srlg-id"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "srlg-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::~SrlgSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::has_data() const
{
if (is_presence_container) return true;
return srlg_id.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(srlg_id.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "srlg-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (srlg_id.is_set || is_set(srlg_id.yfilter)) leaf_name_data.push_back(srlg_id.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "srlg-id")
{
srlg_id = value;
srlg_id.value_namespace = name_space;
srlg_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "srlg-id")
{
srlg_id.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "srlg-id" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::LspSubobject()
:
ignore_lsp_id{YType::boolean, "ignore-lsp-id"},
processing_node_exception{YType::boolean, "processing-node-exception"},
penultimate_node_exception{YType::boolean, "penultimate-node-exception"},
destination_node_exception{YType::boolean, "destination-node-exception"},
exclusion_type{YType::enumeration, "exclusion-type"}
,
fec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec>())
{
fec->parent = this;
yang_name = "lsp-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::~LspSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::has_data() const
{
if (is_presence_container) return true;
return ignore_lsp_id.is_set
|| processing_node_exception.is_set
|| penultimate_node_exception.is_set
|| destination_node_exception.is_set
|| exclusion_type.is_set
|| (fec != nullptr && fec->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ignore_lsp_id.yfilter)
|| ydk::is_set(processing_node_exception.yfilter)
|| ydk::is_set(penultimate_node_exception.yfilter)
|| ydk::is_set(destination_node_exception.yfilter)
|| ydk::is_set(exclusion_type.yfilter)
|| (fec != nullptr && fec->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "lsp-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ignore_lsp_id.is_set || is_set(ignore_lsp_id.yfilter)) leaf_name_data.push_back(ignore_lsp_id.get_name_leafdata());
if (processing_node_exception.is_set || is_set(processing_node_exception.yfilter)) leaf_name_data.push_back(processing_node_exception.get_name_leafdata());
if (penultimate_node_exception.is_set || is_set(penultimate_node_exception.yfilter)) leaf_name_data.push_back(penultimate_node_exception.get_name_leafdata());
if (destination_node_exception.is_set || is_set(destination_node_exception.yfilter)) leaf_name_data.push_back(destination_node_exception.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "fec")
{
if(fec == nullptr)
{
fec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec>();
}
return fec;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(fec != nullptr)
{
_children["fec"] = fec;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ignore-lsp-id")
{
ignore_lsp_id = value;
ignore_lsp_id.value_namespace = name_space;
ignore_lsp_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "processing-node-exception")
{
processing_node_exception = value;
processing_node_exception.value_namespace = name_space;
processing_node_exception.value_namespace_prefix = name_space_prefix;
}
if(value_path == "penultimate-node-exception")
{
penultimate_node_exception = value;
penultimate_node_exception.value_namespace = name_space;
penultimate_node_exception.value_namespace_prefix = name_space_prefix;
}
if(value_path == "destination-node-exception")
{
destination_node_exception = value;
destination_node_exception.value_namespace = name_space;
destination_node_exception.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ignore-lsp-id")
{
ignore_lsp_id.yfilter = yfilter;
}
if(value_path == "processing-node-exception")
{
processing_node_exception.yfilter = yfilter;
}
if(value_path == "penultimate-node-exception")
{
penultimate_node_exception.yfilter = yfilter;
}
if(value_path == "destination-node-exception")
{
destination_node_exception.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "fec" || name == "ignore-lsp-id" || name == "processing-node-exception" || name == "penultimate-node-exception" || name == "destination-node-exception" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::Fec()
:
fec_lsp_id{YType::uint16, "fec-lsp-id"},
fec_tunnel_id{YType::uint16, "fec-tunnel-id"},
fec_extended_tunnel_id{YType::str, "fec-extended-tunnel-id"},
fec_source{YType::str, "fec-source"},
fec_vrf{YType::str, "fec-vrf"}
,
fec_destination_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo>())
{
fec_destination_info->parent = this;
yang_name = "fec"; yang_parent_name = "lsp-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::~Fec()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::has_data() const
{
if (is_presence_container) return true;
return fec_lsp_id.is_set
|| fec_tunnel_id.is_set
|| fec_extended_tunnel_id.is_set
|| fec_source.is_set
|| fec_vrf.is_set
|| (fec_destination_info != nullptr && fec_destination_info->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(fec_lsp_id.yfilter)
|| ydk::is_set(fec_tunnel_id.yfilter)
|| ydk::is_set(fec_extended_tunnel_id.yfilter)
|| ydk::is_set(fec_source.yfilter)
|| ydk::is_set(fec_vrf.yfilter)
|| (fec_destination_info != nullptr && fec_destination_info->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "fec";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (fec_lsp_id.is_set || is_set(fec_lsp_id.yfilter)) leaf_name_data.push_back(fec_lsp_id.get_name_leafdata());
if (fec_tunnel_id.is_set || is_set(fec_tunnel_id.yfilter)) leaf_name_data.push_back(fec_tunnel_id.get_name_leafdata());
if (fec_extended_tunnel_id.is_set || is_set(fec_extended_tunnel_id.yfilter)) leaf_name_data.push_back(fec_extended_tunnel_id.get_name_leafdata());
if (fec_source.is_set || is_set(fec_source.yfilter)) leaf_name_data.push_back(fec_source.get_name_leafdata());
if (fec_vrf.is_set || is_set(fec_vrf.yfilter)) leaf_name_data.push_back(fec_vrf.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "fec-destination-info")
{
if(fec_destination_info == nullptr)
{
fec_destination_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo>();
}
return fec_destination_info;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(fec_destination_info != nullptr)
{
_children["fec-destination-info"] = fec_destination_info;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "fec-lsp-id")
{
fec_lsp_id = value;
fec_lsp_id.value_namespace = name_space;
fec_lsp_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-tunnel-id")
{
fec_tunnel_id = value;
fec_tunnel_id.value_namespace = name_space;
fec_tunnel_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-extended-tunnel-id")
{
fec_extended_tunnel_id = value;
fec_extended_tunnel_id.value_namespace = name_space;
fec_extended_tunnel_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-source")
{
fec_source = value;
fec_source.value_namespace = name_space;
fec_source.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-vrf")
{
fec_vrf = value;
fec_vrf.value_namespace = name_space;
fec_vrf.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "fec-lsp-id")
{
fec_lsp_id.yfilter = yfilter;
}
if(value_path == "fec-tunnel-id")
{
fec_tunnel_id.yfilter = yfilter;
}
if(value_path == "fec-extended-tunnel-id")
{
fec_extended_tunnel_id.yfilter = yfilter;
}
if(value_path == "fec-source")
{
fec_source.yfilter = yfilter;
}
if(value_path == "fec-vrf")
{
fec_vrf.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "fec-destination-info" || name == "fec-lsp-id" || name == "fec-tunnel-id" || name == "fec-extended-tunnel-id" || name == "fec-source" || name == "fec-vrf")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::FecDestinationInfo()
:
fec_ctype{YType::enumeration, "fec-ctype"},
p2p_lsp_destination{YType::str, "p2p-lsp-destination"},
fec_destination_p2mp_id{YType::uint32, "fec-destination-p2mp-id"}
{
yang_name = "fec-destination-info"; yang_parent_name = "fec"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::~FecDestinationInfo()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_data() const
{
if (is_presence_container) return true;
return fec_ctype.is_set
|| p2p_lsp_destination.is_set
|| fec_destination_p2mp_id.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(fec_ctype.yfilter)
|| ydk::is_set(p2p_lsp_destination.yfilter)
|| ydk::is_set(fec_destination_p2mp_id.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "fec-destination-info";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (fec_ctype.is_set || is_set(fec_ctype.yfilter)) leaf_name_data.push_back(fec_ctype.get_name_leafdata());
if (p2p_lsp_destination.is_set || is_set(p2p_lsp_destination.yfilter)) leaf_name_data.push_back(p2p_lsp_destination.get_name_leafdata());
if (fec_destination_p2mp_id.is_set || is_set(fec_destination_p2mp_id.yfilter)) leaf_name_data.push_back(fec_destination_p2mp_id.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "fec-ctype")
{
fec_ctype = value;
fec_ctype.value_namespace = name_space;
fec_ctype.value_namespace_prefix = name_space_prefix;
}
if(value_path == "p2p-lsp-destination")
{
p2p_lsp_destination = value;
p2p_lsp_destination.value_namespace = name_space;
p2p_lsp_destination.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-destination-p2mp-id")
{
fec_destination_p2mp_id = value;
fec_destination_p2mp_id.value_namespace = name_space;
fec_destination_p2mp_id.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "fec-ctype")
{
fec_ctype.yfilter = yfilter;
}
if(value_path == "p2p-lsp-destination")
{
p2p_lsp_destination.yfilter = yfilter;
}
if(value_path == "fec-destination-p2mp-id")
{
fec_destination_p2mp_id.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "fec-ctype" || name == "p2p-lsp-destination" || name == "fec-destination-p2mp-id")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::AttributeSetP2mpte()
:
fast_reroute{YType::boolean, "fast-reroute"},
frr_bandwidth_protection{YType::boolean, "frr-bandwidth-protection"},
setup_priority{YType::uint8, "setup-priority"},
hold_priority{YType::uint8, "hold-priority"},
is_priority_configured{YType::boolean, "is-priority-configured"},
configured_bandwidth{YType::uint32, "configured-bandwidth"},
dste_class_type{YType::uint8, "dste-class-type"},
is_bandwidth_configured{YType::boolean, "is-bandwidth-configured"},
is_affinity_configured{YType::boolean, "is-affinity-configured"}
,
affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity>())
, tunnel_id(this, {})
{
affinity->parent = this;
yang_name = "attribute-set-p2mpte"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::~AttributeSetP2mpte()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_data())
return true;
}
return fast_reroute.is_set
|| frr_bandwidth_protection.is_set
|| setup_priority.is_set
|| hold_priority.is_set
|| is_priority_configured.is_set
|| configured_bandwidth.is_set
|| dste_class_type.is_set
|| is_bandwidth_configured.is_set
|| is_affinity_configured.is_set
|| (affinity != nullptr && affinity->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::has_operation() const
{
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(fast_reroute.yfilter)
|| ydk::is_set(frr_bandwidth_protection.yfilter)
|| ydk::is_set(setup_priority.yfilter)
|| ydk::is_set(hold_priority.yfilter)
|| ydk::is_set(is_priority_configured.yfilter)
|| ydk::is_set(configured_bandwidth.yfilter)
|| ydk::is_set(dste_class_type.yfilter)
|| ydk::is_set(is_bandwidth_configured.yfilter)
|| ydk::is_set(is_affinity_configured.yfilter)
|| (affinity != nullptr && affinity->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-p2mpte";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (fast_reroute.is_set || is_set(fast_reroute.yfilter)) leaf_name_data.push_back(fast_reroute.get_name_leafdata());
if (frr_bandwidth_protection.is_set || is_set(frr_bandwidth_protection.yfilter)) leaf_name_data.push_back(frr_bandwidth_protection.get_name_leafdata());
if (setup_priority.is_set || is_set(setup_priority.yfilter)) leaf_name_data.push_back(setup_priority.get_name_leafdata());
if (hold_priority.is_set || is_set(hold_priority.yfilter)) leaf_name_data.push_back(hold_priority.get_name_leafdata());
if (is_priority_configured.is_set || is_set(is_priority_configured.yfilter)) leaf_name_data.push_back(is_priority_configured.get_name_leafdata());
if (configured_bandwidth.is_set || is_set(configured_bandwidth.yfilter)) leaf_name_data.push_back(configured_bandwidth.get_name_leafdata());
if (dste_class_type.is_set || is_set(dste_class_type.yfilter)) leaf_name_data.push_back(dste_class_type.get_name_leafdata());
if (is_bandwidth_configured.is_set || is_set(is_bandwidth_configured.yfilter)) leaf_name_data.push_back(is_bandwidth_configured.get_name_leafdata());
if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "affinity")
{
if(affinity == nullptr)
{
affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity>();
}
return affinity;
}
if(child_yang_name == "tunnel-id")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId>();
ent_->parent = this;
tunnel_id.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(affinity != nullptr)
{
_children["affinity"] = affinity;
}
count_ = 0;
for (auto ent_ : tunnel_id.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "fast-reroute")
{
fast_reroute = value;
fast_reroute.value_namespace = name_space;
fast_reroute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "frr-bandwidth-protection")
{
frr_bandwidth_protection = value;
frr_bandwidth_protection.value_namespace = name_space;
frr_bandwidth_protection.value_namespace_prefix = name_space_prefix;
}
if(value_path == "setup-priority")
{
setup_priority = value;
setup_priority.value_namespace = name_space;
setup_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "hold-priority")
{
hold_priority = value;
hold_priority.value_namespace = name_space;
hold_priority.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-priority-configured")
{
is_priority_configured = value;
is_priority_configured.value_namespace = name_space;
is_priority_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "configured-bandwidth")
{
configured_bandwidth = value;
configured_bandwidth.value_namespace = name_space;
configured_bandwidth.value_namespace_prefix = name_space_prefix;
}
if(value_path == "dste-class-type")
{
dste_class_type = value;
dste_class_type.value_namespace = name_space;
dste_class_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-bandwidth-configured")
{
is_bandwidth_configured = value;
is_bandwidth_configured.value_namespace = name_space;
is_bandwidth_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured = value;
is_affinity_configured.value_namespace = name_space;
is_affinity_configured.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "fast-reroute")
{
fast_reroute.yfilter = yfilter;
}
if(value_path == "frr-bandwidth-protection")
{
frr_bandwidth_protection.yfilter = yfilter;
}
if(value_path == "setup-priority")
{
setup_priority.yfilter = yfilter;
}
if(value_path == "hold-priority")
{
hold_priority.yfilter = yfilter;
}
if(value_path == "is-priority-configured")
{
is_priority_configured.yfilter = yfilter;
}
if(value_path == "configured-bandwidth")
{
configured_bandwidth.yfilter = yfilter;
}
if(value_path == "dste-class-type")
{
dste_class_type.yfilter = yfilter;
}
if(value_path == "is-bandwidth-configured")
{
is_bandwidth_configured.yfilter = yfilter;
}
if(value_path == "is-affinity-configured")
{
is_affinity_configured.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "affinity" || name == "tunnel-id" || name == "fast-reroute" || name == "frr-bandwidth-protection" || name == "setup-priority" || name == "hold-priority" || name == "is-priority-configured" || name == "configured-bandwidth" || name == "dste-class-type" || name == "is-bandwidth-configured" || name == "is-affinity-configured")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::Affinity()
:
affinity_bits{YType::uint32, "affinity-bits"},
affinity_mask{YType::uint32, "affinity-mask"}
,
named_affinity(this, {})
{
yang_name = "affinity"; yang_parent_name = "attribute-set-p2mpte"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::~Affinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_data())
return true;
}
return affinity_bits.is_set
|| affinity_mask.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::has_operation() const
{
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(affinity_bits.yfilter)
|| ydk::is_set(affinity_mask.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "affinity";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata());
if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "named-affinity")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity>();
ent_->parent = this;
named_affinity.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : named_affinity.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "affinity-bits")
{
affinity_bits = value;
affinity_bits.value_namespace = name_space;
affinity_bits.value_namespace_prefix = name_space_prefix;
}
if(value_path == "affinity-mask")
{
affinity_mask = value;
affinity_mask.value_namespace = name_space;
affinity_mask.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "affinity-bits")
{
affinity_bits.yfilter = yfilter;
}
if(value_path == "affinity-mask")
{
affinity_mask.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::NamedAffinity()
:
constraint_type{YType::uint8, "constraint-type"},
constraint_value{YType::uint32, "constraint-value"},
forward_ref_value{YType::uint32, "forward-ref-value"}
,
constraint_extended_value(this, {})
, extended_forward_ref_value(this, {})
{
yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::~NamedAffinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_data())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_data())
return true;
}
return constraint_type.is_set
|| constraint_value.is_set
|| forward_ref_value.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::has_operation() const
{
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_operation())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(constraint_type.yfilter)
|| ydk::is_set(constraint_value.yfilter)
|| ydk::is_set(forward_ref_value.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "named-affinity";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata());
if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata());
if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "constraint-extended-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue>();
ent_->parent = this;
constraint_extended_value.append(ent_);
return ent_;
}
if(child_yang_name == "extended-forward-ref-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue>();
ent_->parent = this;
extended_forward_ref_value.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : constraint_extended_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : extended_forward_ref_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "constraint-type")
{
constraint_type = value;
constraint_type.value_namespace = name_space;
constraint_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "constraint-value")
{
constraint_value = value;
constraint_value.value_namespace = name_space;
constraint_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "forward-ref-value")
{
forward_ref_value = value;
forward_ref_value.value_namespace = name_space;
forward_ref_value.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "constraint-type")
{
constraint_type.yfilter = yfilter;
}
if(value_path == "constraint-value")
{
constraint_value.yfilter = yfilter;
}
if(value_path == "forward-ref-value")
{
forward_ref_value.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "constraint-extended-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "extended-forward-ref-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::TunnelId()
:
entry{YType::uint16, "entry"}
{
yang_name = "tunnel-id"; yang_parent_name = "attribute-set-p2mpte"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::~TunnelId()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tunnel-id";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::AttributeSetApsPp()
:
snc_mode{YType::enumeration, "snc-mode"},
tcm_id{YType::uint32, "tcm-id"},
protection_type{YType::enumeration, "protection-type"},
protection_mode{YType::enumeration, "protection-mode"},
wait_to_restore_time{YType::uint32, "wait-to-restore-time"},
hold_off_time{YType::uint32, "hold-off-time"},
path_prot_profile_type{YType::enumeration, "path-prot-profile-type"},
restoration_style{YType::enumeration, "restoration-style"}
,
revert_schedule(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule>())
{
revert_schedule->parent = this;
yang_name = "attribute-set-aps-pp"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::~AttributeSetApsPp()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::has_data() const
{
if (is_presence_container) return true;
return snc_mode.is_set
|| tcm_id.is_set
|| protection_type.is_set
|| protection_mode.is_set
|| wait_to_restore_time.is_set
|| hold_off_time.is_set
|| path_prot_profile_type.is_set
|| restoration_style.is_set
|| (revert_schedule != nullptr && revert_schedule->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(snc_mode.yfilter)
|| ydk::is_set(tcm_id.yfilter)
|| ydk::is_set(protection_type.yfilter)
|| ydk::is_set(protection_mode.yfilter)
|| ydk::is_set(wait_to_restore_time.yfilter)
|| ydk::is_set(hold_off_time.yfilter)
|| ydk::is_set(path_prot_profile_type.yfilter)
|| ydk::is_set(restoration_style.yfilter)
|| (revert_schedule != nullptr && revert_schedule->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-aps-pp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (snc_mode.is_set || is_set(snc_mode.yfilter)) leaf_name_data.push_back(snc_mode.get_name_leafdata());
if (tcm_id.is_set || is_set(tcm_id.yfilter)) leaf_name_data.push_back(tcm_id.get_name_leafdata());
if (protection_type.is_set || is_set(protection_type.yfilter)) leaf_name_data.push_back(protection_type.get_name_leafdata());
if (protection_mode.is_set || is_set(protection_mode.yfilter)) leaf_name_data.push_back(protection_mode.get_name_leafdata());
if (wait_to_restore_time.is_set || is_set(wait_to_restore_time.yfilter)) leaf_name_data.push_back(wait_to_restore_time.get_name_leafdata());
if (hold_off_time.is_set || is_set(hold_off_time.yfilter)) leaf_name_data.push_back(hold_off_time.get_name_leafdata());
if (path_prot_profile_type.is_set || is_set(path_prot_profile_type.yfilter)) leaf_name_data.push_back(path_prot_profile_type.get_name_leafdata());
if (restoration_style.is_set || is_set(restoration_style.yfilter)) leaf_name_data.push_back(restoration_style.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "revert-schedule")
{
if(revert_schedule == nullptr)
{
revert_schedule = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule>();
}
return revert_schedule;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(revert_schedule != nullptr)
{
_children["revert-schedule"] = revert_schedule;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "snc-mode")
{
snc_mode = value;
snc_mode.value_namespace = name_space;
snc_mode.value_namespace_prefix = name_space_prefix;
}
if(value_path == "tcm-id")
{
tcm_id = value;
tcm_id.value_namespace = name_space;
tcm_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "protection-type")
{
protection_type = value;
protection_type.value_namespace = name_space;
protection_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "protection-mode")
{
protection_mode = value;
protection_mode.value_namespace = name_space;
protection_mode.value_namespace_prefix = name_space_prefix;
}
if(value_path == "wait-to-restore-time")
{
wait_to_restore_time = value;
wait_to_restore_time.value_namespace = name_space;
wait_to_restore_time.value_namespace_prefix = name_space_prefix;
}
if(value_path == "hold-off-time")
{
hold_off_time = value;
hold_off_time.value_namespace = name_space;
hold_off_time.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-prot-profile-type")
{
path_prot_profile_type = value;
path_prot_profile_type.value_namespace = name_space;
path_prot_profile_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "restoration-style")
{
restoration_style = value;
restoration_style.value_namespace = name_space;
restoration_style.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "snc-mode")
{
snc_mode.yfilter = yfilter;
}
if(value_path == "tcm-id")
{
tcm_id.yfilter = yfilter;
}
if(value_path == "protection-type")
{
protection_type.yfilter = yfilter;
}
if(value_path == "protection-mode")
{
protection_mode.yfilter = yfilter;
}
if(value_path == "wait-to-restore-time")
{
wait_to_restore_time.yfilter = yfilter;
}
if(value_path == "hold-off-time")
{
hold_off_time.yfilter = yfilter;
}
if(value_path == "path-prot-profile-type")
{
path_prot_profile_type.yfilter = yfilter;
}
if(value_path == "restoration-style")
{
restoration_style.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "revert-schedule" || name == "snc-mode" || name == "tcm-id" || name == "protection-type" || name == "protection-mode" || name == "wait-to-restore-time" || name == "hold-off-time" || name == "path-prot-profile-type" || name == "restoration-style")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::RevertSchedule()
:
schedulename{YType::str, "schedulename"},
schedule_date{YType::uint32, "schedule-date"},
schedule_frequency{YType::enumeration, "schedule-frequency"},
duration{YType::uint32, "duration"},
max_tries{YType::uint32, "max-tries"}
{
yang_name = "revert-schedule"; yang_parent_name = "attribute-set-aps-pp"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::~RevertSchedule()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::has_data() const
{
if (is_presence_container) return true;
return schedulename.is_set
|| schedule_date.is_set
|| schedule_frequency.is_set
|| duration.is_set
|| max_tries.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(schedulename.yfilter)
|| ydk::is_set(schedule_date.yfilter)
|| ydk::is_set(schedule_frequency.yfilter)
|| ydk::is_set(duration.yfilter)
|| ydk::is_set(max_tries.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "revert-schedule";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (schedulename.is_set || is_set(schedulename.yfilter)) leaf_name_data.push_back(schedulename.get_name_leafdata());
if (schedule_date.is_set || is_set(schedule_date.yfilter)) leaf_name_data.push_back(schedule_date.get_name_leafdata());
if (schedule_frequency.is_set || is_set(schedule_frequency.yfilter)) leaf_name_data.push_back(schedule_frequency.get_name_leafdata());
if (duration.is_set || is_set(duration.yfilter)) leaf_name_data.push_back(duration.get_name_leafdata());
if (max_tries.is_set || is_set(max_tries.yfilter)) leaf_name_data.push_back(max_tries.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "schedulename")
{
schedulename = value;
schedulename.value_namespace = name_space;
schedulename.value_namespace_prefix = name_space_prefix;
}
if(value_path == "schedule-date")
{
schedule_date = value;
schedule_date.value_namespace = name_space;
schedule_date.value_namespace_prefix = name_space_prefix;
}
if(value_path == "schedule-frequency")
{
schedule_frequency = value;
schedule_frequency.value_namespace = name_space;
schedule_frequency.value_namespace_prefix = name_space_prefix;
}
if(value_path == "duration")
{
duration = value;
duration.value_namespace = name_space;
duration.value_namespace_prefix = name_space_prefix;
}
if(value_path == "max-tries")
{
max_tries = value;
max_tries.value_namespace = name_space;
max_tries.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "schedulename")
{
schedulename.yfilter = yfilter;
}
if(value_path == "schedule-date")
{
schedule_date.yfilter = yfilter;
}
if(value_path == "schedule-frequency")
{
schedule_frequency.yfilter = yfilter;
}
if(value_path == "duration")
{
duration.yfilter = yfilter;
}
if(value_path == "max-tries")
{
max_tries.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "schedulename" || name == "schedule-date" || name == "schedule-frequency" || name == "duration" || name == "max-tries")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::AttributeSetP2pTe()
:
is_affinity_configured{YType::boolean, "is-affinity-configured"},
path_selection_segment_routing_adjacency_protection{YType::enumeration, "path-selection-segment-routing-adjacency-protection"},
is_path_selection_segment_routing_adjacency_protection_configured{YType::boolean, "is-path-selection-segment-routing-adjacency-protection-configured"},
path_invalidation_timeout{YType::uint32, "path-invalidation-timeout"},
path_selection_invalidation_action{YType::enumeration, "path-selection-invalidation-action"},
is_path_invalidation_timeout_configured{YType::boolean, "is-path-invalidation-timeout-configured"},
is_path_invalidation_action_configured{YType::boolean, "is-path-invalidation-action-configured"},
path_selection_metric{YType::enumeration, "path-selection-metric"},
is_path_selection_metric_configured{YType::boolean, "is-path-selection-metric-configured"},
path_selection_segment_routing_margin{YType::uint32, "path-selection-segment-routing-margin"},
is_path_selection_segment_routing_margin_relative{YType::boolean, "is-path-selection-segment-routing-margin-relative"},
is_path_selection_segment_routing_margin_configured{YType::boolean, "is-path-selection-segment-routing-margin-configured"},
path_selection_segment_routing_segment_limit{YType::uint32, "path-selection-segment-routing-segment-limit"},
is_path_selection_segment_routing_segment_limit_configured{YType::boolean, "is-path-selection-segment-routing-segment-limit-configured"},
is_path_select_configured{YType::boolean, "is-path-select-configured"},
is_prepend_list_configured{YType::boolean, "is-prepend-list-configured"},
is_pce_configured{YType::boolean, "is-pce-configured"},
is_pce_disj_source_configured{YType::boolean, "is-pce-disj-source-configured"},
is_pce_disj_type_configured{YType::boolean, "is-pce-disj-type-configured"},
is_pce_disj_group_id_configured{YType::boolean, "is-pce-disj-group-id-configured"},
pcedp_source_address{YType::uint32, "pcedp-source-address"},
pcedp_type{YType::enumeration, "pcedp-type"},
pcedp_group_id{YType::uint32, "pcedp-group-id"},
is_pceb_dj_source_configured{YType::boolean, "is-pceb-dj-source-configured"},
is_pcebd_group_id_configured{YType::boolean, "is-pcebd-group-id-configured"},
pcebd_source_address{YType::uint32, "pcebd-source-address"},
pcebd_group_id{YType::uint32, "pcebd-group-id"}
,
affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity>())
, logging(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging>())
, prepend_list(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList>())
, tunnel_id(this, {})
{
affinity->parent = this;
logging->parent = this;
prepend_list->parent = this;
yang_name = "attribute-set-p2p-te"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::~AttributeSetP2pTe()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_data())
return true;
}
return is_affinity_configured.is_set
|| path_selection_segment_routing_adjacency_protection.is_set
|| is_path_selection_segment_routing_adjacency_protection_configured.is_set
|| path_invalidation_timeout.is_set
|| path_selection_invalidation_action.is_set
|| is_path_invalidation_timeout_configured.is_set
|| is_path_invalidation_action_configured.is_set
|| path_selection_metric.is_set
|| is_path_selection_metric_configured.is_set
|| path_selection_segment_routing_margin.is_set
|| is_path_selection_segment_routing_margin_relative.is_set
|| is_path_selection_segment_routing_margin_configured.is_set
|| path_selection_segment_routing_segment_limit.is_set
|| is_path_selection_segment_routing_segment_limit_configured.is_set
|| is_path_select_configured.is_set
|| is_prepend_list_configured.is_set
|| is_pce_configured.is_set
|| is_pce_disj_source_configured.is_set
|| is_pce_disj_type_configured.is_set
|| is_pce_disj_group_id_configured.is_set
|| pcedp_source_address.is_set
|| pcedp_type.is_set
|| pcedp_group_id.is_set
|| is_pceb_dj_source_configured.is_set
|| is_pcebd_group_id_configured.is_set
|| pcebd_source_address.is_set
|| pcebd_group_id.is_set
|| (affinity != nullptr && affinity->has_data())
|| (logging != nullptr && logging->has_data())
|| (prepend_list != nullptr && prepend_list->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::has_operation() const
{
for (std::size_t index=0; index<tunnel_id.len(); index++)
{
if(tunnel_id[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(is_affinity_configured.yfilter)
|| ydk::is_set(path_selection_segment_routing_adjacency_protection.yfilter)
|| ydk::is_set(is_path_selection_segment_routing_adjacency_protection_configured.yfilter)
|| ydk::is_set(path_invalidation_timeout.yfilter)
|| ydk::is_set(path_selection_invalidation_action.yfilter)
|| ydk::is_set(is_path_invalidation_timeout_configured.yfilter)
|| ydk::is_set(is_path_invalidation_action_configured.yfilter)
|| ydk::is_set(path_selection_metric.yfilter)
|| ydk::is_set(is_path_selection_metric_configured.yfilter)
|| ydk::is_set(path_selection_segment_routing_margin.yfilter)
|| ydk::is_set(is_path_selection_segment_routing_margin_relative.yfilter)
|| ydk::is_set(is_path_selection_segment_routing_margin_configured.yfilter)
|| ydk::is_set(path_selection_segment_routing_segment_limit.yfilter)
|| ydk::is_set(is_path_selection_segment_routing_segment_limit_configured.yfilter)
|| ydk::is_set(is_path_select_configured.yfilter)
|| ydk::is_set(is_prepend_list_configured.yfilter)
|| ydk::is_set(is_pce_configured.yfilter)
|| ydk::is_set(is_pce_disj_source_configured.yfilter)
|| ydk::is_set(is_pce_disj_type_configured.yfilter)
|| ydk::is_set(is_pce_disj_group_id_configured.yfilter)
|| ydk::is_set(pcedp_source_address.yfilter)
|| ydk::is_set(pcedp_type.yfilter)
|| ydk::is_set(pcedp_group_id.yfilter)
|| ydk::is_set(is_pceb_dj_source_configured.yfilter)
|| ydk::is_set(is_pcebd_group_id_configured.yfilter)
|| ydk::is_set(pcebd_source_address.yfilter)
|| ydk::is_set(pcebd_group_id.yfilter)
|| (affinity != nullptr && affinity->has_operation())
|| (logging != nullptr && logging->has_operation())
|| (prepend_list != nullptr && prepend_list->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "attribute-set-p2p-te";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata());
if (path_selection_segment_routing_adjacency_protection.is_set || is_set(path_selection_segment_routing_adjacency_protection.yfilter)) leaf_name_data.push_back(path_selection_segment_routing_adjacency_protection.get_name_leafdata());
if (is_path_selection_segment_routing_adjacency_protection_configured.is_set || is_set(is_path_selection_segment_routing_adjacency_protection_configured.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_adjacency_protection_configured.get_name_leafdata());
if (path_invalidation_timeout.is_set || is_set(path_invalidation_timeout.yfilter)) leaf_name_data.push_back(path_invalidation_timeout.get_name_leafdata());
if (path_selection_invalidation_action.is_set || is_set(path_selection_invalidation_action.yfilter)) leaf_name_data.push_back(path_selection_invalidation_action.get_name_leafdata());
if (is_path_invalidation_timeout_configured.is_set || is_set(is_path_invalidation_timeout_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_timeout_configured.get_name_leafdata());
if (is_path_invalidation_action_configured.is_set || is_set(is_path_invalidation_action_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_action_configured.get_name_leafdata());
if (path_selection_metric.is_set || is_set(path_selection_metric.yfilter)) leaf_name_data.push_back(path_selection_metric.get_name_leafdata());
if (is_path_selection_metric_configured.is_set || is_set(is_path_selection_metric_configured.yfilter)) leaf_name_data.push_back(is_path_selection_metric_configured.get_name_leafdata());
if (path_selection_segment_routing_margin.is_set || is_set(path_selection_segment_routing_margin.yfilter)) leaf_name_data.push_back(path_selection_segment_routing_margin.get_name_leafdata());
if (is_path_selection_segment_routing_margin_relative.is_set || is_set(is_path_selection_segment_routing_margin_relative.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_margin_relative.get_name_leafdata());
if (is_path_selection_segment_routing_margin_configured.is_set || is_set(is_path_selection_segment_routing_margin_configured.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_margin_configured.get_name_leafdata());
if (path_selection_segment_routing_segment_limit.is_set || is_set(path_selection_segment_routing_segment_limit.yfilter)) leaf_name_data.push_back(path_selection_segment_routing_segment_limit.get_name_leafdata());
if (is_path_selection_segment_routing_segment_limit_configured.is_set || is_set(is_path_selection_segment_routing_segment_limit_configured.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_segment_limit_configured.get_name_leafdata());
if (is_path_select_configured.is_set || is_set(is_path_select_configured.yfilter)) leaf_name_data.push_back(is_path_select_configured.get_name_leafdata());
if (is_prepend_list_configured.is_set || is_set(is_prepend_list_configured.yfilter)) leaf_name_data.push_back(is_prepend_list_configured.get_name_leafdata());
if (is_pce_configured.is_set || is_set(is_pce_configured.yfilter)) leaf_name_data.push_back(is_pce_configured.get_name_leafdata());
if (is_pce_disj_source_configured.is_set || is_set(is_pce_disj_source_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_source_configured.get_name_leafdata());
if (is_pce_disj_type_configured.is_set || is_set(is_pce_disj_type_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_type_configured.get_name_leafdata());
if (is_pce_disj_group_id_configured.is_set || is_set(is_pce_disj_group_id_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_group_id_configured.get_name_leafdata());
if (pcedp_source_address.is_set || is_set(pcedp_source_address.yfilter)) leaf_name_data.push_back(pcedp_source_address.get_name_leafdata());
if (pcedp_type.is_set || is_set(pcedp_type.yfilter)) leaf_name_data.push_back(pcedp_type.get_name_leafdata());
if (pcedp_group_id.is_set || is_set(pcedp_group_id.yfilter)) leaf_name_data.push_back(pcedp_group_id.get_name_leafdata());
if (is_pceb_dj_source_configured.is_set || is_set(is_pceb_dj_source_configured.yfilter)) leaf_name_data.push_back(is_pceb_dj_source_configured.get_name_leafdata());
if (is_pcebd_group_id_configured.is_set || is_set(is_pcebd_group_id_configured.yfilter)) leaf_name_data.push_back(is_pcebd_group_id_configured.get_name_leafdata());
if (pcebd_source_address.is_set || is_set(pcebd_source_address.yfilter)) leaf_name_data.push_back(pcebd_source_address.get_name_leafdata());
if (pcebd_group_id.is_set || is_set(pcebd_group_id.yfilter)) leaf_name_data.push_back(pcebd_group_id.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "affinity")
{
if(affinity == nullptr)
{
affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity>();
}
return affinity;
}
if(child_yang_name == "logging")
{
if(logging == nullptr)
{
logging = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging>();
}
return logging;
}
if(child_yang_name == "prepend-list")
{
if(prepend_list == nullptr)
{
prepend_list = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList>();
}
return prepend_list;
}
if(child_yang_name == "tunnel-id")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId>();
ent_->parent = this;
tunnel_id.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(affinity != nullptr)
{
_children["affinity"] = affinity;
}
if(logging != nullptr)
{
_children["logging"] = logging;
}
if(prepend_list != nullptr)
{
_children["prepend-list"] = prepend_list;
}
count_ = 0;
for (auto ent_ : tunnel_id.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "is-affinity-configured")
{
is_affinity_configured = value;
is_affinity_configured.value_namespace = name_space;
is_affinity_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-selection-segment-routing-adjacency-protection")
{
path_selection_segment_routing_adjacency_protection = value;
path_selection_segment_routing_adjacency_protection.value_namespace = name_space;
path_selection_segment_routing_adjacency_protection.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-selection-segment-routing-adjacency-protection-configured")
{
is_path_selection_segment_routing_adjacency_protection_configured = value;
is_path_selection_segment_routing_adjacency_protection_configured.value_namespace = name_space;
is_path_selection_segment_routing_adjacency_protection_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-invalidation-timeout")
{
path_invalidation_timeout = value;
path_invalidation_timeout.value_namespace = name_space;
path_invalidation_timeout.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-selection-invalidation-action")
{
path_selection_invalidation_action = value;
path_selection_invalidation_action.value_namespace = name_space;
path_selection_invalidation_action.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-invalidation-timeout-configured")
{
is_path_invalidation_timeout_configured = value;
is_path_invalidation_timeout_configured.value_namespace = name_space;
is_path_invalidation_timeout_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-invalidation-action-configured")
{
is_path_invalidation_action_configured = value;
is_path_invalidation_action_configured.value_namespace = name_space;
is_path_invalidation_action_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-selection-metric")
{
path_selection_metric = value;
path_selection_metric.value_namespace = name_space;
path_selection_metric.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-selection-metric-configured")
{
is_path_selection_metric_configured = value;
is_path_selection_metric_configured.value_namespace = name_space;
is_path_selection_metric_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-selection-segment-routing-margin")
{
path_selection_segment_routing_margin = value;
path_selection_segment_routing_margin.value_namespace = name_space;
path_selection_segment_routing_margin.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-selection-segment-routing-margin-relative")
{
is_path_selection_segment_routing_margin_relative = value;
is_path_selection_segment_routing_margin_relative.value_namespace = name_space;
is_path_selection_segment_routing_margin_relative.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-selection-segment-routing-margin-configured")
{
is_path_selection_segment_routing_margin_configured = value;
is_path_selection_segment_routing_margin_configured.value_namespace = name_space;
is_path_selection_segment_routing_margin_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "path-selection-segment-routing-segment-limit")
{
path_selection_segment_routing_segment_limit = value;
path_selection_segment_routing_segment_limit.value_namespace = name_space;
path_selection_segment_routing_segment_limit.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-selection-segment-routing-segment-limit-configured")
{
is_path_selection_segment_routing_segment_limit_configured = value;
is_path_selection_segment_routing_segment_limit_configured.value_namespace = name_space;
is_path_selection_segment_routing_segment_limit_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-path-select-configured")
{
is_path_select_configured = value;
is_path_select_configured.value_namespace = name_space;
is_path_select_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-prepend-list-configured")
{
is_prepend_list_configured = value;
is_prepend_list_configured.value_namespace = name_space;
is_prepend_list_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-configured")
{
is_pce_configured = value;
is_pce_configured.value_namespace = name_space;
is_pce_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-disj-source-configured")
{
is_pce_disj_source_configured = value;
is_pce_disj_source_configured.value_namespace = name_space;
is_pce_disj_source_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-disj-type-configured")
{
is_pce_disj_type_configured = value;
is_pce_disj_type_configured.value_namespace = name_space;
is_pce_disj_type_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pce-disj-group-id-configured")
{
is_pce_disj_group_id_configured = value;
is_pce_disj_group_id_configured.value_namespace = name_space;
is_pce_disj_group_id_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcedp-source-address")
{
pcedp_source_address = value;
pcedp_source_address.value_namespace = name_space;
pcedp_source_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcedp-type")
{
pcedp_type = value;
pcedp_type.value_namespace = name_space;
pcedp_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcedp-group-id")
{
pcedp_group_id = value;
pcedp_group_id.value_namespace = name_space;
pcedp_group_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pceb-dj-source-configured")
{
is_pceb_dj_source_configured = value;
is_pceb_dj_source_configured.value_namespace = name_space;
is_pceb_dj_source_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "is-pcebd-group-id-configured")
{
is_pcebd_group_id_configured = value;
is_pcebd_group_id_configured.value_namespace = name_space;
is_pcebd_group_id_configured.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcebd-source-address")
{
pcebd_source_address = value;
pcebd_source_address.value_namespace = name_space;
pcebd_source_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pcebd-group-id")
{
pcebd_group_id = value;
pcebd_group_id.value_namespace = name_space;
pcebd_group_id.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "is-affinity-configured")
{
is_affinity_configured.yfilter = yfilter;
}
if(value_path == "path-selection-segment-routing-adjacency-protection")
{
path_selection_segment_routing_adjacency_protection.yfilter = yfilter;
}
if(value_path == "is-path-selection-segment-routing-adjacency-protection-configured")
{
is_path_selection_segment_routing_adjacency_protection_configured.yfilter = yfilter;
}
if(value_path == "path-invalidation-timeout")
{
path_invalidation_timeout.yfilter = yfilter;
}
if(value_path == "path-selection-invalidation-action")
{
path_selection_invalidation_action.yfilter = yfilter;
}
if(value_path == "is-path-invalidation-timeout-configured")
{
is_path_invalidation_timeout_configured.yfilter = yfilter;
}
if(value_path == "is-path-invalidation-action-configured")
{
is_path_invalidation_action_configured.yfilter = yfilter;
}
if(value_path == "path-selection-metric")
{
path_selection_metric.yfilter = yfilter;
}
if(value_path == "is-path-selection-metric-configured")
{
is_path_selection_metric_configured.yfilter = yfilter;
}
if(value_path == "path-selection-segment-routing-margin")
{
path_selection_segment_routing_margin.yfilter = yfilter;
}
if(value_path == "is-path-selection-segment-routing-margin-relative")
{
is_path_selection_segment_routing_margin_relative.yfilter = yfilter;
}
if(value_path == "is-path-selection-segment-routing-margin-configured")
{
is_path_selection_segment_routing_margin_configured.yfilter = yfilter;
}
if(value_path == "path-selection-segment-routing-segment-limit")
{
path_selection_segment_routing_segment_limit.yfilter = yfilter;
}
if(value_path == "is-path-selection-segment-routing-segment-limit-configured")
{
is_path_selection_segment_routing_segment_limit_configured.yfilter = yfilter;
}
if(value_path == "is-path-select-configured")
{
is_path_select_configured.yfilter = yfilter;
}
if(value_path == "is-prepend-list-configured")
{
is_prepend_list_configured.yfilter = yfilter;
}
if(value_path == "is-pce-configured")
{
is_pce_configured.yfilter = yfilter;
}
if(value_path == "is-pce-disj-source-configured")
{
is_pce_disj_source_configured.yfilter = yfilter;
}
if(value_path == "is-pce-disj-type-configured")
{
is_pce_disj_type_configured.yfilter = yfilter;
}
if(value_path == "is-pce-disj-group-id-configured")
{
is_pce_disj_group_id_configured.yfilter = yfilter;
}
if(value_path == "pcedp-source-address")
{
pcedp_source_address.yfilter = yfilter;
}
if(value_path == "pcedp-type")
{
pcedp_type.yfilter = yfilter;
}
if(value_path == "pcedp-group-id")
{
pcedp_group_id.yfilter = yfilter;
}
if(value_path == "is-pceb-dj-source-configured")
{
is_pceb_dj_source_configured.yfilter = yfilter;
}
if(value_path == "is-pcebd-group-id-configured")
{
is_pcebd_group_id_configured.yfilter = yfilter;
}
if(value_path == "pcebd-source-address")
{
pcebd_source_address.yfilter = yfilter;
}
if(value_path == "pcebd-group-id")
{
pcebd_group_id.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "affinity" || name == "logging" || name == "prepend-list" || name == "tunnel-id" || name == "is-affinity-configured" || name == "path-selection-segment-routing-adjacency-protection" || name == "is-path-selection-segment-routing-adjacency-protection-configured" || name == "path-invalidation-timeout" || name == "path-selection-invalidation-action" || name == "is-path-invalidation-timeout-configured" || name == "is-path-invalidation-action-configured" || name == "path-selection-metric" || name == "is-path-selection-metric-configured" || name == "path-selection-segment-routing-margin" || name == "is-path-selection-segment-routing-margin-relative" || name == "is-path-selection-segment-routing-margin-configured" || name == "path-selection-segment-routing-segment-limit" || name == "is-path-selection-segment-routing-segment-limit-configured" || name == "is-path-select-configured" || name == "is-prepend-list-configured" || name == "is-pce-configured" || name == "is-pce-disj-source-configured" || name == "is-pce-disj-type-configured" || name == "is-pce-disj-group-id-configured" || name == "pcedp-source-address" || name == "pcedp-type" || name == "pcedp-group-id" || name == "is-pceb-dj-source-configured" || name == "is-pcebd-group-id-configured" || name == "pcebd-source-address" || name == "pcebd-group-id")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::Affinity()
:
affinity_bits{YType::uint32, "affinity-bits"},
affinity_mask{YType::uint32, "affinity-mask"}
,
named_affinity(this, {})
{
yang_name = "affinity"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::~Affinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_data())
return true;
}
return affinity_bits.is_set
|| affinity_mask.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::has_operation() const
{
for (std::size_t index=0; index<named_affinity.len(); index++)
{
if(named_affinity[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(affinity_bits.yfilter)
|| ydk::is_set(affinity_mask.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "affinity";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata());
if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "named-affinity")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity>();
ent_->parent = this;
named_affinity.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : named_affinity.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "affinity-bits")
{
affinity_bits = value;
affinity_bits.value_namespace = name_space;
affinity_bits.value_namespace_prefix = name_space_prefix;
}
if(value_path == "affinity-mask")
{
affinity_mask = value;
affinity_mask.value_namespace = name_space;
affinity_mask.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "affinity-bits")
{
affinity_bits.yfilter = yfilter;
}
if(value_path == "affinity-mask")
{
affinity_mask.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::NamedAffinity()
:
constraint_type{YType::uint8, "constraint-type"},
constraint_value{YType::uint32, "constraint-value"},
forward_ref_value{YType::uint32, "forward-ref-value"}
,
constraint_extended_value(this, {})
, extended_forward_ref_value(this, {})
{
yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::~NamedAffinity()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_data())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_data())
return true;
}
return constraint_type.is_set
|| constraint_value.is_set
|| forward_ref_value.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::has_operation() const
{
for (std::size_t index=0; index<constraint_extended_value.len(); index++)
{
if(constraint_extended_value[index]->has_operation())
return true;
}
for (std::size_t index=0; index<extended_forward_ref_value.len(); index++)
{
if(extended_forward_ref_value[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(constraint_type.yfilter)
|| ydk::is_set(constraint_value.yfilter)
|| ydk::is_set(forward_ref_value.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "named-affinity";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata());
if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata());
if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "constraint-extended-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue>();
ent_->parent = this;
constraint_extended_value.append(ent_);
return ent_;
}
if(child_yang_name == "extended-forward-ref-value")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue>();
ent_->parent = this;
extended_forward_ref_value.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : constraint_extended_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : extended_forward_ref_value.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "constraint-type")
{
constraint_type = value;
constraint_type.value_namespace = name_space;
constraint_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "constraint-value")
{
constraint_value = value;
constraint_value.value_namespace = name_space;
constraint_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "forward-ref-value")
{
forward_ref_value = value;
forward_ref_value.value_namespace = name_space;
forward_ref_value.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "constraint-type")
{
constraint_type.yfilter = yfilter;
}
if(value_path == "constraint-value")
{
constraint_value.yfilter = yfilter;
}
if(value_path == "forward-ref-value")
{
forward_ref_value.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "constraint-extended-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue()
:
entry{YType::uint32, "entry"}
{
yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "extended-forward-ref-value";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::Logging()
:
lsp_state{YType::boolean, "lsp-state"},
s2l_state{YType::boolean, "s2l-state"},
lsp_re_route{YType::boolean, "lsp-re-route"},
lsp_re_opt{YType::boolean, "lsp-re-opt"},
lsp_insufficient_bw{YType::boolean, "lsp-insufficient-bw"},
lsp_bandwidth_change{YType::boolean, "lsp-bandwidth-change"},
lsp_pcalc_failure_logging_enabled{YType::boolean, "lsp-pcalc-failure-logging-enabled"},
all_logging_enabled{YType::boolean, "all-logging-enabled"}
{
yang_name = "logging"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::~Logging()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::has_data() const
{
if (is_presence_container) return true;
return lsp_state.is_set
|| s2l_state.is_set
|| lsp_re_route.is_set
|| lsp_re_opt.is_set
|| lsp_insufficient_bw.is_set
|| lsp_bandwidth_change.is_set
|| lsp_pcalc_failure_logging_enabled.is_set
|| all_logging_enabled.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lsp_state.yfilter)
|| ydk::is_set(s2l_state.yfilter)
|| ydk::is_set(lsp_re_route.yfilter)
|| ydk::is_set(lsp_re_opt.yfilter)
|| ydk::is_set(lsp_insufficient_bw.yfilter)
|| ydk::is_set(lsp_bandwidth_change.yfilter)
|| ydk::is_set(lsp_pcalc_failure_logging_enabled.yfilter)
|| ydk::is_set(all_logging_enabled.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "logging";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lsp_state.is_set || is_set(lsp_state.yfilter)) leaf_name_data.push_back(lsp_state.get_name_leafdata());
if (s2l_state.is_set || is_set(s2l_state.yfilter)) leaf_name_data.push_back(s2l_state.get_name_leafdata());
if (lsp_re_route.is_set || is_set(lsp_re_route.yfilter)) leaf_name_data.push_back(lsp_re_route.get_name_leafdata());
if (lsp_re_opt.is_set || is_set(lsp_re_opt.yfilter)) leaf_name_data.push_back(lsp_re_opt.get_name_leafdata());
if (lsp_insufficient_bw.is_set || is_set(lsp_insufficient_bw.yfilter)) leaf_name_data.push_back(lsp_insufficient_bw.get_name_leafdata());
if (lsp_bandwidth_change.is_set || is_set(lsp_bandwidth_change.yfilter)) leaf_name_data.push_back(lsp_bandwidth_change.get_name_leafdata());
if (lsp_pcalc_failure_logging_enabled.is_set || is_set(lsp_pcalc_failure_logging_enabled.yfilter)) leaf_name_data.push_back(lsp_pcalc_failure_logging_enabled.get_name_leafdata());
if (all_logging_enabled.is_set || is_set(all_logging_enabled.yfilter)) leaf_name_data.push_back(all_logging_enabled.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "lsp-state")
{
lsp_state = value;
lsp_state.value_namespace = name_space;
lsp_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "s2l-state")
{
s2l_state = value;
s2l_state.value_namespace = name_space;
s2l_state.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-re-route")
{
lsp_re_route = value;
lsp_re_route.value_namespace = name_space;
lsp_re_route.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-re-opt")
{
lsp_re_opt = value;
lsp_re_opt.value_namespace = name_space;
lsp_re_opt.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-insufficient-bw")
{
lsp_insufficient_bw = value;
lsp_insufficient_bw.value_namespace = name_space;
lsp_insufficient_bw.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-bandwidth-change")
{
lsp_bandwidth_change = value;
lsp_bandwidth_change.value_namespace = name_space;
lsp_bandwidth_change.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-pcalc-failure-logging-enabled")
{
lsp_pcalc_failure_logging_enabled = value;
lsp_pcalc_failure_logging_enabled.value_namespace = name_space;
lsp_pcalc_failure_logging_enabled.value_namespace_prefix = name_space_prefix;
}
if(value_path == "all-logging-enabled")
{
all_logging_enabled = value;
all_logging_enabled.value_namespace = name_space;
all_logging_enabled.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "lsp-state")
{
lsp_state.yfilter = yfilter;
}
if(value_path == "s2l-state")
{
s2l_state.yfilter = yfilter;
}
if(value_path == "lsp-re-route")
{
lsp_re_route.yfilter = yfilter;
}
if(value_path == "lsp-re-opt")
{
lsp_re_opt.yfilter = yfilter;
}
if(value_path == "lsp-insufficient-bw")
{
lsp_insufficient_bw.yfilter = yfilter;
}
if(value_path == "lsp-bandwidth-change")
{
lsp_bandwidth_change.yfilter = yfilter;
}
if(value_path == "lsp-pcalc-failure-logging-enabled")
{
lsp_pcalc_failure_logging_enabled.yfilter = yfilter;
}
if(value_path == "all-logging-enabled")
{
all_logging_enabled.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "lsp-state" || name == "s2l-state" || name == "lsp-re-route" || name == "lsp-re-opt" || name == "lsp-insufficient-bw" || name == "lsp-bandwidth-change" || name == "lsp-pcalc-failure-logging-enabled" || name == "all-logging-enabled")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependList()
:
prepend_entry(this, {})
{
yang_name = "prepend-list"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::~PrependList()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<prepend_entry.len(); index++)
{
if(prepend_entry[index]->has_data())
return true;
}
return false;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::has_operation() const
{
for (std::size_t index=0; index<prepend_entry.len(); index++)
{
if(prepend_entry[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "prepend-list";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "prepend-entry")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry>();
ent_->parent = this;
prepend_entry.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : prepend_entry.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "prepend-entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::PrependEntry()
:
type{YType::enumeration, "type"},
index_{YType::uint32, "index"},
next_label{YType::uint32, "next-label"}
{
yang_name = "prepend-entry"; yang_parent_name = "prepend-list"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::~PrependEntry()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::has_data() const
{
if (is_presence_container) return true;
return type.is_set
|| index_.is_set
|| next_label.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(type.yfilter)
|| ydk::is_set(index_.yfilter)
|| ydk::is_set(next_label.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "prepend-entry";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata());
if (index_.is_set || is_set(index_.yfilter)) leaf_name_data.push_back(index_.get_name_leafdata());
if (next_label.is_set || is_set(next_label.yfilter)) leaf_name_data.push_back(next_label.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "type")
{
type = value;
type.value_namespace = name_space;
type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "index")
{
index_ = value;
index_.value_namespace = name_space;
index_.value_namespace_prefix = name_space_prefix;
}
if(value_path == "next-label")
{
next_label = value;
next_label.value_namespace = name_space;
next_label.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "type")
{
type.yfilter = yfilter;
}
if(value_path == "index")
{
index_.yfilter = yfilter;
}
if(value_path == "next-label")
{
next_label.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "type" || name == "index" || name == "next-label")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::TunnelId()
:
entry{YType::uint16, "entry"}
{
yang_name = "tunnel-id"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::~TunnelId()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::has_data() const
{
if (is_presence_container) return true;
return entry.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(entry.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tunnel-id";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "entry")
{
entry = value;
entry.value_namespace = name_space;
entry.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "entry")
{
entry.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "entry")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::PathCalculationError()
:
error_message{YType::str, "error-message"},
lsp_mode{YType::enumeration, "lsp-mode"},
log_time{YType::uint32, "log-time"}
{
yang_name = "path-calculation-error"; yang_parent_name = "active-path-option"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::~PathCalculationError()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::has_data() const
{
if (is_presence_container) return true;
return error_message.is_set
|| lsp_mode.is_set
|| log_time.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(error_message.yfilter)
|| ydk::is_set(lsp_mode.yfilter)
|| ydk::is_set(log_time.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "path-calculation-error";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (error_message.is_set || is_set(error_message.yfilter)) leaf_name_data.push_back(error_message.get_name_leafdata());
if (lsp_mode.is_set || is_set(lsp_mode.yfilter)) leaf_name_data.push_back(lsp_mode.get_name_leafdata());
if (log_time.is_set || is_set(log_time.yfilter)) leaf_name_data.push_back(log_time.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "error-message")
{
error_message = value;
error_message.value_namespace = name_space;
error_message.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-mode")
{
lsp_mode = value;
lsp_mode.value_namespace = name_space;
lsp_mode.value_namespace_prefix = name_space_prefix;
}
if(value_path == "log-time")
{
log_time = value;
log_time.value_namespace = name_space;
log_time.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "error-message")
{
error_message.yfilter = yfilter;
}
if(value_path == "lsp-mode")
{
lsp_mode.yfilter = yfilter;
}
if(value_path == "log-time")
{
log_time.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "error-message" || name == "lsp-mode" || name == "log-time")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::RemergeError()
:
error_message{YType::str, "error-message"},
lsp_mode{YType::enumeration, "lsp-mode"},
log_time{YType::uint32, "log-time"}
{
yang_name = "remerge-error"; yang_parent_name = "active-path-option"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::~RemergeError()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::has_data() const
{
if (is_presence_container) return true;
return error_message.is_set
|| lsp_mode.is_set
|| log_time.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(error_message.yfilter)
|| ydk::is_set(lsp_mode.yfilter)
|| ydk::is_set(log_time.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "remerge-error";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (error_message.is_set || is_set(error_message.yfilter)) leaf_name_data.push_back(error_message.get_name_leafdata());
if (lsp_mode.is_set || is_set(lsp_mode.yfilter)) leaf_name_data.push_back(lsp_mode.get_name_leafdata());
if (log_time.is_set || is_set(log_time.yfilter)) leaf_name_data.push_back(log_time.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "error-message")
{
error_message = value;
error_message.value_namespace = name_space;
error_message.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-mode")
{
lsp_mode = value;
lsp_mode.value_namespace = name_space;
lsp_mode.value_namespace_prefix = name_space_prefix;
}
if(value_path == "log-time")
{
log_time = value;
log_time.value_namespace = name_space;
log_time.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "error-message")
{
error_message.yfilter = yfilter;
}
if(value_path == "lsp-mode")
{
lsp_mode.yfilter = yfilter;
}
if(value_path == "log-time")
{
log_time.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "error-message" || name == "lsp-mode" || name == "log-time")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::SignallingError()
:
error_node{YType::uint32, "error-node"},
error{YType::uint8, "error"},
sub_code{YType::uint16, "sub-code"},
lsp_mode{YType::enumeration, "lsp-mode"},
log_time{YType::uint32, "log-time"},
signalling_lsp_id{YType::uint16, "signalling-lsp-id"},
error_message{YType::str, "error-message"},
reverse_lsp{YType::boolean, "reverse-lsp"}
{
yang_name = "signalling-error"; yang_parent_name = "active-path-option"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::~SignallingError()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::has_data() const
{
if (is_presence_container) return true;
return error_node.is_set
|| error.is_set
|| sub_code.is_set
|| lsp_mode.is_set
|| log_time.is_set
|| signalling_lsp_id.is_set
|| error_message.is_set
|| reverse_lsp.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(error_node.yfilter)
|| ydk::is_set(error.yfilter)
|| ydk::is_set(sub_code.yfilter)
|| ydk::is_set(lsp_mode.yfilter)
|| ydk::is_set(log_time.yfilter)
|| ydk::is_set(signalling_lsp_id.yfilter)
|| ydk::is_set(error_message.yfilter)
|| ydk::is_set(reverse_lsp.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "signalling-error";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (error_node.is_set || is_set(error_node.yfilter)) leaf_name_data.push_back(error_node.get_name_leafdata());
if (error.is_set || is_set(error.yfilter)) leaf_name_data.push_back(error.get_name_leafdata());
if (sub_code.is_set || is_set(sub_code.yfilter)) leaf_name_data.push_back(sub_code.get_name_leafdata());
if (lsp_mode.is_set || is_set(lsp_mode.yfilter)) leaf_name_data.push_back(lsp_mode.get_name_leafdata());
if (log_time.is_set || is_set(log_time.yfilter)) leaf_name_data.push_back(log_time.get_name_leafdata());
if (signalling_lsp_id.is_set || is_set(signalling_lsp_id.yfilter)) leaf_name_data.push_back(signalling_lsp_id.get_name_leafdata());
if (error_message.is_set || is_set(error_message.yfilter)) leaf_name_data.push_back(error_message.get_name_leafdata());
if (reverse_lsp.is_set || is_set(reverse_lsp.yfilter)) leaf_name_data.push_back(reverse_lsp.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "error-node")
{
error_node = value;
error_node.value_namespace = name_space;
error_node.value_namespace_prefix = name_space_prefix;
}
if(value_path == "error")
{
error = value;
error.value_namespace = name_space;
error.value_namespace_prefix = name_space_prefix;
}
if(value_path == "sub-code")
{
sub_code = value;
sub_code.value_namespace = name_space;
sub_code.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lsp-mode")
{
lsp_mode = value;
lsp_mode.value_namespace = name_space;
lsp_mode.value_namespace_prefix = name_space_prefix;
}
if(value_path == "log-time")
{
log_time = value;
log_time.value_namespace = name_space;
log_time.value_namespace_prefix = name_space_prefix;
}
if(value_path == "signalling-lsp-id")
{
signalling_lsp_id = value;
signalling_lsp_id.value_namespace = name_space;
signalling_lsp_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "error-message")
{
error_message = value;
error_message.value_namespace = name_space;
error_message.value_namespace_prefix = name_space_prefix;
}
if(value_path == "reverse-lsp")
{
reverse_lsp = value;
reverse_lsp.value_namespace = name_space;
reverse_lsp.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "error-node")
{
error_node.yfilter = yfilter;
}
if(value_path == "error")
{
error.yfilter = yfilter;
}
if(value_path == "sub-code")
{
sub_code.yfilter = yfilter;
}
if(value_path == "lsp-mode")
{
lsp_mode.yfilter = yfilter;
}
if(value_path == "log-time")
{
log_time.yfilter = yfilter;
}
if(value_path == "signalling-lsp-id")
{
signalling_lsp_id.yfilter = yfilter;
}
if(value_path == "error-message")
{
error_message.yfilter = yfilter;
}
if(value_path == "reverse-lsp")
{
reverse_lsp.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "error-node" || name == "error" || name == "sub-code" || name == "lsp-mode" || name == "log-time" || name == "signalling-lsp-id" || name == "error-message" || name == "reverse-lsp")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::OutXro()
:
mutual_diversity_flag{YType::boolean, "mutual-diversity-flag"}
,
xro_subobject(this, {})
{
yang_name = "out-xro"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::~OutXro()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<xro_subobject.len(); index++)
{
if(xro_subobject[index]->has_data())
return true;
}
return mutual_diversity_flag.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::has_operation() const
{
for (std::size_t index=0; index<xro_subobject.len(); index++)
{
if(xro_subobject[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(mutual_diversity_flag.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "out-xro";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (mutual_diversity_flag.is_set || is_set(mutual_diversity_flag.yfilter)) leaf_name_data.push_back(mutual_diversity_flag.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "xro-subobject")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject>();
ent_->parent = this;
xro_subobject.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : xro_subobject.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "mutual-diversity-flag")
{
mutual_diversity_flag = value;
mutual_diversity_flag.value_namespace = name_space;
mutual_diversity_flag.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "mutual-diversity-flag")
{
mutual_diversity_flag.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "xro-subobject" || name == "mutual-diversity-flag")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::XroSubobject()
:
type{YType::enumeration, "type"}
,
ipv4_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject>())
, ipv6_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject>())
, unnumbered_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject>())
, as_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject>())
, srlg_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject>())
, lsp_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject>())
{
ipv4_subobject->parent = this;
ipv6_subobject->parent = this;
unnumbered_subobject->parent = this;
as_subobject->parent = this;
srlg_subobject->parent = this;
lsp_subobject->parent = this;
yang_name = "xro-subobject"; yang_parent_name = "out-xro"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::~XroSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::has_data() const
{
if (is_presence_container) return true;
return type.is_set
|| (ipv4_subobject != nullptr && ipv4_subobject->has_data())
|| (ipv6_subobject != nullptr && ipv6_subobject->has_data())
|| (unnumbered_subobject != nullptr && unnumbered_subobject->has_data())
|| (as_subobject != nullptr && as_subobject->has_data())
|| (srlg_subobject != nullptr && srlg_subobject->has_data())
|| (lsp_subobject != nullptr && lsp_subobject->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(type.yfilter)
|| (ipv4_subobject != nullptr && ipv4_subobject->has_operation())
|| (ipv6_subobject != nullptr && ipv6_subobject->has_operation())
|| (unnumbered_subobject != nullptr && unnumbered_subobject->has_operation())
|| (as_subobject != nullptr && as_subobject->has_operation())
|| (srlg_subobject != nullptr && srlg_subobject->has_operation())
|| (lsp_subobject != nullptr && lsp_subobject->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "xro-subobject";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ipv4-subobject")
{
if(ipv4_subobject == nullptr)
{
ipv4_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject>();
}
return ipv4_subobject;
}
if(child_yang_name == "ipv6-subobject")
{
if(ipv6_subobject == nullptr)
{
ipv6_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject>();
}
return ipv6_subobject;
}
if(child_yang_name == "unnumbered-subobject")
{
if(unnumbered_subobject == nullptr)
{
unnumbered_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject>();
}
return unnumbered_subobject;
}
if(child_yang_name == "as-subobject")
{
if(as_subobject == nullptr)
{
as_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject>();
}
return as_subobject;
}
if(child_yang_name == "srlg-subobject")
{
if(srlg_subobject == nullptr)
{
srlg_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject>();
}
return srlg_subobject;
}
if(child_yang_name == "lsp-subobject")
{
if(lsp_subobject == nullptr)
{
lsp_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject>();
}
return lsp_subobject;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(ipv4_subobject != nullptr)
{
_children["ipv4-subobject"] = ipv4_subobject;
}
if(ipv6_subobject != nullptr)
{
_children["ipv6-subobject"] = ipv6_subobject;
}
if(unnumbered_subobject != nullptr)
{
_children["unnumbered-subobject"] = unnumbered_subobject;
}
if(as_subobject != nullptr)
{
_children["as-subobject"] = as_subobject;
}
if(srlg_subobject != nullptr)
{
_children["srlg-subobject"] = srlg_subobject;
}
if(lsp_subobject != nullptr)
{
_children["lsp-subobject"] = lsp_subobject;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "type")
{
type = value;
type.value_namespace = name_space;
type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "type")
{
type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4-subobject" || name == "ipv6-subobject" || name == "unnumbered-subobject" || name == "as-subobject" || name == "srlg-subobject" || name == "lsp-subobject" || name == "type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::Ipv4Subobject()
:
address{YType::str, "address"},
prefix_len{YType::uint8, "prefix-len"},
attribute{YType::enumeration, "attribute"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "ipv4-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::~Ipv4Subobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::has_data() const
{
if (is_presence_container) return true;
return address.is_set
|| prefix_len.is_set
|| attribute.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(address.yfilter)
|| ydk::is_set(prefix_len.yfilter)
|| ydk::is_set(attribute.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv4-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata());
if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata());
if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address = value;
address.value_namespace = name_space;
address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-len")
{
prefix_len = value;
prefix_len.value_namespace = name_space;
prefix_len.value_namespace_prefix = name_space_prefix;
}
if(value_path == "attribute")
{
attribute = value;
attribute.value_namespace = name_space;
attribute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
if(value_path == "prefix-len")
{
prefix_len.yfilter = yfilter;
}
if(value_path == "attribute")
{
attribute.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::Ipv6Subobject()
:
address{YType::str, "address"},
prefix_len{YType::uint8, "prefix-len"},
attribute{YType::enumeration, "attribute"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "ipv6-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::~Ipv6Subobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::has_data() const
{
if (is_presence_container) return true;
return address.is_set
|| prefix_len.is_set
|| attribute.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(address.yfilter)
|| ydk::is_set(prefix_len.yfilter)
|| ydk::is_set(attribute.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv6-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata());
if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata());
if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address = value;
address.value_namespace = name_space;
address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-len")
{
prefix_len = value;
prefix_len.value_namespace = name_space;
prefix_len.value_namespace_prefix = name_space_prefix;
}
if(value_path == "attribute")
{
attribute = value;
attribute.value_namespace = name_space;
attribute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
if(value_path == "prefix-len")
{
prefix_len.yfilter = yfilter;
}
if(value_path == "attribute")
{
attribute.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::UnnumberedSubobject()
:
te_router_id{YType::str, "te-router-id"},
interface_id{YType::uint32, "interface-id"},
attribute{YType::enumeration, "attribute"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "unnumbered-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::~UnnumberedSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::has_data() const
{
if (is_presence_container) return true;
return te_router_id.is_set
|| interface_id.is_set
|| attribute.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(te_router_id.yfilter)
|| ydk::is_set(interface_id.yfilter)
|| ydk::is_set(attribute.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "unnumbered-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (te_router_id.is_set || is_set(te_router_id.yfilter)) leaf_name_data.push_back(te_router_id.get_name_leafdata());
if (interface_id.is_set || is_set(interface_id.yfilter)) leaf_name_data.push_back(interface_id.get_name_leafdata());
if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "te-router-id")
{
te_router_id = value;
te_router_id.value_namespace = name_space;
te_router_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "interface-id")
{
interface_id = value;
interface_id.value_namespace = name_space;
interface_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "attribute")
{
attribute = value;
attribute.value_namespace = name_space;
attribute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "te-router-id")
{
te_router_id.yfilter = yfilter;
}
if(value_path == "interface-id")
{
interface_id.yfilter = yfilter;
}
if(value_path == "attribute")
{
attribute.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "te-router-id" || name == "interface-id" || name == "attribute" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::AsSubobject()
:
as_number{YType::uint16, "as-number"}
{
yang_name = "as-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::~AsSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::has_data() const
{
if (is_presence_container) return true;
return as_number.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(as_number.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "as-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (as_number.is_set || is_set(as_number.yfilter)) leaf_name_data.push_back(as_number.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "as-number")
{
as_number = value;
as_number.value_namespace = name_space;
as_number.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "as-number")
{
as_number.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "as-number")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::SrlgSubobject()
:
srlg_id{YType::uint32, "srlg-id"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "srlg-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::~SrlgSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::has_data() const
{
if (is_presence_container) return true;
return srlg_id.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(srlg_id.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "srlg-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (srlg_id.is_set || is_set(srlg_id.yfilter)) leaf_name_data.push_back(srlg_id.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "srlg-id")
{
srlg_id = value;
srlg_id.value_namespace = name_space;
srlg_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "srlg-id")
{
srlg_id.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "srlg-id" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::LspSubobject()
:
ignore_lsp_id{YType::boolean, "ignore-lsp-id"},
processing_node_exception{YType::boolean, "processing-node-exception"},
penultimate_node_exception{YType::boolean, "penultimate-node-exception"},
destination_node_exception{YType::boolean, "destination-node-exception"},
exclusion_type{YType::enumeration, "exclusion-type"}
,
fec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec>())
{
fec->parent = this;
yang_name = "lsp-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::~LspSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::has_data() const
{
if (is_presence_container) return true;
return ignore_lsp_id.is_set
|| processing_node_exception.is_set
|| penultimate_node_exception.is_set
|| destination_node_exception.is_set
|| exclusion_type.is_set
|| (fec != nullptr && fec->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ignore_lsp_id.yfilter)
|| ydk::is_set(processing_node_exception.yfilter)
|| ydk::is_set(penultimate_node_exception.yfilter)
|| ydk::is_set(destination_node_exception.yfilter)
|| ydk::is_set(exclusion_type.yfilter)
|| (fec != nullptr && fec->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "lsp-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ignore_lsp_id.is_set || is_set(ignore_lsp_id.yfilter)) leaf_name_data.push_back(ignore_lsp_id.get_name_leafdata());
if (processing_node_exception.is_set || is_set(processing_node_exception.yfilter)) leaf_name_data.push_back(processing_node_exception.get_name_leafdata());
if (penultimate_node_exception.is_set || is_set(penultimate_node_exception.yfilter)) leaf_name_data.push_back(penultimate_node_exception.get_name_leafdata());
if (destination_node_exception.is_set || is_set(destination_node_exception.yfilter)) leaf_name_data.push_back(destination_node_exception.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "fec")
{
if(fec == nullptr)
{
fec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec>();
}
return fec;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(fec != nullptr)
{
_children["fec"] = fec;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ignore-lsp-id")
{
ignore_lsp_id = value;
ignore_lsp_id.value_namespace = name_space;
ignore_lsp_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "processing-node-exception")
{
processing_node_exception = value;
processing_node_exception.value_namespace = name_space;
processing_node_exception.value_namespace_prefix = name_space_prefix;
}
if(value_path == "penultimate-node-exception")
{
penultimate_node_exception = value;
penultimate_node_exception.value_namespace = name_space;
penultimate_node_exception.value_namespace_prefix = name_space_prefix;
}
if(value_path == "destination-node-exception")
{
destination_node_exception = value;
destination_node_exception.value_namespace = name_space;
destination_node_exception.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ignore-lsp-id")
{
ignore_lsp_id.yfilter = yfilter;
}
if(value_path == "processing-node-exception")
{
processing_node_exception.yfilter = yfilter;
}
if(value_path == "penultimate-node-exception")
{
penultimate_node_exception.yfilter = yfilter;
}
if(value_path == "destination-node-exception")
{
destination_node_exception.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "fec" || name == "ignore-lsp-id" || name == "processing-node-exception" || name == "penultimate-node-exception" || name == "destination-node-exception" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::Fec()
:
fec_lsp_id{YType::uint16, "fec-lsp-id"},
fec_tunnel_id{YType::uint16, "fec-tunnel-id"},
fec_extended_tunnel_id{YType::str, "fec-extended-tunnel-id"},
fec_source{YType::str, "fec-source"},
fec_vrf{YType::str, "fec-vrf"}
,
fec_destination_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo>())
{
fec_destination_info->parent = this;
yang_name = "fec"; yang_parent_name = "lsp-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::~Fec()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::has_data() const
{
if (is_presence_container) return true;
return fec_lsp_id.is_set
|| fec_tunnel_id.is_set
|| fec_extended_tunnel_id.is_set
|| fec_source.is_set
|| fec_vrf.is_set
|| (fec_destination_info != nullptr && fec_destination_info->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(fec_lsp_id.yfilter)
|| ydk::is_set(fec_tunnel_id.yfilter)
|| ydk::is_set(fec_extended_tunnel_id.yfilter)
|| ydk::is_set(fec_source.yfilter)
|| ydk::is_set(fec_vrf.yfilter)
|| (fec_destination_info != nullptr && fec_destination_info->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "fec";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (fec_lsp_id.is_set || is_set(fec_lsp_id.yfilter)) leaf_name_data.push_back(fec_lsp_id.get_name_leafdata());
if (fec_tunnel_id.is_set || is_set(fec_tunnel_id.yfilter)) leaf_name_data.push_back(fec_tunnel_id.get_name_leafdata());
if (fec_extended_tunnel_id.is_set || is_set(fec_extended_tunnel_id.yfilter)) leaf_name_data.push_back(fec_extended_tunnel_id.get_name_leafdata());
if (fec_source.is_set || is_set(fec_source.yfilter)) leaf_name_data.push_back(fec_source.get_name_leafdata());
if (fec_vrf.is_set || is_set(fec_vrf.yfilter)) leaf_name_data.push_back(fec_vrf.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "fec-destination-info")
{
if(fec_destination_info == nullptr)
{
fec_destination_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo>();
}
return fec_destination_info;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(fec_destination_info != nullptr)
{
_children["fec-destination-info"] = fec_destination_info;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "fec-lsp-id")
{
fec_lsp_id = value;
fec_lsp_id.value_namespace = name_space;
fec_lsp_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-tunnel-id")
{
fec_tunnel_id = value;
fec_tunnel_id.value_namespace = name_space;
fec_tunnel_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-extended-tunnel-id")
{
fec_extended_tunnel_id = value;
fec_extended_tunnel_id.value_namespace = name_space;
fec_extended_tunnel_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-source")
{
fec_source = value;
fec_source.value_namespace = name_space;
fec_source.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-vrf")
{
fec_vrf = value;
fec_vrf.value_namespace = name_space;
fec_vrf.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "fec-lsp-id")
{
fec_lsp_id.yfilter = yfilter;
}
if(value_path == "fec-tunnel-id")
{
fec_tunnel_id.yfilter = yfilter;
}
if(value_path == "fec-extended-tunnel-id")
{
fec_extended_tunnel_id.yfilter = yfilter;
}
if(value_path == "fec-source")
{
fec_source.yfilter = yfilter;
}
if(value_path == "fec-vrf")
{
fec_vrf.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "fec-destination-info" || name == "fec-lsp-id" || name == "fec-tunnel-id" || name == "fec-extended-tunnel-id" || name == "fec-source" || name == "fec-vrf")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::FecDestinationInfo()
:
fec_ctype{YType::enumeration, "fec-ctype"},
p2p_lsp_destination{YType::str, "p2p-lsp-destination"},
fec_destination_p2mp_id{YType::uint32, "fec-destination-p2mp-id"}
{
yang_name = "fec-destination-info"; yang_parent_name = "fec"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::~FecDestinationInfo()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_data() const
{
if (is_presence_container) return true;
return fec_ctype.is_set
|| p2p_lsp_destination.is_set
|| fec_destination_p2mp_id.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(fec_ctype.yfilter)
|| ydk::is_set(p2p_lsp_destination.yfilter)
|| ydk::is_set(fec_destination_p2mp_id.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "fec-destination-info";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (fec_ctype.is_set || is_set(fec_ctype.yfilter)) leaf_name_data.push_back(fec_ctype.get_name_leafdata());
if (p2p_lsp_destination.is_set || is_set(p2p_lsp_destination.yfilter)) leaf_name_data.push_back(p2p_lsp_destination.get_name_leafdata());
if (fec_destination_p2mp_id.is_set || is_set(fec_destination_p2mp_id.yfilter)) leaf_name_data.push_back(fec_destination_p2mp_id.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "fec-ctype")
{
fec_ctype = value;
fec_ctype.value_namespace = name_space;
fec_ctype.value_namespace_prefix = name_space_prefix;
}
if(value_path == "p2p-lsp-destination")
{
p2p_lsp_destination = value;
p2p_lsp_destination.value_namespace = name_space;
p2p_lsp_destination.value_namespace_prefix = name_space_prefix;
}
if(value_path == "fec-destination-p2mp-id")
{
fec_destination_p2mp_id = value;
fec_destination_p2mp_id.value_namespace = name_space;
fec_destination_p2mp_id.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "fec-ctype")
{
fec_ctype.yfilter = yfilter;
}
if(value_path == "p2p-lsp-destination")
{
p2p_lsp_destination.yfilter = yfilter;
}
if(value_path == "fec-destination-p2mp-id")
{
fec_destination_p2mp_id.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "fec-ctype" || name == "p2p-lsp-destination" || name == "fec-destination-p2mp-id")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::InXro()
:
mutual_diversity_flag{YType::boolean, "mutual-diversity-flag"}
,
xro_subobject(this, {})
{
yang_name = "in-xro"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::~InXro()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<xro_subobject.len(); index++)
{
if(xro_subobject[index]->has_data())
return true;
}
return mutual_diversity_flag.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::has_operation() const
{
for (std::size_t index=0; index<xro_subobject.len(); index++)
{
if(xro_subobject[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(mutual_diversity_flag.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "in-xro";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (mutual_diversity_flag.is_set || is_set(mutual_diversity_flag.yfilter)) leaf_name_data.push_back(mutual_diversity_flag.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "xro-subobject")
{
auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject>();
ent_->parent = this;
xro_subobject.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : xro_subobject.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "mutual-diversity-flag")
{
mutual_diversity_flag = value;
mutual_diversity_flag.value_namespace = name_space;
mutual_diversity_flag.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "mutual-diversity-flag")
{
mutual_diversity_flag.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "xro-subobject" || name == "mutual-diversity-flag")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::XroSubobject()
:
type{YType::enumeration, "type"}
,
ipv4_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject>())
, ipv6_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject>())
, unnumbered_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::UnnumberedSubobject>())
, as_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::AsSubobject>())
, srlg_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::SrlgSubobject>())
, lsp_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::LspSubobject>())
{
ipv4_subobject->parent = this;
ipv6_subobject->parent = this;
unnumbered_subobject->parent = this;
as_subobject->parent = this;
srlg_subobject->parent = this;
lsp_subobject->parent = this;
yang_name = "xro-subobject"; yang_parent_name = "in-xro"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::~XroSubobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::has_data() const
{
if (is_presence_container) return true;
return type.is_set
|| (ipv4_subobject != nullptr && ipv4_subobject->has_data())
|| (ipv6_subobject != nullptr && ipv6_subobject->has_data())
|| (unnumbered_subobject != nullptr && unnumbered_subobject->has_data())
|| (as_subobject != nullptr && as_subobject->has_data())
|| (srlg_subobject != nullptr && srlg_subobject->has_data())
|| (lsp_subobject != nullptr && lsp_subobject->has_data());
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(type.yfilter)
|| (ipv4_subobject != nullptr && ipv4_subobject->has_operation())
|| (ipv6_subobject != nullptr && ipv6_subobject->has_operation())
|| (unnumbered_subobject != nullptr && unnumbered_subobject->has_operation())
|| (as_subobject != nullptr && as_subobject->has_operation())
|| (srlg_subobject != nullptr && srlg_subobject->has_operation())
|| (lsp_subobject != nullptr && lsp_subobject->has_operation());
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "xro-subobject";
path_buffer << "[" << get_ylist_key() << "]";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ipv4-subobject")
{
if(ipv4_subobject == nullptr)
{
ipv4_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject>();
}
return ipv4_subobject;
}
if(child_yang_name == "ipv6-subobject")
{
if(ipv6_subobject == nullptr)
{
ipv6_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject>();
}
return ipv6_subobject;
}
if(child_yang_name == "unnumbered-subobject")
{
if(unnumbered_subobject == nullptr)
{
unnumbered_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::UnnumberedSubobject>();
}
return unnumbered_subobject;
}
if(child_yang_name == "as-subobject")
{
if(as_subobject == nullptr)
{
as_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::AsSubobject>();
}
return as_subobject;
}
if(child_yang_name == "srlg-subobject")
{
if(srlg_subobject == nullptr)
{
srlg_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::SrlgSubobject>();
}
return srlg_subobject;
}
if(child_yang_name == "lsp-subobject")
{
if(lsp_subobject == nullptr)
{
lsp_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::LspSubobject>();
}
return lsp_subobject;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(ipv4_subobject != nullptr)
{
_children["ipv4-subobject"] = ipv4_subobject;
}
if(ipv6_subobject != nullptr)
{
_children["ipv6-subobject"] = ipv6_subobject;
}
if(unnumbered_subobject != nullptr)
{
_children["unnumbered-subobject"] = unnumbered_subobject;
}
if(as_subobject != nullptr)
{
_children["as-subobject"] = as_subobject;
}
if(srlg_subobject != nullptr)
{
_children["srlg-subobject"] = srlg_subobject;
}
if(lsp_subobject != nullptr)
{
_children["lsp-subobject"] = lsp_subobject;
}
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "type")
{
type = value;
type.value_namespace = name_space;
type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "type")
{
type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4-subobject" || name == "ipv6-subobject" || name == "unnumbered-subobject" || name == "as-subobject" || name == "srlg-subobject" || name == "lsp-subobject" || name == "type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::Ipv4Subobject()
:
address{YType::str, "address"},
prefix_len{YType::uint8, "prefix-len"},
attribute{YType::enumeration, "attribute"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "ipv4-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::~Ipv4Subobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::has_data() const
{
if (is_presence_container) return true;
return address.is_set
|| prefix_len.is_set
|| attribute.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(address.yfilter)
|| ydk::is_set(prefix_len.yfilter)
|| ydk::is_set(attribute.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv4-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata());
if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata());
if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address = value;
address.value_namespace = name_space;
address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-len")
{
prefix_len = value;
prefix_len.value_namespace = name_space;
prefix_len.value_namespace_prefix = name_space_prefix;
}
if(value_path == "attribute")
{
attribute = value;
attribute.value_namespace = name_space;
attribute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
if(value_path == "prefix-len")
{
prefix_len.yfilter = yfilter;
}
if(value_path == "attribute")
{
attribute.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type")
return true;
return false;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::Ipv6Subobject()
:
address{YType::str, "address"},
prefix_len{YType::uint8, "prefix-len"},
attribute{YType::enumeration, "attribute"},
exclusion_type{YType::enumeration, "exclusion-type"}
{
yang_name = "ipv6-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true;
}
MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::~Ipv6Subobject()
{
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::has_data() const
{
if (is_presence_container) return true;
return address.is_set
|| prefix_len.is_set
|| attribute.is_set
|| exclusion_type.is_set;
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(address.yfilter)
|| ydk::is_set(prefix_len.yfilter)
|| ydk::is_set(attribute.yfilter)
|| ydk::is_set(exclusion_type.yfilter);
}
std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv6-subobject";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata());
if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata());
if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata());
if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address = value;
address.value_namespace = name_space;
address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-len")
{
prefix_len = value;
prefix_len.value_namespace = name_space;
prefix_len.value_namespace_prefix = name_space_prefix;
}
if(value_path == "attribute")
{
attribute = value;
attribute.value_namespace = name_space;
attribute.value_namespace_prefix = name_space_prefix;
}
if(value_path == "exclusion-type")
{
exclusion_type = value;
exclusion_type.value_namespace = name_space;
exclusion_type.value_namespace_prefix = name_space_prefix;
}
}
void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
if(value_path == "prefix-len")
{
prefix_len.yfilter = yfilter;
}
if(value_path == "attribute")
{
attribute.yfilter = yfilter;
}
if(value_path == "exclusion-type")
{
exclusion_type.yfilter = yfilter;
}
}
bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type")
return true;
return false;
}
}
}
| 1,001,202
| 371,407
|
#include <iostream>
#include <SDL2/SDL.h>
// Graphics
const int WINDOW_WIDTH = 512;
const int WINDOW_HEIGHT = 284;
SDL_Window* g_main_window;
SDL_Renderer* g_main_renderer;
// Colors
namespace Colors {
const SDL_Color GREEN = { 0, 255, 0, SDL_ALPHA_OPAQUE };
const SDL_Color BLACK = { 0, 0, 0, SDL_ALPHA_OPAQUE };
}
static void ClearScreen(SDL_Renderer* renderer)
{
SDL_SetRenderDrawColor(renderer, Colors::BLACK.r, Colors::BLACK.g, Colors::BLACK.b, Colors::BLACK.a);
SDL_RenderClear(renderer);
}
static bool Init()
{
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
std::cout << "SDL_Init failed with error: " << SDL_GetError() << std::endl;
return EXIT_FAILURE;
}
g_main_window = SDL_CreateWindow(
"Creating a Window (512x284)",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
WINDOW_WIDTH,
WINDOW_HEIGHT,
SDL_WINDOW_OPENGL
);
if (g_main_window == nullptr) {
std::cout << "Unable to crete the main window. Erro: " << SDL_GetError() << std::endl;
SDL_Quit();
return EXIT_FAILURE;
}
g_main_renderer = SDL_CreateRenderer(g_main_window, -1, SDL_RENDERER_PRESENTVSYNC);
return true;
}
void Shutdown()
{
if (g_main_window != nullptr) {
SDL_DestroyWindow(g_main_window);
g_main_window = nullptr;
}
if (g_main_renderer != nullptr) {
SDL_DestroyRenderer(g_main_renderer);
g_main_renderer = nullptr;
}
SDL_Quit();
}
int main()
{
if (Init() == false) { Shutdown(); }
// Draw loop
SDL_Event event;
bool running = true;
while(running)
{
ClearScreen(g_main_renderer);
// Check and process I/O events
if (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
{
running = event.key.keysym.scancode != SDL_SCANCODE_ESCAPE;
break;
}
case SDL_QUIT:
{
running = false;
break;
}
default:
break;
}
}
// Update the screen with the content rendered in the background
SDL_RenderPresent(g_main_renderer);
}
Shutdown();
return EXIT_SUCCESS;
}
| 2,092
| 857
|
////////////////////////////////////////////////////////////////////////////////
/// \file
/// \brief Main module for Problem 4: Type conversion.
/// \author Georgii Zhulikov
/// \version 0.1.0
/// \date 25.01.2021
/// This code is for educational purposes of the course "Introduction
/// to programming" provided by the Faculty of Computer Science
/// at the Higher School of Economics.
///
/// Create a program that performs the following steps:
/// 1. Reads three integer numbers from input.
/// 2. Multiplies each number by 2.
/// 3. Concatenates the results into a single large number.
/// 4. Multiplies the result by 2.
/// 5. Outputs the resulting number.
///
/// Use stringstream for type converstion between numbers and strings.
/// (Additional) Use a debugger to check that at each step the strings and
/// numbers hold the correct values.
///
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <sstream>
int main()
{
using std::cout;
using std::cin;
// TODO: provide your implementation here
cout << "\n\n";
return 0;
}
| 1,192
| 310
|
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/snapshot/deserializer.h"
#include "src/codegen/assembler-inl.h"
#include "src/execution/isolate.h"
#include "src/heap/heap-inl.h"
#include "src/heap/heap-write-barrier-inl.h"
#include "src/heap/read-only-heap.h"
#include "src/interpreter/interpreter.h"
#include "src/logging/log.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/cell-inl.h"
#include "src/objects/hash-table.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/maybe-object.h"
#include "src/objects/objects-body-descriptors-inl.h"
#include "src/objects/slots.h"
#include "src/objects/smi.h"
#include "src/objects/string.h"
#include "src/roots/roots.h"
#include "src/snapshot/snapshot.h"
#include "src/tracing/trace-event.h"
#include "src/tracing/traced-value.h"
namespace v8 {
namespace internal {
template <typename TSlot>
TSlot Deserializer::Write(TSlot dest, MaybeObject value) {
DCHECK(!allocator()->next_reference_is_weak());
dest.store(value);
return dest + 1;
}
template <typename TSlot>
TSlot Deserializer::WriteAddress(TSlot dest, Address value) {
DCHECK(!allocator()->next_reference_is_weak());
memcpy(dest.ToVoidPtr(), &value, kSystemPointerSize);
STATIC_ASSERT(IsAligned(kSystemPointerSize, TSlot::kSlotDataSize));
return dest + (kSystemPointerSize / TSlot::kSlotDataSize);
}
void Deserializer::Initialize(Isolate* isolate) {
DCHECK_NULL(isolate_);
DCHECK_NOT_NULL(isolate);
isolate_ = isolate;
allocator()->Initialize(isolate->heap());
#ifdef DEBUG
// The read-only deserializer is run by read-only heap set-up before the heap
// is fully set up. External reference table relies on a few parts of this
// set-up (like old-space), so it may be uninitialized at this point.
if (isolate->isolate_data()->external_reference_table()->is_initialized()) {
// Count the number of external references registered through the API.
num_api_references_ = 0;
if (isolate_->api_external_references() != nullptr) {
while (isolate_->api_external_references()[num_api_references_] != 0) {
num_api_references_++;
}
}
}
#endif // DEBUG
CHECK_EQ(magic_number_, SerializedData::kMagicNumber);
}
void Deserializer::Rehash() {
DCHECK(can_rehash() || deserializing_user_code());
for (HeapObject item : to_rehash_) {
item.RehashBasedOnMap(ReadOnlyRoots(isolate_));
}
}
Deserializer::~Deserializer() {
#ifdef DEBUG
// Do not perform checks if we aborted deserialization.
if (source_.position() == 0) return;
// Check that we only have padding bytes remaining.
while (source_.HasMore()) DCHECK_EQ(kNop, source_.Get());
// Check that we've fully used all reserved space.
DCHECK(allocator()->ReservationsAreFullyUsed());
#endif // DEBUG
}
// This is called on the roots. It is the driver of the deserialization
// process. It is also called on the body of each function.
void Deserializer::VisitRootPointers(Root root, const char* description,
FullObjectSlot start, FullObjectSlot end) {
// We are reading to a location outside of JS heap, so pass kNew to avoid
// triggering write barriers.
ReadData(FullMaybeObjectSlot(start), FullMaybeObjectSlot(end),
SnapshotSpace::kNew, kNullAddress);
}
void Deserializer::Synchronize(VisitorSynchronization::SyncTag tag) {
static const byte expected = kSynchronize;
CHECK_EQ(expected, source_.Get());
}
void Deserializer::DeserializeDeferredObjects() {
DisallowHeapAllocation no_gc;
for (int code = source_.Get(); code != kSynchronize; code = source_.Get()) {
switch (code) {
case kAlignmentPrefix:
case kAlignmentPrefix + 1:
case kAlignmentPrefix + 2: {
int alignment = code - (SerializerDeserializer::kAlignmentPrefix - 1);
allocator()->SetAlignment(static_cast<AllocationAlignment>(alignment));
break;
}
default: {
const int space_number = code & kSpaceMask;
DCHECK_LE(space_number, kNumberOfSpaces);
DCHECK_EQ(code - space_number, kNewObject);
SnapshotSpace space = static_cast<SnapshotSpace>(space_number);
HeapObject object = GetBackReferencedObject(space);
int size = source_.GetInt() << kTaggedSizeLog2;
Address obj_address = object.address();
// Object's map is already initialized, now read the rest.
MaybeObjectSlot start(obj_address + kTaggedSize);
MaybeObjectSlot end(obj_address + size);
bool filled = ReadData(start, end, space, obj_address);
CHECK(filled);
DCHECK(CanBeDeferred(object));
PostProcessNewObject(object, space);
}
}
}
}
void Deserializer::LogNewObjectEvents() {
{
// {new_maps_} and {new_code_objects_} are vectors containing raw
// pointers, hence there should be no GC happening.
DisallowHeapAllocation no_gc;
// Issue code events for newly deserialized code objects.
LOG_CODE_EVENT(isolate_, LogCodeObjects());
}
LOG_CODE_EVENT(isolate_, LogCompiledFunctions());
LogNewMapEvents();
}
void Deserializer::LogNewMapEvents() {
DisallowHeapAllocation no_gc;
for (Map map : new_maps()) {
DCHECK(FLAG_trace_maps);
LOG(isolate_, MapCreate(map));
LOG(isolate_, MapDetails(map));
}
}
void Deserializer::LogScriptEvents(Script script) {
DisallowHeapAllocation no_gc;
LOG(isolate_,
ScriptEvent(Logger::ScriptEventType::kDeserialize, script.id()));
LOG(isolate_, ScriptDetails(script));
}
StringTableInsertionKey::StringTableInsertionKey(String string)
: StringTableKey(ComputeHashField(string), string.length()),
string_(string) {
DCHECK(string.IsInternalizedString());
}
bool StringTableInsertionKey::IsMatch(String string) {
// We want to compare the content of two strings here.
return string_.SlowEquals(string);
}
Handle<String> StringTableInsertionKey::AsHandle(Isolate* isolate) {
return handle(string_, isolate);
}
uint32_t StringTableInsertionKey::ComputeHashField(String string) {
// Make sure hash_field() is computed.
string.Hash();
return string.hash_field();
}
namespace {
String ForwardStringIfExists(Isolate* isolate, StringTableInsertionKey* key) {
StringTable table = isolate->heap()->string_table();
InternalIndex entry = table.FindEntry(isolate, key);
if (entry.is_not_found()) return String();
String canonical = String::cast(table.KeyAt(entry));
DCHECK_NE(canonical, key->string());
key->string().MakeThin(isolate, canonical);
return canonical;
}
} // namespace
HeapObject Deserializer::PostProcessNewObject(HeapObject obj,
SnapshotSpace space) {
DisallowHeapAllocation no_gc;
if ((FLAG_rehash_snapshot && can_rehash_) || deserializing_user_code()) {
if (obj.IsString()) {
// Uninitialize hash field as we need to recompute the hash.
String string = String::cast(obj);
string.set_hash_field(String::kEmptyHashField);
// Rehash strings before read-only space is sealed. Strings outside
// read-only space are rehashed lazily. (e.g. when rehashing dictionaries)
if (space == SnapshotSpace::kReadOnlyHeap) {
to_rehash_.push_back(obj);
}
} else if (obj.NeedsRehashing()) {
to_rehash_.push_back(obj);
}
}
if (deserializing_user_code()) {
if (obj.IsString()) {
String string = String::cast(obj);
if (string.IsInternalizedString()) {
// Canonicalize the internalized string. If it already exists in the
// string table, set it to forward to the existing one.
StringTableInsertionKey key(string);
String canonical = ForwardStringIfExists(isolate_, &key);
if (!canonical.is_null()) return canonical;
new_internalized_strings_.push_back(handle(string, isolate_));
return string;
}
} else if (obj.IsScript()) {
new_scripts_.push_back(handle(Script::cast(obj), isolate_));
} else if (obj.IsAllocationSite()) {
// We should link new allocation sites, but we can't do this immediately
// because |AllocationSite::HasWeakNext()| internally accesses
// |Heap::roots_| that may not have been initialized yet. So defer this to
// |ObjectDeserializer::CommitPostProcessedObjects()|.
new_allocation_sites_.push_back(AllocationSite::cast(obj));
} else {
DCHECK(CanBeDeferred(obj));
}
}
if (obj.IsScript()) {
LogScriptEvents(Script::cast(obj));
} else if (obj.IsCode()) {
// We flush all code pages after deserializing the startup snapshot.
// Hence we only remember each individual code object when deserializing
// user code.
if (deserializing_user_code() || space == SnapshotSpace::kLargeObject) {
new_code_objects_.push_back(Code::cast(obj));
}
} else if (FLAG_trace_maps && obj.IsMap()) {
// Keep track of all seen Maps to log them later since they might be only
// partially initialized at this point.
new_maps_.push_back(Map::cast(obj));
} else if (obj.IsAccessorInfo()) {
#ifdef USE_SIMULATOR
accessor_infos_.push_back(AccessorInfo::cast(obj));
#endif
} else if (obj.IsCallHandlerInfo()) {
#ifdef USE_SIMULATOR
call_handler_infos_.push_back(CallHandlerInfo::cast(obj));
#endif
} else if (obj.IsExternalString()) {
ExternalString string = ExternalString::cast(obj);
uint32_t index = string.resource_as_uint32();
Address address =
static_cast<Address>(isolate_->api_external_references()[index]);
string.set_address_as_resource(address);
isolate_->heap()->UpdateExternalString(string, 0,
string.ExternalPayloadSize());
isolate_->heap()->RegisterExternalString(String::cast(obj));
} else if (obj.IsJSDataView()) {
JSDataView data_view = JSDataView::cast(obj);
JSArrayBuffer buffer = JSArrayBuffer::cast(data_view.buffer());
void* backing_store = nullptr;
if (buffer.backing_store() != nullptr) {
// The backing store of the JSArrayBuffer has not been correctly restored
// yet, as that may trigger GC. The backing_store field currently contains
// a numbered reference to an already deserialized backing store.
size_t store_index = reinterpret_cast<size_t>(buffer.backing_store());
backing_store = backing_stores_[store_index]->buffer_start();
}
data_view.set_data_pointer(reinterpret_cast<uint8_t*>(backing_store) +
data_view.byte_offset());
} else if (obj.IsJSTypedArray()) {
JSTypedArray typed_array = JSTypedArray::cast(obj);
// Fixup typed array pointers.
if (typed_array.is_on_heap()) {
typed_array.SetOnHeapDataPtr(HeapObject::cast(typed_array.base_pointer()),
typed_array.external_pointer());
} else {
// Serializer writes backing store ref as a DataPtr() value.
size_t store_index = reinterpret_cast<size_t>(typed_array.DataPtr());
auto backing_store = backing_stores_[store_index];
auto start = backing_store
? reinterpret_cast<byte*>(backing_store->buffer_start())
: nullptr;
typed_array.SetOffHeapDataPtr(start, typed_array.byte_offset());
}
} else if (obj.IsJSArrayBuffer()) {
JSArrayBuffer buffer = JSArrayBuffer::cast(obj);
// Postpone allocation of backing store to avoid triggering the GC.
if (buffer.backing_store() != nullptr) {
new_off_heap_array_buffers_.push_back(handle(buffer, isolate_));
}
} else if (obj.IsBytecodeArray()) {
// TODO(mythria): Remove these once we store the default values for these
// fields in the serializer.
BytecodeArray bytecode_array = BytecodeArray::cast(obj);
bytecode_array.set_osr_loop_nesting_level(0);
}
#ifdef DEBUG
if (obj.IsDescriptorArray()) {
DescriptorArray descriptor_array = DescriptorArray::cast(obj);
DCHECK_EQ(0, descriptor_array.raw_number_of_marked_descriptors());
}
#endif
// Check alignment.
DCHECK_EQ(0, Heap::GetFillToAlign(obj.address(),
HeapObject::RequiredAlignment(obj.map())));
return obj;
}
HeapObject Deserializer::GetBackReferencedObject(SnapshotSpace space) {
HeapObject obj;
switch (space) {
case SnapshotSpace::kLargeObject:
obj = allocator()->GetLargeObject(source_.GetInt());
break;
case SnapshotSpace::kMap:
obj = allocator()->GetMap(source_.GetInt());
break;
case SnapshotSpace::kReadOnlyHeap: {
uint32_t chunk_index = source_.GetInt();
uint32_t chunk_offset = source_.GetInt();
if (isolate()->heap()->deserialization_complete()) {
PagedSpace* read_only_space = isolate()->heap()->read_only_space();
Page* page = read_only_space->first_page();
for (uint32_t i = 0; i < chunk_index; ++i) {
page = page->next_page();
}
Address address = page->OffsetToAddress(chunk_offset);
obj = HeapObject::FromAddress(address);
} else {
obj = allocator()->GetObject(space, chunk_index, chunk_offset);
}
break;
}
default: {
uint32_t chunk_index = source_.GetInt();
uint32_t chunk_offset = source_.GetInt();
obj = allocator()->GetObject(space, chunk_index, chunk_offset);
break;
}
}
if (deserializing_user_code() && obj.IsThinString()) {
obj = ThinString::cast(obj).actual();
}
hot_objects_.Add(obj);
DCHECK(!HasWeakHeapObjectTag(obj));
return obj;
}
HeapObject Deserializer::ReadObject() {
MaybeObject object;
// We are reading to a location outside of JS heap, so pass kNew to avoid
// triggering write barriers.
bool filled =
ReadData(FullMaybeObjectSlot(&object), FullMaybeObjectSlot(&object + 1),
SnapshotSpace::kNew, kNullAddress);
CHECK(filled);
return object.GetHeapObjectAssumeStrong();
}
HeapObject Deserializer::ReadObject(SnapshotSpace space) {
DisallowHeapAllocation no_gc;
const int size = source_.GetInt() << kObjectAlignmentBits;
Address address = allocator()->Allocate(space, size);
HeapObject obj = HeapObject::FromAddress(address);
isolate_->heap()->OnAllocationEvent(obj, size);
MaybeObjectSlot current(address);
MaybeObjectSlot limit(address + size);
if (ReadData(current, limit, space, address)) {
// Only post process if object content has not been deferred.
obj = PostProcessNewObject(obj, space);
}
#ifdef DEBUG
if (obj.IsCode()) {
DCHECK(space == SnapshotSpace::kCode ||
space == SnapshotSpace::kReadOnlyHeap);
} else {
DCHECK_NE(space, SnapshotSpace::kCode);
}
#endif // DEBUG
return obj;
}
void Deserializer::ReadCodeObjectBody(SnapshotSpace space,
Address code_object_address) {
// At this point the code object is already allocated, its map field is
// initialized and its raw data fields and code stream are also read.
// Now we read the rest of code header's fields.
MaybeObjectSlot current(code_object_address + HeapObject::kHeaderSize);
MaybeObjectSlot limit(code_object_address + Code::kDataStart);
bool filled = ReadData(current, limit, space, code_object_address);
CHECK(filled);
// Now iterate RelocInfos the same way it was done by the serialzier and
// deserialize respective data into RelocInfos.
Code code = Code::cast(HeapObject::FromAddress(code_object_address));
RelocIterator it(code, Code::BodyDescriptor::kRelocModeMask);
for (; !it.done(); it.next()) {
RelocInfo rinfo = *it.rinfo();
rinfo.Visit(this);
}
}
void Deserializer::VisitCodeTarget(Code host, RelocInfo* rinfo) {
HeapObject object = ReadObject();
rinfo->set_target_address(Code::cast(object).raw_instruction_start());
}
void Deserializer::VisitEmbeddedPointer(Code host, RelocInfo* rinfo) {
HeapObject object = ReadObject();
// Embedded object reference must be a strong one.
rinfo->set_target_object(isolate_->heap(), object);
}
void Deserializer::VisitRuntimeEntry(Code host, RelocInfo* rinfo) {
// We no longer serialize code that contains runtime entries.
UNREACHABLE();
}
void Deserializer::VisitExternalReference(Code host, RelocInfo* rinfo) {
byte data = source_.Get();
CHECK_EQ(data, kExternalReference);
Address address = ReadExternalReferenceCase();
if (rinfo->IsCodedSpecially()) {
Address location_of_branch_data = rinfo->pc();
Assembler::deserialization_set_special_target_at(location_of_branch_data,
host, address);
} else {
WriteUnalignedValue(rinfo->target_address_address(), address);
}
}
void Deserializer::VisitInternalReference(Code host, RelocInfo* rinfo) {
byte data = source_.Get();
CHECK_EQ(data, kInternalReference);
// Internal reference target is encoded as an offset from code entry.
int target_offset = source_.GetInt();
DCHECK_LT(static_cast<unsigned>(target_offset),
static_cast<unsigned>(host.raw_instruction_size()));
Address target = host.entry() + target_offset;
Assembler::deserialization_set_target_internal_reference_at(
rinfo->pc(), target, rinfo->rmode());
}
void Deserializer::VisitOffHeapTarget(Code host, RelocInfo* rinfo) {
byte data = source_.Get();
CHECK_EQ(data, kOffHeapTarget);
int builtin_index = source_.GetInt();
DCHECK(Builtins::IsBuiltinId(builtin_index));
CHECK_NOT_NULL(isolate_->embedded_blob());
EmbeddedData d = EmbeddedData::FromBlob();
Address address = d.InstructionStartOfBuiltin(builtin_index);
CHECK_NE(kNullAddress, address);
// TODO(ishell): implement RelocInfo::set_target_off_heap_target()
if (RelocInfo::OffHeapTargetIsCodedSpecially()) {
Address location_of_branch_data = rinfo->pc();
Assembler::deserialization_set_special_target_at(location_of_branch_data,
host, address);
} else {
WriteUnalignedValue(rinfo->target_address_address(), address);
}
}
template <typename TSlot>
TSlot Deserializer::ReadRepeatedObject(TSlot current, int repeat_count) {
CHECK_LE(2, repeat_count);
HeapObject heap_object = ReadObject();
DCHECK(!Heap::InYoungGeneration(heap_object));
for (int i = 0; i < repeat_count; i++) {
// Repeated values are not subject to the write barrier so we don't need
// to trigger it.
current = Write(current, MaybeObject::FromObject(heap_object));
}
return current;
}
static void NoExternalReferencesCallback() {
// The following check will trigger if a function or object template
// with references to native functions have been deserialized from
// snapshot, but no actual external references were provided when the
// isolate was created.
CHECK_WITH_MSG(false, "No external references provided via API");
}
template <typename TSlot>
bool Deserializer::ReadData(TSlot current, TSlot limit,
SnapshotSpace source_space,
Address current_object_address) {
Isolate* const isolate = isolate_;
// Write barrier support costs around 1% in startup time. In fact there
// are no new space objects in current boot snapshots, so it's not needed,
// but that may change.
bool write_barrier_needed =
(current_object_address != kNullAddress &&
source_space != SnapshotSpace::kNew &&
source_space != SnapshotSpace::kCode && !FLAG_disable_write_barriers);
while (current < limit) {
byte data = source_.Get();
switch (data) {
#define CASE_STATEMENT(bytecode, snapshot_space) \
case bytecode + static_cast<int>(snapshot_space): \
STATIC_ASSERT((static_cast<int>(snapshot_space) & ~kSpaceMask) == 0);
#define CASE_BODY(bytecode, space_number_if_any) \
current = ReadDataCase<TSlot, bytecode, space_number_if_any>( \
isolate, current, current_object_address, data, write_barrier_needed); \
break;
// This generates a case and a body for the new space (which has to do extra
// write barrier handling) and handles the other spaces with fall-through cases
// and one body.
#define ALL_SPACES(bytecode) \
CASE_STATEMENT(bytecode, SnapshotSpace::kNew) \
CASE_BODY(bytecode, SnapshotSpace::kNew) \
CASE_STATEMENT(bytecode, SnapshotSpace::kOld) \
V8_FALLTHROUGH; \
CASE_STATEMENT(bytecode, SnapshotSpace::kCode) \
V8_FALLTHROUGH; \
CASE_STATEMENT(bytecode, SnapshotSpace::kMap) \
V8_FALLTHROUGH; \
CASE_STATEMENT(bytecode, SnapshotSpace::kLargeObject) \
V8_FALLTHROUGH; \
CASE_STATEMENT(bytecode, SnapshotSpace::kReadOnlyHeap) \
CASE_BODY(bytecode, kAnyOldSpace)
#define FOUR_CASES(byte_code) \
case byte_code: \
case byte_code + 1: \
case byte_code + 2: \
case byte_code + 3:
#define SIXTEEN_CASES(byte_code) \
FOUR_CASES(byte_code) \
FOUR_CASES(byte_code + 4) \
FOUR_CASES(byte_code + 8) \
FOUR_CASES(byte_code + 12)
#define SINGLE_CASE(bytecode, space) \
CASE_STATEMENT(bytecode, space) \
CASE_BODY(bytecode, space)
// Deserialize a new object and write a pointer to it to the current
// object.
ALL_SPACES(kNewObject)
// Find a recently deserialized object using its offset from the current
// allocation point and write a pointer to it to the current object.
ALL_SPACES(kBackref)
// Find an object in the roots array and write a pointer to it to the
// current object.
SINGLE_CASE(kRootArray, SnapshotSpace::kReadOnlyHeap)
// Find an object in the partial snapshots cache and write a pointer to it
// to the current object.
SINGLE_CASE(kPartialSnapshotCache, SnapshotSpace::kReadOnlyHeap)
// Find an object in the partial snapshots cache and write a pointer to it
// to the current object.
SINGLE_CASE(kReadOnlyObjectCache, SnapshotSpace::kReadOnlyHeap)
// Find an object in the attached references and write a pointer to it to
// the current object.
SINGLE_CASE(kAttachedReference, SnapshotSpace::kReadOnlyHeap)
#undef CASE_STATEMENT
#undef CASE_BODY
#undef ALL_SPACES
// Find an external reference and write a pointer to it to the current
// object.
case kExternalReference: {
Address address = ReadExternalReferenceCase();
current = WriteAddress(current, address);
break;
}
case kInternalReference:
case kOffHeapTarget: {
// These bytecodes are expected only during RelocInfo iteration.
UNREACHABLE();
break;
}
case kNop:
break;
case kNextChunk: {
int space = source_.Get();
allocator()->MoveToNextChunk(static_cast<SnapshotSpace>(space));
break;
}
case kDeferred: {
// Deferred can only occur right after the heap object header.
DCHECK_EQ(current.address(), current_object_address + kTaggedSize);
HeapObject obj = HeapObject::FromAddress(current_object_address);
// If the deferred object is a map, its instance type may be used
// during deserialization. Initialize it with a temporary value.
if (obj.IsMap()) Map::cast(obj).set_instance_type(FILLER_TYPE);
current = limit;
return false;
}
case kSynchronize:
// If we get here then that indicates that you have a mismatch between
// the number of GC roots when serializing and deserializing.
UNREACHABLE();
// Deserialize raw data of variable length.
case kVariableRawData: {
int size_in_bytes = source_.GetInt();
DCHECK(IsAligned(size_in_bytes, kTaggedSize));
source_.CopyRaw(current.ToVoidPtr(), size_in_bytes);
current = TSlot(current.address() + size_in_bytes);
break;
}
// Deserialize raw code directly into the body of the code object.
case kVariableRawCode: {
// VariableRawCode can only occur right after the heap object header.
DCHECK_EQ(current.address(), current_object_address + kTaggedSize);
int size_in_bytes = source_.GetInt();
DCHECK(IsAligned(size_in_bytes, kTaggedSize));
source_.CopyRaw(
reinterpret_cast<void*>(current_object_address + Code::kDataStart),
size_in_bytes);
// Deserialize tagged fields in the code object header and reloc infos.
ReadCodeObjectBody(source_space, current_object_address);
// Set current to the code object end.
current = TSlot(current.address() + Code::kDataStart -
HeapObject::kHeaderSize + size_in_bytes);
CHECK_EQ(current, limit);
break;
}
case kVariableRepeat: {
int repeats = DecodeVariableRepeatCount(source_.GetInt());
current = ReadRepeatedObject(current, repeats);
break;
}
case kOffHeapBackingStore: {
int byte_length = source_.GetInt();
std::unique_ptr<BackingStore> backing_store =
BackingStore::Allocate(isolate, byte_length, SharedFlag::kNotShared,
InitializedFlag::kUninitialized);
CHECK_NOT_NULL(backing_store);
source_.CopyRaw(backing_store->buffer_start(), byte_length);
backing_stores_.push_back(std::move(backing_store));
break;
}
case kApiReference: {
uint32_t reference_id = static_cast<uint32_t>(source_.GetInt());
Address address;
if (isolate->api_external_references()) {
DCHECK_WITH_MSG(
reference_id < num_api_references_,
"too few external references provided through the API");
address = static_cast<Address>(
isolate->api_external_references()[reference_id]);
} else {
address = reinterpret_cast<Address>(NoExternalReferencesCallback);
}
current = WriteAddress(current, address);
break;
}
case kClearedWeakReference:
current = Write(current, HeapObjectReference::ClearedValue(isolate_));
break;
case kWeakPrefix:
DCHECK(!allocator()->next_reference_is_weak());
allocator()->set_next_reference_is_weak(true);
break;
case kAlignmentPrefix:
case kAlignmentPrefix + 1:
case kAlignmentPrefix + 2: {
int alignment = data - (SerializerDeserializer::kAlignmentPrefix - 1);
allocator()->SetAlignment(static_cast<AllocationAlignment>(alignment));
break;
}
// First kNumberOfRootArrayConstants roots are guaranteed to be in
// the old space.
STATIC_ASSERT(
static_cast<int>(RootIndex::kFirstImmortalImmovableRoot) == 0);
STATIC_ASSERT(kNumberOfRootArrayConstants <=
static_cast<int>(RootIndex::kLastImmortalImmovableRoot));
STATIC_ASSERT(kNumberOfRootArrayConstants == 32);
SIXTEEN_CASES(kRootArrayConstants)
SIXTEEN_CASES(kRootArrayConstants + 16) {
int id = data & kRootArrayConstantsMask;
RootIndex root_index = static_cast<RootIndex>(id);
MaybeObject object = MaybeObject::FromObject(isolate->root(root_index));
DCHECK(!Heap::InYoungGeneration(object));
current = Write(current, object);
break;
}
STATIC_ASSERT(kNumberOfHotObjects == 8);
FOUR_CASES(kHotObject)
FOUR_CASES(kHotObject + 4) {
int index = data & kHotObjectMask;
Object hot_object = hot_objects_.Get(index);
MaybeObject hot_maybe_object = MaybeObject::FromObject(hot_object);
if (allocator()->GetAndClearNextReferenceIsWeak()) {
hot_maybe_object = MaybeObject::MakeWeak(hot_maybe_object);
}
// Don't update current pointer here as it may be needed for write
// barrier.
Write(current, hot_maybe_object);
if (write_barrier_needed && Heap::InYoungGeneration(hot_object)) {
HeapObject current_object =
HeapObject::FromAddress(current_object_address);
GenerationalBarrier(current_object,
MaybeObjectSlot(current.address()),
hot_maybe_object);
}
++current;
break;
}
// Deserialize raw data of fixed length from 1 to 32 words.
STATIC_ASSERT(kNumberOfFixedRawData == 32);
SIXTEEN_CASES(kFixedRawData)
SIXTEEN_CASES(kFixedRawData + 16) {
int size_in_tagged = data - kFixedRawDataStart;
source_.CopyRaw(current.ToVoidPtr(), size_in_tagged * kTaggedSize);
current += size_in_tagged;
break;
}
STATIC_ASSERT(kNumberOfFixedRepeat == 16);
SIXTEEN_CASES(kFixedRepeat) {
int repeats = DecodeFixedRepeatCount(data);
current = ReadRepeatedObject(current, repeats);
break;
}
#ifdef DEBUG
#define UNUSED_CASE(byte_code) \
case byte_code: \
UNREACHABLE();
UNUSED_SERIALIZER_BYTE_CODES(UNUSED_CASE)
#endif
#undef UNUSED_CASE
#undef SIXTEEN_CASES
#undef FOUR_CASES
#undef SINGLE_CASE
}
}
CHECK_EQ(limit, current);
return true;
}
Address Deserializer::ReadExternalReferenceCase() {
uint32_t reference_id = static_cast<uint32_t>(source_.GetInt());
return isolate_->external_reference_table()->address(reference_id);
}
template <typename TSlot, SerializerDeserializer::Bytecode bytecode,
SnapshotSpace space_number_if_any>
TSlot Deserializer::ReadDataCase(Isolate* isolate, TSlot current,
Address current_object_address, byte data,
bool write_barrier_needed) {
bool emit_write_barrier = false;
SnapshotSpace space = static_cast<SnapshotSpace>(
space_number_if_any == kAnyOldSpace
? static_cast<SnapshotSpace>(data & kSpaceMask)
: space_number_if_any);
HeapObject heap_object;
HeapObjectReferenceType reference_type =
allocator()->GetAndClearNextReferenceIsWeak()
? HeapObjectReferenceType::WEAK
: HeapObjectReferenceType::STRONG;
if (bytecode == kNewObject) {
heap_object = ReadObject(space);
emit_write_barrier = (space == SnapshotSpace::kNew);
} else if (bytecode == kBackref) {
heap_object = GetBackReferencedObject(space);
emit_write_barrier = (space == SnapshotSpace::kNew);
} else if (bytecode == kRootArray) {
int id = source_.GetInt();
RootIndex root_index = static_cast<RootIndex>(id);
heap_object = HeapObject::cast(isolate->root(root_index));
emit_write_barrier = Heap::InYoungGeneration(heap_object);
hot_objects_.Add(heap_object);
} else if (bytecode == kReadOnlyObjectCache) {
int cache_index = source_.GetInt();
heap_object = HeapObject::cast(
isolate->read_only_heap()->cached_read_only_object(cache_index));
DCHECK(!Heap::InYoungGeneration(heap_object));
emit_write_barrier = false;
} else if (bytecode == kPartialSnapshotCache) {
int cache_index = source_.GetInt();
heap_object =
HeapObject::cast(isolate->partial_snapshot_cache()->at(cache_index));
emit_write_barrier = Heap::InYoungGeneration(heap_object);
} else {
DCHECK_EQ(bytecode, kAttachedReference);
int index = source_.GetInt();
heap_object = *attached_objects_[index];
emit_write_barrier = Heap::InYoungGeneration(heap_object);
}
HeapObjectReference heap_object_ref =
reference_type == HeapObjectReferenceType::STRONG
? HeapObjectReference::Strong(heap_object)
: HeapObjectReference::Weak(heap_object);
// Don't update current pointer here as it may be needed for write barrier.
Write(current, heap_object_ref);
if (emit_write_barrier && write_barrier_needed) {
DCHECK_IMPLIES(FLAG_disable_write_barriers, !write_barrier_needed);
HeapObject host_object = HeapObject::FromAddress(current_object_address);
SLOW_DCHECK(isolate->heap()->Contains(host_object));
GenerationalBarrier(host_object, MaybeObjectSlot(current.address()),
heap_object_ref);
}
return current + 1;
}
} // namespace internal
} // namespace v8
| 32,457
| 10,102
|
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
* Copyright (C) 2009-2016, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: normalizer2.cpp
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
*
* created on: 2009nov22
* created by: Markus W. Scherer
*/
#include "unicode/utypes.h"
#if !UCONFIG_NO_NORMALIZATION
#include "unicode/normalizer2.h"
#include "unicode/unistr.h"
#include "unicode/unorm.h"
#include "cstring.h"
#include "mutex.h"
#include "norm2allmodes.h"
#include "normalizer2impl.h"
#include "uassert.h"
#include "ucln_cmn.h"
using icu::Normalizer2Impl;
// NFC/NFD data machine-generated by gennorm2 --csource
#define INCLUDED_FROM_NORMALIZER2_CPP
#include "norm2_nfc_data.h"
U_NAMESPACE_BEGIN
// Public API dispatch via Normalizer2 subclasses -------------------------- ***
Normalizer2::~Normalizer2() {}
UBool
Normalizer2::getRawDecomposition(UChar32, UnicodeString &) const {
return FALSE;
}
UChar32
Normalizer2::composePair(UChar32, UChar32) const {
return U_SENTINEL;
}
uint8_t
Normalizer2::getCombiningClass(UChar32 /*c*/) const {
return 0;
}
// Normalizer2 implementation for the old UNORM_NONE.
class NoopNormalizer2 : public Normalizer2 {
virtual ~NoopNormalizer2();
virtual UnicodeString &
normalize(const UnicodeString &src,
UnicodeString &dest,
UErrorCode &errorCode) const {
if(U_SUCCESS(errorCode)) {
if(&dest!=&src) {
dest=src;
} else {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
}
}
return dest;
}
virtual UnicodeString &
normalizeSecondAndAppend(UnicodeString &first,
const UnicodeString &second,
UErrorCode &errorCode) const {
if(U_SUCCESS(errorCode)) {
if(&first!=&second) {
first.append(second);
} else {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
}
}
return first;
}
virtual UnicodeString &
append(UnicodeString &first,
const UnicodeString &second,
UErrorCode &errorCode) const {
if(U_SUCCESS(errorCode)) {
if(&first!=&second) {
first.append(second);
} else {
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
}
}
return first;
}
virtual UBool
getDecomposition(UChar32, UnicodeString &) const {
return FALSE;
}
// No need to override the default getRawDecomposition().
virtual UBool
isNormalized(const UnicodeString &, UErrorCode &) const {
return TRUE;
}
virtual UNormalizationCheckResult
quickCheck(const UnicodeString &, UErrorCode &) const {
return UNORM_YES;
}
virtual int32_t
spanQuickCheckYes(const UnicodeString &s, UErrorCode &) const {
return s.length();
}
virtual UBool hasBoundaryBefore(UChar32) const { return TRUE; }
virtual UBool hasBoundaryAfter(UChar32) const { return TRUE; }
virtual UBool isInert(UChar32) const { return TRUE; }
};
NoopNormalizer2::~NoopNormalizer2() {}
Normalizer2WithImpl::~Normalizer2WithImpl() {}
DecomposeNormalizer2::~DecomposeNormalizer2() {}
ComposeNormalizer2::~ComposeNormalizer2() {}
FCDNormalizer2::~FCDNormalizer2() {}
// instance cache ---------------------------------------------------------- ***
Norm2AllModes::~Norm2AllModes() {
delete impl;
}
Norm2AllModes *
Norm2AllModes::createInstance(Normalizer2Impl *impl, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) {
delete impl;
return NULL;
}
Norm2AllModes *allModes=new Norm2AllModes(impl);
if(allModes==NULL) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
delete impl;
return NULL;
}
return allModes;
}
Norm2AllModes *
Norm2AllModes::createNFCInstance(UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) {
return NULL;
}
Normalizer2Impl *impl=new Normalizer2Impl;
if(impl==NULL) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
impl->init(norm2_nfc_data_indexes, &norm2_nfc_data_trie,
norm2_nfc_data_extraData, norm2_nfc_data_smallFCD);
return createInstance(impl, errorCode);
}
U_CDECL_BEGIN
static UBool U_CALLCONV uprv_normalizer2_cleanup();
U_CDECL_END
static Norm2AllModes *nfcSingleton;
static Normalizer2 *noopSingleton;
static icu::UInitOnce nfcInitOnce = U_INITONCE_INITIALIZER;
static icu::UInitOnce noopInitOnce = U_INITONCE_INITIALIZER;
// UInitOnce singleton initialization functions
static void U_CALLCONV initNFCSingleton(UErrorCode &errorCode) {
nfcSingleton=Norm2AllModes::createNFCInstance(errorCode);
ucln_common_registerCleanup(UCLN_COMMON_NORMALIZER2, uprv_normalizer2_cleanup);
}
static void U_CALLCONV initNoopSingleton(UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) {
return;
}
noopSingleton=new NoopNormalizer2;
if(noopSingleton==NULL) {
errorCode=U_MEMORY_ALLOCATION_ERROR;
return;
}
ucln_common_registerCleanup(UCLN_COMMON_NORMALIZER2, uprv_normalizer2_cleanup);
}
U_CDECL_BEGIN
static UBool U_CALLCONV uprv_normalizer2_cleanup() {
delete nfcSingleton;
nfcSingleton = NULL;
delete noopSingleton;
noopSingleton = NULL;
nfcInitOnce.reset();
noopInitOnce.reset();
return TRUE;
}
U_CDECL_END
const Norm2AllModes *
Norm2AllModes::getNFCInstance(UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return NULL; }
umtx_initOnce(nfcInitOnce, &initNFCSingleton, errorCode);
return nfcSingleton;
}
const Normalizer2 *
Normalizer2::getNFCInstance(UErrorCode &errorCode) {
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
return allModes!=NULL ? &allModes->comp : NULL;
}
const Normalizer2 *
Normalizer2::getNFDInstance(UErrorCode &errorCode) {
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
return allModes!=NULL ? &allModes->decomp : NULL;
}
const Normalizer2 *Normalizer2Factory::getFCDInstance(UErrorCode &errorCode) {
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
return allModes!=NULL ? &allModes->fcd : NULL;
}
const Normalizer2 *Normalizer2Factory::getFCCInstance(UErrorCode &errorCode) {
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
return allModes!=NULL ? &allModes->fcc : NULL;
}
const Normalizer2 *Normalizer2Factory::getNoopInstance(UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return NULL; }
umtx_initOnce(noopInitOnce, &initNoopSingleton, errorCode);
return noopSingleton;
}
const Normalizer2Impl *
Normalizer2Factory::getNFCImpl(UErrorCode &errorCode) {
const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
return allModes!=NULL ? allModes->impl : NULL;
}
const Normalizer2Impl *
Normalizer2Factory::getImpl(const Normalizer2 *norm2) {
return &((Normalizer2WithImpl *)norm2)->impl;
}
U_NAMESPACE_END
// C API ------------------------------------------------------------------- ***
U_NAMESPACE_USE
U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getNFCInstance(UErrorCode *pErrorCode) {
return (const UNormalizer2 *)Normalizer2::getNFCInstance(*pErrorCode);
}
U_CAPI const UNormalizer2 * U_EXPORT2
unorm2_getNFDInstance(UErrorCode *pErrorCode) {
return (const UNormalizer2 *)Normalizer2::getNFDInstance(*pErrorCode);
}
U_CAPI void U_EXPORT2
unorm2_close(UNormalizer2 *norm2) {
delete (Normalizer2 *)norm2;
}
U_CAPI int32_t U_EXPORT2
unorm2_normalize(const UNormalizer2 *norm2,
const UChar *src, int32_t length,
UChar *dest, int32_t capacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
}
if( (src==NULL ? length!=0 : length<-1) ||
(dest==NULL ? capacity!=0 : capacity<0) ||
(src==dest && src!=NULL)
) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
UnicodeString destString(dest, 0, capacity);
// length==0: Nothing to do, and n2wi->normalize(NULL, NULL, buffer, ...) would crash.
if(length!=0) {
const Normalizer2 *n2=(const Normalizer2 *)norm2;
const Normalizer2WithImpl *n2wi=dynamic_cast<const Normalizer2WithImpl *>(n2);
if(n2wi!=NULL) {
// Avoid duplicate argument checking and support NUL-terminated src.
ReorderingBuffer buffer(n2wi->impl, destString);
if(buffer.init(length, *pErrorCode)) {
n2wi->normalize(src, length>=0 ? src+length : NULL, buffer, *pErrorCode);
}
} else {
UnicodeString srcString(length<0, src, length);
n2->normalize(srcString, destString, *pErrorCode);
}
}
return destString.extract(dest, capacity, *pErrorCode);
}
static int32_t
normalizeSecondAndAppend(const UNormalizer2 *norm2,
UChar *first, int32_t firstLength, int32_t firstCapacity,
const UChar *second, int32_t secondLength,
UBool doNormalize,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
}
if( (second==NULL ? secondLength!=0 : secondLength<-1) ||
(first==NULL ? (firstCapacity!=0 || firstLength!=0) :
(firstCapacity<0 || firstLength<-1)) ||
(first==second && first!=NULL)
) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
UnicodeString firstString(first, firstLength, firstCapacity);
firstLength=firstString.length(); // In case it was -1.
// secondLength==0: Nothing to do, and n2wi->normalizeAndAppend(NULL, NULL, buffer, ...) would crash.
if(secondLength!=0) {
const Normalizer2 *n2=(const Normalizer2 *)norm2;
const Normalizer2WithImpl *n2wi=dynamic_cast<const Normalizer2WithImpl *>(n2);
if(n2wi!=NULL) {
// Avoid duplicate argument checking and support NUL-terminated src.
UnicodeString safeMiddle;
{
ReorderingBuffer buffer(n2wi->impl, firstString);
if(buffer.init(firstLength+secondLength+1, *pErrorCode)) { // destCapacity>=-1
n2wi->normalizeAndAppend(second, secondLength>=0 ? second+secondLength : NULL,
doNormalize, safeMiddle, buffer, *pErrorCode);
}
} // The ReorderingBuffer destructor finalizes firstString.
if(U_FAILURE(*pErrorCode) || firstString.length()>firstCapacity) {
// Restore the modified suffix of the first string.
// This does not restore first[] array contents between firstLength and firstCapacity.
// (That might be uninitialized memory, as far as we know.)
if(first!=NULL) { /* don't dereference NULL */
safeMiddle.extract(0, 0x7fffffff, first+firstLength-safeMiddle.length());
if(firstLength<firstCapacity) {
first[firstLength]=0; // NUL-terminate in case it was originally.
}
}
}
} else {
UnicodeString secondString(secondLength<0, second, secondLength);
if(doNormalize) {
n2->normalizeSecondAndAppend(firstString, secondString, *pErrorCode);
} else {
n2->append(firstString, secondString, *pErrorCode);
}
}
}
return firstString.extract(first, firstCapacity, *pErrorCode);
}
U_CAPI int32_t U_EXPORT2
unorm2_normalizeSecondAndAppend(const UNormalizer2 *norm2,
UChar *first, int32_t firstLength, int32_t firstCapacity,
const UChar *second, int32_t secondLength,
UErrorCode *pErrorCode) {
return normalizeSecondAndAppend(norm2,
first, firstLength, firstCapacity,
second, secondLength,
TRUE, pErrorCode);
}
U_CAPI int32_t U_EXPORT2
unorm2_append(const UNormalizer2 *norm2,
UChar *first, int32_t firstLength, int32_t firstCapacity,
const UChar *second, int32_t secondLength,
UErrorCode *pErrorCode) {
return normalizeSecondAndAppend(norm2,
first, firstLength, firstCapacity,
second, secondLength,
FALSE, pErrorCode);
}
U_CAPI int32_t U_EXPORT2
unorm2_getDecomposition(const UNormalizer2 *norm2,
UChar32 c, UChar *decomposition, int32_t capacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
}
if(decomposition==NULL ? capacity!=0 : capacity<0) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
UnicodeString destString(decomposition, 0, capacity);
if(reinterpret_cast<const Normalizer2 *>(norm2)->getDecomposition(c, destString)) {
return destString.extract(decomposition, capacity, *pErrorCode);
} else {
return -1;
}
}
U_CAPI int32_t U_EXPORT2
unorm2_getRawDecomposition(const UNormalizer2 *norm2,
UChar32 c, UChar *decomposition, int32_t capacity,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
}
if(decomposition==NULL ? capacity!=0 : capacity<0) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
UnicodeString destString(decomposition, 0, capacity);
if(reinterpret_cast<const Normalizer2 *>(norm2)->getRawDecomposition(c, destString)) {
return destString.extract(decomposition, capacity, *pErrorCode);
} else {
return -1;
}
}
U_CAPI UChar32 U_EXPORT2
unorm2_composePair(const UNormalizer2 *norm2, UChar32 a, UChar32 b) {
return reinterpret_cast<const Normalizer2 *>(norm2)->composePair(a, b);
}
U_CAPI uint8_t U_EXPORT2
unorm2_getCombiningClass(const UNormalizer2 *norm2, UChar32 c) {
return reinterpret_cast<const Normalizer2 *>(norm2)->getCombiningClass(c);
}
U_CAPI UBool U_EXPORT2
unorm2_isNormalized(const UNormalizer2 *norm2,
const UChar *s, int32_t length,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
}
if((s==NULL && length!=0) || length<-1) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
UnicodeString sString(length<0, s, length);
return ((const Normalizer2 *)norm2)->isNormalized(sString, *pErrorCode);
}
U_CAPI UNormalizationCheckResult U_EXPORT2
unorm2_quickCheck(const UNormalizer2 *norm2,
const UChar *s, int32_t length,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return UNORM_NO;
}
if((s==NULL && length!=0) || length<-1) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return UNORM_NO;
}
UnicodeString sString(length<0, s, length);
return ((const Normalizer2 *)norm2)->quickCheck(sString, *pErrorCode);
}
U_CAPI int32_t U_EXPORT2
unorm2_spanQuickCheckYes(const UNormalizer2 *norm2,
const UChar *s, int32_t length,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
}
if((s==NULL && length!=0) || length<-1) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
UnicodeString sString(length<0, s, length);
return ((const Normalizer2 *)norm2)->spanQuickCheckYes(sString, *pErrorCode);
}
U_CAPI UBool U_EXPORT2
unorm2_hasBoundaryBefore(const UNormalizer2 *norm2, UChar32 c) {
return ((const Normalizer2 *)norm2)->hasBoundaryBefore(c);
}
U_CAPI UBool U_EXPORT2
unorm2_hasBoundaryAfter(const UNormalizer2 *norm2, UChar32 c) {
return ((const Normalizer2 *)norm2)->hasBoundaryAfter(c);
}
U_CAPI UBool U_EXPORT2
unorm2_isInert(const UNormalizer2 *norm2, UChar32 c) {
return ((const Normalizer2 *)norm2)->isInert(c);
}
// Some properties APIs ---------------------------------------------------- ***
U_CAPI uint8_t U_EXPORT2
u_getCombiningClass(UChar32 c) {
UErrorCode errorCode=U_ZERO_ERROR;
const Normalizer2 *nfd=Normalizer2::getNFDInstance(errorCode);
if(U_SUCCESS(errorCode)) {
return nfd->getCombiningClass(c);
} else {
return 0;
}
}
U_CFUNC uint16_t
unorm_getFCD16(UChar32 c) {
UErrorCode errorCode=U_ZERO_ERROR;
const Normalizer2Impl *impl=Normalizer2Factory::getNFCImpl(errorCode);
if(U_SUCCESS(errorCode)) {
return impl->getFCD16(c);
} else {
return 0;
}
}
#endif // !UCONFIG_NO_NORMALIZATION
| 17,148
| 5,718
|
#include "TactileButton.h"
namespace components {
TactileButton::TactileButton(Ref<Component> parent, DigitalInput input, TriggerOn trigger) : Component(parent), _input(input), _pressed(false), _on_press([](){}), _on_release([](){}), _trigger(trigger) {}
TactileButton::TactileButton(Ref<Component> parent, PinNumber pin, TriggerOn trigger, InputPull pull) : TactileButton(parent, DigitalInput(pin, pull), trigger) {}
void TactileButton::onPress(VoidCallback cbk) {
this->_on_press = cbk;
}
void TactileButton::onRelease(VoidCallback cbk) {
this->_on_release = cbk;
}
bool TactileButton::isPressed() {
return (_trigger == TriggerOn::Low)? _input.isLow(): _input.isHigh();
}
void TactileButton::privateLoop() {
bool pressedState = this->isPressed();
if(pressedState != _pressed) {
if(pressedState == true) _on_press();
else if(pressedState == false) _on_release();
_pressed = pressedState;
}
}
};
| 932
| 331
|
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/layout/flex_layout_view.h"
#include <memory>
#include "ui/views/layout/flex_layout_types.h"
#include "ui/views/layout/layout_types.h"
#include "ui/views/metadata/metadata_impl_macros.h"
#include "ui/views/metadata/type_conversion.h"
namespace views {
FlexLayoutView::FlexLayoutView()
: layout_(SetLayoutManager(std::make_unique<FlexLayout>())),
orientation_(layout_->orientation()),
main_axis_alignment_(layout_->main_axis_alignment()),
cross_axis_alignment_(layout_->cross_axis_alignment()),
interior_margin_(layout_->interior_margin()),
minimum_cross_axis_size_(layout_->minimum_cross_axis_size()),
collapse_margins_(layout_->collapse_margins()),
include_host_insets_in_layout_(layout_->include_host_insets_in_layout()),
ignore_default_main_axis_margins_(
layout_->ignore_default_main_axis_margins()),
flex_allocation_order_(layout_->flex_allocation_order()) {}
FlexLayoutView::~FlexLayoutView() = default;
void FlexLayoutView::SetOrientation(LayoutOrientation orientation) {
if (orientation_ == orientation)
return;
layout_->SetOrientation(orientation);
orientation_ = orientation;
OnPropertyChanged(&orientation_, kPropertyEffectsLayout);
}
LayoutOrientation FlexLayoutView::GetOrientation() const {
return orientation_;
}
void FlexLayoutView::SetMainAxisAlignment(LayoutAlignment main_axis_alignment) {
if (main_axis_alignment_ == main_axis_alignment)
return;
layout_->SetMainAxisAlignment(main_axis_alignment);
main_axis_alignment_ = main_axis_alignment;
OnPropertyChanged(&main_axis_alignment_, kPropertyEffectsLayout);
}
LayoutAlignment FlexLayoutView::GetMainAxisAlignment() const {
return layout_->main_axis_alignment();
}
void FlexLayoutView::SetCrossAxisAlignment(
LayoutAlignment cross_axis_alignment) {
if (cross_axis_alignment_ == cross_axis_alignment)
return;
layout_->SetCrossAxisAlignment(cross_axis_alignment);
cross_axis_alignment_ = cross_axis_alignment;
OnPropertyChanged(&cross_axis_alignment_, kPropertyEffectsLayout);
}
LayoutAlignment FlexLayoutView::GetCrossAxisAlignment() const {
return cross_axis_alignment_;
}
void FlexLayoutView::SetInteriorMargin(const gfx::Insets& interior_margin) {
if (interior_margin_ == interior_margin)
return;
layout_->SetInteriorMargin(interior_margin);
interior_margin_ = interior_margin;
OnPropertyChanged(&interior_margin_, kPropertyEffectsLayout);
}
const gfx::Insets& FlexLayoutView::GetInteriorMargin() const {
return interior_margin_;
}
void FlexLayoutView::SetMinimumCrossAxisSize(int size) {
if (minimum_cross_axis_size_ == size)
return;
layout_->SetMinimumCrossAxisSize(size);
minimum_cross_axis_size_ = size;
OnPropertyChanged(&minimum_cross_axis_size_, kPropertyEffectsLayout);
}
int FlexLayoutView::GetMinimumCrossAxisSize() const {
return minimum_cross_axis_size_;
}
void FlexLayoutView::SetCollapseMargins(bool collapse_margins) {
if (collapse_margins_ == collapse_margins)
return;
layout_->SetCollapseMargins(collapse_margins);
collapse_margins_ = collapse_margins;
OnPropertyChanged(&collapse_margins_, kPropertyEffectsLayout);
}
bool FlexLayoutView::GetCollapseMargins() const {
return collapse_margins_;
}
void FlexLayoutView::SetIncludeHostInsetsInLayout(
bool include_host_insets_in_layout) {
if (include_host_insets_in_layout_ == include_host_insets_in_layout)
return;
layout_->SetIncludeHostInsetsInLayout(include_host_insets_in_layout);
include_host_insets_in_layout_ = include_host_insets_in_layout;
OnPropertyChanged(&include_host_insets_in_layout_, kPropertyEffectsLayout);
}
bool FlexLayoutView::GetIncludeHostInsetsInLayout() const {
return include_host_insets_in_layout_;
}
void FlexLayoutView::SetIgnoreDefaultMainAxisMargins(
bool ignore_default_main_axis_margins) {
if (ignore_default_main_axis_margins == ignore_default_main_axis_margins_) {
return;
}
layout_->SetIgnoreDefaultMainAxisMargins(ignore_default_main_axis_margins);
ignore_default_main_axis_margins_ = ignore_default_main_axis_margins;
OnPropertyChanged(&ignore_default_main_axis_margins_, kPropertyEffectsLayout);
}
bool FlexLayoutView::GetIgnoreDefaultMainAxisMargins() const {
return ignore_default_main_axis_margins_;
}
void FlexLayoutView::SetFlexAllocationOrder(
FlexAllocationOrder flex_allocation_order) {
if (flex_allocation_order_ == flex_allocation_order)
return;
layout_->SetFlexAllocationOrder(flex_allocation_order);
flex_allocation_order_ = flex_allocation_order;
OnPropertyChanged(&flex_allocation_order_, kPropertyEffectsLayout);
}
FlexAllocationOrder FlexLayoutView::GetFlexAllocationOrder() const {
return flex_allocation_order_;
}
FlexRule FlexLayoutView::GetDefaultFlexRule() const {
return layout_->GetDefaultFlexRule();
}
DEFINE_ENUM_CONVERTERS(LayoutOrientation,
{LayoutOrientation::kHorizontal, u"kHorizontal"},
{LayoutOrientation::kVertical, u"kVertical"})
DEFINE_ENUM_CONVERTERS(LayoutAlignment,
{LayoutAlignment::kStart, u"kStart"},
{LayoutAlignment::kCenter, u"kCenter"},
{LayoutAlignment::kEnd, u"kEnd"},
{LayoutAlignment::kStretch, u"kStretch"})
DEFINE_ENUM_CONVERTERS(FlexAllocationOrder,
{FlexAllocationOrder::kNormal, u"kNormal"},
{FlexAllocationOrder::kReverse, u"kReverse"})
BEGIN_METADATA(FlexLayoutView, View)
ADD_PROPERTY_METADATA(LayoutOrientation, Orientation)
ADD_PROPERTY_METADATA(LayoutAlignment, MainAxisAlignment)
ADD_PROPERTY_METADATA(LayoutAlignment, CrossAxisAlignment)
ADD_PROPERTY_METADATA(const gfx::Insets, InteriorMargin)
ADD_PROPERTY_METADATA(int, MinimumCrossAxisSize)
ADD_PROPERTY_METADATA(bool, CollapseMargins)
ADD_PROPERTY_METADATA(bool, IncludeHostInsetsInLayout)
ADD_PROPERTY_METADATA(bool, IgnoreDefaultMainAxisMargins)
ADD_PROPERTY_METADATA(FlexAllocationOrder, FlexAllocationOrder)
END_METADATA
} // namespace views
| 6,248
| 2,023
|
/*
* Copyright (c) 2020, Rapprise.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <set>
#include "common/exceptions/strategy_exception/small_analyzed_period_exception.h"
#include "common/exceptions/undefined_type_exception.h"
#include "common/loggers/file_logger.h"
#include "include/exponential_moving_average/exponential_moving_average.h"
#include "include/moving_averages_crossing/moving_averages_crossing.h"
#include "include/simple_moving_average/simple_moving_average.h"
constexpr unsigned int MIN_MOVING_AVERAGES_COUNT = 2;
namespace auto_trader {
namespace strategies {
void MovingAveragesCrossing::createLines(const std::vector<common::MarketData> &marketData,
int smallerPeriodSize, int biggerPeriodSize,
double lastBuyCrossingPoint, double lastSellCrossingPoint,
common::MovingAverageType type) {
crossingForSellSignal_.second = false;
crossingForBuySignal_.second = false;
if (marketData.size() == 0 || marketData.size() < biggerPeriodSize) {
common::loggers::FileLogger::getLogger() << "MAC: bad data for creating lines.";
throw common::exceptions::StrategyException(
"Moving Averages Crossing: not valid data for creating lines");
}
lastBuyCrossingPoint_ = lastBuyCrossingPoint;
lastSellCrossingPoint_ = lastSellCrossingPoint;
auto movingAveragePtr = createMovingAverage(type);
movingAveragePtr->createLine(marketData, smallerPeriodSize);
smallerPeriodLine_ = movingAveragePtr->getLine();
movingAveragePtr->createLine(marketData, biggerPeriodSize);
biggerPeriodLine_ = movingAveragePtr->getLine();
crossingToBuySignal();
crossingToSellSignal();
}
std::shared_ptr<MovingAverageBase> MovingAveragesCrossing::createMovingAverage(
common::MovingAverageType type) {
switch (type) {
case common::MovingAverageType::EXPONENTIAL:
return std::make_shared<ExponentialMovingAverage>();
case common::MovingAverageType::SIMPLE:
return std::make_shared<SimpleMovingAverage>();
default:
break;
}
throw common::exceptions::UndefinedTypeException("Moving Average Type");
}
MovingAverageLine MovingAveragesCrossing::getSmallerPeriodLine() const {
return smallerPeriodLine_;
}
MovingAverageLine MovingAveragesCrossing::getBiggerPeriodLine() const { return biggerPeriodLine_; }
bool MovingAveragesCrossing::isNeedToBuy() const { return crossingForBuySignal_.second; }
bool MovingAveragesCrossing::isNeedToSell() const { return crossingForSellSignal_.second; }
double MovingAveragesCrossing::getLastBuyCrossingPoint() const { return lastBuyCrossingPoint_; }
double MovingAveragesCrossing::getLastSellCrossingPoint() const { return lastSellCrossingPoint_; }
void MovingAveragesCrossing::setCrossingInterval(unsigned int crossingInterval) {
crossingInterval_ = crossingInterval;
}
void MovingAveragesCrossing::crossingToBuySignal() {
auto lowerPeriodLineSize = smallerPeriodLine_.getSize();
auto highPeriodLineSize = biggerPeriodLine_.getSize();
auto beforeTheLastPointLowerPeriodLine = smallerPeriodLine_.getPoint(lowerPeriodLineSize - 2);
auto beforeTheLastPointHighPeriodLine = biggerPeriodLine_.getPoint(highPeriodLineSize - 2);
auto lastLowerLinePoint = smallerPeriodLine_.getLastPoint();
auto lastHighLinePoint = biggerPeriodLine_.getLastPoint();
if (beforeTheLastPointLowerPeriodLine < beforeTheLastPointHighPeriodLine &&
lastLowerLinePoint > lastHighLinePoint) {
auto isDuplicate = isBuyCrossingDuplicatedOnInterval();
if (!isDuplicate) {
lastBuyCrossingPoint_ = lastLowerLinePoint;
crossingForBuySignal_.second = true;
} else {
crossingForBuySignal_.second = false;
}
} else {
crossingForBuySignal_.second = false;
}
}
void MovingAveragesCrossing::crossingToSellSignal() {
auto lowerPeriodLineSize = smallerPeriodLine_.getSize();
auto highPeriodLineSize = biggerPeriodLine_.getSize();
auto beforeTheLastPointLowerPeriodLine = smallerPeriodLine_.getPoint(lowerPeriodLineSize - 2);
auto beforeTheLastPointHighPeriodLine = biggerPeriodLine_.getPoint(highPeriodLineSize - 2);
auto lastLowerLinePoint = smallerPeriodLine_.getLastPoint();
auto lastHighLinePoint = biggerPeriodLine_.getLastPoint();
if (beforeTheLastPointLowerPeriodLine > beforeTheLastPointHighPeriodLine &&
lastLowerLinePoint < lastHighLinePoint) {
auto isDuplicate = isSellCrossingDuplicatedOnInterval();
if (!isDuplicate) {
lastSellCrossingPoint_ = lastLowerLinePoint;
crossingForSellSignal_.second = true;
} else {
crossingForSellSignal_.second = false;
}
} else {
crossingForSellSignal_.second = false;
}
}
bool MovingAveragesCrossing::isBuyCrossingDuplicatedOnInterval() const {
auto lineSize = smallerPeriodLine_.getSize();
for (size_t index = lineSize - 1; index >= lineSize - crossingInterval_ - 1; --index) {
if (smallerPeriodLine_.getPoint(index) == lastBuyCrossingPoint_) return true;
}
return false;
}
bool MovingAveragesCrossing::isSellCrossingDuplicatedOnInterval() const {
auto lineSize = smallerPeriodLine_.getSize();
for (size_t index = lineSize - 1; index >= lineSize - crossingInterval_ - 1; --index) {
if (smallerPeriodLine_.getPoint(index) == lastSellCrossingPoint_) return true;
}
return false;
}
} // namespace strategies
} // namespace auto_trader
| 6,721
| 2,155
|
///////////////////////////////////////////////////////////////////////////////
/// \file domain.hpp
/// Contains definition of domain\<\> class template and helpers for
/// defining domains with a generator and a grammar for controlling
/// operator overloading.
//
// Copyright 2008 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PROTO_DOMAIN_HPP_EAN_02_13_2007
#define BOOST_PROTO_DOMAIN_HPP_EAN_02_13_2007
#include <boost/ref.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/proto/proto_fwd.hpp>
#include <boost/proto/generate.hpp>
#include <boost/proto/detail/as_expr.hpp>
#include <boost/proto/detail/deduce_domain.hpp>
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined
#endif
namespace boost { namespace proto
{
namespace detail
{
struct not_a_generator
{};
struct not_a_grammar
{};
struct not_a_domain
{};
}
namespace domainns_
{
/// \brief For use in defining domain tags to be used
/// with \c proto::extends\<\>. A \e Domain associates
/// an expression type with a \e Generator, and optionally
/// a \e Grammar.
///
/// The Generator determines how new expressions in the
/// domain are constructed. Typically, a generator wraps
/// all new expressions in a wrapper that imparts
/// domain-specific behaviors to expressions within its
/// domain. (See \c proto::extends\<\>.)
///
/// The Grammar determines whether a given expression is
/// valid within the domain, and automatically disables
/// any operator overloads which would cause an invalid
/// expression to be created. By default, the Grammar
/// parameter defaults to the wildcard, \c proto::_, which
/// makes all expressions valid within the domain.
///
/// The Super declares the domain currently being defined
/// to be a sub-domain of Super. Expressions in sub-domains
/// can be freely combined with expressions in its super-
/// domain (and <I>its</I> super-domain, etc.).
///
/// Example:
/// \code
/// template<typename Expr>
/// struct MyExpr;
///
/// struct MyGrammar
/// : or_< terminal<_>, plus<MyGrammar, MyGrammar> >
/// {};
///
/// // Define MyDomain, in which all expressions are
/// // wrapped in MyExpr<> and only expressions that
/// // conform to MyGrammar are allowed.
/// struct MyDomain
/// : domain<generator<MyExpr>, MyGrammar>
/// {};
///
/// // Use MyDomain to define MyExpr
/// template<typename Expr>
/// struct MyExpr
/// : extends<Expr, MyExpr<Expr>, MyDomain>
/// {
/// // ...
/// };
/// \endcode
///
template<
typename Generator // = default_generator
, typename Grammar // = proto::_
, typename Super // = no_super_domain
>
struct domain
: Generator
{
typedef Generator proto_generator;
typedef Grammar proto_grammar;
typedef Super proto_super_domain;
typedef domain proto_base_domain;
/// INTERNAL ONLY
typedef void proto_is_domain_;
/// \brief A unary MonomorphicFunctionObject that turns objects into Proto
/// expression objects in this domain.
///
/// The <tt>as_expr\<\></tt> function object turns objects into Proto expressions, if
/// they are not already, by making them Proto terminals held by value if
/// possible. Objects that are already Proto expressions are left alone.
///
/// If <tt>wants_basic_expr\<Generator\>::value</tt> is true, then let \c E be \c basic_expr;
/// otherwise, let \t E be \c expr. Given an lvalue \c t of type \c T:
///
/// If \c T is not a Proto expression type the resulting terminal is
/// calculated as follows:
///
/// If \c T is a function type, an abstract type, or a type derived from
/// \c std::ios_base, let \c A be <tt>T &</tt>.
/// Otherwise, let \c A be the type \c T stripped of cv-qualifiers.
/// Then, the result of applying <tt>as_expr\<T\>()(t)</tt> is
/// <tt>Generator()(E\<tag::terminal, term\<A\> \>::make(t))</tt>.
///
/// If \c T is a Proto expression type and its generator type is different from
/// \c Generator, the result is <tt>Generator()(t)</tt>.
///
/// Otherwise, the result is \c t converted to an (un-const) rvalue.
///
template<typename T, typename IsExpr = void, typename Callable = proto::callable>
struct as_expr
: detail::as_expr<
T
, typename detail::base_generator<Generator>::type
, wants_basic_expr<Generator>::value
>
{
BOOST_PROTO_CALLABLE()
};
/// INTERNAL ONLY
///
template<typename T>
struct as_expr<T, typename T::proto_is_expr_, proto::callable>
{
BOOST_PROTO_CALLABLE()
typedef typename remove_const<T>::type result_type;
BOOST_FORCEINLINE
result_type operator()(T &e) const
{
return e;
}
};
/// \brief A unary MonomorphicFunctionObject that turns objects into Proto
/// expression objects in this domain.
///
/// The <tt>as_child\<\></tt> function object turns objects into Proto expressions, if
/// they are not already, by making them Proto terminals held by reference.
/// Objects that are already Proto expressions are simply returned by reference.
///
/// If <tt>wants_basic_expr\<Generator\>::value</tt> is true, then let \c E be \c basic_expr;
/// otherwise, let \t E be \c expr. Given an lvalue \c t of type \c T:
///
/// If \c T is not a Proto expression type the resulting terminal is
/// <tt>Generator()(E\<tag::terminal, term\<T &\> \>::make(t))</tt>.
///
/// If \c T is a Proto expression type and its generator type is different from
/// \c Generator, the result is <tt>Generator()(t)</tt>.
///
/// Otherwise, the result is the lvalue \c t.
///
template<typename T, typename IsExpr = void, typename Callable = proto::callable>
struct as_child
: detail::as_child<
T
, typename detail::base_generator<Generator>::type
, wants_basic_expr<Generator>::value
>
{
BOOST_PROTO_CALLABLE()
};
/// INTERNAL ONLY
///
template<typename T>
struct as_child<T, typename T::proto_is_expr_, proto::callable>
{
BOOST_PROTO_CALLABLE()
typedef T &result_type;
BOOST_FORCEINLINE
result_type operator()(T &e) const
{
return e;
}
};
};
/// \brief The domain expressions have by default, if
/// \c proto::extends\<\> has not been used to associate
/// a domain with an expression.
///
struct default_domain
: domain<>
{};
/// \brief A domain to use when you prefer the use of
/// \c proto::basic_expr\<\> over \c proto::expr\<\>.
///
struct basic_default_domain
: domain<basic_default_generator>
{};
/// \brief A pseudo-domain for use in functions and
/// metafunctions that require a domain parameter. It
/// indicates that the domain of the parent node should
/// be inferred from the domains of the child nodes.
///
/// \attention \c deduce_domain is not itself a valid domain.
///
struct deduce_domain
: domain<detail::not_a_generator, detail::not_a_grammar, detail::not_a_domain>
{};
/// \brief Given a domain, a tag type and an argument list,
/// compute the type of the expression to generate. This is
/// either an instance of \c proto::expr\<\> or
/// \c proto::basic_expr\<\>.
///
template<typename Domain, typename Tag, typename Args, bool WantsBasicExpr>
struct base_expr
{
typedef proto::expr<Tag, Args, Args::arity> type;
};
/// INTERNAL ONLY
///
template<typename Domain, typename Tag, typename Args>
struct base_expr<Domain, Tag, Args, true>
{
typedef proto::basic_expr<Tag, Args, Args::arity> type;
};
}
/// A metafunction that returns \c mpl::true_
/// if the type \c T is the type of a Proto domain;
/// \c mpl::false_ otherwise. If \c T inherits from
/// \c proto::domain\<\>, \c is_domain\<T\> is
/// \c mpl::true_.
template<typename T, typename Void /* = void*/>
struct is_domain
: mpl::false_
{};
/// INTERNAL ONLY
///
template<typename T>
struct is_domain<T, typename T::proto_is_domain_>
: mpl::true_
{};
/// A metafunction that returns the domain of
/// a given type. If \c T is a Proto expression
/// type, it returns that expression's associated
/// domain. If not, it returns
/// \c proto::default_domain.
template<typename T, typename Void /* = void*/>
struct domain_of
{
typedef default_domain type;
};
/// INTERNAL ONLY
///
template<typename T>
struct domain_of<T, typename T::proto_is_expr_>
{
typedef typename T::proto_domain type;
};
/// INTERNAL ONLY
///
template<typename T>
struct domain_of<T &, void>
{
typedef typename domain_of<T>::type type;
};
/// INTERNAL ONLY
///
template<typename T>
struct domain_of<boost::reference_wrapper<T>, void>
{
typedef typename domain_of<T>::type type;
};
/// INTERNAL ONLY
///
template<typename T>
struct domain_of<boost::reference_wrapper<T> const, void>
{
typedef typename domain_of<T>::type type;
};
/// A metafunction that returns \c mpl::true_
/// if the type \c SubDomain is a sub-domain of
/// \c SuperDomain; \c mpl::false_ otherwise.
template<typename SubDomain, typename SuperDomain>
struct is_sub_domain_of
: is_sub_domain_of<typename SubDomain::proto_super_domain, SuperDomain>
{};
/// INTERNAL ONLY
///
template<typename SuperDomain>
struct is_sub_domain_of<proto::no_super_domain, SuperDomain>
: mpl::false_
{};
/// INTERNAL ONLY
///
template<typename SuperDomain>
struct is_sub_domain_of<SuperDomain, SuperDomain>
: mpl::true_
{};
}}
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif
| 11,616
| 3,226
|
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#ifndef _CIPHERCONTEXT_HXX
#define _CIPHERCONTEXT_HXX
#include <com/sun/star/xml/crypto/XCipherContext.hpp>
#include <cppuhelper/implbase1.hxx>
#include <osl/mutex.hxx>
#include <pk11pub.h>
class OCipherContext : public cppu::WeakImplHelper1< ::com::sun::star::xml::crypto::XCipherContext >
{
private:
::osl::Mutex m_aMutex;
PK11SlotInfo* m_pSlot;
PK11SymKey* m_pSymKey;
SECItem* m_pSecParam;
PK11Context* m_pContext;
sal_Int32 m_nBlockSize;
::com::sun::star::uno::Sequence< sal_Int8 > m_aLastBlock;
bool m_bEncryption;
bool m_bPadding;
bool m_bW3CPadding;
sal_Int64 m_nConverted;
bool m_bDisposed;
bool m_bBroken;
void Dispose();
OCipherContext()
: m_pSlot( NULL )
, m_pSymKey( NULL )
, m_pSecParam( NULL )
, m_pContext( NULL )
, m_nBlockSize( 0 )
, m_bEncryption( false )
, m_bPadding( false )
, m_bW3CPadding( false )
, m_nConverted( 0 )
, m_bDisposed( false )
, m_bBroken( false )
{}
public:
virtual ~OCipherContext()
{
Dispose();
}
static ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XCipherContext > Create( CK_MECHANISM_TYPE nNSSCipherID, const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aKey, const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aInitializationVector, bool bEncryption, bool bW3CPadding );
// XCipherContext
virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL convertWithCipherContext( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::DisposedException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL finalizeCipherContextAndDispose( ) throw (::com::sun::star::lang::DisposedException, ::com::sun::star::uno::RuntimeException);
};
#endif
| 2,851
| 997
|
/*
* Copyright (C) 2006-2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "AudioParameter"
//#define LOG_NDEBUG 0
#include <utils/Log.h>
#include <hardware/audio.h>
#include <media/AudioParameter.h>
namespace android {
// static
const char * const AudioParameter::keyRouting = AUDIO_PARAMETER_STREAM_ROUTING;
const char * const AudioParameter::keySamplingRate = AUDIO_PARAMETER_STREAM_SAMPLING_RATE;
const char * const AudioParameter::keyFormat = AUDIO_PARAMETER_STREAM_FORMAT;
const char * const AudioParameter::keyChannels = AUDIO_PARAMETER_STREAM_CHANNELS;
const char * const AudioParameter::keyFrameCount = AUDIO_PARAMETER_STREAM_FRAME_COUNT;
const char * const AudioParameter::keyInputSource = AUDIO_PARAMETER_STREAM_INPUT_SOURCE;
const char * const AudioParameter::keyScreenState = AUDIO_PARAMETER_KEY_SCREEN_STATE;
AudioParameter::AudioParameter(const String8& keyValuePairs)
{
char *str = new char[keyValuePairs.length()+1];
mKeyValuePairs = keyValuePairs;
char *last;
strcpy(str, keyValuePairs.string());
char *pair = strtok_r(str, ";", &last);
while (pair != NULL) {
if (strlen(pair) != 0) {
size_t eqIdx = strcspn(pair, "=");
String8 key = String8(pair, eqIdx);
String8 value;
if (eqIdx == strlen(pair)) {
value = String8("");
} else {
value = String8(pair + eqIdx + 1);
}
if (mParameters.indexOfKey(key) < 0) {
mParameters.add(key, value);
} else {
mParameters.replaceValueFor(key, value);
}
} else {
ALOGV("AudioParameter() cstor empty key value pair");
}
pair = strtok_r(NULL, ";", &last);
}
delete[] str;
}
AudioParameter::~AudioParameter()
{
mParameters.clear();
}
String8 AudioParameter::toString()
{
String8 str = String8("");
size_t size = mParameters.size();
for (size_t i = 0; i < size; i++) {
str += mParameters.keyAt(i);
str += "=";
str += mParameters.valueAt(i);
if (i < (size - 1)) str += ";";
}
return str;
}
status_t AudioParameter::add(const String8& key, const String8& value)
{
if (mParameters.indexOfKey(key) < 0) {
mParameters.add(key, value);
return NO_ERROR;
} else {
mParameters.replaceValueFor(key, value);
return ALREADY_EXISTS;
}
}
status_t AudioParameter::addInt(const String8& key, const int value)
{
char str[12];
if (snprintf(str, 12, "%d", value) > 0) {
String8 str8 = String8(str);
return add(key, str8);
} else {
return BAD_VALUE;
}
}
status_t AudioParameter::addFloat(const String8& key, const float value)
{
char str[23];
if (snprintf(str, 23, "%.10f", value) > 0) {
String8 str8 = String8(str);
return add(key, str8);
} else {
return BAD_VALUE;
}
}
status_t AudioParameter::remove(const String8& key)
{
if (mParameters.indexOfKey(key) >= 0) {
mParameters.removeItem(key);
return NO_ERROR;
} else {
return BAD_VALUE;
}
}
status_t AudioParameter::get(const String8& key, String8& value)
{
if (mParameters.indexOfKey(key) >= 0) {
value = mParameters.valueFor(key);
return NO_ERROR;
} else {
return BAD_VALUE;
}
}
status_t AudioParameter::getInt(const String8& key, int& value)
{
String8 str8;
status_t result = get(key, str8);
value = 0;
if (result == NO_ERROR) {
int val;
if (sscanf(str8.string(), "%d", &val) == 1) {
value = val;
} else {
result = INVALID_OPERATION;
}
}
return result;
}
status_t AudioParameter::getFloat(const String8& key, float& value)
{
String8 str8;
status_t result = get(key, str8);
value = 0;
if (result == NO_ERROR) {
float val;
if (sscanf(str8.string(), "%f", &val) == 1) {
value = val;
} else {
result = INVALID_OPERATION;
}
}
return result;
}
status_t AudioParameter::getAt(size_t index, String8& key, String8& value)
{
if (mParameters.size() > index) {
key = mParameters.keyAt(index);
value = mParameters.valueAt(index);
return NO_ERROR;
} else {
return BAD_VALUE;
}
}
}; // namespace android
| 4,961
| 1,667
|
/*
* Copyright 2015, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bcc/Renderscript/RSTransforms.h"
#include "bcc/Support/Log.h"
#include <cstdlib>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Metadata.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Function.h>
#include <llvm/Pass.h>
namespace { // anonymous namespace
// Create a Module pass that screens all the global functions in the module and
// check if any non-threadable function is callable. If so, we mark the
// Module as non-threadable by adding a metadata flag '#rs_is_threadable'
class RSIsThreadablePass : public llvm::ModulePass {
private:
static char ID;
std::vector<std::string> nonThreadableFns = {
"_Z22rsgBindProgramFragment19rs_program_fragment",
"_Z19rsgBindProgramStore16rs_program_store",
"_Z20rsgBindProgramVertex17rs_program_vertex",
"_Z20rsgBindProgramRaster17rs_program_raster",
"_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler",
"_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation",
"_Z15rsgBindConstant19rs_program_fragmentj13rs_allocation",
"_Z15rsgBindConstant17rs_program_vertexj13rs_allocation",
"_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4",
"_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4",
"_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4",
"_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4",
"_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff",
"_Z11rsgGetWidthv",
"_Z12rsgGetHeightv",
"_Z11rsgDrawRectfffff",
"_Z11rsgDrawQuadffffffffffff",
"_Z20rsgDrawQuadTexCoordsffffffffffffffffffff",
"_Z24rsgDrawSpriteScreenspacefffff",
"_Z11rsgDrawMesh7rs_mesh",
"_Z11rsgDrawMesh7rs_meshj",
"_Z11rsgDrawMesh7rs_meshjjj",
"_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_",
"_Z11rsgDrawPath7rs_path",
"_Z13rsgClearColorffff",
"_Z13rsgClearDepthf",
"_Z11rsgDrawTextPKcii",
"_Z11rsgDrawText13rs_allocationii",
"_Z14rsgMeasureTextPKcPiS1_S1_S1_",
"_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_",
"_Z11rsgBindFont7rs_font",
"_Z12rsgFontColorffff",
"_Z18rsgBindColorTarget13rs_allocationj",
"_Z18rsgBindDepthTarget13rs_allocation",
"_Z19rsgClearColorTargetj",
"_Z19rsgClearDepthTargetv",
"_Z24rsgClearAllRenderTargetsv",
"_Z7rsGetDtv",
"_Z5colorffff",
"_Z9rsgFinishv",
};
bool isPresent(std::vector<std::string> &list, std::string name) {
auto lower = std::lower_bound(list.begin(),
list.end(),
name);
if (lower != list.end() && name.compare(*lower) == 0)
return true;
return false;
}
public:
RSIsThreadablePass()
: ModulePass (ID) {
std::sort(nonThreadableFns.begin(), nonThreadableFns.end());
}
virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const override {
AU.setPreservesAll();
}
bool runOnModule(llvm::Module &M) override {
bool threadable = true;
auto &FunctionList(M.getFunctionList());
for (auto &F: FunctionList) {
if (isPresent(nonThreadableFns, F.getName().str())) {
threadable = false;
break;
}
}
llvm::LLVMContext &context = M.getContext();
llvm::MDString *val =
llvm::MDString::get(context, (threadable) ? "yes" : "no");
llvm::NamedMDNode *node =
M.getOrInsertNamedMetadata("#rs_is_threadable");
node->addOperand(llvm::MDNode::get(context, val));
return false;
}
};
}
char RSIsThreadablePass::ID = 0;
namespace bcc {
llvm::ModulePass *
createRSIsThreadablePass () {
return new RSIsThreadablePass();
}
}
| 4,208
| 1,526
|
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
#include <time.h>
#pragma once
#include "../Blocks/Block.hpp"
#include "../Map/Map.hpp"
class Engine {
public:
Engine();
void move();
void rotation();
void tick(Block block[]);
void check_lines();
void check_gameover();
void run_timer();
void set_default();
void check_events(sf::Event &event);
void render(sf::RenderWindow &window,sf::Text game_over[]);
private:
const int figures[7][4] =
{
{1,3,5,7}, // I
{2,4,5,7}, // Z
{3,5,4,6}, // S
{3,5,4,7}, // T
{2,3,5,7}, // L
{3,5,7,6}, // J
{2,3,4,5} // O
};
float time;
int delay;
bool game;
int direction;
int score;
bool rotate;
bool first;
bool play_once;
sf::Music music;
sf::SoundBuffer buffer;
sf::SoundBuffer game_over_buffer;
sf::Sound dissmiss;
sf::Sound gameover;
sf::RectangleShape s;
sf::Clock timer;
Block a[4],b[4];
Map Map;
bool check();
friend class UI;
};
| 1,318
| 410
|
/*************************************************************************/
/* box_container.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "box_container.h"
#include "label.h"
#include "margin_container.h"
struct _MinSizeCache {
int min_size;
bool will_stretch;
int final_size;
};
void BoxContainer::_resort() {
/** First pass, determine minimum size AND amount of stretchable elements */
Size2i new_size = get_size();
int sep = get_theme_constant("separation"); //,vertical?"VBoxContainer":"HBoxContainer");
bool first = true;
int children_count = 0;
int stretch_min = 0;
int stretch_avail = 0;
float stretch_ratio_total = 0;
Map<Control *, _MinSizeCache> min_size_cache;
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
if (!c || !c->is_visible_in_tree()) {
continue;
}
if (c->is_set_as_top_level()) {
continue;
}
Size2i size = c->get_combined_minimum_size();
_MinSizeCache msc;
if (vertical) { /* VERTICAL */
stretch_min += size.height;
msc.min_size = size.height;
msc.will_stretch = c->get_v_size_flags() & SIZE_EXPAND;
} else { /* HORIZONTAL */
stretch_min += size.width;
msc.min_size = size.width;
msc.will_stretch = c->get_h_size_flags() & SIZE_EXPAND;
}
if (msc.will_stretch) {
stretch_avail += msc.min_size;
stretch_ratio_total += c->get_stretch_ratio();
}
msc.final_size = msc.min_size;
min_size_cache[c] = msc;
children_count++;
}
if (children_count == 0) {
return;
}
int stretch_max = (vertical ? new_size.height : new_size.width) - (children_count - 1) * sep;
int stretch_diff = stretch_max - stretch_min;
if (stretch_diff < 0) {
//avoid negative stretch space
stretch_diff = 0;
}
stretch_avail += stretch_diff; //available stretch space.
/** Second, pass successively to discard elements that can't be stretched, this will run while stretchable
elements exist */
bool has_stretched = false;
while (stretch_ratio_total > 0) { // first of all, don't even be here if no stretchable objects exist
has_stretched = true;
bool refit_successful = true; //assume refit-test will go well
float error = 0; // Keep track of accumulated error in pixels
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
if (!c || !c->is_visible_in_tree()) {
continue;
}
if (c->is_set_as_top_level()) {
continue;
}
ERR_FAIL_COND(!min_size_cache.has(c));
_MinSizeCache &msc = min_size_cache[c];
if (msc.will_stretch) { //wants to stretch
//let's see if it can really stretch
float final_pixel_size = stretch_avail * c->get_stretch_ratio() / stretch_ratio_total;
// Add leftover fractional pixels to error accumulator
error += final_pixel_size - (int)final_pixel_size;
if (final_pixel_size < msc.min_size) {
//if available stretching area is too small for widget,
//then remove it from stretching area
msc.will_stretch = false;
stretch_ratio_total -= c->get_stretch_ratio();
refit_successful = false;
stretch_avail -= msc.min_size;
msc.final_size = msc.min_size;
break;
} else {
msc.final_size = final_pixel_size;
// Dump accumulated error if one pixel or more
if (error >= 1) {
msc.final_size += 1;
error -= 1;
}
}
}
}
if (refit_successful) { //uf refit went well, break
break;
}
}
/** Final pass, draw and stretch elements **/
int ofs = 0;
if (!has_stretched) {
switch (align) {
case ALIGN_BEGIN:
break;
case ALIGN_CENTER:
ofs = stretch_diff / 2;
break;
case ALIGN_END:
ofs = stretch_diff;
break;
}
}
first = true;
int idx = 0;
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
if (!c || !c->is_visible_in_tree()) {
continue;
}
if (c->is_set_as_top_level()) {
continue;
}
_MinSizeCache &msc = min_size_cache[c];
if (first) {
first = false;
} else {
ofs += sep;
}
int from = ofs;
int to = ofs + msc.final_size;
if (msc.will_stretch && idx == children_count - 1) {
//adjust so the last one always fits perfect
//compensating for numerical imprecision
to = vertical ? new_size.height : new_size.width;
}
int size = to - from;
Rect2 rect;
if (vertical) {
rect = Rect2(0, from, new_size.width, size);
} else {
rect = Rect2(from, 0, size, new_size.height);
}
fit_child_in_rect(c, rect);
ofs = to;
idx++;
}
}
Size2 BoxContainer::get_minimum_size() const {
/* Calculate MINIMUM SIZE */
Size2i minimum;
int sep = get_theme_constant("separation"); //,vertical?"VBoxContainer":"HBoxContainer");
bool first = true;
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
if (!c) {
continue;
}
if (c->is_set_as_top_level()) {
continue;
}
if (!c->is_visible()) {
continue;
}
Size2i size = c->get_combined_minimum_size();
if (vertical) { /* VERTICAL */
if (size.width > minimum.width) {
minimum.width = size.width;
}
minimum.height += size.height + (first ? 0 : sep);
} else { /* HORIZONTAL */
if (size.height > minimum.height) {
minimum.height = size.height;
}
minimum.width += size.width + (first ? 0 : sep);
}
first = false;
}
return minimum;
}
void BoxContainer::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_SORT_CHILDREN: {
_resort();
} break;
case NOTIFICATION_THEME_CHANGED: {
minimum_size_changed();
} break;
}
}
void BoxContainer::set_alignment(AlignMode p_align) {
align = p_align;
_resort();
}
BoxContainer::AlignMode BoxContainer::get_alignment() const {
return align;
}
void BoxContainer::add_spacer(bool p_begin) {
Control *c = memnew(Control);
c->set_mouse_filter(MOUSE_FILTER_PASS); //allow spacer to pass mouse events
if (vertical) {
c->set_v_size_flags(SIZE_EXPAND_FILL);
} else {
c->set_h_size_flags(SIZE_EXPAND_FILL);
}
add_child(c);
if (p_begin) {
move_child(c, 0);
}
}
BoxContainer::BoxContainer(bool p_vertical) {
vertical = p_vertical;
align = ALIGN_BEGIN;
}
void BoxContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_spacer", "begin"), &BoxContainer::add_spacer);
ClassDB::bind_method(D_METHOD("get_alignment"), &BoxContainer::get_alignment);
ClassDB::bind_method(D_METHOD("set_alignment", "alignment"), &BoxContainer::set_alignment);
BIND_ENUM_CONSTANT(ALIGN_BEGIN);
BIND_ENUM_CONSTANT(ALIGN_CENTER);
BIND_ENUM_CONSTANT(ALIGN_END);
ADD_PROPERTY(PropertyInfo(Variant::INT, "alignment", PROPERTY_HINT_ENUM, "Begin,Center,End"), "set_alignment", "get_alignment");
}
MarginContainer *VBoxContainer::add_margin_child(const String &p_label, Control *p_control, bool p_expand) {
Label *l = memnew(Label);
l->set_text(p_label);
add_child(l);
MarginContainer *mc = memnew(MarginContainer);
mc->add_theme_constant_override("margin_left", 0);
mc->add_child(p_control);
add_child(mc);
if (p_expand) {
mc->set_v_size_flags(SIZE_EXPAND_FILL);
}
return mc;
}
| 9,170
| 3,547
|
// Fill out your copyright notice in the Description page of Project Settings.
#include "Empty_AMC_Character.h"
#include "AMC_MovementComponent.h"
// Sets default values
AEmpty_AMC_Character::AEmpty_AMC_Character(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<UAMC_MovementComponent>(ACharacter::CharacterMovementComponentName))
{
PrimaryActorTick.bCanEverTick = true;
}
void AEmpty_AMC_Character::StartSprinting()
{
UAMC_MovementComponent* MovCom = Cast<UAMC_MovementComponent>(GetCharacterMovement());
if (MovCom)
{
MovCom->SetSprinting(true);
}
}
void AEmpty_AMC_Character::StopSprinting()
{
UAMC_MovementComponent* MovCom = Cast<UAMC_MovementComponent>(GetCharacterMovement());
if (MovCom)
{
MovCom->SetSprinting(false);
}
}
void AEmpty_AMC_Character::StartJetpacking()
{
UAMC_MovementComponent* MovCom = Cast<UAMC_MovementComponent>(GetCharacterMovement());
if (MovCom)
{
MovCom->SetJetpacking(true);
}
}
void AEmpty_AMC_Character::StopJetpacking()
{
UAMC_MovementComponent* MovCom = Cast<UAMC_MovementComponent>(GetCharacterMovement());
if (MovCom)
{
MovCom->SetJetpacking(false);
}
}
// Called when the game starts or when spawned
void AEmpty_AMC_Character::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AEmpty_AMC_Character::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AEmpty_AMC_Character::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
| 1,585
| 586
|
// Copyright (C) 2018 ETH Zurich
// Copyright (C) 2018 UT-Battelle, LLC
// All rights reserved.
// See LICENSE.txt for terms of usage./
// See CITATION.md for citation guidelines, if DCA++ is used for scientific publications.
//
// Authors: Giovanni Balduzzi (gbalduzz@itp.phys.ethz.ch)
//
// This class represent all possible interaction terms of the hamiltonian, and provide
// functionalities to randomly sample from them and pair non density-density terms together.
#ifndef DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_CTINT_STRUCTS_INTERACTION_VERTICES_HPP
#define DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_CTINT_STRUCTS_INTERACTION_VERTICES_HPP
#include <algorithm>
#include <cmath>
#include <stdexcept>
#include <vector>
#include "dca/function/function.hpp"
namespace dca {
namespace phys {
namespace solver {
namespace ctint {
// dca::phys::solver::ctint::
// Represent a matrix element W(i,j,k,l) of the interaction hamiltonian.
// Each index represent a cluster position and a spin-band index.
struct InteractionElement {
std::array<ushort, 4> r;
std::array<ushort, 4> nu;
double w;
// TODO: write proper constructor.
std::vector<ushort> partners_id = std::vector<ushort>();
// Returns true if r and nu members are equal.
bool operator==(const InteractionElement& other) const;
};
// Store the interaction terms and allow drawing a random vertex with strength |w|.
class InteractionVertices {
public:
// Initialize vertices with a density-density Hamiltonian.
// Precondition: Domain has the shape of dmn_variadic<Nu, Nu, Rdmn>
template <class Nu, class Rdmn>
void initializeFromHamiltonian(const func::function<double, func::dmn_variadic<Nu, Nu, Rdmn>>& H_int);
template <class Nu, class Rdmn>
void initializeFromNonDensityHamiltonian(
const func::function<double, func::dmn_variadic<Nu, Nu, Nu, Nu, Rdmn>>& H_int);
void insertElement(InteractionElement v);
void insertElement(const std::vector<double>& vec);
template <class Nu, class Rdmn, class TDmn>
void checkForInterbandPropagators(
const func::function<double, func::dmn_variadic<Nu, Nu, Rdmn, TDmn>>& G_r_t);
void reset();
// In: random number generator object.
// Returns: first: random vertex sampled with probability proportional to |vertex.w|.
// second: first vertex partner's id if it exists, -1 otherwise.
template <class Rng>
std::pair<short, short> getInsertionIndices(Rng& rng, double double_update_prob) const;
// Returns: the sum of the absolute values of the interaction strengths.
double integratedInteraction() const {
return total_weigth_;
}
std::size_t size() const {
return elements_.size();
}
const InteractionElement& operator[](const int idx) const {
assert(idx < int(size()));
return elements_[idx];
}
// Returns the number of possible partners for each non density-density interaction.
int possiblePartners() const {
const int partners = elements_.back().partners_id.size();
// TODO: generalize if number of possible pairings is not constant or at the back.
return partners;
}
std::vector<InteractionElement> elements_;
private:
std::vector<double> cumulative_weigths_;
double total_weigth_ = 0;
bool interband_propagator_ = false;
};
template <class Rng>
std::pair<short, short> InteractionVertices::getInsertionIndices(Rng& rng,
double double_update_prob) const {
const double random = rng() * total_weigth_;
// search in reverse order.
const auto it_to_vertex =
std::upper_bound(cumulative_weigths_.rbegin(), cumulative_weigths_.rend(), random);
const int index = cumulative_weigths_.rend() - it_to_vertex - 1;
assert(index >= 0 && index < size());
assert(double_update_prob >= 0 && double_update_prob <= 1);
auto do_double = [&]() -> bool {
if (double_update_prob == 0)
return 0;
else if (double_update_prob == 1)
return 1;
else
return rng() < double_update_prob;
};
if (elements_[index].partners_id.size() && do_double()) { // double insertion
const auto& partners = elements_[index].partners_id;
auto partner_id = partners[rng() * partners.size()];
return std::make_pair(index, partner_id);
}
else {
return std::make_pair(index, -1);
}
}
template <class Nu, class Rdmn>
void InteractionVertices::initializeFromHamiltonian(
const func::function<double, func::dmn_variadic<Nu, Nu, Rdmn>>& H_int) {
// Note: Use this version of the code if double counting in the interaction hamiltonian is removed.
//
// for (ushort nu1 = 0; nu1 < Nu::dmn_size(); nu1++) {
// for (ushort nu2 = 0; nu2 < Nu::dmn_size(); nu2++)
// for (ushort delta_r = 0; delta_r < Rdmn::dmn_size(); delta_r++) {
// const double value = H_int(nu1, nu2, delta_r);
// if (std::abs(value) < 1e-8)
// continue;
// for (ushort r1 = 0; r1 < Rdmn::dmn_size(); r1++) {
// const ushort r2 = Rdmn::parameter_type::subtract(delta_r, r1); // delta_r = r1 - r2
// insertElement(InteractionElement{{r1, r1, r2, r2}, {nu1, nu1, nu2, nu2}, value, short(-1)});
// }
// }
// }
// Assume the density-density interaction Hamiltonian function is double counted, i.e.
// H(b1, b2, r1 - r2) == H(b2, b1, r -r2) and both terms describe the same addendum to the
// physical Hamiltonian.
func::function<bool, func::dmn_variadic<Nu, Nu, Rdmn>> already_inserted;
const int r0 = Rdmn::parameter_type::origin_index();
for (ushort nu1 = 0; nu1 < Nu::dmn_size(); nu1++) {
for (ushort nu2 = 0; nu2 < Nu::dmn_size(); nu2++)
for (ushort delta_r = 0; delta_r < Rdmn::dmn_size(); delta_r++) {
const double value = H_int(nu1, nu2, delta_r);
if (std::abs(value) < 1e-8)
continue;
const double minus_delta_r = Rdmn::parameter_type::subtract(delta_r, r0);
if (std::abs(H_int(nu1, nu2, delta_r) - H_int(nu2, nu1, minus_delta_r)) > 1e-8)
throw(std::logic_error("The interaction double counting is not consistent."));
if (already_inserted(nu2, nu1, minus_delta_r)) // Avoid double counting.
continue;
// Insert
already_inserted(nu1, nu2, delta_r) = true;
for (ushort r1 = 0; r1 < Rdmn::dmn_size(); r1++) {
const ushort r2 = Rdmn::parameter_type::subtract(delta_r, r1); // delta_r = r1 - r2
insertElement(InteractionElement{{r1, r1, r2, r2}, {nu1, nu1, nu2, nu2}, value});
}
}
}
}
template <class Nu, class Rdmn>
void InteractionVertices::initializeFromNonDensityHamiltonian(
const func::function<double, func::dmn_variadic<Nu, Nu, Nu, Nu, Rdmn>>& H_int) {
auto spin = [](ushort nu) { return nu >= Nu::dmn_size() / 2; };
auto check_spins = [&](ushort nu1, ushort nu2, ushort nu3, ushort nu4) -> bool {
return spin(nu1) == spin(nu2) && spin(nu3) == spin(nu4);
};
for (ushort nu1 = 0; nu1 < Nu::dmn_size(); nu1++)
for (ushort nu2 = 0; nu2 < Nu::dmn_size(); nu2++)
for (ushort nu3 = 0; nu3 < Nu::dmn_size(); nu3++)
for (ushort nu4 = 0; nu4 < Nu::dmn_size(); nu4++)
for (ushort delta_r = 0; delta_r < Rdmn::dmn_size(); delta_r++) {
const double value = H_int(nu1, nu2, nu3, nu4, delta_r);
if (std::abs(value) < 1e-8)
continue;
if (not check_spins(nu1, nu2, nu3, nu4))
throw(std::logic_error(
"Format input hamiltonian s.t. pair of creation and annihilation "
"operators have same spin."));
for (ushort r1 = 0; r1 < Rdmn::dmn_size(); r1++) {
const ushort r2 = Rdmn::parameter_type::subtract(delta_r, r1);
insertElement(InteractionElement{{r1, r1, r2, r2}, {nu1, nu2, nu3, nu4}, value});
}
}
}
template <class Nu, class RDmn, class TDmn>
void InteractionVertices::checkForInterbandPropagators(
const func::function<double, func::dmn_variadic<Nu, Nu, RDmn, TDmn>>& G_r_t) {
interband_propagator_ = false;
const int t0 = TDmn::dmn_size() / 2;
const int nb = Nu::dmn_size() / 2;
const int r0 = RDmn::parameter_type::origin_index();
for (int r = 0; r < RDmn::dmn_size(); ++r)
for (int b1 = 0; b1 < nb; ++b1)
for (int b2 = 0; b2 < nb; ++b2) {
if (r != r0 && b1 != b2 && std::abs(G_r_t(b1, 0, b2, 0, r, t0)) > 1e-8) {
interband_propagator_ = true;
return;
}
}
}
} // namespace ctint
} // namespace solver
} // namespace phys
} // namespace dca
#endif // DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_CTINT_STRUCTS_INTERACTION_VERTICES_HPP
| 8,635
| 3,104
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Responsible for drawing the scene
//
//===========================================================================//
#include "cbase.h"
#include "materialsystem/imaterialsystem.h"
#include "materialsystem/imaterialvar.h"
#include "materialsystem/imaterialsystemhardwareconfig.h"
#include "rendertexture.h"
#include "view_scene.h"
#include "viewrender.h"
#include "headtrack/isourcevirtualreality.h"
#include "client_virtualreality.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
//-----------------------------------------------------------------------------
// Convars related to controlling rendering
//-----------------------------------------------------------------------------
ConVar r_updaterefracttexture( "r_updaterefracttexture", "1", FCVAR_CHEAT );
ConVar r_depthoverlay( "r_depthoverlay", "0", FCVAR_CHEAT, "Replaces opaque objects with their grayscaled depth values. r_showz_power scales the output." );
int g_viewscene_refractUpdateFrame = 0;
bool g_bAllowMultipleRefractUpdatesPerScenePerFrame = false;
#if defined( _X360 )
class CAllowMultipleRefractsLogic : public CAutoGameSystem
{
public:
void LevelInitPreEntity()
{
// EP1 core room needs many refract updates per frame to avoid looking broken (ep1_citadel_03)
// Same with Kleiner's lab (d1_trainstation_05)
g_bAllowMultipleRefractUpdatesPerScenePerFrame = FStrEq( MapName(), "ep1_citadel_03" ) || FStrEq( MapName(), "d1_trainstation_05" );
}
};
static CAllowMultipleRefractsLogic s_AllowMultipleRefractsLogic;
#endif
void ViewTransform( const Vector &worldSpace, Vector &viewSpace )
{
const VMatrix &viewMatrix = engine->WorldToViewMatrix();
Vector3DMultiplyPosition( viewMatrix, worldSpace, viewSpace );
}
//-----------------------------------------------------------------------------
// Purpose: Transforms a world-space position into a 2D position inside a supplied frustum.
//-----------------------------------------------------------------------------
int FrustumTransform( const VMatrix &worldToSurface, const Vector& point, Vector& screen )
{
// UNDONE: Clean this up some, handle off-screen vertices
float w;
screen.x = worldToSurface[0][0] * point[0] + worldToSurface[0][1] * point[1] + worldToSurface[0][2] * point[2] + worldToSurface[0][3];
screen.y = worldToSurface[1][0] * point[0] + worldToSurface[1][1] * point[1] + worldToSurface[1][2] * point[2] + worldToSurface[1][3];
// z = worldToSurface[2][0] * point[0] + worldToSurface[2][1] * point[1] + worldToSurface[2][2] * point[2] + worldToSurface[2][3];
w = worldToSurface[3][0] * point[0] + worldToSurface[3][1] * point[1] + worldToSurface[3][2] * point[2] + worldToSurface[3][3];
// Just so we have something valid here
screen.z = 0.0f;
bool behind;
if( w < 0.001f )
{
behind = true;
screen.x *= 100000;
screen.y *= 100000;
}
else
{
behind = false;
float invw = 1.0f / w;
screen.x *= invw;
screen.y *= invw;
}
return behind;
}
//-----------------------------------------------------------------------------
// Purpose: UNDONE: Clean this up some, handle off-screen vertices
// Input : *point -
// *screen -
// Output : int
//-----------------------------------------------------------------------------
int ScreenTransform( const Vector& point, Vector& screen )
{
// UNDONE: Clean this up some, handle off-screen vertices
return FrustumTransform ( engine->WorldToScreenMatrix(), point, screen );
}
//-----------------------------------------------------------------------------
// Purpose: Same as ScreenTransform, but transforms to HUD space.
// These are totally different things in VR mode!
//-----------------------------------------------------------------------------
int HudTransform( const Vector& point, Vector& screen )
{
if ( UseVR() )
{
return FrustumTransform ( g_ClientVirtualReality.GetHudProjectionFromWorld(), point, screen );
}
else
{
return FrustumTransform ( engine->WorldToScreenMatrix(), point, screen );
}
}
void UpdateFullScreenDepthTexture( void )
{
if( !g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_b() )
return;
ITexture *pDepthTex = GetFullFrameDepthTexture();
CMatRenderContextPtr pRenderContext( materials );
if( IsX360() )
{
pRenderContext->CopyRenderTargetToTextureEx( pDepthTex, -1, NULL, NULL );
}
else
{
pRenderContext->CopyRenderTargetToTextureEx( pDepthTex, 0, NULL, NULL );
}
pRenderContext->SetFullScreenDepthTextureValidityFlag( true );
if( r_depthoverlay.GetBool() )
{
IMaterial *pMaterial = materials->FindMaterial( "debug/showz", TEXTURE_GROUP_OTHER, true );
pMaterial->IncrementReferenceCount();
IMaterialVar *BaseTextureVar = pMaterial->FindVar( "$basetexture", NULL, false );
IMaterialVar *pDepthInAlpha = NULL;
if( IsPC() )
{
pDepthInAlpha = pMaterial->FindVar( "$ALPHADEPTH", NULL, false );
pDepthInAlpha->SetIntValue( 1 );
}
BaseTextureVar->SetTextureValue( pDepthTex );
pRenderContext->OverrideDepthEnable( true, false ); //don't write to depth, or else we'll never see translucents
pRenderContext->DrawScreenSpaceQuad( pMaterial );
pRenderContext->OverrideDepthEnable( false, true );
pMaterial->DecrementReferenceCount();
}
}
| 5,460
| 1,849
|
//SWEngine
#include "../../include/SWEngine.h"
#pragma comment (lib,"../../lib/SWUtil.lib")
#pragma comment (lib,"../../lib/SWTypes.lib")
#pragma comment (lib,"../../lib/SWCore.lib")
#pragma comment (lib,"../../lib/SWEngine.lib")
swApplication pointSpriteApp;
int pointSpriteID=-1;
swPoint pointS[3];
swColor colorS[3];
//-------------------------------------------------------------------------------------------
void GameLoop(){
swGraphicsBeginScene();
swGraphicsSetBlendingMode(SW_BLENDING_MODE_ADDITIVE_ACCORDING2_ALPHA);
swGraphicsRenderPointSprite0(pointSpriteID,60,3,colorS,pointS);
swGraphicsEndScene();
}
//-------------------------------------------------------------------------------------------
void GameInit(){
pointSpriteID=swGraphicsCreatePointSprite("particleX.tga");
pointS[0].x=100; pointS[0].y=100;
colorS[0].r=0.2; colorS[0].g=0.8; colorS[0].b=0.8; colorS[0].a=0.5;
pointS[1].x=300; pointS[1].y=300;
colorS[1].r=0.8; colorS[1].g=0.8; colorS[1].b=0.8; colorS[1].a=1;
pointS[2].x=500; pointS[2].y=500;
colorS[2].r=1.0; colorS[2].g=0.1; colorS[2].b=0.1; colorS[2].a=1;
}
//-------------------------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
//Application Settings
pointSpriteApp.hInstance=hInstance;
pointSpriteApp.fullScreen=false;
pointSpriteApp.cursor=true;
pointSpriteApp.width=800;
pointSpriteApp.height=600;
pointSpriteApp.title="Point Sprite";
pointSpriteApp.path="\\rsc\\PointSprites\\";
pointSpriteApp.appRun=GameLoop;
//Application Execution
swEngineInit(&pointSpriteApp);
GameInit();
swEngineRun();
swEngineExit();
return 0;
}
| 1,745
| 684
|
#include<float.h>
#include<math.h>
#include<stdbool.h>
#include<stddef.h>
#include<stdint.h>
#include<stdio.h>
#include<string.h>
#include "ap_int.h"
#include "tlp.h"
#define BURST_WIDTH 512
#define UNROLL_FACTOR 64
#define TILE_SIZE_DIM_0 8000
#ifndef BURST_WIDTH
#define BURST_WIDTH 512
#endif//BURST_WIDTH
#if UNROLL_FACTOR != 64
#error UNROLL_FACTOR != 64
#endif//UNROLL_FACTOR != 64
#if TILE_SIZE_DIM_0 != 8000
#error TILE_SIZE_DIM_0 != 8000
#endif//TILE_SIZE_DIM_0 != 8000
#if BURST_WIDTH != 512
#error BURST_WIDTH != 512
#endif//BURST_WIDTH != 512
void compute(
tlp::ostream<ap_uint<BURST_WIDTH> >& to_chan_0_bank_0,
tlp::ostream<ap_uint<BURST_WIDTH> >& to_chan_0_bank_1,
tlp::ostream<ap_uint<BURST_WIDTH> >& to_chan_0_bank_2,
tlp::ostream<ap_uint<BURST_WIDTH> >& to_chan_0_bank_3,
tlp::istream<ap_uint<BURST_WIDTH> >& from_chan_0_bank_0,
tlp::istream<ap_uint<BURST_WIDTH> >& from_chan_0_bank_1,
tlp::istream<ap_uint<BURST_WIDTH> >& from_chan_0_bank_2,
tlp::istream<ap_uint<BURST_WIDTH> >& from_chan_0_bank_3,
int64_t coalesced_data_num,
int64_t tile_data_num,
int32_t tile_num_dim_0,
int32_t input_size_dim_0,
int32_t input_size_dim_1)
{
#pragma HLS data_pack variable = to_chan_0_bank_0.fifo
#pragma HLS data_pack variable = to_chan_0_bank_1.fifo
#pragma HLS data_pack variable = to_chan_0_bank_2.fifo
#pragma HLS data_pack variable = to_chan_0_bank_3.fifo
#pragma HLS data_pack variable = from_chan_0_bank_0.fifo
#pragma HLS data_pack variable = from_chan_0_bank_0.peek_val
#pragma HLS data_pack variable = from_chan_0_bank_1.fifo
#pragma HLS data_pack variable = from_chan_0_bank_1.peek_val
#pragma HLS data_pack variable = from_chan_0_bank_2.fifo
#pragma HLS data_pack variable = from_chan_0_bank_2.peek_val
#pragma HLS data_pack variable = from_chan_0_bank_3.fifo
#pragma HLS data_pack variable = from_chan_0_bank_3.peek_val
int32_t tile_index_dim_0 = 0;
// reuse chains for t1
float FF_t1_chan_0[2];
float FIFO_125_t1_chan_0[126][125];
float FIFO_124_t1_chan_0[2][124];
#pragma HLS array_partition variable=FF_t1_chan_0 complete
#pragma HLS resource variable=FF_t1_chan_0 latency=1
#pragma HLS array_partition variable=FIFO_125_t1_chan_0 complete dim=1
#pragma HLS array_partition variable=FIFO_124_t1_chan_0 complete dim=1
uint8_t FIFO_125_t1_ptr = 0;
uint8_t FIFO_124_t1_ptr = 0;
// points aliases for t1
float points_from_t1_to_t0_chan_0[UNROLL_FACTOR][5];
// points_from_t1_to_t0_chan_x[UNROLL_FACTOR][0] <=> t1[x](1, 0)
// points_from_t1_to_t0_chan_x[UNROLL_FACTOR][1] <=> t1[x](0, 1)
// points_from_t1_to_t0_chan_x[UNROLL_FACTOR][2] <=> t1[x](1, 1)
// points_from_t1_to_t0_chan_x[UNROLL_FACTOR][3] <=> t1[x](2, 1)
// points_from_t1_to_t0_chan_x[UNROLL_FACTOR][4] <=> t1[x](1, 2)
#pragma HLS array_partition variable=points_from_t1_to_t0_chan_0 complete dim=0
// input buffer
float buffer_t1_chan_0[UNROLL_FACTOR];
#pragma HLS array_partition variable=buffer_t1_chan_0 complete dim=0
#pragma HLS resource variable=buffer_t1_chan_0 latency=1
// intermediate buffer for t1
// output buffer
float buffer_t0_chan_0[UNROLL_FACTOR];
#pragma HLS array_partition variable=buffer_t0_chan_0 complete dim=0
#pragma HLS resource variable=buffer_t0_chan_0 latency=1
// produce output
compute_epoch:
for(int32_t epoch = 0; epoch < coalesced_data_num*1; ++epoch)
{
#pragma HLS dependence variable=FF_t1_chan_0 inter false
#pragma HLS dependence variable=FIFO_125_t1_chan_0 inter false
#pragma HLS dependence variable=FIFO_124_t1_chan_0 inter false
#pragma HLS pipeline II=1
{
ap_uint<BURST_WIDTH> tmp_chan_0_bank_0, tmp_chan_0_bank_1, tmp_chan_0_bank_2, tmp_chan_0_bank_3;
tmp_chan_0_bank_0 = from_chan_0_bank_0.read();
tmp_chan_0_bank_1 = from_chan_0_bank_1.read();
tmp_chan_0_bank_2 = from_chan_0_bank_2.read();
tmp_chan_0_bank_3 = from_chan_0_bank_3.read();
load_coalesced:
for(int j = 0; j < BURST_WIDTH/32; ++j)
{
#pragma HLS unroll
uint32_t raw_bits_chan_0_bank_0 = tmp_chan_0_bank_0((j+1)*32-1, j*32);
buffer_t1_chan_0[BURST_WIDTH/32*4*0+j*4+0] = *(float*)(&raw_bits_chan_0_bank_0);
uint32_t raw_bits_chan_0_bank_1 = tmp_chan_0_bank_1((j+1)*32-1, j*32);
buffer_t1_chan_0[BURST_WIDTH/32*4*0+j*4+1] = *(float*)(&raw_bits_chan_0_bank_1);
uint32_t raw_bits_chan_0_bank_2 = tmp_chan_0_bank_2((j+1)*32-1, j*32);
buffer_t1_chan_0[BURST_WIDTH/32*4*0+j*4+2] = *(float*)(&raw_bits_chan_0_bank_2);
uint32_t raw_bits_chan_0_bank_3 = tmp_chan_0_bank_3((j+1)*32-1, j*32);
buffer_t1_chan_0[BURST_WIDTH/32*4*0+j*4+3] = *(float*)(&raw_bits_chan_0_bank_3);
}
}
float& FIFO_125_t1_chan_0_fifo_0 = FIFO_125_t1_chan_0[0][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_1 = FIFO_125_t1_chan_0[1][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_2 = FIFO_125_t1_chan_0[2][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_3 = FIFO_125_t1_chan_0[3][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_4 = FIFO_125_t1_chan_0[4][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_5 = FIFO_125_t1_chan_0[5][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_6 = FIFO_125_t1_chan_0[6][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_7 = FIFO_125_t1_chan_0[7][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_8 = FIFO_125_t1_chan_0[8][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_9 = FIFO_125_t1_chan_0[9][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_10 = FIFO_125_t1_chan_0[10][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_11 = FIFO_125_t1_chan_0[11][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_12 = FIFO_125_t1_chan_0[12][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_13 = FIFO_125_t1_chan_0[13][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_14 = FIFO_125_t1_chan_0[14][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_15 = FIFO_125_t1_chan_0[15][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_16 = FIFO_125_t1_chan_0[16][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_17 = FIFO_125_t1_chan_0[17][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_18 = FIFO_125_t1_chan_0[18][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_19 = FIFO_125_t1_chan_0[19][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_20 = FIFO_125_t1_chan_0[20][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_21 = FIFO_125_t1_chan_0[21][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_22 = FIFO_125_t1_chan_0[22][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_23 = FIFO_125_t1_chan_0[23][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_24 = FIFO_125_t1_chan_0[24][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_25 = FIFO_125_t1_chan_0[25][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_26 = FIFO_125_t1_chan_0[26][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_27 = FIFO_125_t1_chan_0[27][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_28 = FIFO_125_t1_chan_0[28][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_29 = FIFO_125_t1_chan_0[29][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_30 = FIFO_125_t1_chan_0[30][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_31 = FIFO_125_t1_chan_0[31][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_32 = FIFO_125_t1_chan_0[32][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_33 = FIFO_125_t1_chan_0[33][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_34 = FIFO_125_t1_chan_0[34][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_35 = FIFO_125_t1_chan_0[35][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_36 = FIFO_125_t1_chan_0[36][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_37 = FIFO_125_t1_chan_0[37][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_38 = FIFO_125_t1_chan_0[38][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_39 = FIFO_125_t1_chan_0[39][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_40 = FIFO_125_t1_chan_0[40][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_41 = FIFO_125_t1_chan_0[41][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_42 = FIFO_125_t1_chan_0[42][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_43 = FIFO_125_t1_chan_0[43][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_44 = FIFO_125_t1_chan_0[44][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_45 = FIFO_125_t1_chan_0[45][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_46 = FIFO_125_t1_chan_0[46][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_47 = FIFO_125_t1_chan_0[47][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_48 = FIFO_125_t1_chan_0[48][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_49 = FIFO_125_t1_chan_0[49][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_50 = FIFO_125_t1_chan_0[50][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_51 = FIFO_125_t1_chan_0[51][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_52 = FIFO_125_t1_chan_0[52][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_53 = FIFO_125_t1_chan_0[53][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_54 = FIFO_125_t1_chan_0[54][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_55 = FIFO_125_t1_chan_0[55][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_56 = FIFO_125_t1_chan_0[56][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_57 = FIFO_125_t1_chan_0[57][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_58 = FIFO_125_t1_chan_0[58][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_59 = FIFO_125_t1_chan_0[59][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_60 = FIFO_125_t1_chan_0[60][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_61 = FIFO_125_t1_chan_0[61][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_62 = FIFO_125_t1_chan_0[62][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_63 = FIFO_125_t1_chan_0[63][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_64 = FIFO_125_t1_chan_0[64][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_65 = FIFO_125_t1_chan_0[65][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_66 = FIFO_125_t1_chan_0[66][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_67 = FIFO_125_t1_chan_0[67][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_68 = FIFO_125_t1_chan_0[68][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_69 = FIFO_125_t1_chan_0[69][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_70 = FIFO_125_t1_chan_0[70][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_71 = FIFO_125_t1_chan_0[71][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_72 = FIFO_125_t1_chan_0[72][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_73 = FIFO_125_t1_chan_0[73][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_74 = FIFO_125_t1_chan_0[74][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_75 = FIFO_125_t1_chan_0[75][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_76 = FIFO_125_t1_chan_0[76][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_77 = FIFO_125_t1_chan_0[77][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_78 = FIFO_125_t1_chan_0[78][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_79 = FIFO_125_t1_chan_0[79][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_80 = FIFO_125_t1_chan_0[80][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_81 = FIFO_125_t1_chan_0[81][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_82 = FIFO_125_t1_chan_0[82][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_83 = FIFO_125_t1_chan_0[83][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_84 = FIFO_125_t1_chan_0[84][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_85 = FIFO_125_t1_chan_0[85][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_86 = FIFO_125_t1_chan_0[86][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_87 = FIFO_125_t1_chan_0[87][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_88 = FIFO_125_t1_chan_0[88][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_89 = FIFO_125_t1_chan_0[89][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_90 = FIFO_125_t1_chan_0[90][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_91 = FIFO_125_t1_chan_0[91][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_92 = FIFO_125_t1_chan_0[92][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_93 = FIFO_125_t1_chan_0[93][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_94 = FIFO_125_t1_chan_0[94][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_95 = FIFO_125_t1_chan_0[95][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_96 = FIFO_125_t1_chan_0[96][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_97 = FIFO_125_t1_chan_0[97][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_98 = FIFO_125_t1_chan_0[98][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_99 = FIFO_125_t1_chan_0[99][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_100 = FIFO_125_t1_chan_0[100][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_101 = FIFO_125_t1_chan_0[101][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_102 = FIFO_125_t1_chan_0[102][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_103 = FIFO_125_t1_chan_0[103][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_104 = FIFO_125_t1_chan_0[104][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_105 = FIFO_125_t1_chan_0[105][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_106 = FIFO_125_t1_chan_0[106][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_107 = FIFO_125_t1_chan_0[107][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_108 = FIFO_125_t1_chan_0[108][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_109 = FIFO_125_t1_chan_0[109][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_110 = FIFO_125_t1_chan_0[110][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_111 = FIFO_125_t1_chan_0[111][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_112 = FIFO_125_t1_chan_0[112][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_113 = FIFO_125_t1_chan_0[113][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_114 = FIFO_125_t1_chan_0[114][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_115 = FIFO_125_t1_chan_0[115][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_116 = FIFO_125_t1_chan_0[116][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_117 = FIFO_125_t1_chan_0[117][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_118 = FIFO_125_t1_chan_0[118][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_119 = FIFO_125_t1_chan_0[119][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_120 = FIFO_125_t1_chan_0[120][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_121 = FIFO_125_t1_chan_0[121][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_122 = FIFO_125_t1_chan_0[122][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_123 = FIFO_125_t1_chan_0[123][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_124 = FIFO_125_t1_chan_0[124][FIFO_125_t1_ptr];
float& FIFO_125_t1_chan_0_fifo_125 = FIFO_125_t1_chan_0[125][FIFO_125_t1_ptr];
float& FIFO_124_t1_chan_0_fifo_0 = FIFO_124_t1_chan_0[0][FIFO_124_t1_ptr];
float& FIFO_124_t1_chan_0_fifo_1 = FIFO_124_t1_chan_0[1][FIFO_124_t1_ptr];
points_from_t1_to_t0_chan_0[0][4] = buffer_t1_chan_0[0]; // t1[0](1, 2) @ unroll_index=0
points_from_t1_to_t0_chan_0[1][4] = buffer_t1_chan_0[1]; // t1[0](1, 2) @ unroll_index=1
points_from_t1_to_t0_chan_0[2][4] = buffer_t1_chan_0[2]; // t1[0](1, 2) @ unroll_index=2
points_from_t1_to_t0_chan_0[3][4] = buffer_t1_chan_0[3]; // t1[0](1, 2) @ unroll_index=3
points_from_t1_to_t0_chan_0[4][4] = buffer_t1_chan_0[4]; // t1[0](1, 2) @ unroll_index=4
points_from_t1_to_t0_chan_0[5][4] = buffer_t1_chan_0[5]; // t1[0](1, 2) @ unroll_index=5
points_from_t1_to_t0_chan_0[6][4] = buffer_t1_chan_0[6]; // t1[0](1, 2) @ unroll_index=6
points_from_t1_to_t0_chan_0[7][4] = buffer_t1_chan_0[7]; // t1[0](1, 2) @ unroll_index=7
points_from_t1_to_t0_chan_0[8][4] = buffer_t1_chan_0[8]; // t1[0](1, 2) @ unroll_index=8
points_from_t1_to_t0_chan_0[9][4] = buffer_t1_chan_0[9]; // t1[0](1, 2) @ unroll_index=9
points_from_t1_to_t0_chan_0[10][4] = buffer_t1_chan_0[10]; // t1[0](1, 2) @ unroll_index=10
points_from_t1_to_t0_chan_0[11][4] = buffer_t1_chan_0[11]; // t1[0](1, 2) @ unroll_index=11
points_from_t1_to_t0_chan_0[12][4] = buffer_t1_chan_0[12]; // t1[0](1, 2) @ unroll_index=12
points_from_t1_to_t0_chan_0[13][4] = buffer_t1_chan_0[13]; // t1[0](1, 2) @ unroll_index=13
points_from_t1_to_t0_chan_0[14][4] = buffer_t1_chan_0[14]; // t1[0](1, 2) @ unroll_index=14
points_from_t1_to_t0_chan_0[15][4] = buffer_t1_chan_0[15]; // t1[0](1, 2) @ unroll_index=15
points_from_t1_to_t0_chan_0[16][4] = buffer_t1_chan_0[16]; // t1[0](1, 2) @ unroll_index=16
points_from_t1_to_t0_chan_0[17][4] = buffer_t1_chan_0[17]; // t1[0](1, 2) @ unroll_index=17
points_from_t1_to_t0_chan_0[18][4] = buffer_t1_chan_0[18]; // t1[0](1, 2) @ unroll_index=18
points_from_t1_to_t0_chan_0[19][4] = buffer_t1_chan_0[19]; // t1[0](1, 2) @ unroll_index=19
points_from_t1_to_t0_chan_0[20][4] = buffer_t1_chan_0[20]; // t1[0](1, 2) @ unroll_index=20
points_from_t1_to_t0_chan_0[21][4] = buffer_t1_chan_0[21]; // t1[0](1, 2) @ unroll_index=21
points_from_t1_to_t0_chan_0[22][4] = buffer_t1_chan_0[22]; // t1[0](1, 2) @ unroll_index=22
points_from_t1_to_t0_chan_0[23][4] = buffer_t1_chan_0[23]; // t1[0](1, 2) @ unroll_index=23
points_from_t1_to_t0_chan_0[24][4] = buffer_t1_chan_0[24]; // t1[0](1, 2) @ unroll_index=24
points_from_t1_to_t0_chan_0[25][4] = buffer_t1_chan_0[25]; // t1[0](1, 2) @ unroll_index=25
points_from_t1_to_t0_chan_0[26][4] = buffer_t1_chan_0[26]; // t1[0](1, 2) @ unroll_index=26
points_from_t1_to_t0_chan_0[27][4] = buffer_t1_chan_0[27]; // t1[0](1, 2) @ unroll_index=27
points_from_t1_to_t0_chan_0[28][4] = buffer_t1_chan_0[28]; // t1[0](1, 2) @ unroll_index=28
points_from_t1_to_t0_chan_0[29][4] = buffer_t1_chan_0[29]; // t1[0](1, 2) @ unroll_index=29
points_from_t1_to_t0_chan_0[30][4] = buffer_t1_chan_0[30]; // t1[0](1, 2) @ unroll_index=30
points_from_t1_to_t0_chan_0[31][4] = buffer_t1_chan_0[31]; // t1[0](1, 2) @ unroll_index=31
points_from_t1_to_t0_chan_0[32][4] = buffer_t1_chan_0[32]; // t1[0](1, 2) @ unroll_index=32
points_from_t1_to_t0_chan_0[33][4] = buffer_t1_chan_0[33]; // t1[0](1, 2) @ unroll_index=33
points_from_t1_to_t0_chan_0[34][4] = buffer_t1_chan_0[34]; // t1[0](1, 2) @ unroll_index=34
points_from_t1_to_t0_chan_0[35][4] = buffer_t1_chan_0[35]; // t1[0](1, 2) @ unroll_index=35
points_from_t1_to_t0_chan_0[36][4] = buffer_t1_chan_0[36]; // t1[0](1, 2) @ unroll_index=36
points_from_t1_to_t0_chan_0[37][4] = buffer_t1_chan_0[37]; // t1[0](1, 2) @ unroll_index=37
points_from_t1_to_t0_chan_0[38][4] = buffer_t1_chan_0[38]; // t1[0](1, 2) @ unroll_index=38
points_from_t1_to_t0_chan_0[39][4] = buffer_t1_chan_0[39]; // t1[0](1, 2) @ unroll_index=39
points_from_t1_to_t0_chan_0[40][4] = buffer_t1_chan_0[40]; // t1[0](1, 2) @ unroll_index=40
points_from_t1_to_t0_chan_0[41][4] = buffer_t1_chan_0[41]; // t1[0](1, 2) @ unroll_index=41
points_from_t1_to_t0_chan_0[42][4] = buffer_t1_chan_0[42]; // t1[0](1, 2) @ unroll_index=42
points_from_t1_to_t0_chan_0[43][4] = buffer_t1_chan_0[43]; // t1[0](1, 2) @ unroll_index=43
points_from_t1_to_t0_chan_0[44][4] = buffer_t1_chan_0[44]; // t1[0](1, 2) @ unroll_index=44
points_from_t1_to_t0_chan_0[45][4] = buffer_t1_chan_0[45]; // t1[0](1, 2) @ unroll_index=45
points_from_t1_to_t0_chan_0[46][4] = buffer_t1_chan_0[46]; // t1[0](1, 2) @ unroll_index=46
points_from_t1_to_t0_chan_0[47][4] = buffer_t1_chan_0[47]; // t1[0](1, 2) @ unroll_index=47
points_from_t1_to_t0_chan_0[48][4] = buffer_t1_chan_0[48]; // t1[0](1, 2) @ unroll_index=48
points_from_t1_to_t0_chan_0[49][4] = buffer_t1_chan_0[49]; // t1[0](1, 2) @ unroll_index=49
points_from_t1_to_t0_chan_0[50][4] = buffer_t1_chan_0[50]; // t1[0](1, 2) @ unroll_index=50
points_from_t1_to_t0_chan_0[51][4] = buffer_t1_chan_0[51]; // t1[0](1, 2) @ unroll_index=51
points_from_t1_to_t0_chan_0[52][4] = buffer_t1_chan_0[52]; // t1[0](1, 2) @ unroll_index=52
points_from_t1_to_t0_chan_0[53][4] = buffer_t1_chan_0[53]; // t1[0](1, 2) @ unroll_index=53
points_from_t1_to_t0_chan_0[54][4] = buffer_t1_chan_0[54]; // t1[0](1, 2) @ unroll_index=54
points_from_t1_to_t0_chan_0[55][4] = buffer_t1_chan_0[55]; // t1[0](1, 2) @ unroll_index=55
points_from_t1_to_t0_chan_0[56][4] = buffer_t1_chan_0[56]; // t1[0](1, 2) @ unroll_index=56
points_from_t1_to_t0_chan_0[57][4] = buffer_t1_chan_0[57]; // t1[0](1, 2) @ unroll_index=57
points_from_t1_to_t0_chan_0[58][4] = buffer_t1_chan_0[58]; // t1[0](1, 2) @ unroll_index=58
points_from_t1_to_t0_chan_0[59][4] = buffer_t1_chan_0[59]; // t1[0](1, 2) @ unroll_index=59
points_from_t1_to_t0_chan_0[60][4] = buffer_t1_chan_0[60]; // t1[0](1, 2) @ unroll_index=60
points_from_t1_to_t0_chan_0[61][4] = buffer_t1_chan_0[61]; // t1[0](1, 2) @ unroll_index=61
points_from_t1_to_t0_chan_0[62][4] = buffer_t1_chan_0[62]; // t1[0](1, 2) @ unroll_index=62
points_from_t1_to_t0_chan_0[63][4] = buffer_t1_chan_0[63]; // t1[0](1, 2) @ unroll_index=63
points_from_t1_to_t0_chan_0[0][2] = FF_t1_chan_0[0]; // t1[0](1, 1) @ unroll_index=0
points_from_t1_to_t0_chan_0[1][1] = FF_t1_chan_0[0]; // t1[0](0, 1) @ unroll_index=1
points_from_t1_to_t0_chan_0[0][1] = FF_t1_chan_0[1]; // t1[0](0, 1) @ unroll_index=0
points_from_t1_to_t0_chan_0[62][3] = FIFO_125_t1_chan_0_fifo_0; // t1[0](2, 1) @ unroll_index=62
points_from_t1_to_t0_chan_0[63][2] = FIFO_125_t1_chan_0_fifo_0; // t1[0](1, 1) @ unroll_index=63
points_from_t1_to_t0_chan_0[61][3] = FIFO_125_t1_chan_0_fifo_1; // t1[0](2, 1) @ unroll_index=61
points_from_t1_to_t0_chan_0[62][2] = FIFO_125_t1_chan_0_fifo_1; // t1[0](1, 1) @ unroll_index=62
points_from_t1_to_t0_chan_0[63][1] = FIFO_125_t1_chan_0_fifo_1; // t1[0](0, 1) @ unroll_index=63
points_from_t1_to_t0_chan_0[60][3] = FIFO_125_t1_chan_0_fifo_2; // t1[0](2, 1) @ unroll_index=60
points_from_t1_to_t0_chan_0[61][2] = FIFO_125_t1_chan_0_fifo_2; // t1[0](1, 1) @ unroll_index=61
points_from_t1_to_t0_chan_0[62][1] = FIFO_125_t1_chan_0_fifo_2; // t1[0](0, 1) @ unroll_index=62
points_from_t1_to_t0_chan_0[59][3] = FIFO_125_t1_chan_0_fifo_3; // t1[0](2, 1) @ unroll_index=59
points_from_t1_to_t0_chan_0[60][2] = FIFO_125_t1_chan_0_fifo_3; // t1[0](1, 1) @ unroll_index=60
points_from_t1_to_t0_chan_0[61][1] = FIFO_125_t1_chan_0_fifo_3; // t1[0](0, 1) @ unroll_index=61
points_from_t1_to_t0_chan_0[58][3] = FIFO_125_t1_chan_0_fifo_4; // t1[0](2, 1) @ unroll_index=58
points_from_t1_to_t0_chan_0[59][2] = FIFO_125_t1_chan_0_fifo_4; // t1[0](1, 1) @ unroll_index=59
points_from_t1_to_t0_chan_0[60][1] = FIFO_125_t1_chan_0_fifo_4; // t1[0](0, 1) @ unroll_index=60
points_from_t1_to_t0_chan_0[57][3] = FIFO_125_t1_chan_0_fifo_5; // t1[0](2, 1) @ unroll_index=57
points_from_t1_to_t0_chan_0[58][2] = FIFO_125_t1_chan_0_fifo_5; // t1[0](1, 1) @ unroll_index=58
points_from_t1_to_t0_chan_0[59][1] = FIFO_125_t1_chan_0_fifo_5; // t1[0](0, 1) @ unroll_index=59
points_from_t1_to_t0_chan_0[56][3] = FIFO_125_t1_chan_0_fifo_6; // t1[0](2, 1) @ unroll_index=56
points_from_t1_to_t0_chan_0[57][2] = FIFO_125_t1_chan_0_fifo_6; // t1[0](1, 1) @ unroll_index=57
points_from_t1_to_t0_chan_0[58][1] = FIFO_125_t1_chan_0_fifo_6; // t1[0](0, 1) @ unroll_index=58
points_from_t1_to_t0_chan_0[56][2] = FIFO_125_t1_chan_0_fifo_7; // t1[0](1, 1) @ unroll_index=56
points_from_t1_to_t0_chan_0[57][1] = FIFO_125_t1_chan_0_fifo_7; // t1[0](0, 1) @ unroll_index=57
points_from_t1_to_t0_chan_0[55][3] = FIFO_125_t1_chan_0_fifo_7; // t1[0](2, 1) @ unroll_index=55
points_from_t1_to_t0_chan_0[56][1] = FIFO_125_t1_chan_0_fifo_8; // t1[0](0, 1) @ unroll_index=56
points_from_t1_to_t0_chan_0[54][3] = FIFO_125_t1_chan_0_fifo_8; // t1[0](2, 1) @ unroll_index=54
points_from_t1_to_t0_chan_0[55][2] = FIFO_125_t1_chan_0_fifo_8; // t1[0](1, 1) @ unroll_index=55
points_from_t1_to_t0_chan_0[53][3] = FIFO_125_t1_chan_0_fifo_9; // t1[0](2, 1) @ unroll_index=53
points_from_t1_to_t0_chan_0[54][2] = FIFO_125_t1_chan_0_fifo_9; // t1[0](1, 1) @ unroll_index=54
points_from_t1_to_t0_chan_0[55][1] = FIFO_125_t1_chan_0_fifo_9; // t1[0](0, 1) @ unroll_index=55
points_from_t1_to_t0_chan_0[52][3] = FIFO_125_t1_chan_0_fifo_10; // t1[0](2, 1) @ unroll_index=52
points_from_t1_to_t0_chan_0[53][2] = FIFO_125_t1_chan_0_fifo_10; // t1[0](1, 1) @ unroll_index=53
points_from_t1_to_t0_chan_0[54][1] = FIFO_125_t1_chan_0_fifo_10; // t1[0](0, 1) @ unroll_index=54
points_from_t1_to_t0_chan_0[51][3] = FIFO_125_t1_chan_0_fifo_11; // t1[0](2, 1) @ unroll_index=51
points_from_t1_to_t0_chan_0[52][2] = FIFO_125_t1_chan_0_fifo_11; // t1[0](1, 1) @ unroll_index=52
points_from_t1_to_t0_chan_0[53][1] = FIFO_125_t1_chan_0_fifo_11; // t1[0](0, 1) @ unroll_index=53
points_from_t1_to_t0_chan_0[50][3] = FIFO_125_t1_chan_0_fifo_12; // t1[0](2, 1) @ unroll_index=50
points_from_t1_to_t0_chan_0[51][2] = FIFO_125_t1_chan_0_fifo_12; // t1[0](1, 1) @ unroll_index=51
points_from_t1_to_t0_chan_0[52][1] = FIFO_125_t1_chan_0_fifo_12; // t1[0](0, 1) @ unroll_index=52
points_from_t1_to_t0_chan_0[49][3] = FIFO_125_t1_chan_0_fifo_13; // t1[0](2, 1) @ unroll_index=49
points_from_t1_to_t0_chan_0[50][2] = FIFO_125_t1_chan_0_fifo_13; // t1[0](1, 1) @ unroll_index=50
points_from_t1_to_t0_chan_0[51][1] = FIFO_125_t1_chan_0_fifo_13; // t1[0](0, 1) @ unroll_index=51
points_from_t1_to_t0_chan_0[48][3] = FIFO_125_t1_chan_0_fifo_14; // t1[0](2, 1) @ unroll_index=48
points_from_t1_to_t0_chan_0[49][2] = FIFO_125_t1_chan_0_fifo_14; // t1[0](1, 1) @ unroll_index=49
points_from_t1_to_t0_chan_0[50][1] = FIFO_125_t1_chan_0_fifo_14; // t1[0](0, 1) @ unroll_index=50
points_from_t1_to_t0_chan_0[48][2] = FIFO_125_t1_chan_0_fifo_15; // t1[0](1, 1) @ unroll_index=48
points_from_t1_to_t0_chan_0[49][1] = FIFO_125_t1_chan_0_fifo_15; // t1[0](0, 1) @ unroll_index=49
points_from_t1_to_t0_chan_0[47][3] = FIFO_125_t1_chan_0_fifo_15; // t1[0](2, 1) @ unroll_index=47
points_from_t1_to_t0_chan_0[48][1] = FIFO_125_t1_chan_0_fifo_16; // t1[0](0, 1) @ unroll_index=48
points_from_t1_to_t0_chan_0[46][3] = FIFO_125_t1_chan_0_fifo_16; // t1[0](2, 1) @ unroll_index=46
points_from_t1_to_t0_chan_0[47][2] = FIFO_125_t1_chan_0_fifo_16; // t1[0](1, 1) @ unroll_index=47
points_from_t1_to_t0_chan_0[45][3] = FIFO_125_t1_chan_0_fifo_17; // t1[0](2, 1) @ unroll_index=45
points_from_t1_to_t0_chan_0[46][2] = FIFO_125_t1_chan_0_fifo_17; // t1[0](1, 1) @ unroll_index=46
points_from_t1_to_t0_chan_0[47][1] = FIFO_125_t1_chan_0_fifo_17; // t1[0](0, 1) @ unroll_index=47
points_from_t1_to_t0_chan_0[44][3] = FIFO_125_t1_chan_0_fifo_18; // t1[0](2, 1) @ unroll_index=44
points_from_t1_to_t0_chan_0[45][2] = FIFO_125_t1_chan_0_fifo_18; // t1[0](1, 1) @ unroll_index=45
points_from_t1_to_t0_chan_0[46][1] = FIFO_125_t1_chan_0_fifo_18; // t1[0](0, 1) @ unroll_index=46
points_from_t1_to_t0_chan_0[43][3] = FIFO_125_t1_chan_0_fifo_19; // t1[0](2, 1) @ unroll_index=43
points_from_t1_to_t0_chan_0[44][2] = FIFO_125_t1_chan_0_fifo_19; // t1[0](1, 1) @ unroll_index=44
points_from_t1_to_t0_chan_0[45][1] = FIFO_125_t1_chan_0_fifo_19; // t1[0](0, 1) @ unroll_index=45
points_from_t1_to_t0_chan_0[42][3] = FIFO_125_t1_chan_0_fifo_20; // t1[0](2, 1) @ unroll_index=42
points_from_t1_to_t0_chan_0[43][2] = FIFO_125_t1_chan_0_fifo_20; // t1[0](1, 1) @ unroll_index=43
points_from_t1_to_t0_chan_0[44][1] = FIFO_125_t1_chan_0_fifo_20; // t1[0](0, 1) @ unroll_index=44
points_from_t1_to_t0_chan_0[41][3] = FIFO_125_t1_chan_0_fifo_21; // t1[0](2, 1) @ unroll_index=41
points_from_t1_to_t0_chan_0[42][2] = FIFO_125_t1_chan_0_fifo_21; // t1[0](1, 1) @ unroll_index=42
points_from_t1_to_t0_chan_0[43][1] = FIFO_125_t1_chan_0_fifo_21; // t1[0](0, 1) @ unroll_index=43
points_from_t1_to_t0_chan_0[40][3] = FIFO_125_t1_chan_0_fifo_22; // t1[0](2, 1) @ unroll_index=40
points_from_t1_to_t0_chan_0[41][2] = FIFO_125_t1_chan_0_fifo_22; // t1[0](1, 1) @ unroll_index=41
points_from_t1_to_t0_chan_0[42][1] = FIFO_125_t1_chan_0_fifo_22; // t1[0](0, 1) @ unroll_index=42
points_from_t1_to_t0_chan_0[40][2] = FIFO_125_t1_chan_0_fifo_23; // t1[0](1, 1) @ unroll_index=40
points_from_t1_to_t0_chan_0[41][1] = FIFO_125_t1_chan_0_fifo_23; // t1[0](0, 1) @ unroll_index=41
points_from_t1_to_t0_chan_0[39][3] = FIFO_125_t1_chan_0_fifo_23; // t1[0](2, 1) @ unroll_index=39
points_from_t1_to_t0_chan_0[40][1] = FIFO_125_t1_chan_0_fifo_24; // t1[0](0, 1) @ unroll_index=40
points_from_t1_to_t0_chan_0[38][3] = FIFO_125_t1_chan_0_fifo_24; // t1[0](2, 1) @ unroll_index=38
points_from_t1_to_t0_chan_0[39][2] = FIFO_125_t1_chan_0_fifo_24; // t1[0](1, 1) @ unroll_index=39
points_from_t1_to_t0_chan_0[37][3] = FIFO_125_t1_chan_0_fifo_25; // t1[0](2, 1) @ unroll_index=37
points_from_t1_to_t0_chan_0[38][2] = FIFO_125_t1_chan_0_fifo_25; // t1[0](1, 1) @ unroll_index=38
points_from_t1_to_t0_chan_0[39][1] = FIFO_125_t1_chan_0_fifo_25; // t1[0](0, 1) @ unroll_index=39
points_from_t1_to_t0_chan_0[36][3] = FIFO_125_t1_chan_0_fifo_26; // t1[0](2, 1) @ unroll_index=36
points_from_t1_to_t0_chan_0[37][2] = FIFO_125_t1_chan_0_fifo_26; // t1[0](1, 1) @ unroll_index=37
points_from_t1_to_t0_chan_0[38][1] = FIFO_125_t1_chan_0_fifo_26; // t1[0](0, 1) @ unroll_index=38
points_from_t1_to_t0_chan_0[35][3] = FIFO_125_t1_chan_0_fifo_27; // t1[0](2, 1) @ unroll_index=35
points_from_t1_to_t0_chan_0[36][2] = FIFO_125_t1_chan_0_fifo_27; // t1[0](1, 1) @ unroll_index=36
points_from_t1_to_t0_chan_0[37][1] = FIFO_125_t1_chan_0_fifo_27; // t1[0](0, 1) @ unroll_index=37
points_from_t1_to_t0_chan_0[34][3] = FIFO_125_t1_chan_0_fifo_28; // t1[0](2, 1) @ unroll_index=34
points_from_t1_to_t0_chan_0[35][2] = FIFO_125_t1_chan_0_fifo_28; // t1[0](1, 1) @ unroll_index=35
points_from_t1_to_t0_chan_0[36][1] = FIFO_125_t1_chan_0_fifo_28; // t1[0](0, 1) @ unroll_index=36
points_from_t1_to_t0_chan_0[33][3] = FIFO_125_t1_chan_0_fifo_29; // t1[0](2, 1) @ unroll_index=33
points_from_t1_to_t0_chan_0[34][2] = FIFO_125_t1_chan_0_fifo_29; // t1[0](1, 1) @ unroll_index=34
points_from_t1_to_t0_chan_0[35][1] = FIFO_125_t1_chan_0_fifo_29; // t1[0](0, 1) @ unroll_index=35
points_from_t1_to_t0_chan_0[32][3] = FIFO_125_t1_chan_0_fifo_30; // t1[0](2, 1) @ unroll_index=32
points_from_t1_to_t0_chan_0[33][2] = FIFO_125_t1_chan_0_fifo_30; // t1[0](1, 1) @ unroll_index=33
points_from_t1_to_t0_chan_0[34][1] = FIFO_125_t1_chan_0_fifo_30; // t1[0](0, 1) @ unroll_index=34
points_from_t1_to_t0_chan_0[32][2] = FIFO_125_t1_chan_0_fifo_31; // t1[0](1, 1) @ unroll_index=32
points_from_t1_to_t0_chan_0[33][1] = FIFO_125_t1_chan_0_fifo_31; // t1[0](0, 1) @ unroll_index=33
points_from_t1_to_t0_chan_0[31][3] = FIFO_125_t1_chan_0_fifo_31; // t1[0](2, 1) @ unroll_index=31
points_from_t1_to_t0_chan_0[32][1] = FIFO_125_t1_chan_0_fifo_32; // t1[0](0, 1) @ unroll_index=32
points_from_t1_to_t0_chan_0[30][3] = FIFO_125_t1_chan_0_fifo_32; // t1[0](2, 1) @ unroll_index=30
points_from_t1_to_t0_chan_0[31][2] = FIFO_125_t1_chan_0_fifo_32; // t1[0](1, 1) @ unroll_index=31
points_from_t1_to_t0_chan_0[29][3] = FIFO_125_t1_chan_0_fifo_33; // t1[0](2, 1) @ unroll_index=29
points_from_t1_to_t0_chan_0[30][2] = FIFO_125_t1_chan_0_fifo_33; // t1[0](1, 1) @ unroll_index=30
points_from_t1_to_t0_chan_0[31][1] = FIFO_125_t1_chan_0_fifo_33; // t1[0](0, 1) @ unroll_index=31
points_from_t1_to_t0_chan_0[28][3] = FIFO_125_t1_chan_0_fifo_34; // t1[0](2, 1) @ unroll_index=28
points_from_t1_to_t0_chan_0[29][2] = FIFO_125_t1_chan_0_fifo_34; // t1[0](1, 1) @ unroll_index=29
points_from_t1_to_t0_chan_0[30][1] = FIFO_125_t1_chan_0_fifo_34; // t1[0](0, 1) @ unroll_index=30
points_from_t1_to_t0_chan_0[27][3] = FIFO_125_t1_chan_0_fifo_35; // t1[0](2, 1) @ unroll_index=27
points_from_t1_to_t0_chan_0[28][2] = FIFO_125_t1_chan_0_fifo_35; // t1[0](1, 1) @ unroll_index=28
points_from_t1_to_t0_chan_0[29][1] = FIFO_125_t1_chan_0_fifo_35; // t1[0](0, 1) @ unroll_index=29
points_from_t1_to_t0_chan_0[26][3] = FIFO_125_t1_chan_0_fifo_36; // t1[0](2, 1) @ unroll_index=26
points_from_t1_to_t0_chan_0[27][2] = FIFO_125_t1_chan_0_fifo_36; // t1[0](1, 1) @ unroll_index=27
points_from_t1_to_t0_chan_0[28][1] = FIFO_125_t1_chan_0_fifo_36; // t1[0](0, 1) @ unroll_index=28
points_from_t1_to_t0_chan_0[25][3] = FIFO_125_t1_chan_0_fifo_37; // t1[0](2, 1) @ unroll_index=25
points_from_t1_to_t0_chan_0[26][2] = FIFO_125_t1_chan_0_fifo_37; // t1[0](1, 1) @ unroll_index=26
points_from_t1_to_t0_chan_0[27][1] = FIFO_125_t1_chan_0_fifo_37; // t1[0](0, 1) @ unroll_index=27
points_from_t1_to_t0_chan_0[24][3] = FIFO_125_t1_chan_0_fifo_38; // t1[0](2, 1) @ unroll_index=24
points_from_t1_to_t0_chan_0[25][2] = FIFO_125_t1_chan_0_fifo_38; // t1[0](1, 1) @ unroll_index=25
points_from_t1_to_t0_chan_0[26][1] = FIFO_125_t1_chan_0_fifo_38; // t1[0](0, 1) @ unroll_index=26
points_from_t1_to_t0_chan_0[24][2] = FIFO_125_t1_chan_0_fifo_39; // t1[0](1, 1) @ unroll_index=24
points_from_t1_to_t0_chan_0[25][1] = FIFO_125_t1_chan_0_fifo_39; // t1[0](0, 1) @ unroll_index=25
points_from_t1_to_t0_chan_0[23][3] = FIFO_125_t1_chan_0_fifo_39; // t1[0](2, 1) @ unroll_index=23
points_from_t1_to_t0_chan_0[24][1] = FIFO_125_t1_chan_0_fifo_40; // t1[0](0, 1) @ unroll_index=24
points_from_t1_to_t0_chan_0[22][3] = FIFO_125_t1_chan_0_fifo_40; // t1[0](2, 1) @ unroll_index=22
points_from_t1_to_t0_chan_0[23][2] = FIFO_125_t1_chan_0_fifo_40; // t1[0](1, 1) @ unroll_index=23
points_from_t1_to_t0_chan_0[21][3] = FIFO_125_t1_chan_0_fifo_41; // t1[0](2, 1) @ unroll_index=21
points_from_t1_to_t0_chan_0[22][2] = FIFO_125_t1_chan_0_fifo_41; // t1[0](1, 1) @ unroll_index=22
points_from_t1_to_t0_chan_0[23][1] = FIFO_125_t1_chan_0_fifo_41; // t1[0](0, 1) @ unroll_index=23
points_from_t1_to_t0_chan_0[20][3] = FIFO_125_t1_chan_0_fifo_42; // t1[0](2, 1) @ unroll_index=20
points_from_t1_to_t0_chan_0[21][2] = FIFO_125_t1_chan_0_fifo_42; // t1[0](1, 1) @ unroll_index=21
points_from_t1_to_t0_chan_0[22][1] = FIFO_125_t1_chan_0_fifo_42; // t1[0](0, 1) @ unroll_index=22
points_from_t1_to_t0_chan_0[19][3] = FIFO_125_t1_chan_0_fifo_43; // t1[0](2, 1) @ unroll_index=19
points_from_t1_to_t0_chan_0[20][2] = FIFO_125_t1_chan_0_fifo_43; // t1[0](1, 1) @ unroll_index=20
points_from_t1_to_t0_chan_0[21][1] = FIFO_125_t1_chan_0_fifo_43; // t1[0](0, 1) @ unroll_index=21
points_from_t1_to_t0_chan_0[18][3] = FIFO_125_t1_chan_0_fifo_44; // t1[0](2, 1) @ unroll_index=18
points_from_t1_to_t0_chan_0[19][2] = FIFO_125_t1_chan_0_fifo_44; // t1[0](1, 1) @ unroll_index=19
points_from_t1_to_t0_chan_0[20][1] = FIFO_125_t1_chan_0_fifo_44; // t1[0](0, 1) @ unroll_index=20
points_from_t1_to_t0_chan_0[17][3] = FIFO_125_t1_chan_0_fifo_45; // t1[0](2, 1) @ unroll_index=17
points_from_t1_to_t0_chan_0[18][2] = FIFO_125_t1_chan_0_fifo_45; // t1[0](1, 1) @ unroll_index=18
points_from_t1_to_t0_chan_0[19][1] = FIFO_125_t1_chan_0_fifo_45; // t1[0](0, 1) @ unroll_index=19
points_from_t1_to_t0_chan_0[16][3] = FIFO_125_t1_chan_0_fifo_46; // t1[0](2, 1) @ unroll_index=16
points_from_t1_to_t0_chan_0[17][2] = FIFO_125_t1_chan_0_fifo_46; // t1[0](1, 1) @ unroll_index=17
points_from_t1_to_t0_chan_0[18][1] = FIFO_125_t1_chan_0_fifo_46; // t1[0](0, 1) @ unroll_index=18
points_from_t1_to_t0_chan_0[16][2] = FIFO_125_t1_chan_0_fifo_47; // t1[0](1, 1) @ unroll_index=16
points_from_t1_to_t0_chan_0[17][1] = FIFO_125_t1_chan_0_fifo_47; // t1[0](0, 1) @ unroll_index=17
points_from_t1_to_t0_chan_0[15][3] = FIFO_125_t1_chan_0_fifo_47; // t1[0](2, 1) @ unroll_index=15
points_from_t1_to_t0_chan_0[16][1] = FIFO_125_t1_chan_0_fifo_48; // t1[0](0, 1) @ unroll_index=16
points_from_t1_to_t0_chan_0[14][3] = FIFO_125_t1_chan_0_fifo_48; // t1[0](2, 1) @ unroll_index=14
points_from_t1_to_t0_chan_0[15][2] = FIFO_125_t1_chan_0_fifo_48; // t1[0](1, 1) @ unroll_index=15
points_from_t1_to_t0_chan_0[13][3] = FIFO_125_t1_chan_0_fifo_49; // t1[0](2, 1) @ unroll_index=13
points_from_t1_to_t0_chan_0[14][2] = FIFO_125_t1_chan_0_fifo_49; // t1[0](1, 1) @ unroll_index=14
points_from_t1_to_t0_chan_0[15][1] = FIFO_125_t1_chan_0_fifo_49; // t1[0](0, 1) @ unroll_index=15
points_from_t1_to_t0_chan_0[12][3] = FIFO_125_t1_chan_0_fifo_50; // t1[0](2, 1) @ unroll_index=12
points_from_t1_to_t0_chan_0[13][2] = FIFO_125_t1_chan_0_fifo_50; // t1[0](1, 1) @ unroll_index=13
points_from_t1_to_t0_chan_0[14][1] = FIFO_125_t1_chan_0_fifo_50; // t1[0](0, 1) @ unroll_index=14
points_from_t1_to_t0_chan_0[11][3] = FIFO_125_t1_chan_0_fifo_51; // t1[0](2, 1) @ unroll_index=11
points_from_t1_to_t0_chan_0[12][2] = FIFO_125_t1_chan_0_fifo_51; // t1[0](1, 1) @ unroll_index=12
points_from_t1_to_t0_chan_0[13][1] = FIFO_125_t1_chan_0_fifo_51; // t1[0](0, 1) @ unroll_index=13
points_from_t1_to_t0_chan_0[10][3] = FIFO_125_t1_chan_0_fifo_52; // t1[0](2, 1) @ unroll_index=10
points_from_t1_to_t0_chan_0[11][2] = FIFO_125_t1_chan_0_fifo_52; // t1[0](1, 1) @ unroll_index=11
points_from_t1_to_t0_chan_0[12][1] = FIFO_125_t1_chan_0_fifo_52; // t1[0](0, 1) @ unroll_index=12
points_from_t1_to_t0_chan_0[9][3] = FIFO_125_t1_chan_0_fifo_53; // t1[0](2, 1) @ unroll_index=9
points_from_t1_to_t0_chan_0[10][2] = FIFO_125_t1_chan_0_fifo_53; // t1[0](1, 1) @ unroll_index=10
points_from_t1_to_t0_chan_0[11][1] = FIFO_125_t1_chan_0_fifo_53; // t1[0](0, 1) @ unroll_index=11
points_from_t1_to_t0_chan_0[8][3] = FIFO_125_t1_chan_0_fifo_54; // t1[0](2, 1) @ unroll_index=8
points_from_t1_to_t0_chan_0[9][2] = FIFO_125_t1_chan_0_fifo_54; // t1[0](1, 1) @ unroll_index=9
points_from_t1_to_t0_chan_0[10][1] = FIFO_125_t1_chan_0_fifo_54; // t1[0](0, 1) @ unroll_index=10
points_from_t1_to_t0_chan_0[8][2] = FIFO_125_t1_chan_0_fifo_55; // t1[0](1, 1) @ unroll_index=8
points_from_t1_to_t0_chan_0[9][1] = FIFO_125_t1_chan_0_fifo_55; // t1[0](0, 1) @ unroll_index=9
points_from_t1_to_t0_chan_0[7][3] = FIFO_125_t1_chan_0_fifo_55; // t1[0](2, 1) @ unroll_index=7
points_from_t1_to_t0_chan_0[8][1] = FIFO_125_t1_chan_0_fifo_56; // t1[0](0, 1) @ unroll_index=8
points_from_t1_to_t0_chan_0[6][3] = FIFO_125_t1_chan_0_fifo_56; // t1[0](2, 1) @ unroll_index=6
points_from_t1_to_t0_chan_0[7][2] = FIFO_125_t1_chan_0_fifo_56; // t1[0](1, 1) @ unroll_index=7
points_from_t1_to_t0_chan_0[5][3] = FIFO_125_t1_chan_0_fifo_57; // t1[0](2, 1) @ unroll_index=5
points_from_t1_to_t0_chan_0[6][2] = FIFO_125_t1_chan_0_fifo_57; // t1[0](1, 1) @ unroll_index=6
points_from_t1_to_t0_chan_0[7][1] = FIFO_125_t1_chan_0_fifo_57; // t1[0](0, 1) @ unroll_index=7
points_from_t1_to_t0_chan_0[4][3] = FIFO_125_t1_chan_0_fifo_58; // t1[0](2, 1) @ unroll_index=4
points_from_t1_to_t0_chan_0[5][2] = FIFO_125_t1_chan_0_fifo_58; // t1[0](1, 1) @ unroll_index=5
points_from_t1_to_t0_chan_0[6][1] = FIFO_125_t1_chan_0_fifo_58; // t1[0](0, 1) @ unroll_index=6
points_from_t1_to_t0_chan_0[3][3] = FIFO_125_t1_chan_0_fifo_59; // t1[0](2, 1) @ unroll_index=3
points_from_t1_to_t0_chan_0[4][2] = FIFO_125_t1_chan_0_fifo_59; // t1[0](1, 1) @ unroll_index=4
points_from_t1_to_t0_chan_0[5][1] = FIFO_125_t1_chan_0_fifo_59; // t1[0](0, 1) @ unroll_index=5
points_from_t1_to_t0_chan_0[2][3] = FIFO_125_t1_chan_0_fifo_60; // t1[0](2, 1) @ unroll_index=2
points_from_t1_to_t0_chan_0[3][2] = FIFO_125_t1_chan_0_fifo_60; // t1[0](1, 1) @ unroll_index=3
points_from_t1_to_t0_chan_0[4][1] = FIFO_125_t1_chan_0_fifo_60; // t1[0](0, 1) @ unroll_index=4
points_from_t1_to_t0_chan_0[1][3] = FIFO_125_t1_chan_0_fifo_61; // t1[0](2, 1) @ unroll_index=1
points_from_t1_to_t0_chan_0[2][2] = FIFO_125_t1_chan_0_fifo_61; // t1[0](1, 1) @ unroll_index=2
points_from_t1_to_t0_chan_0[3][1] = FIFO_125_t1_chan_0_fifo_61; // t1[0](0, 1) @ unroll_index=3
points_from_t1_to_t0_chan_0[0][3] = FIFO_125_t1_chan_0_fifo_62; // t1[0](2, 1) @ unroll_index=0
points_from_t1_to_t0_chan_0[1][2] = FIFO_125_t1_chan_0_fifo_62; // t1[0](1, 1) @ unroll_index=1
points_from_t1_to_t0_chan_0[2][1] = FIFO_125_t1_chan_0_fifo_62; // t1[0](0, 1) @ unroll_index=2
points_from_t1_to_t0_chan_0[62][0] = FIFO_125_t1_chan_0_fifo_63; // t1[0](1, 0) @ unroll_index=62
points_from_t1_to_t0_chan_0[61][0] = FIFO_125_t1_chan_0_fifo_64; // t1[0](1, 0) @ unroll_index=61
points_from_t1_to_t0_chan_0[60][0] = FIFO_125_t1_chan_0_fifo_65; // t1[0](1, 0) @ unroll_index=60
points_from_t1_to_t0_chan_0[59][0] = FIFO_125_t1_chan_0_fifo_66; // t1[0](1, 0) @ unroll_index=59
points_from_t1_to_t0_chan_0[58][0] = FIFO_125_t1_chan_0_fifo_67; // t1[0](1, 0) @ unroll_index=58
points_from_t1_to_t0_chan_0[57][0] = FIFO_125_t1_chan_0_fifo_68; // t1[0](1, 0) @ unroll_index=57
points_from_t1_to_t0_chan_0[56][0] = FIFO_125_t1_chan_0_fifo_69; // t1[0](1, 0) @ unroll_index=56
points_from_t1_to_t0_chan_0[55][0] = FIFO_125_t1_chan_0_fifo_70; // t1[0](1, 0) @ unroll_index=55
points_from_t1_to_t0_chan_0[54][0] = FIFO_125_t1_chan_0_fifo_71; // t1[0](1, 0) @ unroll_index=54
points_from_t1_to_t0_chan_0[53][0] = FIFO_125_t1_chan_0_fifo_72; // t1[0](1, 0) @ unroll_index=53
points_from_t1_to_t0_chan_0[52][0] = FIFO_125_t1_chan_0_fifo_73; // t1[0](1, 0) @ unroll_index=52
points_from_t1_to_t0_chan_0[51][0] = FIFO_125_t1_chan_0_fifo_74; // t1[0](1, 0) @ unroll_index=51
points_from_t1_to_t0_chan_0[50][0] = FIFO_125_t1_chan_0_fifo_75; // t1[0](1, 0) @ unroll_index=50
points_from_t1_to_t0_chan_0[49][0] = FIFO_125_t1_chan_0_fifo_76; // t1[0](1, 0) @ unroll_index=49
points_from_t1_to_t0_chan_0[48][0] = FIFO_125_t1_chan_0_fifo_77; // t1[0](1, 0) @ unroll_index=48
points_from_t1_to_t0_chan_0[47][0] = FIFO_125_t1_chan_0_fifo_78; // t1[0](1, 0) @ unroll_index=47
points_from_t1_to_t0_chan_0[46][0] = FIFO_125_t1_chan_0_fifo_79; // t1[0](1, 0) @ unroll_index=46
points_from_t1_to_t0_chan_0[45][0] = FIFO_125_t1_chan_0_fifo_80; // t1[0](1, 0) @ unroll_index=45
points_from_t1_to_t0_chan_0[44][0] = FIFO_125_t1_chan_0_fifo_81; // t1[0](1, 0) @ unroll_index=44
points_from_t1_to_t0_chan_0[43][0] = FIFO_125_t1_chan_0_fifo_82; // t1[0](1, 0) @ unroll_index=43
points_from_t1_to_t0_chan_0[42][0] = FIFO_125_t1_chan_0_fifo_83; // t1[0](1, 0) @ unroll_index=42
points_from_t1_to_t0_chan_0[41][0] = FIFO_125_t1_chan_0_fifo_84; // t1[0](1, 0) @ unroll_index=41
points_from_t1_to_t0_chan_0[40][0] = FIFO_125_t1_chan_0_fifo_85; // t1[0](1, 0) @ unroll_index=40
points_from_t1_to_t0_chan_0[39][0] = FIFO_125_t1_chan_0_fifo_86; // t1[0](1, 0) @ unroll_index=39
points_from_t1_to_t0_chan_0[38][0] = FIFO_125_t1_chan_0_fifo_87; // t1[0](1, 0) @ unroll_index=38
points_from_t1_to_t0_chan_0[37][0] = FIFO_125_t1_chan_0_fifo_88; // t1[0](1, 0) @ unroll_index=37
points_from_t1_to_t0_chan_0[36][0] = FIFO_125_t1_chan_0_fifo_89; // t1[0](1, 0) @ unroll_index=36
points_from_t1_to_t0_chan_0[35][0] = FIFO_125_t1_chan_0_fifo_90; // t1[0](1, 0) @ unroll_index=35
points_from_t1_to_t0_chan_0[34][0] = FIFO_125_t1_chan_0_fifo_91; // t1[0](1, 0) @ unroll_index=34
points_from_t1_to_t0_chan_0[33][0] = FIFO_125_t1_chan_0_fifo_92; // t1[0](1, 0) @ unroll_index=33
points_from_t1_to_t0_chan_0[32][0] = FIFO_125_t1_chan_0_fifo_93; // t1[0](1, 0) @ unroll_index=32
points_from_t1_to_t0_chan_0[31][0] = FIFO_125_t1_chan_0_fifo_94; // t1[0](1, 0) @ unroll_index=31
points_from_t1_to_t0_chan_0[30][0] = FIFO_125_t1_chan_0_fifo_95; // t1[0](1, 0) @ unroll_index=30
points_from_t1_to_t0_chan_0[29][0] = FIFO_125_t1_chan_0_fifo_96; // t1[0](1, 0) @ unroll_index=29
points_from_t1_to_t0_chan_0[28][0] = FIFO_125_t1_chan_0_fifo_97; // t1[0](1, 0) @ unroll_index=28
points_from_t1_to_t0_chan_0[27][0] = FIFO_125_t1_chan_0_fifo_98; // t1[0](1, 0) @ unroll_index=27
points_from_t1_to_t0_chan_0[26][0] = FIFO_125_t1_chan_0_fifo_99; // t1[0](1, 0) @ unroll_index=26
points_from_t1_to_t0_chan_0[25][0] = FIFO_125_t1_chan_0_fifo_100; // t1[0](1, 0) @ unroll_index=25
points_from_t1_to_t0_chan_0[24][0] = FIFO_125_t1_chan_0_fifo_101; // t1[0](1, 0) @ unroll_index=24
points_from_t1_to_t0_chan_0[23][0] = FIFO_125_t1_chan_0_fifo_102; // t1[0](1, 0) @ unroll_index=23
points_from_t1_to_t0_chan_0[22][0] = FIFO_125_t1_chan_0_fifo_103; // t1[0](1, 0) @ unroll_index=22
points_from_t1_to_t0_chan_0[21][0] = FIFO_125_t1_chan_0_fifo_104; // t1[0](1, 0) @ unroll_index=21
points_from_t1_to_t0_chan_0[20][0] = FIFO_125_t1_chan_0_fifo_105; // t1[0](1, 0) @ unroll_index=20
points_from_t1_to_t0_chan_0[19][0] = FIFO_125_t1_chan_0_fifo_106; // t1[0](1, 0) @ unroll_index=19
points_from_t1_to_t0_chan_0[18][0] = FIFO_125_t1_chan_0_fifo_107; // t1[0](1, 0) @ unroll_index=18
points_from_t1_to_t0_chan_0[17][0] = FIFO_125_t1_chan_0_fifo_108; // t1[0](1, 0) @ unroll_index=17
points_from_t1_to_t0_chan_0[16][0] = FIFO_125_t1_chan_0_fifo_109; // t1[0](1, 0) @ unroll_index=16
points_from_t1_to_t0_chan_0[15][0] = FIFO_125_t1_chan_0_fifo_110; // t1[0](1, 0) @ unroll_index=15
points_from_t1_to_t0_chan_0[14][0] = FIFO_125_t1_chan_0_fifo_111; // t1[0](1, 0) @ unroll_index=14
points_from_t1_to_t0_chan_0[13][0] = FIFO_125_t1_chan_0_fifo_112; // t1[0](1, 0) @ unroll_index=13
points_from_t1_to_t0_chan_0[12][0] = FIFO_125_t1_chan_0_fifo_113; // t1[0](1, 0) @ unroll_index=12
points_from_t1_to_t0_chan_0[11][0] = FIFO_125_t1_chan_0_fifo_114; // t1[0](1, 0) @ unroll_index=11
points_from_t1_to_t0_chan_0[10][0] = FIFO_125_t1_chan_0_fifo_115; // t1[0](1, 0) @ unroll_index=10
points_from_t1_to_t0_chan_0[9][0] = FIFO_125_t1_chan_0_fifo_116; // t1[0](1, 0) @ unroll_index=9
points_from_t1_to_t0_chan_0[8][0] = FIFO_125_t1_chan_0_fifo_117; // t1[0](1, 0) @ unroll_index=8
points_from_t1_to_t0_chan_0[7][0] = FIFO_125_t1_chan_0_fifo_118; // t1[0](1, 0) @ unroll_index=7
points_from_t1_to_t0_chan_0[6][0] = FIFO_125_t1_chan_0_fifo_119; // t1[0](1, 0) @ unroll_index=6
points_from_t1_to_t0_chan_0[5][0] = FIFO_125_t1_chan_0_fifo_120; // t1[0](1, 0) @ unroll_index=5
points_from_t1_to_t0_chan_0[4][0] = FIFO_125_t1_chan_0_fifo_121; // t1[0](1, 0) @ unroll_index=4
points_from_t1_to_t0_chan_0[3][0] = FIFO_125_t1_chan_0_fifo_122; // t1[0](1, 0) @ unroll_index=3
points_from_t1_to_t0_chan_0[2][0] = FIFO_125_t1_chan_0_fifo_123; // t1[0](1, 0) @ unroll_index=2
points_from_t1_to_t0_chan_0[1][0] = FIFO_125_t1_chan_0_fifo_124; // t1[0](1, 0) @ unroll_index=1
points_from_t1_to_t0_chan_0[0][0] = FIFO_125_t1_chan_0_fifo_125; // t1[0](1, 0) @ unroll_index=0
points_from_t1_to_t0_chan_0[63][3] = FIFO_124_t1_chan_0_fifo_0; // t1[0](2, 1) @ unroll_index=63
points_from_t1_to_t0_chan_0[63][0] = FIFO_124_t1_chan_0_fifo_1; // t1[0](1, 0) @ unroll_index=63
compute_t0_unrolled:
for(int32_t unroll_index = 0; unroll_index < UNROLL_FACTOR; ++unroll_index)
{
#pragma HLS unroll
#pragma HLS latency min=1
float& load_t1_for_t0_chan_0_at_1_0 = points_from_t1_to_t0_chan_0[unroll_index][0];
float& load_t1_for_t0_chan_0_at_0_1 = points_from_t1_to_t0_chan_0[unroll_index][1];
float& load_t1_for_t0_chan_0_at_1_1 = points_from_t1_to_t0_chan_0[unroll_index][2];
float& load_t1_for_t0_chan_0_at_2_1 = points_from_t1_to_t0_chan_0[unroll_index][3];
float& load_t1_for_t0_chan_0_at_1_2 = points_from_t1_to_t0_chan_0[unroll_index][4];
float result_chan_0;
float assign_0 = load_t1_for_t0_chan_0_at_1_2;
float assign_1 = load_t1_for_t0_chan_0_at_2_1;
float assign_2[1];
#pragma HLS resource variable=assign_2 latency=1 core=RAM_2P_LUTRAM
{
#pragma HLS latency min=1
assign_2[0] = assign_0 + assign_1;
}
float assign_3 = assign_2[0];
float assign_4 = load_t1_for_t0_chan_0_at_1_1;
float assign_5[1];
#pragma HLS resource variable=assign_5 latency=1 core=RAM_2P_LUTRAM
{
#pragma HLS latency min=1
assign_5[0] = assign_3 + assign_4;
}
float assign_6 = assign_5[0];
float assign_7 = load_t1_for_t0_chan_0_at_1_0;
float assign_8[1];
#pragma HLS resource variable=assign_8 latency=1 core=RAM_2P_LUTRAM
{
#pragma HLS latency min=1
assign_8[0] = assign_6 + assign_7;
}
float assign_9 = assign_8[0];
float assign_10 = load_t1_for_t0_chan_0_at_0_1;
float assign_11[1];
#pragma HLS resource variable=assign_11 latency=1 core=RAM_2P_LUTRAM
{
#pragma HLS latency min=1
assign_11[0] = assign_9 + assign_10;
}
float assign_12 = assign_11[0];
float assign_13 = (assign_12);
float assign_14 = 0.2f;
float assign_15[1];
#pragma HLS resource variable=assign_15 latency=1 core=RAM_2P_LUTRAM
{
#pragma HLS latency min=10
assign_15[0] = assign_13 * assign_14;
}
float assign_16 = assign_15[0];
result_chan_0 = assign_16;
buffer_t0_chan_0[unroll_index] = result_chan_0;
} // unroll_index
// move reuse chain 0 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[125][FIFO_125_t1_ptr] = FF_t1_chan_0[0];
}
{
#pragma HLS latency min=1
FF_t1_chan_0[0] = FIFO_124_t1_chan_0_fifo_0;
}
{
#pragma HLS latency min=1
FIFO_124_t1_chan_0[0][FIFO_124_t1_ptr] = buffer_t1_chan_0[0];
}
// move reuse chain 1 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[124][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_62;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[62][FIFO_125_t1_ptr] = buffer_t1_chan_0[1];
}
// move reuse chain 2 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[123][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_61;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[61][FIFO_125_t1_ptr] = buffer_t1_chan_0[2];
}
// move reuse chain 3 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[122][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_60;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[60][FIFO_125_t1_ptr] = buffer_t1_chan_0[3];
}
// move reuse chain 4 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[121][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_59;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[59][FIFO_125_t1_ptr] = buffer_t1_chan_0[4];
}
// move reuse chain 5 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[120][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_58;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[58][FIFO_125_t1_ptr] = buffer_t1_chan_0[5];
}
// move reuse chain 6 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[119][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_57;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[57][FIFO_125_t1_ptr] = buffer_t1_chan_0[6];
}
// move reuse chain 7 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[118][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_56;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[56][FIFO_125_t1_ptr] = buffer_t1_chan_0[7];
}
// move reuse chain 8 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[117][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_55;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[55][FIFO_125_t1_ptr] = buffer_t1_chan_0[8];
}
// move reuse chain 9 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[116][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_54;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[54][FIFO_125_t1_ptr] = buffer_t1_chan_0[9];
}
// move reuse chain 10 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[115][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_53;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[53][FIFO_125_t1_ptr] = buffer_t1_chan_0[10];
}
// move reuse chain 11 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[114][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_52;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[52][FIFO_125_t1_ptr] = buffer_t1_chan_0[11];
}
// move reuse chain 12 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[113][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_51;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[51][FIFO_125_t1_ptr] = buffer_t1_chan_0[12];
}
// move reuse chain 13 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[112][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_50;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[50][FIFO_125_t1_ptr] = buffer_t1_chan_0[13];
}
// move reuse chain 14 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[111][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_49;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[49][FIFO_125_t1_ptr] = buffer_t1_chan_0[14];
}
// move reuse chain 15 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[110][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_48;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[48][FIFO_125_t1_ptr] = buffer_t1_chan_0[15];
}
// move reuse chain 16 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[109][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_47;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[47][FIFO_125_t1_ptr] = buffer_t1_chan_0[16];
}
// move reuse chain 17 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[108][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_46;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[46][FIFO_125_t1_ptr] = buffer_t1_chan_0[17];
}
// move reuse chain 18 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[107][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_45;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[45][FIFO_125_t1_ptr] = buffer_t1_chan_0[18];
}
// move reuse chain 19 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[106][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_44;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[44][FIFO_125_t1_ptr] = buffer_t1_chan_0[19];
}
// move reuse chain 20 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[105][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_43;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[43][FIFO_125_t1_ptr] = buffer_t1_chan_0[20];
}
// move reuse chain 21 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[104][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_42;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[42][FIFO_125_t1_ptr] = buffer_t1_chan_0[21];
}
// move reuse chain 22 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[103][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_41;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[41][FIFO_125_t1_ptr] = buffer_t1_chan_0[22];
}
// move reuse chain 23 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[102][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_40;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[40][FIFO_125_t1_ptr] = buffer_t1_chan_0[23];
}
// move reuse chain 24 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[101][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_39;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[39][FIFO_125_t1_ptr] = buffer_t1_chan_0[24];
}
// move reuse chain 25 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[100][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_38;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[38][FIFO_125_t1_ptr] = buffer_t1_chan_0[25];
}
// move reuse chain 26 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[99][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_37;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[37][FIFO_125_t1_ptr] = buffer_t1_chan_0[26];
}
// move reuse chain 27 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[98][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_36;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[36][FIFO_125_t1_ptr] = buffer_t1_chan_0[27];
}
// move reuse chain 28 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[97][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_35;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[35][FIFO_125_t1_ptr] = buffer_t1_chan_0[28];
}
// move reuse chain 29 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[96][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_34;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[34][FIFO_125_t1_ptr] = buffer_t1_chan_0[29];
}
// move reuse chain 30 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[95][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_33;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[33][FIFO_125_t1_ptr] = buffer_t1_chan_0[30];
}
// move reuse chain 31 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[94][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_32;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[32][FIFO_125_t1_ptr] = buffer_t1_chan_0[31];
}
// move reuse chain 32 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[93][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_31;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[31][FIFO_125_t1_ptr] = buffer_t1_chan_0[32];
}
// move reuse chain 33 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[92][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_30;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[30][FIFO_125_t1_ptr] = buffer_t1_chan_0[33];
}
// move reuse chain 34 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[91][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_29;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[29][FIFO_125_t1_ptr] = buffer_t1_chan_0[34];
}
// move reuse chain 35 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[90][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_28;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[28][FIFO_125_t1_ptr] = buffer_t1_chan_0[35];
}
// move reuse chain 36 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[89][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_27;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[27][FIFO_125_t1_ptr] = buffer_t1_chan_0[36];
}
// move reuse chain 37 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[88][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_26;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[26][FIFO_125_t1_ptr] = buffer_t1_chan_0[37];
}
// move reuse chain 38 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[87][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_25;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[25][FIFO_125_t1_ptr] = buffer_t1_chan_0[38];
}
// move reuse chain 39 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[86][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_24;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[24][FIFO_125_t1_ptr] = buffer_t1_chan_0[39];
}
// move reuse chain 40 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[85][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_23;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[23][FIFO_125_t1_ptr] = buffer_t1_chan_0[40];
}
// move reuse chain 41 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[84][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_22;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[22][FIFO_125_t1_ptr] = buffer_t1_chan_0[41];
}
// move reuse chain 42 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[83][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_21;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[21][FIFO_125_t1_ptr] = buffer_t1_chan_0[42];
}
// move reuse chain 43 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[82][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_20;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[20][FIFO_125_t1_ptr] = buffer_t1_chan_0[43];
}
// move reuse chain 44 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[81][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_19;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[19][FIFO_125_t1_ptr] = buffer_t1_chan_0[44];
}
// move reuse chain 45 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[80][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_18;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[18][FIFO_125_t1_ptr] = buffer_t1_chan_0[45];
}
// move reuse chain 46 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[79][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_17;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[17][FIFO_125_t1_ptr] = buffer_t1_chan_0[46];
}
// move reuse chain 47 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[78][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_16;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[16][FIFO_125_t1_ptr] = buffer_t1_chan_0[47];
}
// move reuse chain 48 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[77][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_15;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[15][FIFO_125_t1_ptr] = buffer_t1_chan_0[48];
}
// move reuse chain 49 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[76][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_14;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[14][FIFO_125_t1_ptr] = buffer_t1_chan_0[49];
}
// move reuse chain 50 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[75][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_13;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[13][FIFO_125_t1_ptr] = buffer_t1_chan_0[50];
}
// move reuse chain 51 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[74][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_12;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[12][FIFO_125_t1_ptr] = buffer_t1_chan_0[51];
}
// move reuse chain 52 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[73][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_11;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[11][FIFO_125_t1_ptr] = buffer_t1_chan_0[52];
}
// move reuse chain 53 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[72][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_10;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[10][FIFO_125_t1_ptr] = buffer_t1_chan_0[53];
}
// move reuse chain 54 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[71][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_9;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[9][FIFO_125_t1_ptr] = buffer_t1_chan_0[54];
}
// move reuse chain 55 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[70][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_8;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[8][FIFO_125_t1_ptr] = buffer_t1_chan_0[55];
}
// move reuse chain 56 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[69][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_7;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[7][FIFO_125_t1_ptr] = buffer_t1_chan_0[56];
}
// move reuse chain 57 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[68][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_6;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[6][FIFO_125_t1_ptr] = buffer_t1_chan_0[57];
}
// move reuse chain 58 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[67][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_5;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[5][FIFO_125_t1_ptr] = buffer_t1_chan_0[58];
}
// move reuse chain 59 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[66][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_4;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[4][FIFO_125_t1_ptr] = buffer_t1_chan_0[59];
}
// move reuse chain 60 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[65][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_3;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[3][FIFO_125_t1_ptr] = buffer_t1_chan_0[60];
}
// move reuse chain 61 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[64][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_2;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[2][FIFO_125_t1_ptr] = buffer_t1_chan_0[61];
}
// move reuse chain 62 for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[63][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_1;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[1][FIFO_125_t1_ptr] = buffer_t1_chan_0[62];
}
// move reuse chain 63 for buffer t1
{
#pragma HLS latency min=1
FIFO_124_t1_chan_0[1][FIFO_124_t1_ptr] = FF_t1_chan_0[1];
}
{
#pragma HLS latency min=1
FF_t1_chan_0[1] = FIFO_125_t1_chan_0_fifo_0;
}
{
#pragma HLS latency min=1
FIFO_125_t1_chan_0[0][FIFO_125_t1_ptr] = buffer_t1_chan_0[63];
}
// move FIFO ptrs for buffer t1
{
#pragma HLS latency min=1
FIFO_125_t1_ptr = FIFO_125_t1_ptr==uint8_t(125-1) ? 0 : FIFO_125_t1_ptr+1;
}
{
#pragma HLS latency min=1
FIFO_124_t1_ptr = FIFO_124_t1_ptr==uint8_t(124-1) ? 0 : FIFO_124_t1_ptr+1;
}
{
ap_uint<BURST_WIDTH> tmp_chan_0_bank_0, tmp_chan_0_bank_1, tmp_chan_0_bank_2, tmp_chan_0_bank_3;
store_coalesced:
for(int j = 0; j < BURST_WIDTH/32; ++j)
{
#pragma HLS unroll
float raw_bits_chan_0_bank_0 = buffer_t0_chan_0[BURST_WIDTH/32*4*0+j*4+0];
tmp_chan_0_bank_0((j+1)*32-1, j*32) = *(uint32_t*)(&raw_bits_chan_0_bank_0);
float raw_bits_chan_0_bank_1 = buffer_t0_chan_0[BURST_WIDTH/32*4*0+j*4+1];
tmp_chan_0_bank_1((j+1)*32-1, j*32) = *(uint32_t*)(&raw_bits_chan_0_bank_1);
float raw_bits_chan_0_bank_2 = buffer_t0_chan_0[BURST_WIDTH/32*4*0+j*4+2];
tmp_chan_0_bank_2((j+1)*32-1, j*32) = *(uint32_t*)(&raw_bits_chan_0_bank_2);
float raw_bits_chan_0_bank_3 = buffer_t0_chan_0[BURST_WIDTH/32*4*0+j*4+3];
tmp_chan_0_bank_3((j+1)*32-1, j*32) = *(uint32_t*)(&raw_bits_chan_0_bank_3);
}
to_chan_0_bank_0.write(tmp_chan_0_bank_0);
to_chan_0_bank_1.write(tmp_chan_0_bank_1);
to_chan_0_bank_2.write(tmp_chan_0_bank_2);
to_chan_0_bank_3.write(tmp_chan_0_bank_3);
}
}
}
| 72,215
| 39,360
|
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2021 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* DoFFamilyPolicyMng.cc (C) 2000-2016 */
/* */
/* Gestionnaire des politiques d'une famille de DoF. */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
#include "arcane/utils/NotSupportedException.h"
#include "arcane/mesh/ItemFamilyPolicyMng.h"
#include "arcane/mesh/ItemFamilyCompactPolicy.h"
#include "arcane/mesh/ItemFamilySerializer.h"
#include "arcane/mesh/IndirectItemFamilySerializer.h"
#include "arcane/mesh/DoFFamily.h"
#include "arcane/mesh/DynamicMesh.h"
#include "arcane/mesh/DynamicMeshIncrementalBuilder.h"
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
ARCANE_BEGIN_NAMESPACE
ARCANE_MESH_BEGIN_NAMESPACE
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
class DoFFamilyCompactPolicy
: public ItemFamilyCompactPolicy
{
public:
DoFFamilyCompactPolicy(ItemFamily* family) : ItemFamilyCompactPolicy(family){}
public:
void updateInternalReferences(IMeshCompacter* compacter) override
{
// Pour l'instant ne fait rien car c'est la famille source qui gère la
// mise à jour dans ItemFamily::beginCompactItems().
ARCANE_UNUSED(compacter);
}
};
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!
* \brief Gestionnaire des politiques d'une famille de DoF.
*/
class ARCANE_MESH_EXPORT DoFFamilyPolicyMng
: public ItemFamilyPolicyMng
{
public:
DoFFamilyPolicyMng(DoFFamily* family)
: ItemFamilyPolicyMng(family,new DoFFamilyCompactPolicy(family))
, m_family(family){}
public:
IItemFamilySerializer* createSerializer(bool use_flags) override
{
if (use_flags)
throw NotSupportedException(A_FUNCINFO,"serialisation with 'use_flags==true'");
IMesh* mesh = m_family->mesh();
DynamicMesh* dmesh = ARCANE_CHECK_POINTER(dynamic_cast<DynamicMesh*>(mesh));
return new ItemFamilySerializer(m_family, m_family, dmesh->incrementalBuilder());
//return new IndirectItemFamilySerializer(m_family);
}
private:
DoFFamily* m_family;
};
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
extern "C++" ARCANE_MESH_EXPORT IItemFamilyPolicyMng*
createDoFFamilyPolicyMng(ItemFamily* family)
{
DoFFamily* f = ARCANE_CHECK_POINTER(dynamic_cast<DoFFamily*>(family));
return new DoFFamilyPolicyMng(f);
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
ARCANE_MESH_END_NAMESPACE
ARCANE_END_NAMESPACE
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
| 3,867
| 1,021
|
// Copyright (c) YugaByte, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations
// under the License.
//
#include <algorithm>
#include <memory>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include "yb/common/hybrid_time.h"
#include "yb/common/redis_protocol.pb.h"
#include "yb/common/transaction.h"
#include "yb/docdb/conflict_resolution.h"
#include "yb/docdb/docdb-internal.h"
#include "yb/docdb/docdb.h"
#include "yb/docdb/docdb.pb.h"
#include "yb/docdb/docdb_compaction_filter.h"
#include "yb/docdb/docdb_rocksdb_util.h"
#include "yb/docdb/docdb_util.h"
#include "yb/docdb/intent.h"
#include "yb/docdb/intent_aware_iterator.h"
#include "yb/docdb/shared_lock_manager.h"
#include "yb/docdb/subdocument.h"
#include "yb/docdb/value.h"
#include "yb/docdb/value_type.h"
#include "yb/gutil/strings/substitute.h"
#include "yb/rocksutil/write_batch_formatter.h"
#include "yb/rocksutil/yb_rocksdb.h"
#include "yb/server/hybrid_clock.h"
#include "yb/util/bytes_formatter.h"
#include "yb/util/date_time.h"
#include "yb/util/enums.h"
#include "yb/util/logging.h"
#include "yb/util/status.h"
#include "yb/util/metrics.h"
using std::endl;
using std::list;
using std::string;
using std::stringstream;
using std::unique_ptr;
using std::shared_ptr;
using std::stack;
using std::vector;
using std::make_shared;
using yb::HybridTime;
using yb::util::FormatBytesAsStr;
using yb::FormatRocksDBSliceAsStr;
using strings::Substitute;
namespace yb {
namespace docdb {
namespace {
constexpr size_t kMaxWordsPerEncodedHybridTimeWithValueType =
((kMaxBytesPerEncodedHybridTime + 1) + sizeof(size_t) - 1) / sizeof(size_t);
// Main intent data::
// Prefix + DocPath + IntentType + DocHybridTime -> TxnId + value of the intent
// Reverse index by txn id:
// Prefix + TxnId + DocHybridTime -> Main intent data key
//
// Expects that last entry of key is DocHybridTime.
void AddIntent(
const TransactionId& transaction_id,
const SliceParts& key,
const SliceParts& value,
rocksdb::WriteBatch* rocksdb_write_batch) {
char reverse_key_prefix[1] = { ValueTypeAsChar::kTransactionId };
size_t doc_ht_buffer[kMaxWordsPerEncodedHybridTimeWithValueType];
auto doc_ht_slice = key.parts[key.num_parts - 1];
memcpy(doc_ht_buffer, doc_ht_slice.data(), doc_ht_slice.size());
for (size_t i = 0; i != kMaxWordsPerEncodedHybridTimeWithValueType; ++i) {
doc_ht_buffer[i] = ~doc_ht_buffer[i];
}
doc_ht_slice = Slice(pointer_cast<char*>(doc_ht_buffer), doc_ht_slice.size());
std::array<Slice, 3> reverse_key = {{
Slice(reverse_key_prefix, sizeof(reverse_key_prefix)),
Slice(transaction_id.data, transaction_id.size()),
doc_ht_slice,
}};
rocksdb_write_batch->Put(key, value);
rocksdb_write_batch->Put(reverse_key, key);
}
void ApplyIntent(const string& lock_string,
const IntentType intent,
KeyToIntentTypeMap *keys_locked) {
auto itr = keys_locked->find(lock_string);
if (itr == keys_locked->end()) {
keys_locked->emplace(lock_string, intent);
} else {
itr->second = SharedLockManager::CombineIntents(itr->second, intent);
}
}
} // namespace
const SliceKeyBound& SliceKeyBound::Invalid() {
static SliceKeyBound result;
return result;
}
const IndexBound& IndexBound::Empty() {
static IndexBound result;
return result;
}
void PrepareDocWriteOperation(const vector<unique_ptr<DocOperation>>& doc_write_ops,
const scoped_refptr<Histogram>& write_lock_latency,
IsolationLevel isolation_level,
SharedLockManager *lock_manager,
LockBatch *keys_locked,
bool *need_read_snapshot) {
KeyToIntentTypeMap key_to_lock_type;
*need_read_snapshot = false;
for (const unique_ptr<DocOperation>& doc_op : doc_write_ops) {
list<DocPath> doc_paths;
IsolationLevel level;
doc_op->GetDocPathsToLock(&doc_paths, &level);
if (isolation_level != IsolationLevel::NON_TRANSACTIONAL) {
level = isolation_level;
}
const IntentTypePair intent_types = GetWriteIntentsForIsolationLevel(level);
for (const auto& doc_path : doc_paths) {
KeyBytes current_prefix = doc_path.encoded_doc_key();
for (int i = 0; i < doc_path.num_subkeys(); i++) {
ApplyIntent(current_prefix.AsStringRef(), intent_types.weak, &key_to_lock_type);
doc_path.subkey(i).AppendToKey(¤t_prefix);
}
ApplyIntent(current_prefix.AsStringRef(), intent_types.strong, &key_to_lock_type);
}
if (doc_op->RequireReadSnapshot()) {
*need_read_snapshot = true;
}
}
const MonoTime start_time = (write_lock_latency != nullptr) ? MonoTime::Now() : MonoTime();
*keys_locked = LockBatch(lock_manager, std::move(key_to_lock_type));
if (write_lock_latency != nullptr) {
const MonoDelta elapsed_time = MonoTime::Now().GetDeltaSince(start_time);
write_lock_latency->Increment(elapsed_time.ToMicroseconds());
}
}
Status SetDocOpQLErrorResponse(DocOperation* doc_op, std::string err_msg) {
switch (doc_op->OpType()) {
case DocOperation::Type::QL_WRITE_OPERATION: {
const auto &resp = down_cast<QLWriteOperation *>(doc_op)->response();
resp->set_status(QLResponsePB::YQL_STATUS_SQL_ERROR);
resp->set_error_message(err_msg);
break;
}
case DocOperation::Type::PGSQL_WRITE_OPERATION: {
const auto &resp = down_cast<PgsqlWriteOperation *>(doc_op)->response();
resp->set_status(PgsqlResponsePB::PGSQL_STATUS_USAGE_ERROR);
resp->set_error_message(err_msg);
break;
}
default:
return STATUS_FORMAT(InternalError,
"Invalid status (QLError) for doc operation %d",
doc_op->OpType());
}
return Status::OK();
}
Status ExecuteDocWriteOperation(const vector<unique_ptr<DocOperation>>& doc_write_ops,
MonoTime deadline,
const ReadHybridTime& read_time,
const DocDB& doc_db,
KeyValueWriteBatchPB* write_batch,
InitMarkerBehavior init_marker_behavior,
std::atomic<int64_t>* monotonic_counter,
HybridTime* restart_read_ht) {
DCHECK_ONLY_NOTNULL(restart_read_ht);
DocWriteBatch doc_write_batch(doc_db, init_marker_behavior, monotonic_counter);
DocOperationApplyData data = {&doc_write_batch, deadline, read_time, restart_read_ht};
for (const unique_ptr<DocOperation>& doc_op : doc_write_ops) {
Status s = doc_op->Apply(data);
if (s.IsQLError()) {
// Ensure we set appropriate error in the response object for QL errors.
SetDocOpQLErrorResponse(doc_op.get(), s.message().ToBuffer());
continue;
}
RETURN_NOT_OK(s);
}
doc_write_batch.MoveToWriteBatchPB(write_batch);
return Status::OK();
}
void PrepareNonTransactionWriteBatch(
const KeyValueWriteBatchPB& put_batch,
HybridTime hybrid_time,
rocksdb::WriteBatch* rocksdb_write_batch) {
DocHybridTimeBuffer doc_ht_buffer;
for (int write_id = 0; write_id < put_batch.kv_pairs_size(); ++write_id) {
const auto& kv_pair = put_batch.kv_pairs(write_id);
CHECK(!kv_pair.key().empty());
CHECK(!kv_pair.value().empty());
#ifndef NDEBUG
// Debug-only: ensure all keys we get in Raft replication can be decoded.
{
SubDocKey subdoc_key;
Status s = subdoc_key.FullyDecodeFromKeyWithOptionalHybridTime(kv_pair.key());
CHECK(s.ok())
<< "Failed decoding key: " << s.ToString() << "; "
<< "Problematic key: " << BestEffortDocDBKeyToStr(KeyBytes(kv_pair.key())) << "\n"
<< "value: " << util::FormatBytesAsStr(kv_pair.value()) << "\n"
<< "put_batch:\n" << put_batch.DebugString();
}
#endif
// We replicate encoded SubDocKeys without a HybridTime at the end, and only append it here.
// The reason for this is that the HybridTime timestamp is only picked at the time of
// appending an entry to the tablet's Raft log. Also this is a good way to save network
// bandwidth.
//
// "Write id" is the final component of our HybridTime encoding (or, to be more precise,
// DocHybridTime encoding) that helps disambiguate between different updates to the
// same key (row/column) within a transaction. We set it based on the position of the write
// operation in its write batch.
std::array<Slice, 2> key_parts = {{
Slice(kv_pair.key()),
doc_ht_buffer.EncodeWithValueType(hybrid_time, write_id),
}};
Slice key_value = kv_pair.value();
rocksdb_write_batch->Put(key_parts, { &key_value, 1 });
}
}
CHECKED_STATUS EnumerateIntents(
const google::protobuf::RepeatedPtrField<KeyValuePairPB> &kv_pairs,
boost::function<Status(IntentKind, Slice, KeyBytes*)> functor) {
KeyBytes encoded_key;
for (int index = 0; index < kv_pairs.size(); ++index) {
const auto &kv_pair = kv_pairs.Get(index);
CHECK(!kv_pair.key().empty());
CHECK(!kv_pair.value().empty());
Slice key = kv_pair.key();
auto key_size = DocKey::EncodedSize(key, DocKeyPart::WHOLE_DOC_KEY);
CHECK_OK(key_size);
encoded_key.Clear();
encoded_key.AppendRawBytes(key.cdata(), *key_size);
key.remove_prefix(*key_size);
for (;;) {
auto subkey_begin = key.cdata();
auto decode_result = SubDocKey::DecodeSubkey(&key);
CHECK_OK(decode_result);
if (!decode_result.get()) {
break;
}
RETURN_NOT_OK(functor(IntentKind::kWeak, Slice(), &encoded_key));
encoded_key.AppendRawBytes(subkey_begin, key.cdata() - subkey_begin);
}
RETURN_NOT_OK(functor(IntentKind::kStrong, kv_pair.value(), &encoded_key));
}
return Status::OK();
}
class PrepareTransactionWriteBatchHelper {
public:
PrepareTransactionWriteBatchHelper(const PrepareTransactionWriteBatchHelper&) = delete;
void operator=(const PrepareTransactionWriteBatchHelper&) = delete;
// `rocksdb_write_batch` - in-out parameter is filled by this prepare.
PrepareTransactionWriteBatchHelper(HybridTime hybrid_time,
rocksdb::WriteBatch* rocksdb_write_batch,
const TransactionId& transaction_id,
IsolationLevel isolation_level,
IntraTxnWriteId* intra_txn_write_id)
: hybrid_time_(hybrid_time),
rocksdb_write_batch_(rocksdb_write_batch),
transaction_id_(transaction_id),
intent_types_(GetWriteIntentsForIsolationLevel(isolation_level)),
intra_txn_write_id_(intra_txn_write_id) {
}
// Using operator() to pass this object conveniently to EnumerateIntents.
CHECKED_STATUS operator()(IntentKind intent_kind, Slice value_slice, KeyBytes* key) {
if (intent_kind == IntentKind::kWeak) {
weak_intents_.insert(key->data());
return Status::OK();
}
const auto transaction_value_type = ValueTypeAsChar::kTransactionId;
const auto write_id_value_type = ValueTypeAsChar::kWriteId;
IntraTxnWriteId big_endian_write_id = BigEndian::FromHost32(*intra_txn_write_id_);
std::array<Slice, 5> value = {{
Slice(&transaction_value_type, 1),
Slice(transaction_id_.data, transaction_id_.size()),
Slice(&write_id_value_type, 1),
Slice(pointer_cast<char*>(&big_endian_write_id), sizeof(big_endian_write_id)),
value_slice
}};
++*intra_txn_write_id_;
char intent_type[2] = { ValueTypeAsChar::kIntentType, static_cast<char>(intent_types_.strong) };
DocHybridTimeBuffer doc_ht_buffer;
std::array<Slice, 3> key_parts = {{
key->AsSlice(),
Slice(intent_type, 2),
doc_ht_buffer.EncodeWithValueType(hybrid_time_, write_id_++),
}};
AddIntent(transaction_id_, key_parts, value, rocksdb_write_batch_);
return Status::OK();
}
void Finish() {
char transaction_id_value_type = ValueTypeAsChar::kTransactionId;
char intent_type[2] = { ValueTypeAsChar::kIntentType, static_cast<char>(intent_types_.weak) };
DocHybridTimeBuffer doc_ht_buffer;
std::array<Slice, 2> value = {{
Slice(&transaction_id_value_type, 1),
Slice(transaction_id_.data, transaction_id_.size()),
}};
for (const auto& intent : weak_intents_) {
std::array<Slice, 3> key = {{
Slice(intent),
Slice(intent_type, 2),
doc_ht_buffer.EncodeWithValueType(hybrid_time_, write_id_++),
}};
AddIntent(transaction_id_, key, value, rocksdb_write_batch_);
}
}
private:
// TODO(dtxn) weak & strong intent in one batch.
// TODO(dtxn) extract part of code knowning about intents structure to lower level.
HybridTime hybrid_time_;
rocksdb::WriteBatch* rocksdb_write_batch_;
const TransactionId& transaction_id_;
IntentTypePair intent_types_;
std::unordered_set<std::string> weak_intents_;
IntraTxnWriteId write_id_ = 0;
IntraTxnWriteId* intra_txn_write_id_;
};
// We have the following distinct types of data in this "intent store":
// Main intent data:
// Prefix + SubDocKey (no HybridTime) + IntentType + HybridTime -> TxnId + value of the intent
// Transaction metadata
// TxnId -> status tablet id + isolation level
// Reverse index by txn id
// TxnId + HybridTime -> Main intent data key
//
// Where prefix is just a single byte prefix. TxnId, IntentType, HybridTime all prefixed with
// appropriate value type.
void PrepareTransactionWriteBatch(
const KeyValueWriteBatchPB& put_batch,
HybridTime hybrid_time,
rocksdb::WriteBatch* rocksdb_write_batch,
const TransactionId& transaction_id,
IsolationLevel isolation_level,
IntraTxnWriteId* write_id) {
VLOG(4) << "PrepareTransactionWriteBatch(), write_id = " << *write_id;
PrepareTransactionWriteBatchHelper helper(
hybrid_time, rocksdb_write_batch, transaction_id, isolation_level, write_id);
// We cannot recover from failures here, because it means that we cannot apply replicated
// operation.
CHECK_OK(EnumerateIntents(put_batch.kv_pairs(), std::ref(helper)));
helper.Finish();
}
// ------------------------------------------------------------------------------------------------
// Standalone functions
// ------------------------------------------------------------------------------------------------
namespace {
void SeekToLowerBound(const SliceKeyBound& lower_bound, IntentAwareIterator* iter) {
if (lower_bound.is_exclusive()) {
iter->SeekPastSubKey(lower_bound.key());
} else {
iter->SeekForward(lower_bound.key());
}
}
// This function does not assume that object init_markers are present. If no init marker is present,
// or if a tombstone is found at some level, it still looks for subkeys inside it if they have
// larger timestamps.
//
// TODO(akashnil): ENG-1152: If object init markers were required, this read path may be optimized.
// We look at all rocksdb keys with prefix = subdocument_key, and construct a subdocument out of
// them, between the timestamp range high_ts and low_ts.
//
// The iterator is expected to be placed at the smallest key that is subdocument_key or later, and
// after the function returns, the iterator should be placed just completely outside the
// subdocument_key prefix. Although if high_subkey is specified, the iterator is only guaranteed
// to be positioned after the high_subkey and not necessarily outside the subdocument_key prefix.
// num_values_observed is used for queries on indices, and keeps track of the number of primitive
// values observed thus far. In a query with lower index bound k, ignore the first k primitive
// values before building the subdocument.
CHECKED_STATUS BuildSubDocument(
IntentAwareIterator* iter,
const GetSubDocumentData& data,
DocHybridTime low_ts,
int64* num_values_observed) {
VLOG(3) << "BuildSubDocument data: " << data << " read_time: " << iter->read_time()
<< " low_ts: " << low_ts;
while (iter->valid()) {
// Since we modify num_values_observed on recursive calls, we keep a local copy of the value.
int64 current_values_observed = *num_values_observed;
DocHybridTime write_time;
auto key = VERIFY_RESULT(iter->FetchKey(&write_time));
VLOG(4) << "iter: " << SubDocKey::DebugSliceToString(key)
<< ", key: " << SubDocKey::DebugSliceToString(data.subdocument_key);
DCHECK(key.starts_with(data.subdocument_key))
<< "iter: " << SubDocKey::DebugSliceToString(key)
<< ", key: " << SubDocKey::DebugSliceToString(data.subdocument_key);
// Key could be invalidated because we could move iterator, so back it up.
KeyBytes key_copy(key);
key = key_copy.AsSlice();
rocksdb::Slice value = iter->value();
// Checking that IntentAwareIterator returns an entry with correct time.
DCHECK_GE(iter->read_time().global_limit, write_time.hybrid_time())
<< "Found key: " << SubDocKey::DebugSliceToString(key);
if (low_ts > write_time) {
VLOG(3) << "SeekPastSubKey: " << SubDocKey::DebugSliceToString(key);
iter->SeekPastSubKey(key);
continue;
}
Value doc_value;
RETURN_NOT_OK(doc_value.Decode(value));
ValueType value_type = doc_value.value_type();
if (key == data.subdocument_key) {
if (write_time == DocHybridTime::kMin)
return STATUS(Corruption, "No hybrid timestamp found on entry");
// We may need to update the TTL in individual columns.
if (write_time.hybrid_time() >= data.exp.write_ht) {
// We want to keep the default TTL otherwise.
if (doc_value.ttl() != Value::kMaxTtl) {
data.exp.write_ht = write_time.hybrid_time();
data.exp.ttl = doc_value.ttl();
} else if (data.exp.ttl.IsNegative()) {
data.exp.ttl = -data.exp.ttl;
}
}
// If the hybrid time is kMin, then we must be using default TTL.
if (data.exp.write_ht == HybridTime::kMin) {
data.exp.write_ht = write_time.hybrid_time();
}
bool has_expired;
CHECK_OK(HasExpiredTTL(data.exp.write_ht, data.exp.ttl,
iter->read_time().read, &has_expired));
// Treat an expired value as a tombstone written at the same time as the original value.
if (has_expired) {
doc_value = Value::Tombstone();
value_type = ValueType::kTombstone;
}
const bool is_collection = IsCollectionType(value_type);
// We have found some key that matches our entire subdocument_key, i.e. we didn't skip ahead
// to a lower level key (with optional object init markers).
if (is_collection || value_type == ValueType::kTombstone) {
if (low_ts < write_time) {
low_ts = write_time;
}
if (is_collection) {
*data.result = SubDocument(value_type);
}
// If the subkey lower bound filters out the key we found, we want to skip to the lower
// bound. If it does not, we want to seek to the next key. This prevents an infinite loop
// where the iterator keeps seeking to itself if the key we found matches the low subkey.
// TODO: why are not we doing this for arrays?
if (IsObjectType(value_type) && !data.low_subkey->CanInclude(key)) {
// Try to seek to the low_subkey for efficiency.
SeekToLowerBound(*data.low_subkey, iter);
} else {
VLOG(3) << "SeekPastSubKey: " << SubDocKey::DebugSliceToString(key);
iter->SeekPastSubKey(key);
}
continue;
} else {
if (!IsPrimitiveValueType(value_type)) {
return STATUS_FORMAT(Corruption,
"Expected primitive value type, got $0", value_type);
}
DCHECK_GE(iter->read_time().global_limit, write_time.hybrid_time());
// TODO: the ttl_seconds in primitive value is currently only in use for CQL. At some
// point streamline by refactoring CQL to use the mutable Expiration in GetSubDocumentData.
if (data.exp.ttl == Value::kMaxTtl) {
doc_value.mutable_primitive_value()->SetTtl(-1);
} else {
int64_t time_since_write_seconds = (
server::HybridClock::GetPhysicalValueMicros(iter->read_time().read) -
server::HybridClock::GetPhysicalValueMicros(write_time.hybrid_time())) /
MonoTime::kMicrosecondsPerSecond;
int64_t ttl_seconds = std::max(static_cast<int64_t>(0),
data.exp.ttl.ToMilliseconds() /
MonoTime::kMillisecondsPerSecond - time_since_write_seconds);
doc_value.mutable_primitive_value()->SetTtl(ttl_seconds);
}
// Choose the user supplied timestamp if present.
const UserTimeMicros user_timestamp = doc_value.user_timestamp();
doc_value.mutable_primitive_value()->SetWriteTime(
user_timestamp == Value::kInvalidUserTimestamp
? write_time.hybrid_time().GetPhysicalValueMicros()
: doc_value.user_timestamp());
if (!data.high_index->CanInclude(current_values_observed)) {
iter->SeekOutOfSubDoc(&key_copy);
return Status::OK();
}
if (data.low_index->CanInclude(*num_values_observed)) {
*data.result = SubDocument(doc_value.primitive_value());
}
(*num_values_observed)++;
VLOG(3) << "SeekOutOfSubDoc: " << SubDocKey::DebugSliceToString(key);
iter->SeekOutOfSubDoc(&key_copy);
return Status::OK();
}
}
SubDocument descendant{PrimitiveValue(ValueType::kInvalid)};
// TODO: what if the key we found is the same as before?
// We'll get into an infinite recursion then.
{
IntentAwareIteratorPrefixScope prefix_scope(key, iter);
RETURN_NOT_OK(BuildSubDocument(
iter, data.Adjusted(key, &descendant), low_ts,
num_values_observed));
}
if (descendant.value_type() == ValueType::kInvalid) {
// The document was not found in this level (maybe a tombstone was encountered).
continue;
}
if (!data.low_subkey->CanInclude(key)) {
VLOG(3) << "Filtered by low_subkey: " << data.low_subkey->ToString()
<< ", key: " << SubDocKey::DebugSliceToString(key);
// The value provided is lower than what we are looking for, seek to the lower bound.
SeekToLowerBound(*data.low_subkey, iter);
continue;
}
// We use num_values_observed as a conservative figure for lower bound and
// current_values_observed for upper bound so we don't lose any data we should be including.
if (!data.low_index->CanInclude(*num_values_observed)) {
continue;
}
if (!data.high_subkey->CanInclude(key)) {
VLOG(3) << "Filtered by high_subkey: " << data.high_subkey->ToString()
<< ", key: " << SubDocKey::DebugSliceToString(key);
// We have encountered a subkey higher than our constraints, we should stop here.
return Status::OK();
}
if (!data.high_index->CanInclude(current_values_observed)) {
return Status::OK();
}
if (!IsObjectType(data.result->value_type())) {
*data.result = SubDocument();
}
SubDocument* current = data.result;
size_t num_children;
RETURN_NOT_OK(current->NumChildren(&num_children));
if (data.limit != 0 && num_children >= data.limit) {
// We have processed enough records.
return Status::OK();
}
if (data.count_only) {
// We need to only count the records that we found.
data.record_count++;
} else {
Slice temp = key;
temp.remove_prefix(data.subdocument_key.size());
for (;;) {
PrimitiveValue child;
RETURN_NOT_OK(child.DecodeFromKey(&temp));
if (temp.empty()) {
current->SetChild(child, std::move(descendant));
break;
}
current = current->GetOrAddChild(child).first;
}
}
}
return Status::OK();
}
} // namespace
yb::Status FindLastWriteTime(
IntentAwareIterator* iter,
const Slice& key_without_ht,
DocHybridTime* max_overwrite_time,
Expiration* exp,
Value* result_value) {
Slice value;
DocHybridTime doc_ht = *max_overwrite_time;
RETURN_NOT_OK(iter->FindLatestRecord(key_without_ht, &doc_ht, &value));
if (!iter->valid()) {
return Status::OK();
}
uint64_t merge_flags = 0;
MonoDelta ttl;
ValueType value_type;
RETURN_NOT_OK(Value::DecodePrimitiveValueType(value, &value_type, &merge_flags, &ttl));
if (value_type == ValueType::kInvalid) {
return Status::OK();
}
// We update the expiration if and only if the write time is later than the write time
// currently stored in expiration, and the record is not a regular record with default TTL.
// This is done independently of whether the row is a TTL row.
// In the case that the always_override flag is true, default TTL will not be preserved.
Expiration new_exp = *exp;
if (doc_ht.hybrid_time() >= exp->write_ht) {
// We want to keep the default TTL otherwise.
if (ttl != Value::kMaxTtl || merge_flags == Value::kTtlFlag || exp->always_override) {
new_exp.write_ht = doc_ht.hybrid_time();
new_exp.ttl = ttl;
} else if (exp->ttl.IsNegative()) {
new_exp.ttl = -new_exp.ttl;
}
}
// If we encounter a TTL row, we assign max_overwrite_time to be the write time of the
// original value/init marker.
if (merge_flags == Value::kTtlFlag) {
DocHybridTime new_ht;
RETURN_NOT_OK(iter->NextFullValue(&new_ht, &value));
// There could be a case where the TTL row exists, but the value has been
// compacted away. Then, it is treated as a Tombstone written at the time
// of the TTL row.
if (!iter->valid() && !new_exp.ttl.IsNegative()) {
new_exp.ttl = -new_exp.ttl;
} else {
ValueType value_type;
RETURN_NOT_OK(Value::DecodePrimitiveValueType(value, &value_type));
// Because we still do not know whether we are seeking something expired,
// we must take the max_overwrite_time as if the value were not expired.
doc_ht = new_ht;
}
}
if ((value_type == ValueType::kTombstone || value_type == ValueType::kInvalid) &&
!new_exp.ttl.IsNegative()) {
new_exp.ttl = -new_exp.ttl;
}
*exp = new_exp;
if (doc_ht > *max_overwrite_time) {
*max_overwrite_time = doc_ht;
VLOG(4) << "Max overwritten time for " << key_without_ht.ToDebugHexString() << ": "
<< *max_overwrite_time;
}
if (result_value)
RETURN_NOT_OK(result_value->Decode(value));
return Status::OK();
}
yb::Status GetSubDocument(
const DocDB& doc_db,
const GetSubDocumentData& data,
const rocksdb::QueryId query_id,
const TransactionOperationContextOpt& txn_op_context,
MonoTime deadline,
const ReadHybridTime& read_time) {
auto iter = CreateIntentAwareIterator(
doc_db, BloomFilterMode::USE_BLOOM_FILTER, data.subdocument_key, query_id,
txn_op_context, deadline, read_time);
return GetSubDocument(iter.get(), data, nullptr /* projection */, SeekFwdSuffices::kFalse);
}
yb::Status GetSubDocument(
IntentAwareIterator *db_iter,
const GetSubDocumentData& data,
const std::vector<PrimitiveValue>* projection,
const SeekFwdSuffices seek_fwd_suffices) {
// TODO(dtxn) scan through all involved first transactions to cache statuses in a batch,
// so during building subdocument we don't need to request them one by one.
// TODO(dtxn) we need to restart read with scan_ht = commit_ht if some transaction was committed
// at time commit_ht within [scan_ht; read_request_time + max_clock_skew). Also we need
// to wait until time scan_ht = commit_ht passed.
// TODO(dtxn) for each scanned key (and its subkeys) we need to avoid new values commits at
// ht <= scan_ht (or just ht < scan_ht?)
// Question: what will break if we allow later commit at ht <= scan_ht ? Need to write down
// detailed example.
*data.doc_found = false;
DOCDB_DEBUG_LOG("GetSubDocument for key $0 @ $1", data.subdocument_key.ToDebugHexString(),
db_iter->read_time().ToString());
// The latest time at which any prefix of the given key was overwritten.
DocHybridTime max_overwrite_ht(DocHybridTime::kMin);
VLOG(4) << "GetSubDocument(" << data << ")";
SubDocKey found_subdoc_key;
auto dockey_size =
VERIFY_RESULT(DocKey::EncodedSize(data.subdocument_key, DocKeyPart::WHOLE_DOC_KEY));
Slice key_slice(data.subdocument_key.data(), dockey_size);
IntentAwareIteratorPrefixScope prefix_scope(key_slice, db_iter);
if (seek_fwd_suffices) {
db_iter->SeekForward(key_slice);
} else {
db_iter->Seek(key_slice);
}
Value doc_value;
// Check ancestors for init markers, tombstones, and expiration, tracking
// the expiration and corresponding most recent write time in exp, and the
// the general most recent overwrite time in max_overwrite_ht
{
auto temp_key = data.subdocument_key;
temp_key.remove_prefix(dockey_size);
for (;;) {
auto decode_result = VERIFY_RESULT(SubDocKey::DecodeSubkey(&temp_key));
if (!decode_result) {
break;
}
RETURN_NOT_OK(FindLastWriteTime(db_iter, key_slice, &max_overwrite_ht, &data.exp));
key_slice = Slice(key_slice.data(), temp_key.data() - key_slice.data());
}
}
// By this point key_bytes is the encoded representation of the DocKey and all the subkeys of
// subdocument_key. Check for init-marker / tombstones at the top level, update max_overwrite_ht.
doc_value = Value(PrimitiveValue(ValueType::kInvalid));
RETURN_NOT_OK(FindLastWriteTime(db_iter, key_slice, &max_overwrite_ht, &data.exp, &doc_value));
const ValueType value_type = doc_value.value_type();
if (data.return_type_only) {
*data.doc_found = value_type != ValueType::kInvalid &&
!data.exp.ttl.IsNegative();
// Check for expiration.
if (*data.doc_found && max_overwrite_ht != DocHybridTime::kMin) {
bool has_expired;
CHECK_OK(HasExpiredTTL(data.exp.write_ht, data.exp.ttl,
db_iter->read_time().read, &has_expired));
*data.doc_found = !has_expired;
}
if (*data.doc_found) {
// Observe that this will have the right type but not necessarily the right value.
*data.result = SubDocument(doc_value.primitive_value());
}
return Status::OK();
}
if (projection == nullptr) {
*data.result = SubDocument(ValueType::kInvalid);
int64 num_values_observed = 0;
IntentAwareIteratorPrefixScope prefix_scope(key_slice, db_iter);
RETURN_NOT_OK(BuildSubDocument(db_iter, data, max_overwrite_ht,
&num_values_observed));
*data.doc_found = data.result->value_type() != ValueType::kInvalid;
if (*data.doc_found) {
if (value_type == ValueType::kRedisSet) {
RETURN_NOT_OK(data.result->ConvertToRedisSet());
} else if (value_type == ValueType::kRedisTS) {
RETURN_NOT_OK(data.result->ConvertToRedisTS());
} else if (value_type == ValueType::kRedisSortedSet) {
RETURN_NOT_OK(data.result->ConvertToRedisSortedSet());
} else if (value_type == ValueType::kRedisList) {
RETURN_NOT_OK(data.result->ConvertToRedisList());
}
}
return Status::OK();
}
// Seed key_bytes with the subdocument key. For each subkey in the projection, build subdocument
// and reuse key_bytes while appending the subkey.
*data.result = SubDocument();
KeyBytes key_bytes(data.subdocument_key);
const size_t subdocument_key_size = key_bytes.size();
for (const PrimitiveValue& subkey : *projection) {
// Append subkey to subdocument key. Reserve extra kMaxBytesPerEncodedHybridTime + 1 bytes in
// key_bytes to avoid the internal buffer from getting reallocated and moved by SeekForward()
// appending the hybrid time, thereby invalidating the buffer pointer saved by prefix_scope.
subkey.AppendToKey(&key_bytes);
key_bytes.Reserve(key_bytes.size() + kMaxBytesPerEncodedHybridTime + 1);
// This seek is to initialize the iterator for BuildSubDocument call.
IntentAwareIteratorPrefixScope prefix_scope(key_bytes, db_iter);
db_iter->SeekForward(&key_bytes);
SubDocument descendant(ValueType::kInvalid);
int64 num_values_observed = 0;
RETURN_NOT_OK(BuildSubDocument(
db_iter, data.Adjusted(key_bytes, &descendant), max_overwrite_ht,
&num_values_observed));
*data.doc_found = descendant.value_type() != ValueType::kInvalid;
data.result->SetChild(subkey, std::move(descendant));
// Restore subdocument key by truncating the appended subkey.
key_bytes.Truncate(subdocument_key_size);
}
// Make sure the iterator is placed outside the whole document in the end.
key_bytes.Truncate(dockey_size);
key_bytes.AppendValueType(ValueType::kMaxByte);
db_iter->SeekForward(&key_bytes);
return Status::OK();
}
// Note: Do not use if also retrieving other value, as some work will be repeated.
// Assumes every value has a TTL, and the TTL is stored in the row with this key.
// Also observe that tombstone checking only works because we assume the key has
// no ancestors.
yb::Status GetTtl(const Slice& encoded_subdoc_key,
IntentAwareIterator* iter,
bool* doc_found,
Expiration* exp) {
auto dockey_size =
VERIFY_RESULT(DocKey::EncodedSize(encoded_subdoc_key, DocKeyPart::WHOLE_DOC_KEY));
Slice key_slice(encoded_subdoc_key.data(), dockey_size);
iter->Seek(key_slice);
if (!iter->valid())
return Status::OK();
DocHybridTime doc_ht;
auto key = VERIFY_RESULT(iter->FetchKey(&doc_ht));
if ((*doc_found = (!key.compare(key_slice)))) {
Value doc_value = Value(PrimitiveValue(ValueType::kInvalid));
RETURN_NOT_OK(doc_value.Decode(iter->value()));
if (doc_value.value_type() == ValueType::kTombstone) {
*doc_found = false;
} else {
exp->ttl = doc_value.ttl();
exp->write_ht = doc_ht.hybrid_time();
}
}
return Status::OK();
}
// ------------------------------------------------------------------------------------------------
// Debug output
// ------------------------------------------------------------------------------------------------
namespace {
Result<std::string> DocDBKeyToDebugStr(Slice key_slice, StorageDbType db_type, KeyType* key_type) {
*key_type = GetKeyType(key_slice, db_type);
SubDocKey subdoc_key;
switch (*key_type) {
case KeyType::kIntentKey:
{
Slice intent_prefix;
IntentType intent_type;
DocHybridTime doc_ht;
RETURN_NOT_OK_PREPEND(
DecodeIntentKey(key_slice, &intent_prefix, &intent_type, &doc_ht),
"Error: failed decoding RocksDB intent key " + FormatRocksDBSliceAsStr(key_slice));
RETURN_NOT_OK(subdoc_key.FullyDecodeFromKeyWithOptionalHybridTime(intent_prefix));
return subdoc_key.ToString() + " " + ToString(intent_type) + " " + doc_ht.ToString();
}
case KeyType::kReverseTxnKey:
{
RETURN_NOT_OK(key_slice.consume_byte(ValueTypeAsChar::kTransactionId));
auto transaction_id = VERIFY_RESULT(DecodeTransactionId(&key_slice));
if (key_slice.empty() || key_slice.size() > kMaxBytesPerEncodedHybridTime + 1) {
return STATUS_FORMAT(
Corruption,
"Invalid doc hybrid time in reverse intent record, transaction id: $0, suffix: $1",
transaction_id, key_slice.ToDebugHexString());
}
size_t doc_ht_buffer[kMaxWordsPerEncodedHybridTimeWithValueType];
memcpy(doc_ht_buffer, key_slice.data(), key_slice.size());
for (size_t i = 0; i != kMaxWordsPerEncodedHybridTimeWithValueType; ++i) {
doc_ht_buffer[i] = ~doc_ht_buffer[i];
}
key_slice = Slice(pointer_cast<char*>(doc_ht_buffer), key_slice.size());
if (static_cast<ValueType>(key_slice[0]) != ValueType::kHybridTime) {
return STATUS_FORMAT(
Corruption,
"Invalid prefix of doc hybrid time in reverse intent record, transaction id: $0, "
"decoded suffix: $1",
transaction_id, key_slice.ToDebugHexString());
}
key_slice.consume_byte();
DocHybridTime doc_ht;
RETURN_NOT_OK(doc_ht.DecodeFrom(&key_slice));
return Format("TXN REV $0 $1", transaction_id, doc_ht);
}
case KeyType::kTransactionMetadata:
{
RETURN_NOT_OK(key_slice.consume_byte(ValueTypeAsChar::kTransactionId));
auto transaction_id = DecodeTransactionId(&key_slice);
RETURN_NOT_OK(transaction_id);
return Format("TXN META $0", *transaction_id);
}
case KeyType::kEmpty: FALLTHROUGH_INTENDED;
case KeyType::kValueKey:
RETURN_NOT_OK_PREPEND(
subdoc_key.FullyDecodeFrom(key_slice),
"Error: failed decoding RocksDB intent key " + FormatRocksDBSliceAsStr(key_slice));
return subdoc_key.ToString();
}
return STATUS_SUBSTITUTE(Corruption, "Corrupted KeyType: $0", yb::ToString(*key_type));
}
Result<std::string> DocDBValueToDebugStr(Slice value_slice, const KeyType& key_type) {
std::string prefix;
if (key_type == KeyType::kIntentKey) {
auto txn_id_res = VERIFY_RESULT(DecodeTransactionIdFromIntentValue(&value_slice));
prefix = Format("TransactionId($0) ", txn_id_res);
if (!value_slice.empty()) {
RETURN_NOT_OK(value_slice.consume_byte(ValueTypeAsChar::kWriteId));
if (value_slice.size() < sizeof(IntraTxnWriteId)) {
return STATUS_FORMAT(Corruption, "Not enought bytes for write id: $0", value_slice.size());
}
auto write_id = BigEndian::Load32(value_slice.data());
value_slice.remove_prefix(sizeof(write_id));
prefix += Format("WriteId($0) ", write_id);
}
}
// Empty values are allowed for weak intents.
if (!value_slice.empty() || key_type != KeyType::kIntentKey) {
Value v;
RETURN_NOT_OK_PREPEND(
v.Decode(value_slice),
Substitute("Error: failed to decode value $0", prefix));
return prefix + v.ToString();
} else {
return prefix + "none";
}
}
Result<std::string> DocDBValueToDebugStr(
KeyType key_type, const std::string& key_str, Slice value) {
switch (key_type) {
case KeyType::kTransactionMetadata: {
TransactionMetadataPB metadata_pb;
if (!metadata_pb.ParseFromArray(value.cdata(), value.size())) {
return STATUS_FORMAT(Corruption, "Bad metadata: $0", value.ToDebugHexString());
}
auto metadata = TransactionMetadata::FromPB(metadata_pb);
RETURN_NOT_OK(metadata);
return ToString(*metadata);
}
case KeyType::kReverseTxnKey: {
KeyType ignore_key_type;
return DocDBKeyToDebugStr(value, StorageDbType::kIntents, &ignore_key_type);
}
case KeyType::kEmpty: FALLTHROUGH_INTENDED;
case KeyType::kIntentKey: FALLTHROUGH_INTENDED;
case KeyType::kValueKey:
return DocDBValueToDebugStr(value, key_type);
}
FATAL_INVALID_ENUM_VALUE(KeyType, key_type);
}
void ProcessDumpEntry(Slice key, Slice value, IncludeBinary include_binary, StorageDbType db_type,
std::ostream* out) {
KeyType key_type;
Result<std::string> key_str = DocDBKeyToDebugStr(key, db_type, &key_type);
if (!key_str.ok()) {
*out << key_str.status() << endl;
return;
}
Result<std::string> value_str = DocDBValueToDebugStr(key_type, *key_str, value);
if (!value_str.ok()) {
*out << value_str.status().CloneAndAppend(Substitute(". Key: $0", *key_str)) << endl;
return;
}
*out << *key_str << " -> " << *value_str << endl;
if (include_binary) {
*out << FormatRocksDBSliceAsStr(key) << " -> "
<< FormatRocksDBSliceAsStr(value) << endl << endl;
}
}
std::string EntryToString(const rocksdb::Iterator& iterator, StorageDbType db_type) {
std::ostringstream out;
ProcessDumpEntry(iterator.key(), iterator.value(), IncludeBinary::kFalse, db_type, &out);
return out.str();
}
} // namespace
void DocDBDebugDump(rocksdb::DB* rocksdb, ostream& out, StorageDbType db_type,
IncludeBinary include_binary) {
rocksdb::ReadOptions read_opts;
read_opts.query_id = rocksdb::kDefaultQueryId;
auto iter = unique_ptr<rocksdb::Iterator>(rocksdb->NewIterator(read_opts));
iter->SeekToFirst();
while (iter->Valid()) {
ProcessDumpEntry(iter->key(), iter->value(), include_binary, db_type, &out);
iter->Next();
}
}
std::string DocDBDebugDumpToStr(DocDB docdb, IncludeBinary include_binary) {
stringstream ss;
DocDBDebugDump(docdb.regular, ss, StorageDbType::kRegular, include_binary);
if (docdb.intents) {
DocDBDebugDump(docdb.intents, ss, StorageDbType::kIntents, include_binary);
}
return ss.str();
}
std::string DocDBDebugDumpToStr(rocksdb::DB* rocksdb, StorageDbType db_type,
IncludeBinary include_binary) {
stringstream ss;
DocDBDebugDump(rocksdb, ss, db_type, include_binary);
return ss.str();
}
void AppendTransactionKeyPrefix(const TransactionId& transaction_id, KeyBytes* out) {
out->AppendValueType(ValueType::kTransactionId);
out->AppendRawBytes(Slice(transaction_id.data, transaction_id.size()));
}
DocHybridTimeBuffer::DocHybridTimeBuffer() {
buffer_[0] = ValueTypeAsChar::kHybridTime;
}
Slice DocHybridTimeBuffer::EncodeWithValueType(const DocHybridTime& doc_ht) {
auto end = doc_ht.EncodedInDocDbFormat(buffer_.data() + 1);
return Slice(buffer_.data(), end);
}
CHECKED_STATUS IntentToWriteRequest(
const Slice& transaction_id_slice,
HybridTime commit_ht,
rocksdb::Iterator* reverse_index_iter,
rocksdb::Iterator* intent_iter,
rocksdb::WriteBatch* regular_batch,
IntraTxnWriteId* write_id) {
DocHybridTimeBuffer doc_ht_buffer;
intent_iter->Seek(reverse_index_iter->value());
if (!intent_iter->Valid() || intent_iter->key() != reverse_index_iter->value()) {
LOG(DFATAL) << "Unable to find intent: " << reverse_index_iter->value().ToDebugString()
<< " for " << reverse_index_iter->key().ToDebugString();
return Status::OK();
}
auto intent = VERIFY_RESULT(ParseIntentKey(intent_iter->key(), transaction_id_slice));
if (IsStrongIntent(intent.type)) {
IntraTxnWriteId stored_write_id;
Slice intent_value;
RETURN_NOT_OK(DecodeIntentValue(
intent_iter->value(), transaction_id_slice, &stored_write_id, &intent_value));
// Write id should match to one that were calculated during append of intents.
// Doing it just for sanity check.
DCHECK_EQ(stored_write_id, *write_id)
<< "Value: " << intent_iter->value().ToDebugHexString();
// After strip of prefix and suffix intent_key contains just SubDocKey w/o a hybrid time.
// Time will be added when writing batch to RocksDB.
std::array<Slice, 2> key_parts = {{
intent.doc_path,
doc_ht_buffer.EncodeWithValueType(commit_ht, *write_id),
}};
std::array<Slice, 2> value_parts = {{
intent.doc_ht,
intent_value,
}};
regular_batch->Put(key_parts, value_parts);
++*write_id;
}
return Status::OK();
}
Status PrepareApplyIntentsBatch(
const TransactionId &transaction_id, HybridTime commit_ht,
rocksdb::WriteBatch *regular_batch,
rocksdb::DB *intents_db, rocksdb::WriteBatch *intents_batch) {
Slice reverse_index_upperbound;
auto reverse_index_iter = CreateRocksDBIterator(
intents_db, BloomFilterMode::DONT_USE_BLOOM_FILTER, boost::none, rocksdb::kDefaultQueryId,
nullptr /* read_filter */, &reverse_index_upperbound);
std::unique_ptr<rocksdb::Iterator> intent_iter;
// If we don't have regular_batch, it means that we just removing intents.
// We don't need intent iterator, since reverse index iterator is enough in this case.
if (regular_batch) {
intent_iter = CreateRocksDBIterator(
intents_db, BloomFilterMode::DONT_USE_BLOOM_FILTER, boost::none, rocksdb::kDefaultQueryId);
}
KeyBytes txn_reverse_index_prefix;
Slice transaction_id_slice(transaction_id.data, TransactionId::static_size());
AppendTransactionKeyPrefix(transaction_id, &txn_reverse_index_prefix);
KeyBytes txn_reverse_index_upperbound = txn_reverse_index_prefix;
txn_reverse_index_upperbound.AppendValueType(ValueType::kMaxByte);
reverse_index_upperbound = txn_reverse_index_upperbound.AsSlice();
reverse_index_iter->Seek(txn_reverse_index_prefix.data());
DocHybridTimeBuffer doc_ht_buffer;
IntraTxnWriteId write_id = 0;
while (reverse_index_iter->Valid()) {
rocksdb::Slice key_slice(reverse_index_iter->key());
if (!key_slice.starts_with(txn_reverse_index_prefix.data())) {
break;
}
VLOG(4) << "Apply reverse index record: "
<< EntryToString(*reverse_index_iter, StorageDbType::kIntents);
// If the key ends at the transaction id then it is transaction metadata (status tablet,
// isolation level etc.).
if (key_slice.size() > txn_reverse_index_prefix.size()) {
// Value of reverse index is a key of original intent record, so seek it and check match.
if (regular_batch) {
RETURN_NOT_OK(IntentToWriteRequest(
transaction_id_slice, commit_ht, reverse_index_iter.get(), intent_iter.get(),
regular_batch, &write_id));
}
intents_batch->Delete(reverse_index_iter->value());
}
intents_batch->Delete(reverse_index_iter->key());
reverse_index_iter->Next();
}
return Status::OK();
}
} // namespace docdb
} // namespace yb
| 46,010
| 15,022
|
//---------------------------------------------------------------------------
// Greenplum Database
// Copyright (C) 2009 - 2011 EMC Corp.
//
// @filename:
// CEngine.cpp
//
// @doc:
// Implementation of optimization engine
//---------------------------------------------------------------------------
#include "gpos/base.h"
#include "gpos/common/CAutoTimer.h"
#include "gpos/io/COstreamString.h"
#include "gpos/string/CWStringDynamic.h"
#include "gpos/task/CAutoTaskProxy.h"
#include "gpos/task/CAutoTraceFlag.h"
#include "gpos/memory/CAutoMemoryPool.h"
#include "gpopt/exception.h"
#include "gpopt/base/CDrvdPropCtxtPlan.h"
#include "gpopt/base/CCostContext.h"
#include "gpopt/base/COptimizationContext.h"
#include "gpopt/base/CReqdPropPlan.h"
#include "gpopt/base/CReqdPropRelational.h"
#include "gpopt/base/CQueryContext.h"
#include "gpopt/base/COptCtxt.h"
#include "gpopt/engine/CEngine.h"
#include "gpopt/engine/CEnumeratorConfig.h"
#include "gpopt/engine/CStatisticsConfig.h"
#include "gpopt/minidump/CSerializableStackTrace.h"
#include "gpopt/operators/CExpression.h"
#include "gpopt/operators/CExpressionHandle.h"
#include "gpopt/operators/CLogical.h"
#include "gpopt/operators/CPattern.h"
#include "gpopt/operators/CPatternLeaf.h"
#include "gpopt/operators/CPhysicalMotionGather.h"
#include "gpopt/operators/CPhysicalAgg.h"
#include "gpopt/operators/CPhysicalSort.h"
#include "gpopt/optimizer/COptimizerConfig.h"
#include "gpopt/search/CGroup.h"
#include "gpopt/search/CGroupExpression.h"
#include "gpopt/search/CGroupProxy.h"
#include "gpopt/search/CJob.h"
#include "gpopt/search/CJobFactory.h"
#include "gpopt/search/CMemo.h"
#include "gpopt/search/CScheduler.h"
#include "gpopt/search/CSchedulerContext.h"
#include "gpopt/xforms/CXformFactory.h"
#include "naucrates/traceflags/traceflags.h"
#define GPOPT_SAMPLING_MAX_ITERS 30
#define GPOPT_JOBS_CAP 5000 // maximum number of initial optimization jobs
#define GPOPT_JOBS_PER_GROUP 20 // estimated number of needed optimization jobs per memo group
// memory consumption unit in bytes -- currently MB
#define GPOPT_MEM_UNIT (1024 * 1024)
#define GPOPT_MEM_UNIT_NAME "MB"
using namespace gpopt;
//---------------------------------------------------------------------------
// @function:
// CEngine::CEngine
//
// @doc:
// Ctor
//
//---------------------------------------------------------------------------
CEngine::CEngine
(
IMemoryPool *pmp
)
:
m_pmp(pmp),
m_pqc(NULL),
m_pdrgpss(NULL),
m_ulCurrSearchStage(0),
m_pmemo(NULL),
m_pexprEnforcerPattern(NULL),
m_pxfs(NULL),
m_pdrgpulpXformCalls(NULL),
m_pdrgpulpXformTimes(NULL)
{
m_pmemo = GPOS_NEW(pmp) CMemo(pmp);
m_pexprEnforcerPattern = GPOS_NEW(pmp) CExpression(pmp, GPOS_NEW(pmp) CPatternLeaf(pmp));
m_pxfs = GPOS_NEW(pmp) CXformSet(pmp);
m_pdrgpulpXformCalls = GPOS_NEW(pmp) DrgPulp(pmp);
m_pdrgpulpXformTimes = GPOS_NEW(pmp) DrgPulp(pmp);
}
//---------------------------------------------------------------------------
// @function:
// CEngine::~CEngine
//
// @doc:
// Dtor
//
//---------------------------------------------------------------------------
CEngine::~CEngine()
{
#ifdef GPOS_DEBUG
// in optimized build, we flush-down memory pools without leak checking,
// we can save time in optimized build by skipping all de-allocations here,
// we still have all de-llocations enabled in debug-build to detect any possible leaks
GPOS_DELETE(m_pmemo);
CRefCount::SafeRelease(m_pxfs);
m_pdrgpulpXformCalls->Release();
m_pdrgpulpXformTimes->Release();
m_pexprEnforcerPattern->Release();
CRefCount::SafeRelease(m_pdrgpss);
#endif // GPOS_DEBUG
}
//---------------------------------------------------------------------------
// @function:
// CEngine::InitLogicalExpression
//
// @doc:
// Initialize engine with a given expression
//
//---------------------------------------------------------------------------
void
CEngine::InitLogicalExpression
(
CExpression *pexpr
)
{
GPOS_ASSERT(NULL == m_pmemo->PgroupRoot() && "Root is already set");
GPOS_ASSERT(pexpr->Pop()->FLogical());
CGroup *pgroupRoot = PgroupInsert(NULL /*pgroupTarget*/, pexpr, CXform::ExfInvalid, NULL /*pgexprOrigin*/, false /*fIntermediate*/);
m_pmemo->SetRoot(pgroupRoot);
}
//---------------------------------------------------------------------------
// @function:
// CEngine::Init
//
// @doc:
// Initialize engine using a given query context
//
//---------------------------------------------------------------------------
void
CEngine::Init
(
CQueryContext *pqc,
DrgPss *pdrgpss
)
{
GPOS_ASSERT(NULL == m_pqc);
GPOS_ASSERT(NULL != pqc);
GPOS_ASSERT_IMP
(
0 == CDrvdPropRelational::Pdprel(pqc->Pexpr()->PdpDerive())->PcrsOutput()->CElements(),
0 == pqc->Prpp()->PcrsRequired()->CElements() &&
"requiring columns from a zero column expression"
);
m_pdrgpss = pdrgpss;
if (NULL == pdrgpss)
{
m_pdrgpss = CSearchStage::PdrgpssDefault(m_pmp);
}
GPOS_ASSERT(0 < m_pdrgpss->UlLength());
if (GPOS_FTRACE(EopttracePrintOptimizationStatistics))
{
// initialize per-stage xform calls array
const ULONG ulStages = m_pdrgpss->UlLength();
for (ULONG ul = 0; ul < ulStages; ul++)
{
ULONG_PTR *pulpXformCalls = GPOS_NEW_ARRAY(m_pmp, ULONG_PTR, CXform::ExfSentinel);
ULONG_PTR *pulpXformTimes = GPOS_NEW_ARRAY(m_pmp, ULONG_PTR, CXform::ExfSentinel);
for (ULONG ulXform = 0; ulXform < CXform::ExfSentinel; ulXform++)
{
pulpXformCalls[ulXform] = 0;
pulpXformTimes[ulXform] = 0;
}
m_pdrgpulpXformCalls->Append(pulpXformCalls);
m_pdrgpulpXformTimes->Append(pulpXformTimes);
}
}
m_pqc = pqc;
InitLogicalExpression(m_pqc->Pexpr());
m_pqc->PdrgpcrSystemCols()->AddRef();
COptCtxt::PoctxtFromTLS()->SetReqdSystemCols(m_pqc->PdrgpcrSystemCols());
}
//---------------------------------------------------------------------------
// @function:
// CEngine::AddEnforcers
//
// @doc:
// Add enforcers to a memo group
//
//---------------------------------------------------------------------------
void
CEngine::AddEnforcers
(
CGroupExpression *pgexpr, // belongs to group where we need to add enforcers
DrgPexpr *pdrgpexprEnforcers
)
{
GPOS_ASSERT(NULL != pdrgpexprEnforcers);
GPOS_ASSERT(NULL != pgexpr);
for (ULONG ul = 0; ul < pdrgpexprEnforcers->UlLength(); ul++)
{
// assemble an expression rooted by the enforcer operator
CExpression *pexprEnforcer = (*pdrgpexprEnforcers)[ul];
#ifdef GPOS_DEBUG
CGroup * pgroup =
#endif // GPOS_DEBUG
PgroupInsert(pgexpr->Pgroup(), pexprEnforcer, CXform::ExfInvalid, NULL /*pgexprOrigin*/, false /*fIntermediate*/);
GPOS_ASSERT(pgroup == pgexpr->Pgroup());
}
}
//---------------------------------------------------------------------------
// @function:
// CEngine::InsertExpressionChildren
//
// @doc:
// Insert children of the given expression to memo, and copy the groups
// they end up at to the given group array
//
//---------------------------------------------------------------------------
void
CEngine::InsertExpressionChildren
(
CExpression *pexpr,
DrgPgroup *pdrgpgroupChildren,
CXform::EXformId exfidOrigin,
CGroupExpression *pgexprOrigin
)
{
GPOS_ASSERT(NULL != pexpr);
GPOS_ASSERT(NULL != pdrgpgroupChildren);
ULONG ulArity = pexpr->UlArity();
for (ULONG i = 0; i < ulArity; i++)
{
CGroup *pgroupChild = NULL;
COperator *popChild = (*pexpr)[i]->Pop();
if (popChild->FPattern() && CPattern::PopConvert(popChild)->FLeaf())
{
GPOS_ASSERT(NULL != (*pexpr)[i]->Pgexpr()->Pgroup());
// group is already assigned during binding extraction;
pgroupChild = (*pexpr)[i]->Pgexpr()->Pgroup();
}
else
{
// insert child expression recursively
pgroupChild = PgroupInsert(NULL /*pgroupTarget*/, (*pexpr)[i], exfidOrigin, pgexprOrigin, true /*fIntermediate*/);
}
pdrgpgroupChildren->Append(pgroupChild);
}
}
//---------------------------------------------------------------------------
// @function:
// CEngine::PgroupInsert
//
// @doc:
// Insert an expression tree into the memo, with explicit target group;
// the function returns a pointer to the group that contains the given
// group expression
//
//---------------------------------------------------------------------------
CGroup *
CEngine::PgroupInsert
(
CGroup *pgroupTarget,
CExpression *pexpr,
CXform::EXformId exfidOrigin,
CGroupExpression *pgexprOrigin,
BOOL fIntermediate
)
{
// recursive function - check stack
GPOS_CHECK_STACK_SIZE;
GPOS_CHECK_ABORT;
GPOS_ASSERT_IMP(CXform::ExfInvalid != exfidOrigin, NULL != pgexprOrigin);
CGroup *pgroupOrigin = NULL;
// check if expression was produced by extracting
// a binding from the memo
if (NULL != pexpr->Pgexpr())
{
pgroupOrigin = pexpr->Pgexpr()->Pgroup();
GPOS_ASSERT(NULL != pgroupOrigin && NULL == pgroupTarget &&
"A valid group is expected");
// if parent has group pointer, all children must have group pointers;
// terminate recursive insertion here
return pgroupOrigin;
}
// if we have a valid origin group, target group must be NULL
GPOS_ASSERT_IMP(NULL != pgroupOrigin, NULL == pgroupTarget);
// insert expression's children to memo by recursive call
DrgPgroup *pdrgpgroupChildren = GPOS_NEW(m_pmp) DrgPgroup(m_pmp, pexpr->UlArity());
InsertExpressionChildren(pexpr, pdrgpgroupChildren, exfidOrigin, pgexprOrigin);
COperator *pop = pexpr->Pop();
pop->AddRef();
CGroupExpression *pgexpr =
GPOS_NEW(m_pmp) CGroupExpression
(
m_pmp,
pop,
pdrgpgroupChildren,
exfidOrigin,
pgexprOrigin,
fIntermediate
);
// find the group that contains created group expression
CGroup *pgroupContainer = m_pmemo->PgroupInsert(pgroupTarget, pexpr, pgexpr);
if (NULL == pgexpr->Pgroup())
{
// insertion failed, release created group expression
pgexpr->Release();
}
return pgroupContainer;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::InsertXformResult
//
// @doc:
// Insert a set of transformation results to memo
//
//---------------------------------------------------------------------------
void
CEngine::InsertXformResult
(
CGroup *pgroupOrigin,
CXformResult *pxfres,
CXform::EXformId exfidOrigin,
CGroupExpression *pgexprOrigin,
ULONG ulXformTime // time consumed by transformation in msec
)
{
GPOS_ASSERT(NULL != pxfres);
GPOS_ASSERT(NULL != pgroupOrigin);
GPOS_ASSERT(CXform::ExfInvalid != exfidOrigin);
GPOS_ASSERT(NULL != pgexprOrigin);
if (GPOS_FTRACE(EopttracePrintOptimizationStatistics) && 0 < pxfres->Pdrgpexpr()->UlLength())
{
(void) m_pxfs->FExchangeSet(exfidOrigin);
(void) UlpExchangeAdd(&(*m_pdrgpulpXformCalls)[m_ulCurrSearchStage][exfidOrigin], 1);
{
CAutoMutex am(m_mutexOptStats);
am.Lock();
(*m_pdrgpulpXformTimes)[m_ulCurrSearchStage][exfidOrigin] += ulXformTime;
}
}
CExpression *pexpr = pxfres->PexprNext();
while (NULL != pexpr)
{
CGroup *pgroupContainer = PgroupInsert(pgroupOrigin, pexpr, exfidOrigin, pgexprOrigin, false /*fIntermediate*/);
if (pgroupContainer != pgroupOrigin && FPossibleDuplicateGroups(pgroupContainer, pgroupOrigin))
{
m_pmemo->MarkDuplicates(pgroupOrigin, pgroupContainer);
}
pexpr = pxfres->PexprNext();
}
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FPossibleDuplicateGroups
//
// @doc:
// Check whether the given memo groups can be marked as duplicates. This is
// true only if they have the same logical properties
//
//---------------------------------------------------------------------------
BOOL
CEngine::FPossibleDuplicateGroups
(
CGroup *pgroupFst,
CGroup *pgroupSnd
)
{
GPOS_ASSERT(NULL != pgroupFst);
GPOS_ASSERT(NULL != pgroupSnd);
CDrvdPropRelational *pdprelFst = CDrvdPropRelational::Pdprel(pgroupFst->Pdp());
CDrvdPropRelational *pdprelSnd = CDrvdPropRelational::Pdprel(pgroupSnd->Pdp());
// right now we only check the output columns, but we may possibly need to
// check other properties as well
return pdprelFst->PcrsOutput()->FEqual(pdprelSnd->PcrsOutput());
}
//---------------------------------------------------------------------------
// @function:
// CEngine::DeriveStats
//
// @doc:
// Derive statistics on the root group
//
//---------------------------------------------------------------------------
void
CEngine::DeriveStats
(
IMemoryPool *pmpLocal
)
{
CWStringDynamic str(m_pmp);
COstreamString oss (&str);
oss << "\n[OPT]: Statistics Derivation Time (stage " << m_ulCurrSearchStage <<") ";
CHAR *sz = CUtils::SzFromWsz(m_pmp, const_cast<WCHAR *>(str.Wsz()));
{
CAutoTimer at(sz, GPOS_FTRACE(EopttracePrintOptimizationStatistics));
// derive stats on root group
CEngine::DeriveStats(pmpLocal, m_pmp, PgroupRoot(), NULL /*prprel*/);
}
GPOS_DELETE_ARRAY(sz);
}
//---------------------------------------------------------------------------
// @function:
// CEngine::DeriveStats
//
// @doc:
// Derive statistics on the group
//
//---------------------------------------------------------------------------
void
CEngine::DeriveStats
(
IMemoryPool *pmpLocal,
IMemoryPool *pmpGlobal,
CGroup *pgroup,
CReqdPropRelational *prprel
)
{
CGroupExpression *pgexprFirst = CEngine::PgexprFirst(pgroup);
CExpressionHandle exprhdl(pmpGlobal);
exprhdl.Attach(pgexprFirst);
exprhdl.DeriveStats(pmpLocal, pmpGlobal, prprel, NULL /*pdrgpstatCtxt*/);
}
//---------------------------------------------------------------------------
// @function:
// CEngine::PgexprFirst
//
// @doc:
// Return the first group expression in a given group
//
//---------------------------------------------------------------------------
CGroupExpression *
CEngine::PgexprFirst
(
CGroup *pgroup
)
{
CGroupExpression *pgexprFirst = NULL;
{
// group proxy scope
CGroupProxy gp(pgroup);
pgexprFirst = gp.PgexprFirst();
}
GPOS_ASSERT(NULL != pgexprFirst);
return pgexprFirst;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::EolDamp
//
// @doc:
// Damp optimization level
//
//---------------------------------------------------------------------------
EOptimizationLevel
CEngine::EolDamp
(
EOptimizationLevel eol
)
{
if (EolHigh == eol)
{
return EolLow;
}
return EolSentinel;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FOptimizeChild
//
// @doc:
// Check if parent group expression needs to optimize child group expression.
// This method is called right before a group optimization job is about to
// schedule a group expression optimization job.
//
// Relation properties as well the optimizing parent group expression is
// available to make the decision. So, operators can reject being optimized
// under specific parent operators. For example, a GatherMerge under a Sort
// can be prevented here since it destroys the order from a GatherMerge.
//---------------------------------------------------------------------------
BOOL
CEngine::FOptimizeChild
(
CGroupExpression *pgexprParent,
CGroupExpression *pgexprChild,
COptimizationContext *pocChild,
EOptimizationLevel eolCurrent // current optimization level in child group
)
{
GPOS_ASSERT(NULL != PgroupRoot());
GPOS_ASSERT(PgroupRoot()->FImplemented());
GPOS_ASSERT(NULL != pgexprChild);
GPOS_ASSERT_IMP(NULL == pgexprParent, pgexprChild->Pgroup() == PgroupRoot());
if (pgexprParent == pgexprChild)
{
// a group expression cannot optimize itself
return false;
}
if (pgexprChild->Eol() != eolCurrent)
{
// child group expression does not match current optimization level
return false;
}
COperator *popChild = pgexprChild->Pop();
if (NULL != pgexprParent &&
COperator::EopPhysicalSort == pgexprParent->Pop()->Eopid() &&
COperator::EopPhysicalMotionGather == popChild->Eopid())
{
// prevent (Sort --> GatherMerge), since Sort destroys order maintained by GatherMerge
return !CPhysicalMotionGather::PopConvert(popChild)->FOrderPreserving();
}
return COptimizationContext::FOptimize(m_pmp, pgexprParent, pgexprChild, pocChild, UlSearchStages());
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FSafeToPruneWithDPEStats
//
// @doc:
// Determine if a plan rooted by given group expression can be safely
// pruned during optimization when stats for Dynamic Partition Elimination
// are derived
//
//---------------------------------------------------------------------------
BOOL
CEngine::FSafeToPruneWithDPEStats
(
CGroupExpression *pgexpr,
CReqdPropPlan *, // prpp
CCostContext *pccChild,
ULONG ulChildIndex
)
{
GPOS_ASSERT(GPOS_FTRACE(EopttraceDeriveStatsForDPE));
GPOS_ASSERT(GPOS_FTRACE(EopttraceEnableSpacePruning));
if (NULL == pccChild)
{
// group expression has not been optimized yet
CDrvdPropRelational *pdprel = CDrvdPropRelational::Pdprel(pgexpr->Pgroup()->Pdp());
if (0 < pdprel->Ppartinfo()->UlConsumers())
{
// we cannot bound cost here because of possible DPE that can happen below the operator
return false;
}
return true;
}
// first child has been optimized
CExpressionHandle exprhdl(m_pmp);
exprhdl.Attach(pgexpr);
ULONG ulNextChild = exprhdl.UlNextOptimizedChildIndex(ulChildIndex);
CDrvdPropRelational *pdprelChild = CDrvdPropRelational::Pdprel((*pgexpr)[ulNextChild]->Pdp());
if (0 < pdprelChild->Ppartinfo()->UlConsumers())
{
// we cannot bound cost here because of possible DPE that can happen for the unoptimized child
return false;
}
return true;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FSafeToPrune
//
// @doc:
// Determine if a plan rooted by given group expression can be safely
// pruned during optimization
//
//---------------------------------------------------------------------------
BOOL
CEngine::FSafeToPrune
(
CGroupExpression *pgexpr,
CReqdPropPlan *prpp,
CCostContext *pccChild,
ULONG ulChildIndex,
CCost *pcostLowerBound // output: a lower bound on plan's cost
)
{
GPOS_ASSERT(NULL != pcostLowerBound);
*pcostLowerBound = GPOPT_INVALID_COST;
if (!GPOS_FTRACE(EopttraceEnableSpacePruning))
{
// space pruning is disabled
return false;
}
if (GPOS_FTRACE(EopttraceDeriveStatsForDPE) &&
!FSafeToPruneWithDPEStats(pgexpr, prpp, pccChild, ulChildIndex))
{
// stat derivation for Dynamic Partition Elimination may not allow non-trivial cost bounds
return false;
}
// check if container group has a plan for given properties
CGroup *pgroup = pgexpr->Pgroup();
COptimizationContext *pocGroup = pgroup->PocLookupBest(m_pmp, UlSearchStages(), prpp);
if (NULL != pocGroup && NULL != pocGroup->PccBest())
{
// compute a cost lower bound for the equivalent plan rooted by given group expression
CCost costLowerBound = pgexpr->CostLowerBound(m_pmp, prpp, pccChild, ulChildIndex);
*pcostLowerBound = costLowerBound;
if (costLowerBound > pocGroup->PccBest()->Cost())
{
// group expression cannot deliver a better plan for given properties and can be safely pruned
return true;
}
}
return false;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::Pmemotmap
//
// @doc:
// Build tree map on memo
//
//---------------------------------------------------------------------------
MemoTreeMap *
CEngine::Pmemotmap()
{
COptimizerConfig *poconf = COptCtxt::PoctxtFromTLS()->Poconf();
if (NULL == m_pmemo->Pmemotmap())
{
m_pqc->Prpp()->AddRef();
COptimizationContext *poc = GPOS_NEW(m_pmp) COptimizationContext
(
m_pmp,
PgroupRoot(),
m_pqc->Prpp(),
GPOS_NEW(m_pmp) CReqdPropRelational(GPOS_NEW(m_pmp) CColRefSet(m_pmp)), // pass empty required relational properties initially
GPOS_NEW(m_pmp) DrgPstat(m_pmp), // pass empty stats context initially
0 // ulSearchStageIndex
);
m_pmemo->BuildTreeMap(poc);
poconf->Pec()->SetPlanSpaceSize(m_pmemo->Pmemotmap()->UllCount());
poc->Release();
}
return m_pmemo->Pmemotmap();
}
#ifdef GPOS_DEBUG
//---------------------------------------------------------------------------
// @function:
// CEngine::ApplyTransformations
//
// @doc:
// Applies given set of xforms to group expression and insert
// results to memo
//
//---------------------------------------------------------------------------
void
CEngine::ApplyTransformations
(
IMemoryPool *pmpLocal,
CXformSet *pxfs,
CGroupExpression *pgexpr
)
{
// iterate over xforms
CXformSetIter xsi(*pxfs);
while (xsi.FAdvance())
{
GPOS_CHECK_ABORT;
CXform *pxform = CXformFactory::Pxff()->Pxf(xsi.TBit());
// transform group expression, and insert results to memo
CXformResult *pxfres = GPOS_NEW(m_pmp) CXformResult(m_pmp);
ULONG ulElapsedTime = 0;
pgexpr->Transform(m_pmp, pmpLocal, pxform, pxfres, &ulElapsedTime);
InsertXformResult(pgexpr->Pgroup(), pxfres, pxform->Exfid(), pgexpr, ulElapsedTime);
pxfres->Release();
if (PssCurrent()->FTimedOut())
{
break;
}
}
}
//---------------------------------------------------------------------------
// @function:
// CEngine::TransitionGroupExpression
//
// @doc:
// Transition group expression to a given target state
//
//---------------------------------------------------------------------------
void
CEngine::TransitionGroupExpression
(
IMemoryPool *pmpLocal,
CGroupExpression *pgexpr,
CGroupExpression::EState estTarget
)
{
GPOS_ASSERT(CGroupExpression::estExplored == estTarget ||
CGroupExpression::estImplemented == estTarget);
if (PssCurrent()->FTimedOut())
{
return;
}
CGroupExpression::EState estInitial = CGroupExpression::estExploring;
CGroup::EState estGroupTargetState = CGroup::estExplored;
if (CGroupExpression::estImplemented == estTarget)
{
estInitial = CGroupExpression::estImplementing;
estGroupTargetState = CGroup::estImplemented;
}
pgexpr->SetState(estInitial);
// transition all child groups
ULONG ulArity = pgexpr->UlArity();
for (ULONG i = 0; i < ulArity; i++)
{
TransitionGroup(pmpLocal, (*pgexpr)[i], estGroupTargetState);
GPOS_CHECK_ABORT;
}
// find which set of xforms should be used
CXformSet *pxfs = CXformFactory::Pxff()->PxfsExploration();
if (CGroupExpression::estImplemented == estTarget)
{
pxfs = CXformFactory::Pxff()->PxfsImplementation();
}
// get all applicable xforms
COperator *pop = pgexpr->Pop();
CXformSet *pxfsCandidates = CLogical::PopConvert(pop)->PxfsCandidates(m_pmp);
// intersect them with the required set of xforms, then apply transformations
pxfsCandidates->Intersection(pxfs);
pxfsCandidates->Intersection(PxfsCurrentStage());
ApplyTransformations(pmpLocal, pxfsCandidates, pgexpr);
pxfsCandidates->Release();
pgexpr->SetState(estTarget);
}
//---------------------------------------------------------------------------
// @function:
// CEngine::TransitionGroup
//
// @doc:
// Transition group to a target state
//
//---------------------------------------------------------------------------
void
CEngine::TransitionGroup
(
IMemoryPool *pmpLocal,
CGroup *pgroup,
CGroup::EState estTarget
)
{
// check stack size
GPOS_CHECK_STACK_SIZE;
if (PssCurrent()->FTimedOut())
{
return;
}
GPOS_ASSERT(CGroup::estExplored == estTarget ||
CGroup::estImplemented == estTarget);
BOOL fTransitioned = false;
{
CGroupProxy gp(pgroup);
fTransitioned = gp.FTransitioned(estTarget);
}
// check if we can end recursion early
if (!fTransitioned)
{
CGroup::EState estInitial = CGroup::estExploring;
CGroupExpression::EState estGExprTargetState = CGroupExpression::estExplored;
if (CGroup::estImplemented == estTarget)
{
estInitial = CGroup::estImplementing;
estGExprTargetState = CGroupExpression::estImplemented;
}
CGroupExpression *pgexprCurrent = NULL;
// transition group's state to initial state
{
CGroupProxy gp(pgroup);
gp.SetState(estInitial);
}
// get first group expression
{
CGroupProxy gp(pgroup);
pgexprCurrent = gp.PgexprFirst();
}
while (NULL != pgexprCurrent)
{
if (!pgexprCurrent->FTransitioned(estGExprTargetState))
{
TransitionGroupExpression
(
pmpLocal,
pgexprCurrent,
estGExprTargetState
);
}
if (PssCurrent()->FTimedOut())
{
break;
}
// get next group expression
{
CGroupProxy gp(pgroup);
pgexprCurrent = gp.PgexprNext(pgexprCurrent);
}
GPOS_CHECK_ABORT;
}
// transition group to target state
{
CGroupProxy gp(pgroup);
gp.SetState(estTarget);
}
}
}
//---------------------------------------------------------------------------
// @function:
// CEngine::PocChild
//
// @doc:
// Create optimization context for child group
//
//---------------------------------------------------------------------------
COptimizationContext *
CEngine::PocChild
(
CGroupExpression *pgexpr, // parent expression
COptimizationContext *pocOrigin, // optimization context of parent operator
CExpressionHandle &exprhdlPlan, // handle to compute required plan properties
CExpressionHandle &exprhdlRel, // handle to compute required relational properties
DrgPdp *pdrgpdpChildren, // derived plan properties of optimized children
DrgPstat *pdrgpstatCurrentCtxt,
ULONG ulChildIndex,
ULONG ulOptReq
)
{
GPOS_ASSERT(exprhdlPlan.Pgexpr() == pgexpr);
GPOS_ASSERT(NULL != pocOrigin);
GPOS_ASSERT(NULL != pdrgpdpChildren);
GPOS_ASSERT(NULL != pdrgpstatCurrentCtxt);
CGroup *pgroupChild = (*pgexpr)[ulChildIndex];
// compute required properties of the n-th child
exprhdlPlan.ComputeChildReqdProps(ulChildIndex, pdrgpdpChildren, ulOptReq);
exprhdlPlan.Prpp(ulChildIndex)->AddRef();
// use current stats for optimizing current child
DrgPstat *pdrgpstatCtxt = GPOS_NEW(m_pmp) DrgPstat(m_pmp);
CUtils::AddRefAppend<IStatistics, CleanupStats>(pdrgpstatCtxt, pdrgpstatCurrentCtxt);
// compute required relational properties
CReqdPropRelational *prprel = NULL;
if (CPhysical::PopConvert(pgexpr->Pop())->FPassThruStats())
{
// copy requirements from origin context
prprel = pocOrigin->Prprel();
}
else
{
// retrieve requirements from handle
prprel = exprhdlRel.Prprel(ulChildIndex);
}
GPOS_ASSERT(NULL != prprel);
prprel->AddRef();
COptimizationContext *pocChild =
GPOS_NEW(m_pmp) COptimizationContext
(
m_pmp,
pgroupChild,
exprhdlPlan.Prpp(ulChildIndex),
prprel,
pdrgpstatCtxt,
m_ulCurrSearchStage
);
return pocChild;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::PccOptimizeChild
//
// @doc:
// Optimize child group and return best cost context satisfying
// required properties
//
//---------------------------------------------------------------------------
CCostContext *
CEngine::PccOptimizeChild
(
CExpressionHandle &exprhdl, // initialized with required properties
CExpressionHandle &exprhdlRel,
COptimizationContext *pocOrigin, // optimization context of parent operator
DrgPdp *pdrgpdp,
DrgPstat *pdrgpstatCurrentCtxt,
ULONG ulChildIndex,
ULONG ulOptReq
)
{
CGroupExpression *pgexpr = exprhdl.Pgexpr();
CGroup *pgroupChild = (*exprhdl.Pgexpr())[ulChildIndex];
// create optimization context for child group
COptimizationContext *pocChild =
PocChild(pgexpr, pocOrigin, exprhdl, exprhdlRel, pdrgpdp, pdrgpstatCurrentCtxt, ulChildIndex, ulOptReq);
if (pgroupChild == pgexpr->Pgroup() && pocChild->FMatch(pocOrigin))
{
// child context is the same as origin context, this is a deadlock
pocChild->Release();
return NULL;
}
// optimize child group
CGroupExpression *pgexprChildBest = PgexprOptimize(pgroupChild, pocChild, pgexpr);
pocChild->Release();
if (NULL == pgexprChildBest || PssCurrent()->FTimedOut())
{
// failed to generate a plan for the child, or search stage is timed-out
return NULL;
}
// derive plan properties of child group optimal implementation
COptimizationContext *pocFound = pgroupChild->PocLookupBest(m_pmp, m_pdrgpss->UlLength(), exprhdl.Prpp(ulChildIndex));
GPOS_ASSERT(NULL != pocFound);
CCostContext *pccChildBest = pocFound->PccBest();
GPOS_ASSERT(NULL != pccChildBest);
// check if optimization can be early terminated after first child has been optimized
CCost costLowerBound(GPOPT_INVALID_COST);
if (exprhdl.UlFirstOptimizedChildIndex() == ulChildIndex &&
FSafeToPrune(pgexpr, pocOrigin->Prpp(), pccChildBest, ulChildIndex, &costLowerBound))
{
// failed to optimize child due to cost bounding
(void) pgexpr->PccComputeCost(m_pmp, pocOrigin, ulOptReq, NULL /*pdrgpoc*/, true /*fPruned*/, costLowerBound);
return NULL;
}
return pccChildBest;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::PdrgpocOptimizeChildren
//
// @doc:
// Optimize child groups of a given group expression;
//
//---------------------------------------------------------------------------
DrgPoc *
CEngine::PdrgpocOptimizeChildren
(
CExpressionHandle &exprhdl, // initialized with required properties
COptimizationContext *pocOrigin, // optimization context of parent operator
ULONG ulOptReq
)
{
GPOS_ASSERT(NULL != exprhdl.Pgexpr());
CGroupExpression *pgexpr = exprhdl.Pgexpr();
const ULONG ulArity = exprhdl.UlArity();
if (0 == ulArity)
{
// return empty array if no children
return GPOS_NEW(m_pmp) DrgPoc(m_pmp);
}
// create array of child derived properties
DrgPdp *pdrgpdp = GPOS_NEW(m_pmp) DrgPdp(m_pmp);
// initialize current stats context with input stats context
DrgPstat *pdrgpstatCurrentCtxt = GPOS_NEW(m_pmp) DrgPstat(m_pmp);
CUtils::AddRefAppend<IStatistics, CleanupStats>(pdrgpstatCurrentCtxt, pocOrigin->Pdrgpstat());
// initialize required relational properties computation
CExpressionHandle exprhdlRel(m_pmp);
CGroupExpression *pgexprForStats = pgexpr->Pgroup()->PgexprBestPromise(m_pmp, pgexpr);
if (NULL != pgexprForStats)
{
exprhdlRel.Attach(pgexprForStats);
exprhdlRel.DeriveProps(NULL /*pdpctxt*/);
exprhdlRel.ComputeReqdProps(pocOrigin->Prprel(), 0 /*ulOptReq*/);
}
// iterate over child groups and optimize them
BOOL fSuccess = true;
ULONG ulChildIndex = exprhdl.UlFirstOptimizedChildIndex();
do
{
CGroup *pgroupChild = (*exprhdl.Pgexpr())[ulChildIndex];
if (pgroupChild->FScalar())
{
// skip scalar groups from optimization
continue;
}
CCostContext *pccChildBest = PccOptimizeChild(exprhdl, exprhdlRel, pocOrigin, pdrgpdp, pdrgpstatCurrentCtxt, ulChildIndex, ulOptReq);
if (NULL == pccChildBest)
{
fSuccess = false;
break;
}
CExpressionHandle exprhdlChild(m_pmp);
exprhdlChild.Attach(pccChildBest);
exprhdlChild.DerivePlanProps();
exprhdlChild.Pdp()->AddRef();
pdrgpdp->Append(exprhdlChild.Pdp());
// copy stats of child's best cost context to current stats context
IStatistics *pstat = pccChildBest->Pstats();
pstat->AddRef();
pdrgpstatCurrentCtxt->Append(pstat);
GPOS_CHECK_ABORT;
}
while (exprhdl.FNextChildIndex(&ulChildIndex));
pdrgpdp->Release();
pdrgpstatCurrentCtxt->Release();
if (!fSuccess)
{
return NULL;
}
// return child optimization contexts array
return PdrgpocChildren(m_pmp, exprhdl);
}
//---------------------------------------------------------------------------
// @function:
// CEngine::OptimizeGroupExpression
//
// @doc:
// Optimize group expression under a given context
//
//---------------------------------------------------------------------------
void
CEngine::OptimizeGroupExpression
(
CGroupExpression *pgexpr,
COptimizationContext *poc
)
{
CGroup *pgroup = pgexpr->Pgroup();
const ULONG ulOptRequests = CPhysical::PopConvert(pgexpr->Pop())->UlOptRequests();
for (ULONG ul = 0; ul < ulOptRequests; ul++)
{
CExpressionHandle exprhdl(m_pmp);
exprhdl.Attach(pgexpr);
exprhdl.DeriveProps(NULL /*pdpctxt*/);
// check if group expression optimization can be early terminated without optimizing any child
CCost costLowerBound(GPOPT_INVALID_COST);
if (FSafeToPrune(pgexpr, poc->Prpp(), NULL /*pccChild*/, ULONG_MAX /*ulChildIndex*/, &costLowerBound))
{
(void) pgexpr->PccComputeCost(m_pmp, poc, ul, NULL /*pdrgpoc*/, true /*fPruned*/, costLowerBound);
continue;
}
if (FCheckReqdProps(exprhdl, poc->Prpp(), ul))
{
// load required properties on the handle
exprhdl.InitReqdProps(poc->Prpp());
// optimize child groups
DrgPoc *pdrgpoc = PdrgpocOptimizeChildren(exprhdl, poc, ul);
if (NULL != pdrgpoc && FCheckEnfdProps(m_pmp, pgexpr, poc, ul, pdrgpoc))
{
// compute group expression cost under the current optimization context
CCostContext *pccComputed = pgexpr->PccComputeCost(m_pmp, poc, ul, pdrgpoc, false /*fPruned*/, CCost(0.0));
if (NULL != pccComputed)
{
// update best group expression under the current optimization context
pgroup->UpdateBestCost(poc, pccComputed);
}
}
CRefCount::SafeRelease(pdrgpoc);
}
GPOS_CHECK_ABORT;
}
}
//---------------------------------------------------------------------------
// @function:
// CEngine::PgexprOptimize
//
// @doc:
// Optimize group under a given context;
//
//---------------------------------------------------------------------------
CGroupExpression *
CEngine::PgexprOptimize
(
CGroup *pgroup,
COptimizationContext *poc,
CGroupExpression *pgexprOrigin
)
{
// recursive function - check stack
GPOS_CHECK_STACK_SIZE;
COptimizationContext *pocFound = pgroup->PocInsert(poc);
if (poc != pocFound)
{
GPOS_ASSERT(COptimizationContext::estOptimized == pocFound->Est());
return pocFound->PgexprBest();
}
// add-ref context to pin it in hash table
poc->AddRef();
poc->SetState(COptimizationContext::estOptimizing);
EOptimizationLevel eolCurrent = pgroup->EolMax();
while (EolSentinel != eolCurrent)
{
CGroupExpression *pgexprCurrent = NULL;
{
CGroupProxy gp(pgroup);
pgexprCurrent = gp.PgexprSkipLogical(NULL /*pgexpr*/);
}
while (NULL != pgexprCurrent)
{
if (FOptimizeChild(pgexprOrigin, pgexprCurrent, poc, eolCurrent))
{
OptimizeGroupExpression(pgexprCurrent, poc);
}
if (PssCurrent()->FTimedOut())
{
break;
}
// move to next group expression
{
CGroupProxy gp(pgroup);
pgexprCurrent = gp.PgexprSkipLogical(pgexprCurrent);
}
}
// damp optimization level
eolCurrent = EolDamp(eolCurrent);
GPOS_CHECK_ABORT;
}
poc->SetState(COptimizationContext::estOptimized);
return poc->PgexprBest();
}
//---------------------------------------------------------------------------
// @function:
// CEngine::Explore
//
// @doc:
// Apply all exploration xforms
//
//---------------------------------------------------------------------------
void
CEngine::Explore()
{
GPOS_ASSERT(NULL != m_pqc);
GPOS_ASSERT(NULL != PgroupRoot());
// explore root group
GPOS_ASSERT(!PgroupRoot()->FExplored());
TransitionGroup(m_pmp, PgroupRoot(), CGroup::estExplored /*estTarget*/);
GPOS_ASSERT_IMP
(
!PssCurrent()->FTimedOut(),
PgroupRoot()->FExplored()
);
}
//---------------------------------------------------------------------------
// @function:
// CEngine::Implement
//
// @doc:
// Apply all implementation xforms
//
//---------------------------------------------------------------------------
void
CEngine::Implement()
{
GPOS_ASSERT(NULL != m_pqc);
GPOS_ASSERT(NULL != PgroupRoot());
// implement root group
GPOS_ASSERT(!PgroupRoot()->FImplemented());
TransitionGroup(m_pmp, PgroupRoot(), CGroup::estImplemented /*estTarget*/);
GPOS_ASSERT_IMP
(
!PssCurrent()->FTimedOut(),
PgroupRoot()->FImplemented()
);
}
//---------------------------------------------------------------------------
// @function:
// CEngine::RecursiveOptimize
//
// @doc:
// Recursive optimization
//
//---------------------------------------------------------------------------
void
CEngine::RecursiveOptimize()
{
COptimizerConfig *poconf = COptCtxt::PoctxtFromTLS()->Poconf();
CAutoTimer at("\n[OPT]: Total Optimization Time", GPOS_FTRACE(EopttracePrintOptimizationStatistics));
const ULONG ulSearchStages = m_pdrgpss->UlLength();
for (ULONG ul = 0; !FSearchTerminated() && ul < ulSearchStages; ul++)
{
PssCurrent()->RestartTimer();
// apply exploration xforms
Explore();
// run exploration completion operations
FinalizeExploration();
// apply implementation xforms
Implement();
// run implementation completion operations
FinalizeImplementation();
// optimize root group
m_pqc->Prpp()->AddRef();
COptimizationContext *poc =
GPOS_NEW(m_pmp) COptimizationContext
(
m_pmp,
PgroupRoot(),
m_pqc->Prpp(),
GPOS_NEW(m_pmp) CReqdPropRelational(GPOS_NEW(m_pmp) CColRefSet(m_pmp)), // pass empty required relational properties initially
GPOS_NEW(m_pmp) DrgPstat(m_pmp), // pass an empty stats context initially
m_ulCurrSearchStage
);
(void) PgexprOptimize(PgroupRoot(), poc, NULL /*pgexprOrigin*/);
poc->Release();
// extract best plan found at the end of current search stage
CExpression *pexprPlan =
m_pmemo->PexprExtractPlan
(
m_pmp,
m_pmemo->PgroupRoot(),
m_pqc->Prpp(),
m_pdrgpss->UlLength()
);
PssCurrent()->SetBestExpr(pexprPlan);
FinalizeSearchStage();
}
{
CAutoTrace atSearch(m_pmp);
atSearch.Os() << "[OPT]: Search terminated at stage " << m_ulCurrSearchStage << "/" << m_pdrgpss->UlLength();
}
if (poconf->Pec()->FSample())
{
SamplePlans();
}
}
#endif // GPOS_DEBUG
//---------------------------------------------------------------------------
// @function:
// CEngine::PdrgpocChildren
//
// @doc:
// Return array of child optimization contexts corresponding
// to handle requirements
//
//---------------------------------------------------------------------------
DrgPoc *
CEngine::PdrgpocChildren
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl
)
{
GPOS_ASSERT(NULL != exprhdl.Pgexpr());
DrgPoc *pdrgpoc = GPOS_NEW(pmp) DrgPoc(pmp);
const ULONG ulArity = exprhdl.UlArity();
for (ULONG ul = 0; ul < ulArity; ul++)
{
CGroup *pgroupChild = (*exprhdl.Pgexpr())[ul];
if (!pgroupChild->FScalar())
{
COptimizationContext *poc =
pgroupChild->PocLookupBest(pmp, m_pdrgpss->UlLength(), exprhdl.Prpp(ul));
GPOS_ASSERT(NULL != poc);
poc->AddRef();
pdrgpoc->Append(poc);
}
}
return pdrgpoc;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::ScheduleMainJob
//
// @doc:
// Create and schedule the main optimization job
//
//---------------------------------------------------------------------------
void
CEngine::ScheduleMainJob
(
CSchedulerContext *psc,
COptimizationContext *poc
)
{
GPOS_ASSERT(NULL != PgroupRoot());
CJobGroupOptimization::ScheduleJob(psc, PgroupRoot(), NULL /*pgexprOrigin*/, poc, NULL /*pjParent*/);
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FinalizeExploration
//
// @doc:
// Execute operations after exploration completes
//
//---------------------------------------------------------------------------
void
CEngine::FinalizeExploration()
{
GroupMerge();
if (m_pqc->FDeriveStats())
{
// derive statistics
m_pmemo->ResetStats();
DeriveStats(m_pmp);
}
if (!GPOS_FTRACE(EopttraceDonotDeriveStatsForAllGroups))
{
// derive stats for every group without stats
m_pmemo->DeriveStatsIfAbsent(m_pmp);
}
if (GPOS_FTRACE(EopttracePrintMemoAfterExploration))
{
{
CAutoTrace at(m_pmp);
at.Os() << "MEMO after exploration (stage " << m_ulCurrSearchStage << ")" << std::endl;
}
{
CAutoTrace at(m_pmp);
at.Os() << *this;
}
}
if (GPOS_FTRACE(EopttracePrintOptimizationStatistics))
{
CAutoTrace at(m_pmp);
(void) OsPrintMemoryConsumption(at.Os(), "Memory consumption after exploration ");
}
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FinalizeImplementation
//
// @doc:
// Execute operations after implementation completes
//
//---------------------------------------------------------------------------
void
CEngine::FinalizeImplementation()
{
if (GPOS_FTRACE(EopttracePrintMemoAfterImplementation))
{
{
CAutoTrace at(m_pmp);
at.Os() << "MEMO after implementation (stage " << m_ulCurrSearchStage << ")" << std::endl;
}
{
CAutoTrace at(m_pmp);
at.Os() << *this;
}
}
if (GPOS_FTRACE(EopttracePrintOptimizationStatistics))
{
CAutoTrace at(m_pmp);
(void) OsPrintMemoryConsumption(at.Os(), "Memory consumption after implementation ");
}
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FinalizeSearchStage
//
// @doc:
// Execute operations after search stage completes
//
//---------------------------------------------------------------------------
void
CEngine::FinalizeSearchStage()
{
ProcessTraceFlags();
m_pxfs->Release();
m_pxfs = NULL;
m_pxfs = GPOS_NEW(m_pmp) CXformSet(m_pmp);
m_ulCurrSearchStage++;
m_pmemo->ResetGroupStates();
}
//---------------------------------------------------------------------------
// @function:
// CEngine::PrintActivatedXforms
//
// @doc:
// Print activated xform
//
//---------------------------------------------------------------------------
void
CEngine::PrintActivatedXforms
(
IOstream &os
)
const
{
if (GPOS_FTRACE(EopttracePrintOptimizationStatistics))
{
os << std::endl << "[OPT]: <Begin Xforms - stage " << m_ulCurrSearchStage << ">" << std::endl;
CXformSetIter xsi(*m_pxfs);
while (xsi.FAdvance())
{
CXform *pxform = CXformFactory::Pxff()->Pxf(xsi.TBit());
ULONG ulCalls = (ULONG) (*m_pdrgpulpXformCalls)[m_ulCurrSearchStage][pxform->Exfid()];
ULONG ulTime = (ULONG) (*m_pdrgpulpXformTimes)[m_ulCurrSearchStage][pxform->Exfid()];
os
<< pxform->SzId() << ": "
<< ulCalls << " calls, "
<< ulTime << "ms"<< std::endl;
}
os << "[OPT]: <End Xforms - stage " << m_ulCurrSearchStage << ">" << std::endl;
}
}
//---------------------------------------------------------------------------
// @function:
// CEngine::PrintMemoryConsumption
//
// @doc:
// Print current memory consumption
//
//---------------------------------------------------------------------------
IOstream &
CEngine::OsPrintMemoryConsumption
(
IOstream &os,
const CHAR *szHeader
)
const
{
CMDAccessor *pmda = COptCtxt::PoctxtFromTLS()->Pmda();
CMDAccessor::MDCache *pcache = pmda->Pcache();
os << std::endl << szHeader
<< "Engine: [" << (DOUBLE) m_pmp->UllTotalAllocatedSize() / GPOPT_MEM_UNIT << "] " << GPOPT_MEM_UNIT_NAME
<< ", MD Cache: [" << (DOUBLE) (pcache->UllTotalAllocatedSize()) / GPOPT_MEM_UNIT << "] " << GPOPT_MEM_UNIT_NAME
<< ", Total: [" << (DOUBLE) (CMemoryPoolManager::Pmpm()->UllTotalAllocatedSize()) / GPOPT_MEM_UNIT << "] " << GPOPT_MEM_UNIT_NAME;
return os;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::ProcessTraceFlags
//
// @doc:
// Process trace flags after optimization is complete
//
//---------------------------------------------------------------------------
void
CEngine::ProcessTraceFlags()
{
if (GPOS_FTRACE(EopttracePrintMemoAfterOptimization))
{
{
CAutoTrace at(m_pmp);
at.Os() << "MEMO after optimization (stage "<< m_ulCurrSearchStage << "):" << std::endl;
}
{
CAutoTrace at(m_pmp);
at.Os() << *this;
}
}
if (GPOS_FTRACE(EopttracePrintOptimizationStatistics))
{
CAutoTrace at(m_pmp);
// print optimization stats
at.Os()
<< std::endl << "[OPT]: Memo (stage "<< m_ulCurrSearchStage << "): ["
<< (ULONG) (m_pmemo->UlpGroups()) << " groups"
<< ", " << m_pmemo->UlDuplicateGroups() << " duplicate groups"
<< ", " << m_pmemo->UlGrpExprs() << " group expressions"
<< ", " << m_pxfs->CElements() << " activated xforms]";
at.Os()
<< std::endl << "[OPT]: stage "<< m_ulCurrSearchStage << " completed in "
<< PssCurrent()->UlElapsedTime() << " msec, ";
if (NULL == PssCurrent()->PexprBest())
{
at.Os() << " no plan was found";
}
else
{
at.Os() << " plan with cost "<< PssCurrent()->CostBest() <<" was found";
}
PrintActivatedXforms(at.Os());
(void) OsPrintMemoryConsumption(at.Os(), "Memory consumption after optimization ");
}
}
//---------------------------------------------------------------------------
// @function:
// CEngine::Optimize
//
// @doc:
// Main driver of optimization engine
//
//---------------------------------------------------------------------------
void
CEngine::Optimize()
{
COptimizerConfig *poconf = COptCtxt::PoctxtFromTLS()->Poconf();
CAutoTimer at("\n[OPT]: Total Optimization Time", GPOS_FTRACE(EopttracePrintOptimizationStatistics));
if (GPOS_FTRACE(EopttraceParallel))
{
MultiThreadedOptimize(2 /*ulWorkers*/);
}
else
{
MainThreadOptimize();
}
{
if (GPOS_FTRACE(EopttracePrintOptimizationStatistics))
{
CAutoTrace atSearch(m_pmp);
atSearch.Os() << "[OPT]: Search terminated at stage " << m_ulCurrSearchStage << "/" << m_pdrgpss->UlLength();
}
}
if (poconf->Pec()->FSample())
{
SamplePlans();
}
}
//---------------------------------------------------------------------------
// @function:
// CEngine::MainThreadOptimize
//
// @doc:
// Run optimizer on the main thread
//
//---------------------------------------------------------------------------
void
CEngine::MainThreadOptimize()
{
GPOS_ASSERT(NULL != PgroupRoot());
GPOS_ASSERT(NULL != COptCtxt::PoctxtFromTLS());
const ULONG ulJobs = std::min((ULONG) GPOPT_JOBS_CAP, (ULONG) (m_pmemo->UlpGroups() * GPOPT_JOBS_PER_GROUP));
CJobFactory jf(m_pmp, ulJobs);
CScheduler sched(m_pmp, ulJobs, 1 /*ulWorkers*/);
CSchedulerContext sc;
sc.Init(m_pmp, &jf, &sched, this);
const ULONG ulSearchStages = m_pdrgpss->UlLength();
for (ULONG ul = 0; !FSearchTerminated() && ul < ulSearchStages; ul++)
{
PssCurrent()->RestartTimer();
// optimize root group
m_pqc->Prpp()->AddRef();
COptimizationContext *poc = GPOS_NEW(m_pmp) COptimizationContext
(
m_pmp,
PgroupRoot(),
m_pqc->Prpp(),
GPOS_NEW(m_pmp) CReqdPropRelational(GPOS_NEW(m_pmp) CColRefSet(m_pmp)), // pass empty required relational properties initially
GPOS_NEW(m_pmp) DrgPstat(m_pmp), // pass empty stats context initially
m_ulCurrSearchStage
);
// schedule main optimization job
ScheduleMainJob(&sc, poc);
// run optimization job
CScheduler::Run(&sc);
poc->Release();
// extract best plan found at the end of current search stage
CExpression *pexprPlan =
m_pmemo->PexprExtractPlan
(
m_pmp,
m_pmemo->PgroupRoot(),
m_pqc->Prpp(),
m_pdrgpss->UlLength()
);
PssCurrent()->SetBestExpr(pexprPlan);
FinalizeSearchStage();
}
}
//---------------------------------------------------------------------------
// @function:
// CEngine::MultiThreadedOptimize
//
// @doc:
// Multi-threaded optimization
//
//---------------------------------------------------------------------------
void
CEngine::MultiThreadedOptimize
(
ULONG ulWorkers
)
{
GPOS_ASSERT(NULL != PgroupRoot());
GPOS_ASSERT(NULL != COptCtxt::PoctxtFromTLS());
const ULONG ulJobs = std::min((ULONG) GPOPT_JOBS_CAP, (ULONG) (m_pmemo->UlpGroups() * GPOPT_JOBS_PER_GROUP));
CJobFactory jf(m_pmp, ulJobs);
CScheduler sched(m_pmp, ulJobs, ulWorkers);
CSchedulerContext sc;
sc.Init(m_pmp, &jf, &sched, this);
const ULONG ulSearchStages = m_pdrgpss->UlLength();
for (ULONG ul = 0; !FSearchTerminated() && ul < ulSearchStages; ul++)
{
PssCurrent()->RestartTimer();
// optimize root group
m_pqc->Prpp()->AddRef();
COptimizationContext *poc = GPOS_NEW(m_pmp) COptimizationContext
(
m_pmp,
PgroupRoot(),
m_pqc->Prpp(),
GPOS_NEW(m_pmp) CReqdPropRelational(GPOS_NEW(m_pmp) CColRefSet(m_pmp)), // pass empty required relational properties initially
GPOS_NEW(m_pmp) DrgPstat(m_pmp), // pass empty stats context initially
m_ulCurrSearchStage
);
// schedule main optimization job
ScheduleMainJob(&sc, poc);
// create task array
CAutoRg<CTask*> a_rgptsk;
a_rgptsk = GPOS_NEW_ARRAY(m_pmp, CTask*, ulWorkers);
// create scheduling contexts
CAutoRg<CSchedulerContext> a_rgsc;
a_rgsc = GPOS_NEW_ARRAY(m_pmp, CSchedulerContext, ulWorkers);
// scope for ATP
{
CWorkerPoolManager *pwpm = CWorkerPoolManager::Pwpm();
CAutoTaskProxy atp(m_pmp, pwpm);
for (ULONG i = 0; i < ulWorkers; i++)
{
// initialize scheduling context
a_rgsc[i].Init(m_pmp, &jf, &sched, this);
// create scheduling task
a_rgptsk[i] = atp.PtskCreate(CScheduler::Run, &a_rgsc[i]);
// store a pointer to optimizer's context in current task local storage
a_rgptsk[i]->Tls().Reset(m_pmp);
a_rgptsk[i]->Tls().Store(COptCtxt::PoctxtFromTLS());
}
// start tasks
for (ULONG i = 0; i < ulWorkers; i++)
{
atp.Schedule(a_rgptsk[i]);
}
// wait for tasks to complete
for (ULONG i = 0; i < ulWorkers; i++)
{
CTask *ptsk;
atp.WaitAny(&ptsk);
}
}
poc->Release();
// extract best plan found at the end of current search stage
CExpression *pexprPlan =
m_pmemo->PexprExtractPlan
(
m_pmp,
m_pmemo->PgroupRoot(),
m_pqc->Prpp(),
m_pdrgpss->UlLength()
);
PssCurrent()->SetBestExpr(pexprPlan);
FinalizeSearchStage();
}
}
//---------------------------------------------------------------------------
// @function:
// CEngine::CEngine
//
// @doc:
// Ctor
//
//---------------------------------------------------------------------------
CExpression *
CEngine::PexprUnrank
(
ULLONG ullPlanId
)
{
// The CTE map will be updated by the Producer instead of the Sequence operator
// because we are doing a DFS traversal of the TreeMap.
CDrvdPropCtxtPlan *pdpctxtplan = GPOS_NEW(m_pmp) CDrvdPropCtxtPlan(m_pmp, false /*fUpdateCTEMap*/);
CExpression *pexpr = Pmemotmap()->PrUnrank(m_pmp, pdpctxtplan, ullPlanId);
pdpctxtplan->Release();
#ifdef GPOS_DEBUG
// check plan using configured plan checker, if any
COptimizerConfig *poconf = COptCtxt::PoctxtFromTLS()->Poconf();
CEnumeratorConfig *pec = poconf->Pec();
BOOL fCheck = pec->FCheckPlan(pexpr);
if (!fCheck)
{
CAutoTrace at(m_pmp);
at.Os() << "\nextracted plan failed PlanChecker function: " << std::endl << *pexpr;
}
GPOS_ASSERT(fCheck);
#endif // GPOS_DEBUG
return pexpr;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::PexprExtractPlan
//
// @doc:
// Extract a physical plan from the memo
//
//---------------------------------------------------------------------------
CExpression *
CEngine::PexprExtractPlan()
{
GPOS_ASSERT(NULL != m_pqc);
GPOS_ASSERT(NULL != m_pmemo);
GPOS_ASSERT(NULL != m_pmemo->PgroupRoot());
BOOL fGenerateAlt = false;
COptimizerConfig *poconf = COptCtxt::PoctxtFromTLS()->Poconf();
CEnumeratorConfig *pec = poconf->Pec();
if (pec->FEnumerate())
{
CAutoTrace at(m_pmp);
ULLONG ullCount = Pmemotmap()->UllCount();
at.Os() << "[OPT]: Number of plan alternatives: " << ullCount << std::endl;
if (0 < pec->UllPlanId())
{
if (pec->UllPlanId() > ullCount)
{
// an invalid plan number is chosen
GPOS_RAISE(gpopt::ExmaGPOPT, gpopt::ExmiInvalidPlanAlternative, pec->UllPlanId(), ullCount);
}
// a valid plan number was chosen
fGenerateAlt = true;
}
}
CExpression *pexpr = NULL;
if (fGenerateAlt)
{
pexpr = PexprUnrank(pec->UllPlanId() - 1 /*rank of plan alternative is zero-based*/);
CAutoTrace at(m_pmp);
at.Os() << "[OPT]: Successfully generated plan: " << pec->UllPlanId() << std::endl;
}
else
{
pexpr = m_pmemo->PexprExtractPlan
(
m_pmp,
m_pmemo->PgroupRoot(),
m_pqc->Prpp(),
m_pdrgpss->UlLength()
);
}
if (NULL == pexpr)
{
GPOS_RAISE(gpopt::ExmaGPOPT, gpopt::ExmiNoPlanFound);
}
return pexpr;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::UllRandomPlanId
//
// @doc:
// Generate random plan id
//
//---------------------------------------------------------------------------
ULLONG
CEngine::UllRandomPlanId
(
ULONG *pulSeed
)
{
ULLONG ullCount = Pmemotmap()->UllCount();
ULLONG ullPlanId = 0;
do
{
ullPlanId = clib::UlRandR(pulSeed);
}
while (ullPlanId >= ullCount);
return ullPlanId;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FValidPlanSample
//
// @doc:
// Extract a plan sample and handle exceptions according to enumerator
// configurations
//
//---------------------------------------------------------------------------
BOOL
CEngine::FValidPlanSample
(
CEnumeratorConfig *pec,
ULLONG ullPlanId,
CExpression **ppexpr // output: extracted plan
)
{
GPOS_ASSERT(NULL != pec);
GPOS_ASSERT(NULL != ppexpr);
BOOL fValidPlan = true;
if (pec->FSampleValidPlans())
{
// if enumerator is configured to extract valid plans only,
// we extract plan and catch invalid plan exception here
GPOS_TRY
{
*ppexpr = PexprUnrank(ullPlanId);
}
GPOS_CATCH_EX(ex)
{
if (GPOS_MATCH_EX(ex, gpopt::ExmaGPOPT, gpopt::ExmiUnsatisfiedRequiredProperties))
{
GPOS_RESET_EX;
fValidPlan = false;
}
else
{
// for all other exceptions, we bail out
GPOS_RETHROW(ex);
}
}
GPOS_CATCH_END;
}
else
{
// otherwise, we extract plan and leave exception handling to the caller
*ppexpr = PexprUnrank(ullPlanId);
}
return fValidPlan;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::SamplePlans
//
// @doc:
// Sample distribution of possible plans uniformly;
//
//---------------------------------------------------------------------------
void
CEngine::SamplePlans()
{
COptimizerConfig *poconf = COptCtxt::PoctxtFromTLS()->Poconf();
GPOS_ASSERT(NULL != poconf);
CEnumeratorConfig *pec = poconf->Pec();
ULLONG ullSamples = pec->UllInputSamples();
GPOS_ASSERT(0 < ullSamples);
pec->ClearSamples();
ULLONG ullCount = Pmemotmap()->UllCount();
if (0 == ullCount)
{
// optimizer generated no plans
return;
}
// generate full plan space when space size is less than or equal to
// the required number of samples
BOOL fGenerateAll = (ullSamples >= ullCount);
ULLONG ullTargetSamples = ullSamples;
if (fGenerateAll)
{
ullTargetSamples = ullCount;
}
// find cost of best plan
CExpression *pexpr =
m_pmemo->PexprExtractPlan
(
m_pmp,
m_pmemo->PgroupRoot(),
m_pqc->Prpp(),
m_pdrgpss->UlLength()
);
CCost costBest = pexpr->Cost();
pec->SetBestCost(costBest);
pexpr->Release();
// generate randomized seed using local time
TIMEVAL tv;
syslib::GetTimeOfDay(&tv, NULL/*timezone*/);
ULONG ulSeed = UlCombineHashes((ULONG) tv.tv_sec, (ULONG)tv.tv_usec);
// set maximum number of iterations based number of samples
// we use maximum iteration to prevent infinite looping below
const ULLONG ullMaxIters = ullTargetSamples * GPOPT_SAMPLING_MAX_ITERS;
ULLONG ullIters = 0;
ULLONG ull = 0;
while (ullIters < ullMaxIters && ull < ullTargetSamples)
{
// generate id of plan to be extracted
ULLONG ullPlanId = ull;
if (!fGenerateAll)
{
ullPlanId = UllRandomPlanId(&ulSeed);
}
pexpr = NULL;
BOOL fAccept = false;
if (FValidPlanSample(pec, ullPlanId, &pexpr))
{
// add plan to the sample if it is below cost threshold
CCost cost = pexpr->Cost();
fAccept = pec->FAddSample(ullPlanId, cost);
pexpr->Release();
}
if (fGenerateAll || fAccept)
{
ull++;
}
ullIters++;
}
pec->PrintPlanSample();
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FCheckEnfdProps
//
// @doc:
// Check enforceable properties and append enforcers to the current group if
// required.
//
// This check is done in two steps:
//
// First, it determines if any particular property needs to be enforced at
// all. For example, the EopttraceDisableSort traceflag can disable order
// enforcement. Also, if there are no partitioned tables referenced in the
// subtree, partition propagation enforcement can be skipped.
//
// Second, EPET methods are called for each property to determine if an
// enforcer needs to be added. These methods in turn call into virtual
// methods in the different operators. For example, CPhysical::EpetOrder()
// is used to determine a Sort node needs to be added to the group. These
// methods are passed an expression handle (to access derived properties of
// the subtree) and the required properties as a object of a subclass of
// CEnfdProp.
//
// Finally, based on return values of the EPET methods,
// CEnfdProp::AppendEnforcers() is called for each of the enforced
// properties.
//
// Returns true if no enforcers were created because they were deemed
// unnecessary or optional i.e all enforced properties were satisfied for
// the group expression under the current optimization context. Returns
// false otherwise.
//
// NB: This method is only concerned with a certain enforcer needs to be
// added into the group. Once added, there is no connection between the
// enforcer and the operator that created it. That is although some group
// expression X created the enforcer E, later, during costing, E can still
// decide to pick some other group expression Y for its child, since
// theoretically, all group expressions in a group are equivalent.
//
//---------------------------------------------------------------------------
BOOL
CEngine::FCheckEnfdProps
(
IMemoryPool *pmp,
CGroupExpression *pgexpr,
COptimizationContext *poc,
ULONG ulOptReq,
DrgPoc *pdrgpoc
)
{
GPOS_CHECK_ABORT;
if (GPOS_FTRACE(EopttracePrintMemoEnforcement))
{
CAutoTrace at(m_pmp);
at.Os() << "CEngine::FCheckEnfdProps (Group ID: " << pgexpr->Pgroup()->UlId() <<
" Expression ID: " << pgexpr->UlId() << ")"<< std::endl;
m_pmemo->OsPrint(at.Os());
}
// check if all children could be successfully optimized
if (!FChildrenOptimized(pdrgpoc))
{
return false;
}
// load a handle with derived plan properties
poc->AddRef();
pgexpr->AddRef();
pdrgpoc->AddRef();
CCostContext *pcc= GPOS_NEW(pmp) CCostContext(pmp, poc, ulOptReq, pgexpr);
pcc->SetChildContexts(pdrgpoc);
CExpressionHandle exprhdl(pmp);
exprhdl.Attach(pcc);
exprhdl.DerivePlanProps();
pcc->Release();
CPhysical *popPhysical = CPhysical::PopConvert(exprhdl.Pop());
CReqdPropPlan *prpp = poc->Prpp();
// check whether the current physical operator satisfies the CTE requirements
// and whether it is a motion over unresolved part consumers
if (!FValidCTEAndPartitionProperties(pmp, exprhdl, prpp))
{
return false;
}
// Determine if any property enforcement is disable or unnecessary
BOOL fOrderReqd =
!GPOS_FTRACE(EopttraceDisableSort) &&
!prpp->Peo()->PosRequired()->FEmpty();
BOOL fDistributionReqd =
!GPOS_FTRACE(EopttraceDisableMotions) &&
(CDistributionSpec::EdtAny != prpp->Ped()->PdsRequired()->Edt());
BOOL fRewindabilityReqd =
!GPOS_FTRACE(EopttraceDisableSpool) &&
(CRewindabilitySpec::ErtNone != prpp->Per()->PrsRequired()->Ert());
BOOL fPartPropagationReqd =
!GPOS_FTRACE(EopttraceDisablePartPropagation) &&
prpp->Pepp()->PppsRequired()->FPartPropagationReqd();
// Determine if adding an enforcer to the group is required, optional,
// unnecessary or prohibited over the group expression and given the current
// optimization context (required properties)
// get order enforcing type
CEnfdProp::EPropEnforcingType epetOrder =
prpp->Peo()->Epet(exprhdl, popPhysical, fOrderReqd);
// get distribution enforcing type
CEnfdProp::EPropEnforcingType epetDistribution = prpp->Ped()->Epet(exprhdl, popPhysical, prpp->Pepp()->PppsRequired(), fDistributionReqd);
// get rewindability enforcing type
CEnfdProp::EPropEnforcingType epetRewindability =
prpp->Per()->Epet(exprhdl, popPhysical, fRewindabilityReqd);
// get partition propagation enforcing type
CEnfdProp::EPropEnforcingType epetPartitionPropagation =
prpp->Pepp()->Epet(exprhdl, popPhysical, fPartPropagationReqd);
// Skip adding enforcers entirely if any property determines it to be
// 'prohibited'. In this way, a property may veto out the creation of an
// enforcer for the current group expression and optimization context.
//
// NB: Even though an enforcer E is not added because of some group
// expression G because it was prohibited, some other group expression H may
// decide to add it. And if E is added, it is possible for E to consider both
// G and H as its child.
if (FProhibited(epetOrder, epetDistribution, epetRewindability, epetPartitionPropagation))
{
return false;
}
DrgPexpr *pdrgpexprEnforcers = GPOS_NEW(pmp) DrgPexpr(pmp);
// extract a leaf pattern from target group
CBinding binding;
CExpression *pexpr =
binding.PexprExtract(m_pmp, exprhdl.Pgexpr(), m_pexprEnforcerPattern, NULL /* pexprLast */);
GPOS_ASSERT(NULL != pexpr);
GPOS_ASSERT(pexpr->Pgexpr()->Pgroup() == pgexpr->Pgroup());
prpp->Peo()->AppendEnforcers(pmp, prpp, pdrgpexprEnforcers, pexpr, epetOrder, exprhdl);
prpp->Ped()->AppendEnforcers(pmp, prpp, pdrgpexprEnforcers, pexpr, epetDistribution, exprhdl);
prpp->Per()->AppendEnforcers(pmp, prpp, pdrgpexprEnforcers, pexpr, epetRewindability, exprhdl);
prpp->Pepp()->AppendEnforcers(pmp, prpp, pdrgpexprEnforcers, pexpr, epetPartitionPropagation, exprhdl);
if (0 < pdrgpexprEnforcers->UlLength())
{
AddEnforcers(exprhdl.Pgexpr(), pdrgpexprEnforcers);
}
pdrgpexprEnforcers->Release();
pexpr->Release();
return FOptimize(epetOrder, epetDistribution, epetRewindability, epetPartitionPropagation);
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FValidCTEAndPartitionProperties
//
// @doc:
// Check if the given expression has valid cte and partition properties
// with respect to the given requirements. This function returns true iff
// ALL the following conditions are met:
// 1. The expression satisfies the CTE requirements
// 2. The root of the expression is not a motion over an unresolved part consumer
// 3. The expression does not have an unneeded part propagator
//
//---------------------------------------------------------------------------
BOOL
CEngine::FValidCTEAndPartitionProperties
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl,
CReqdPropPlan *prpp
)
{
CPhysical *popPhysical = CPhysical::PopConvert(exprhdl.Pop());
CPartIndexMap *ppimDrvd = CDrvdPropPlan::Pdpplan(exprhdl.Pdp())->Ppim();
return popPhysical->FProvidesReqdCTEs(exprhdl, prpp->Pcter()) &&
!CUtils::FMotionOverUnresolvedPartConsumers(pmp, exprhdl, prpp->Pepp()->PppsRequired()->Ppim()) &&
!ppimDrvd->FContainsRedundantPartitionSelectors(prpp->Pepp()->PppsRequired()->Ppim());
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FChildrenOptimized
//
// @doc:
// Check if all children were successfully optimized
//
//---------------------------------------------------------------------------
BOOL
CEngine::FChildrenOptimized
(
DrgPoc *pdrgpoc
)
{
GPOS_ASSERT(NULL != pdrgpoc);
const ULONG ulLen = pdrgpoc->UlLength();
for (ULONG ul = 0; ul < ulLen; ul++)
{
if (NULL == (*pdrgpoc)[ul]->PgexprBest())
{
return false;
}
}
return true;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FOptimize
//
// @doc:
// Check if optimization is possible under the given property enforcing
// types
//
//---------------------------------------------------------------------------
BOOL
CEngine::FOptimize
(
CEnfdProp::EPropEnforcingType epetOrder,
CEnfdProp::EPropEnforcingType epetDistribution,
CEnfdProp::EPropEnforcingType epetRewindability,
CEnfdProp::EPropEnforcingType epetPropagation
)
{
return CEnfdProp::FOptimize(epetOrder) &&
CEnfdProp::FOptimize(epetDistribution) &&
CEnfdProp::FOptimize(epetRewindability) &&
CEnfdProp::FOptimize(epetPropagation);
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FProhibited
//
// @doc:
// Check if any of the given property enforcing types prohibits enforcement
//
//---------------------------------------------------------------------------
BOOL
CEngine::FProhibited
(
CEnfdProp::EPropEnforcingType epetOrder,
CEnfdProp::EPropEnforcingType epetDistribution,
CEnfdProp::EPropEnforcingType epetRewindability,
CEnfdProp::EPropEnforcingType epetPropagation
)
{
return (CEnfdProp::EpetProhibited == epetOrder ||
CEnfdProp::EpetProhibited == epetDistribution ||
CEnfdProp::EpetProhibited == epetRewindability ||
CEnfdProp::EpetProhibited == epetPropagation);
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FCheckReqdPartPropagation
//
// @doc:
// Check if partition propagation resolver is passed an empty part propagation
// spec
//
//---------------------------------------------------------------------------
BOOL
CEngine::FCheckReqdPartPropagation
(
CPhysical *pop,
CEnfdPartitionPropagation *pepp
)
{
BOOL fPartPropagationReqd = (NULL != pepp && pepp->PppsRequired()->Ppim()->FContainsUnresolvedZeroPropagators());
return fPartPropagationReqd || COperator::EopPhysicalPartitionSelector != pop->Eopid();
}
//---------------------------------------------------------------------------
// @function:
// CEngine::FCheckReqdProps
//
// @doc:
// Determine if checking required properties is needed.
// This method is called after a group expression optimization job has
// started executing and can be used to cancel the job early.
//
// This is useful to prevent deadlocks when an enforcer optimizes same
// group with the same optimization context. Also, in case the subtree
// doesn't provide the required columns we can save optimization time by
// skipping this optimization request.
//
// NB: Only relational properties are available at this stage to make this
// decision.
//---------------------------------------------------------------------------
BOOL
CEngine::FCheckReqdProps
(
CExpressionHandle &exprhdl,
CReqdPropPlan *prpp,
ULONG ulOptReq
)
{
GPOS_CHECK_ABORT;
if (GPOS_FTRACE(EopttracePrintMemoEnforcement))
{
CAutoTrace at(m_pmp);
at.Os() << "CEngine::FCheckReqdProps (Group ID: " << exprhdl.Pgexpr()->Pgroup()->UlId() <<
" Expression ID: " << exprhdl.Pgexpr()->UlId() << ")" << std::endl;
m_pmemo->OsPrint(at.Os());
}
// check if operator provides required columns
if (!prpp->FProvidesReqdCols(m_pmp, exprhdl, ulOptReq))
{
return false;
}
CPhysical *popPhysical = CPhysical::PopConvert(exprhdl.Pop());
COperator::EOperatorId eopid = popPhysical->Eopid();
// check if sort operator is passed an empty order spec;
// this check is required to avoid self-deadlocks, i.e.
// sort optimizing same group with the same optimization context;
BOOL fOrderReqd = !prpp->Peo()->PosRequired()->FEmpty();
if (!fOrderReqd && COperator::EopPhysicalSort == eopid)
{
return false;
}
// check if motion operator is passed an ANY distribution spec;
// this check is required to avoid self-deadlocks, i.e.
// motion optimizing same group with the same optimization context;
BOOL fDistributionReqd =
(CDistributionSpec::EdtAny != prpp->Ped()->PdsRequired()->Edt());
if (!fDistributionReqd && CUtils::FPhysicalMotion(popPhysical))
{
return false;
}
// check if spool operator is passed a non-rewindable spec;
// this check is required to avoid self-deadlocks, i.e.
// spool optimizing same group with the same optimization context;
BOOL fRewindabilityReqd =
(CRewindabilitySpec::ErtNone != prpp->Per()->PrsRequired()->Ert());
if (!fRewindabilityReqd && COperator::EopPhysicalSpool == eopid)
{
return false;
}
return FCheckReqdPartPropagation(popPhysical, prpp->Pepp());
}
#ifdef GPOS_DEBUG
//---------------------------------------------------------------------------
// @function:
// CEngine::PrintRoot
//
// @doc:
// Print root group
//
//---------------------------------------------------------------------------
void
CEngine::PrintRoot()
{
CAutoTrace at(m_pmp);
at.Os() << "Root Group:" << std::endl;
m_pmemo->Pgroup(m_pmemo->PgroupRoot()->UlId())->OsPrint(at.Os());
at.Os() << std::endl;
}
//---------------------------------------------------------------------------
// @function:
// CEngine::PrintOptCtxts
//
// @doc:
// Print main optimization context and optimal cost context
//
//---------------------------------------------------------------------------
void
CEngine::PrintOptCtxts()
{
CAutoTrace at(m_pmp);
COptimizationContext *poc =
m_pmemo->PgroupRoot()->PocLookupBest(m_pmp, m_pdrgpss->UlLength(), m_pqc->Prpp());
GPOS_ASSERT(NULL != poc);
at.Os() << std::endl << "Main Opt Ctxt:" << std::endl;
(void) poc->OsPrint(at.Os(), " ");
at.Os() << std::endl;
at.Os() << "Optimal Cost Ctxt:" << std::endl;
(void) poc->PccBest()->OsPrint(at.Os());
at.Os() << std::endl;
}
#endif // GPOS_DEBUG
//---------------------------------------------------------------------------
// @function:
// CEngine::OsPrint
//
// @doc:
// print function
//
//---------------------------------------------------------------------------
IOstream &
CEngine::OsPrint
(
IOstream &os
)
const
{
return m_pmemo->OsPrint(os);
}
// EOF
| 69,509
| 25,720
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "android_webview/browser/input_stream.h"
#include "android_webview/browser/net/android_stream_reader_url_request_job.h"
#include "android_webview/browser/net/aw_url_request_job_factory.h"
#include "android_webview/browser/net/input_stream_reader.h"
#include "base/format_macros.h"
#include "base/message_loop.h"
#include "base/run_loop.h"
#include "base/stringprintf.h"
#include "net/url_request/url_request_job_factory_impl.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using android_webview::InputStream;
using android_webview::InputStreamReader;
using net::TestDelegate;
using net::TestJobInterceptor;
using net::TestNetworkDelegate;
using net::TestURLRequestContext;
using net::TestURLRequest;
using testing::DoAll;
using testing::Ge;
using testing::Gt;
using testing::InSequence;
using testing::Invoke;
using testing::InvokeWithoutArgs;
using testing::NotNull;
using testing::Return;
using testing::SaveArg;
using testing::SetArgPointee;
using testing::StrictMock;
using testing::Test;
using testing::WithArg;
using testing::WithArgs;
using testing::_;
// Some of the classes will DCHECK on a null InputStream (which is desirable).
// The workaround is to use this class. None of the methods need to be
// implemented as the mock InputStreamReader should never forward calls to the
// InputStream.
class NotImplInputStream : public InputStream {
public:
NotImplInputStream() {}
virtual ~NotImplInputStream() {}
virtual bool BytesAvailable(int* bytes_available) const OVERRIDE {
NOTIMPLEMENTED();
return false;
}
virtual bool Skip(int64_t n, int64_t* bytes_skipped) OVERRIDE {
NOTIMPLEMENTED();
return false;
}
virtual bool Read(net::IOBuffer* dest, int length, int* bytes_read) OVERRIDE {
NOTIMPLEMENTED();
return false;
}
};
// Required in order to create an instance of AndroidStreamReaderURLRequestJob.
class StreamReaderDelegate :
public AndroidStreamReaderURLRequestJob::Delegate {
public:
StreamReaderDelegate() {}
virtual scoped_ptr<InputStream> OpenInputStream(
JNIEnv* env,
const GURL& url) OVERRIDE {
return make_scoped_ptr<InputStream>(new NotImplInputStream());
}
virtual void OnInputStreamOpenFailed(net::URLRequest* request,
bool* restart) OVERRIDE {
*restart = false;
}
virtual bool GetMimeType(JNIEnv* env,
net::URLRequest* request,
android_webview::InputStream* stream,
std::string* mime_type) OVERRIDE {
return false;
}
virtual bool GetCharset(JNIEnv* env,
net::URLRequest* request,
android_webview::InputStream* stream,
std::string* charset) OVERRIDE {
return false;
}
};
class NullStreamReaderDelegate : public StreamReaderDelegate {
public:
NullStreamReaderDelegate() {}
virtual scoped_ptr<InputStream> OpenInputStream(
JNIEnv* env,
const GURL& url) OVERRIDE {
return make_scoped_ptr<InputStream>(NULL);
}
};
class MockInputStreamReader : public InputStreamReader {
public:
MockInputStreamReader() : InputStreamReader(new NotImplInputStream()) {}
~MockInputStreamReader() {}
MOCK_METHOD1(Seek, int(const net::HttpByteRange& byte_range));
MOCK_METHOD2(ReadRawData, int(net::IOBuffer* buffer, int buffer_size));
};
class TestStreamReaderJob : public AndroidStreamReaderURLRequestJob {
public:
TestStreamReaderJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
scoped_ptr<Delegate> delegate,
scoped_ptr<InputStreamReader> stream_reader)
: AndroidStreamReaderURLRequestJob(request,
network_delegate,
delegate.Pass()),
stream_reader_(stream_reader.Pass()) {
message_loop_proxy_ = base::MessageLoopProxy::current();
}
virtual scoped_ptr<InputStreamReader> CreateStreamReader(
InputStream* stream) OVERRIDE {
return stream_reader_.Pass();
}
protected:
virtual ~TestStreamReaderJob() {}
virtual base::TaskRunner* GetWorkerThreadRunner() OVERRIDE {
return message_loop_proxy_.get();
}
scoped_ptr<InputStreamReader> stream_reader_;
scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
};
class AndroidStreamReaderURLRequestJobTest : public Test {
public:
AndroidStreamReaderURLRequestJobTest() : loop_(base::MessageLoop::TYPE_IO) {}
protected:
virtual void SetUp() {
context_.set_job_factory(&factory_);
context_.set_network_delegate(&network_delegate_);
req_.reset(
new TestURLRequest(GURL("content://foo"),
&url_request_delegate_,
&context_,
&network_delegate_));
req_->set_method("GET");
}
void SetRange(net::URLRequest* req, int first_byte, int last_byte) {
net::HttpRequestHeaders headers;
headers.SetHeader(net::HttpRequestHeaders::kRange,
base::StringPrintf(
"bytes=%" PRIuS "-%" PRIuS,
first_byte, last_byte));
req->SetExtraRequestHeaders(headers);
}
void SetUpTestJob(scoped_ptr<InputStreamReader> stream_reader) {
SetUpTestJob(stream_reader.Pass(),
make_scoped_ptr(new StreamReaderDelegate())
.PassAs<AndroidStreamReaderURLRequestJob::Delegate>());
}
void SetUpTestJob(scoped_ptr<InputStreamReader> stream_reader,
scoped_ptr<AndroidStreamReaderURLRequestJob::Delegate>
stream_reader_delegate) {
TestStreamReaderJob* test_stream_reader_job =
new TestStreamReaderJob(
req_.get(),
&network_delegate_,
stream_reader_delegate.Pass(),
stream_reader.Pass());
// The Interceptor is owned by the |factory_|.
TestJobInterceptor* protocol_handler = new TestJobInterceptor;
protocol_handler->set_main_intercept_job(test_stream_reader_job);
bool set_protocol = factory_.SetProtocolHandler("http", protocol_handler);
DCHECK(set_protocol);
protocol_handler = new TestJobInterceptor;
protocol_handler->set_main_intercept_job(test_stream_reader_job);
set_protocol = factory_.SetProtocolHandler("content", protocol_handler);
DCHECK(set_protocol);
}
base::MessageLoop loop_;
TestURLRequestContext context_;
android_webview::AwURLRequestJobFactory factory_;
TestDelegate url_request_delegate_;
TestNetworkDelegate network_delegate_;
scoped_ptr<TestURLRequest> req_;
};
TEST_F(AndroidStreamReaderURLRequestJobTest, ReadEmptyStream) {
scoped_ptr<StrictMock<MockInputStreamReader> > stream_reader(
new StrictMock<MockInputStreamReader>());
{
InSequence s;
EXPECT_CALL(*stream_reader, Seek(_))
.WillOnce(Return(0));
EXPECT_CALL(*stream_reader, ReadRawData(NotNull(), Gt(0)))
.WillOnce(Return(0));
}
SetUpTestJob(stream_reader.PassAs<InputStreamReader>());
req_->Start();
// The TestDelegate will quit the message loop on request completion.
base::MessageLoop::current()->Run();
EXPECT_FALSE(url_request_delegate_.request_failed());
EXPECT_EQ(1, network_delegate_.completed_requests());
EXPECT_EQ(0, network_delegate_.error_count());
EXPECT_EQ(200, req_->GetResponseCode());
}
TEST_F(AndroidStreamReaderURLRequestJobTest, ReadWithNullStream) {
SetUpTestJob(scoped_ptr<InputStreamReader>(),
make_scoped_ptr(new NullStreamReaderDelegate())
.PassAs<AndroidStreamReaderURLRequestJob::Delegate>());
req_->Start();
// The TestDelegate will quit the message loop on request completion.
base::MessageLoop::current()->Run();
// The request_failed() method is named confusingly but all it checks is
// whether the request got as far as calling NotifyHeadersComplete.
EXPECT_FALSE(url_request_delegate_.request_failed());
EXPECT_EQ(1, network_delegate_.completed_requests());
// A null input stream shouldn't result in an error. See crbug.com/180950.
EXPECT_EQ(0, network_delegate_.error_count());
EXPECT_EQ(404, req_->GetResponseCode());
}
TEST_F(AndroidStreamReaderURLRequestJobTest, ReadPartOfStream) {
const int bytes_available = 128;
const int offset = 32;
const int bytes_to_read = bytes_available - offset;
scoped_ptr<StrictMock<MockInputStreamReader> > stream_reader(
new StrictMock<MockInputStreamReader>());
{
InSequence s;
EXPECT_CALL(*stream_reader, Seek(_))
.WillOnce(Return(bytes_available));
EXPECT_CALL(*stream_reader, ReadRawData(NotNull(), Ge(bytes_to_read)))
.WillOnce(Return(bytes_to_read/2));
EXPECT_CALL(*stream_reader, ReadRawData(NotNull(), Ge(bytes_to_read)))
.WillOnce(Return(bytes_to_read/2));
EXPECT_CALL(*stream_reader, ReadRawData(NotNull(), Ge(bytes_to_read)))
.WillOnce(Return(0));
}
SetUpTestJob(stream_reader.PassAs<InputStreamReader>());
SetRange(req_.get(), offset, bytes_available);
req_->Start();
base::MessageLoop::current()->Run();
EXPECT_FALSE(url_request_delegate_.request_failed());
EXPECT_EQ(bytes_to_read, url_request_delegate_.bytes_received());
EXPECT_EQ(1, network_delegate_.completed_requests());
EXPECT_EQ(0, network_delegate_.error_count());
}
TEST_F(AndroidStreamReaderURLRequestJobTest,
ReadStreamWithMoreAvailableThanActual) {
const int bytes_available_reported = 190;
const int bytes_available = 128;
const int offset = 0;
const int bytes_to_read = bytes_available - offset;
scoped_ptr<StrictMock<MockInputStreamReader> > stream_reader(
new StrictMock<MockInputStreamReader>());
{
InSequence s;
EXPECT_CALL(*stream_reader, Seek(_))
.WillOnce(Return(bytes_available_reported));
EXPECT_CALL(*stream_reader, ReadRawData(NotNull(), Ge(bytes_to_read)))
.WillOnce(Return(bytes_available));
EXPECT_CALL(*stream_reader, ReadRawData(NotNull(), Ge(bytes_to_read)))
.WillOnce(Return(0));
}
SetUpTestJob(stream_reader.PassAs<InputStreamReader>());
SetRange(req_.get(), offset, bytes_available_reported);
req_->Start();
base::MessageLoop::current()->Run();
EXPECT_FALSE(url_request_delegate_.request_failed());
EXPECT_EQ(bytes_to_read, url_request_delegate_.bytes_received());
EXPECT_EQ(1, network_delegate_.completed_requests());
EXPECT_EQ(0, network_delegate_.error_count());
}
TEST_F(AndroidStreamReaderURLRequestJobTest, DeleteJobMidWaySeek) {
const int offset = 20;
const int bytes_available = 128;
base::RunLoop loop;
scoped_ptr<StrictMock<MockInputStreamReader> > stream_reader(
new StrictMock<MockInputStreamReader>());
EXPECT_CALL(*stream_reader, Seek(_))
.WillOnce(DoAll(InvokeWithoutArgs(&loop, &base::RunLoop::Quit),
Return(bytes_available)));
ON_CALL(*stream_reader, ReadRawData(_, _))
.WillByDefault(Return(0));
SetUpTestJob(stream_reader.PassAs<InputStreamReader>());
SetRange(req_.get(), offset, bytes_available);
req_->Start();
loop.Run();
EXPECT_EQ(0, network_delegate_.completed_requests());
req_->Cancel();
EXPECT_EQ(1, network_delegate_.completed_requests());
}
TEST_F(AndroidStreamReaderURLRequestJobTest, DeleteJobMidWayRead) {
const int offset = 20;
const int bytes_available = 128;
base::RunLoop loop;
scoped_ptr<StrictMock<MockInputStreamReader> > stream_reader(
new StrictMock<MockInputStreamReader>());
net::CompletionCallback read_completion_callback;
EXPECT_CALL(*stream_reader, Seek(_))
.WillOnce(Return(bytes_available));
EXPECT_CALL(*stream_reader, ReadRawData(_, _))
.WillOnce(DoAll(InvokeWithoutArgs(&loop, &base::RunLoop::Quit),
Return(bytes_available)));
SetUpTestJob(stream_reader.PassAs<InputStreamReader>());
SetRange(req_.get(), offset, bytes_available);
req_->Start();
loop.Run();
EXPECT_EQ(0, network_delegate_.completed_requests());
req_->Cancel();
EXPECT_EQ(1, network_delegate_.completed_requests());
}
| 12,342
| 3,790
|
#ifndef _TESTMESSAGE_H_
#define _TESTMESSAGE_H_
#include <iostream>
#include <sstream>
#include <cstdint>
#include <vector>
/**
* Struct representing the data to send down the wire
*/
struct TestMessage
{
uint32_t m_MessageSize;
uint16_t m_p1Size;
uint16_t m_p2Size;
std::string m_p1;
std::string m_p2;
std::ostream& serialize(std::ostream &out) const
{
out << m_MessageSize;
out << ",";
out << m_p1Size;
out << ",";
out << m_p2Size;
out << ",";
out << m_p1;
out << ",";
out << m_p2;
return out;
}
std::istream& deserialize(std::istream &in)
{
if (in)
{
char comma;
in >> m_MessageSize;
in >> comma;
in >> m_p1Size;
in >> comma;
in >> m_p2Size;
in >> comma;
{
std::vector<char> tmp(m_p1Size);
in.read(&tmp[0], m_p1Size);
m_p1.assign(&tmp[0], m_p1Size);
}
in >> comma;
{
std::vector<char> tmp(m_p2Size);
in.read(&tmp[0], m_p2Size);
m_p2.assign(&tmp[0], m_p2Size);
}
}
return in;
}
};
#endif // _TESTMESSAGE_H_
| 1,310
| 459
|
//
// Copyright (c) 2017-2018 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#include "misc/debug.h"
#include "misc/object_tracker.h"
#include <algorithm>
static Anvil::ObjectTracker* object_tracker_ptr = nullptr;
/** Constructor. */
Anvil::ObjectTracker::ObjectTracker()
:CallbacksSupportProvider(OBJECT_TRACKER_CALLBACK_ID_COUNT)
{
/* Stub */
}
/* Please see header for specification */
void Anvil::ObjectTracker::destroy()
{
delete object_tracker_ptr;
object_tracker_ptr = nullptr;
}
/* Please see header for specification */
Anvil::ObjectTracker* Anvil::ObjectTracker::get()
{
if (object_tracker_ptr == nullptr)
{
object_tracker_ptr = new ObjectTracker();
}
return object_tracker_ptr;
}
/* Please see header for specification */
void Anvil::ObjectTracker::check_for_leaks() const
{
std::unique_lock<std::mutex> lock(m_cs);
for (const auto& current_object_type_alloc_data : m_object_allocations)
{
const uint32_t n_object_allocations = static_cast<uint32_t>(current_object_type_alloc_data.second.size() );
if (n_object_allocations > 0)
{
fprintf(stdout,
"The following %s instances have not been released:\n",
get_object_type_name(current_object_type_alloc_data.first) );
for (const auto& current_alloc : current_object_type_alloc_data.second)
{
fprintf(stdout,
"[%d]. %p\n",
current_alloc.n_allocation,
current_alloc.object_ptr);
}
fprintf(stdout,
"\n");
}
}
}
/** Converts @param object_type enum to a null-terminated string.
*
* @param object_type Internal wrapper object type to return the string for.
*
* @return As per description.
**/
const char* Anvil::ObjectTracker::get_object_type_name(const Anvil::ObjectType& in_object_type) const
{
const char* result_ptr = "?!";
switch (in_object_type)
{
case Anvil::ObjectType::BUFFER: result_ptr = "Buffer"; break;
case Anvil::ObjectType::BUFFER_VIEW: result_ptr = "Buffer View"; break;
case Anvil::ObjectType::COMMAND_BUFFER: result_ptr = "Command Buffer"; break;
case Anvil::ObjectType::COMMAND_POOL: result_ptr = "Command Pool"; break;
case Anvil::ObjectType::DESCRIPTOR_POOL: result_ptr = "Descriptor Pool"; break;
case Anvil::ObjectType::DESCRIPTOR_SET: result_ptr = "Descriptor Set"; break;
case Anvil::ObjectType::DESCRIPTOR_SET_LAYOUT: result_ptr = "Descriptor Set Layout"; break;
case Anvil::ObjectType::DESCRIPTOR_UPDATE_TEMPLATE: result_ptr = "Descriptor Update Template"; break;
case Anvil::ObjectType::DEVICE: result_ptr = "Device"; break;
case Anvil::ObjectType::EVENT: result_ptr = "Event"; break;
case Anvil::ObjectType::FENCE: result_ptr = "Fence"; break;
case Anvil::ObjectType::FRAMEBUFFER: result_ptr = "Framebuffer"; break;
case Anvil::ObjectType::IMAGE: result_ptr = "Image"; break;
case Anvil::ObjectType::IMAGE_VIEW: result_ptr = "Image View"; break;
case Anvil::ObjectType::INSTANCE: result_ptr = "Instance"; break;
case Anvil::ObjectType::PHYSICAL_DEVICE: result_ptr = "Physical Device"; break;
case Anvil::ObjectType::PIPELINE_CACHE: result_ptr = "Pipeline Cache"; break;
case Anvil::ObjectType::PIPELINE_LAYOUT: result_ptr = "Pipeline Layout"; break;
case Anvil::ObjectType::QUERY_POOL: result_ptr = "Query Pool"; break;
case Anvil::ObjectType::QUEUE: result_ptr = "Queue"; break;
case Anvil::ObjectType::RENDER_PASS: result_ptr = "Render Pass"; break;
case Anvil::ObjectType::RENDERING_SURFACE: result_ptr = "Rendering Surface"; break;
case Anvil::ObjectType::SAMPLER: result_ptr = "Sampler"; break;
case Anvil::ObjectType::SEMAPHORE: result_ptr = "Semaphore"; break;
case Anvil::ObjectType::SHADER_MODULE: result_ptr = "Shader Module"; break;
case Anvil::ObjectType::SWAPCHAIN: result_ptr = "Swapchain"; break;
case Anvil::ObjectType::ANVIL_COMPUTE_PIPELINE_MANAGER: result_ptr = "Anvil Compute Pipeline Manager"; break;
case Anvil::ObjectType::ANVIL_DESCRIPTOR_SET_GROUP: result_ptr = "Anvil Descriptor Set Group"; break;
case Anvil::ObjectType::ANVIL_DESCRIPTOR_SET_LAYOUT_MANAGER: result_ptr = "Anvil Descriptor Set Layout Manager"; break;
case Anvil::ObjectType::ANVIL_GLSL_SHADER_TO_SPIRV_GENERATOR: result_ptr = "Anvil GLSL Shader->SPIRV Generator"; break;
case Anvil::ObjectType::ANVIL_GRAPHICS_PIPELINE_MANAGER: result_ptr = "Anvil Graphics Pipeline Manager"; break;
case Anvil::ObjectType::ANVIL_MEMORY_BLOCK: result_ptr = "Anvil Memory Block"; break;
case Anvil::ObjectType::ANVIL_PIPELINE_LAYOUT_MANAGER: result_ptr = "Anvil Pipeline Layout Manager"; break;
default:
{
anvil_assert_fail();
}
}
return result_ptr;
}
/* Please see header for specification */
void* Anvil::ObjectTracker::get_object_at_index(const ObjectType& in_object_type,
uint32_t in_alloc_index) const
{
std::unique_lock<std::mutex> lock (m_cs);
void* result(nullptr);
if (m_object_allocations[in_object_type].size() > in_alloc_index)
{
result = m_object_allocations[in_object_type][in_alloc_index].object_ptr;
}
return result;
}
/* Please see header for specification */
void Anvil::ObjectTracker::register_object(const ObjectType& in_object_type,
void* in_object_ptr)
{
anvil_assert(in_object_ptr != nullptr);
{
std::unique_lock<std::mutex> lock(m_cs);
m_object_allocations[in_object_type].push_back(ObjectAllocation(m_n_objects_allocated_array[in_object_type]++,
in_object_ptr) );
}
/* Notify any observers about the new object */
OnObjectRegisteredCallbackArgument callback_arg(in_object_type,
in_object_ptr);
if (in_object_type == Anvil::ObjectType::ANVIL_GLSL_SHADER_TO_SPIRV_GENERATOR)
{
callback_safe(OBJECT_TRACKER_CALLBACK_ID_ON_GLSL_SHADER_TO_SPIRV_GENERATOR_OBJECT_REGISTERED,
&callback_arg);
}
else
if (in_object_type == Anvil::ObjectType::SHADER_MODULE)
{
callback_safe(OBJECT_TRACKER_CALLBACK_ID_ON_SHADER_MODULE_OBJECT_REGISTERED,
&callback_arg);
}
}
/* Please see header for specification */
void Anvil::ObjectTracker::unregister_object(const ObjectType& in_object_type,
void* in_object_ptr)
{
OnObjectAboutToBeUnregisteredCallbackArgument callback_arg(in_object_type,
in_object_ptr);
{
std::unique_lock<std::mutex> lock (m_cs);
auto object_allocation_iterator(std::find(m_object_allocations[in_object_type].begin(),
m_object_allocations[in_object_type].end(),
in_object_ptr) );
if (object_allocation_iterator == m_object_allocations[in_object_type].end() )
{
anvil_assert_fail();
goto end;
}
m_object_allocations[in_object_type].erase(object_allocation_iterator);
}
/* Notify any observers about the event. */
if (in_object_type == Anvil::ObjectType::DEVICE)
{
callback_safe(OBJECT_TRACKER_CALLBACK_ID_ON_DEVICE_OBJECT_ABOUT_TO_BE_UNREGISTERED,
&callback_arg);
}
else
if (in_object_type == Anvil::ObjectType::ANVIL_GLSL_SHADER_TO_SPIRV_GENERATOR)
{
callback_safe(OBJECT_TRACKER_CALLBACK_ID_ON_GLSL_SHADER_TO_SPIRV_GENERATOR_OBJECT_ABOUT_TO_BE_UNREGISTERED,
&callback_arg);
}
else
if (in_object_type == Anvil::ObjectType::PIPELINE_LAYOUT)
{
callback_safe(OBJECT_TRACKER_CALLBACK_ID_ON_PIPELINE_LAYOUT_OBJECT_ABOUT_TO_BE_UNREGISTERED,
&callback_arg);
}
else
if (in_object_type == Anvil::ObjectType::SHADER_MODULE)
{
callback_safe(OBJECT_TRACKER_CALLBACK_ID_ON_SHADER_MODULE_OBJECT_ABOUT_TO_BE_UNREGISTERED,
&callback_arg);
}
end:
;
}
| 10,597
| 3,208
|
//
// libtgvoip is free and unencumbered public domain software.
// For more information, see http://unlicense.org or the UNLICENSE file
// you should have received with this source code distribution.
//
#include "EchoCanceller.h"
#include "audio/AudioOutput.h"
#include "audio/AudioInput.h"
#include "logging.h"
#include <string.h>
#include <stdio.h>
#ifndef TGVOIP_NO_DSP
#ifndef TGVOIP_USE_DESKTOP_DSP
#include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h"
#include "webrtc/modules/audio_processing/ns/noise_suppression_x.h"
#else
#include "webrtc/modules/audio_processing/aec/echo_cancellation.h"
//#include "webrtc/modules/audio_processing/ns/noise_suppression.h"
#include "webrtc/modules/audio_processing/ns/noise_suppression_x.h"
#endif
#include "webrtc/modules/audio_processing/splitting_filter.h"
#include "webrtc/common_audio/channel_buffer.h"
#include "webrtc/modules/audio_processing/agc/legacy/gain_control.h"
#endif
#define AEC_FRAME_SIZE 160
#define OFFSET_STEP AEC_FRAME_SIZE*2
//#define CLAMP(x, min, max) (x<max ? (x>min ? x : min) : max)
#define CLAMP(x, min, max) x
using namespace tgvoip;
#ifdef TGVOIP_USE_DESKTOP_DSP
namespace webrtc{
void WebRtcAec_enable_delay_agnostic(AecCore* self, int enable);
}
#endif
EchoCanceller::EchoCanceller(bool enableAEC, bool enableNS, bool enableAGC){
#ifndef TGVOIP_NO_DSP
this->enableAEC=enableAEC;
this->enableAGC=enableAGC;
this->enableNS=enableNS;
isOn=true;
splittingFilter=new webrtc::SplittingFilter(1, 3, 960);
splittingFilterFarend=new webrtc::SplittingFilter(1, 3, 960);
splittingFilterIn=new webrtc::IFChannelBuffer(960, 1, 1);
splittingFilterFarendIn=new webrtc::IFChannelBuffer(960, 1, 1);
splittingFilterOut=new webrtc::IFChannelBuffer(960, 1, 3);
splittingFilterFarendOut=new webrtc::IFChannelBuffer(960, 1, 3);
if(enableAEC){
#ifndef TGVOIP_USE_DESKTOP_DSP
aec=WebRtcAecm_Create();
WebRtcAecm_Init(aec, 16000);
AecmConfig cfg;
cfg.cngMode=AecmFalse;
cfg.echoMode=0;
WebRtcAecm_set_config(aec, cfg);
#else
aec=webrtc::WebRtcAec_Create();
webrtc::WebRtcAec_Init(aec, 48000, 48000);
webrtc::WebRtcAec_enable_delay_agnostic(webrtc::WebRtcAec_aec_core(aec), 1);
webrtc::AecConfig config;
config.metricsMode=webrtc::kAecFalse;
config.nlpMode=webrtc::kAecNlpAggressive;
config.skewMode=webrtc::kAecFalse;
config.delay_logging=webrtc::kAecFalse;
webrtc::WebRtcAec_set_config(aec, config);
#endif
farendQueue=new BlockingQueue<int16_t*>(11);
farendBufferPool=new BufferPool(960*2, 10);
running=true;
bufferFarendThread=new Thread(new MethodPointer<EchoCanceller>(&EchoCanceller::RunBufferFarendThread, this), NULL);
bufferFarendThread->Start();
}else{
aec=NULL;
}
if(enableNS){
//#ifndef TGVOIP_USE_DESKTOP_DSP
ns=WebRtcNsx_Create();
WebRtcNsx_Init((NsxHandle*)ns, 48000);
WebRtcNsx_set_policy((NsxHandle*)ns, 0);
/*#else
ns=WebRtcNs_Create();
WebRtcNs_Init((NsHandle*)ns, 48000);
WebRtcNs_set_policy((NsHandle*)ns, 1);
#endif*/
}else{
ns=NULL;
}
if(enableAGC){
agc=WebRtcAgc_Create();
WebRtcAgcConfig agcConfig;
agcConfig.compressionGaindB = 20;
agcConfig.limiterEnable = 1;
agcConfig.targetLevelDbfs = 9;
WebRtcAgc_Init(agc, 0, 255, kAgcModeAdaptiveDigital, 48000);
WebRtcAgc_set_config(agc, agcConfig);
agcMicLevel=0;
}else{
agc=NULL;
}
#else
this->enableAEC=this->enableAGC=enableAGC=this->enableNS=enableNS=false;
isOn=true;
#endif
}
EchoCanceller::~EchoCanceller(){
#ifndef TGVOIP_NO_DSP
if(enableAEC){
running=false;
farendQueue->Put(NULL);
bufferFarendThread->Join();
delete bufferFarendThread;
delete farendQueue;
delete farendBufferPool;
#ifndef TGVOIP_USE_DESKTOP_DSP
WebRtcAecm_Free(aec);
#else
webrtc::WebRtcAec_Free(aec);
#endif
}
if(enableNS){
//#ifndef TGVOIP_USE_DESKTOP_DSP
WebRtcNsx_Free((NsxHandle*)ns);
/*#else
WebRtcNs_Free((NsHandle*)ns);
#endif*/
}
if(enableAGC){
WebRtcAgc_Free(agc);
}
//webrtc::WebRtcAec_Free(state);
delete (webrtc::SplittingFilter*)splittingFilter;
delete (webrtc::SplittingFilter*)splittingFilterFarend;
delete (webrtc::IFChannelBuffer*)splittingFilterIn;
delete (webrtc::IFChannelBuffer*)splittingFilterOut;
delete (webrtc::IFChannelBuffer*)splittingFilterFarendIn;
delete (webrtc::IFChannelBuffer*)splittingFilterFarendOut;
#endif
}
void EchoCanceller::Start(){
}
void EchoCanceller::Stop(){
}
void EchoCanceller::SpeakerOutCallback(unsigned char* data, size_t len){
if(len!=960*2 || !enableAEC || !isOn)
return;
/*size_t offset=0;
while(offset<len){
WebRtcAecm_BufferFarend(state, (int16_t*)(data+offset), AEC_FRAME_SIZE);
offset+=OFFSET_STEP;
}*/
#ifndef TGVOIP_NO_DSP
int16_t* buf=(int16_t*)farendBufferPool->Get();
if(buf){
memcpy(buf, data, 960*2);
farendQueue->Put(buf);
}
#endif
}
#ifndef TGVOIP_NO_DSP
void EchoCanceller::RunBufferFarendThread(void* arg){
while(running){
int16_t* samplesIn=farendQueue->GetBlocking();
if(samplesIn){
webrtc::IFChannelBuffer* bufIn=(webrtc::IFChannelBuffer*) splittingFilterFarendIn;
webrtc::IFChannelBuffer* bufOut=(webrtc::IFChannelBuffer*) splittingFilterFarendOut;
memcpy(bufIn->ibuf()->bands(0)[0], samplesIn, 960*2);
farendBufferPool->Reuse((unsigned char *) samplesIn);
((webrtc::SplittingFilter*)splittingFilterFarend)->Analysis(bufIn, bufOut);
aecMutex.Lock();
//outstandingFarendFrames++;
//LOGV("BufferFarend: %d frames", outstandingFarendFrames);
#ifndef TGVOIP_USE_DESKTOP_DSP
WebRtcAecm_BufferFarend(aec, bufOut->ibuf_const()->bands(0)[0], 160);
WebRtcAecm_BufferFarend(aec, bufOut->ibuf_const()->bands(0)[0]+160, 160);
#else
webrtc::WebRtcAec_BufferFarend(aec, bufOut->fbuf_const()->bands(0)[0], 160);
webrtc::WebRtcAec_BufferFarend(aec, bufOut->fbuf_const()->bands(0)[0]+160, 160);
#endif
aecMutex.Unlock();
didBufferFarend=true;
}
}
}
#endif
void EchoCanceller::Enable(bool enabled){
isOn=enabled;
}
void EchoCanceller::ProcessInput(unsigned char* data, unsigned char* out, size_t len){
int i;
if(!isOn || (!enableAEC && !enableAGC && !enableNS)){
memcpy(out, data, len);
return;
}
#ifndef TGVOIP_NO_DSP
int16_t* samplesIn=(int16_t*)data;
int16_t* samplesOut=(int16_t*)out;
webrtc::IFChannelBuffer* bufIn=(webrtc::IFChannelBuffer*) splittingFilterIn;
webrtc::IFChannelBuffer* bufOut=(webrtc::IFChannelBuffer*) splittingFilterOut;
memcpy(bufIn->ibuf()->bands(0)[0], samplesIn, 960*2);
((webrtc::SplittingFilter*)splittingFilter)->Analysis(bufIn, bufOut);
#ifndef TGVOIP_USE_DESKTOP_DSP
if(enableAEC && enableNS){
int16_t _nsOut[3][320];
int16_t* nsIn[3];
int16_t* nsOut[3];
for(i=0;i<3;i++){
nsIn[i]=(int16_t*)bufOut->ibuf_const()->bands(0)[i];
nsOut[i]=_nsOut[i];
}
WebRtcNsx_Process((NsxHandle*)ns, (const short *const *) nsIn, 3, nsOut);
for(i=0;i<3;i++){
nsOut[i]+=160;
nsIn[i]+=160;
}
WebRtcNsx_Process((NsxHandle*)ns, (const short *const *) nsIn, 3, nsOut);
memcpy(bufOut->ibuf()->bands(0)[1], _nsOut[1], 320*2*2);
aecMutex.Lock();
WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0], _nsOut[0], samplesOut, AEC_FRAME_SIZE, (int16_t) tgvoip::audio::AudioOutput::GetEstimatedDelay());
WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0]+160, _nsOut[0]+160, samplesOut+160, AEC_FRAME_SIZE, (int16_t) (tgvoip::audio::AudioOutput::GetEstimatedDelay()+audio::AudioInput::GetEstimatedDelay()));
aecMutex.Unlock();
memcpy(bufOut->ibuf()->bands(0)[0], samplesOut, 320*2);
}else if(enableAEC){
aecMutex.Lock();
WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0], NULL, samplesOut, AEC_FRAME_SIZE, (int16_t) tgvoip::audio::AudioOutput::GetEstimatedDelay());
WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0]+160, NULL, samplesOut+160, AEC_FRAME_SIZE, (int16_t) (tgvoip::audio::AudioOutput::GetEstimatedDelay()+audio::AudioInput::GetEstimatedDelay()));
aecMutex.Unlock();
memcpy(bufOut->ibuf()->bands(0)[0], samplesOut, 320*2);
}else if(enableNS){
int16_t _nsOut[3][320];
int16_t* nsIn[3];
int16_t* nsOut[3];
for(i=0;i<3;i++){
nsIn[i]=(int16_t*)bufOut->ibuf_const()->bands(0)[i];
nsOut[i]=_nsOut[i];
}
WebRtcNsx_Process((NsxHandle*)ns, (const short *const *) nsIn, 3, nsOut);
for(i=0;i<3;i++){
nsOut[i]+=160;
nsIn[i]+=160;
}
WebRtcNsx_Process((NsxHandle*)ns, (const short *const *) nsIn, 3, nsOut);
memcpy(bufOut->ibuf()->bands(0)[0], _nsOut[0], 320*2);
memcpy(bufOut->ibuf()->bands(0)[1], _nsOut[1], 320*2);
memcpy(bufOut->ibuf()->bands(0)[2], _nsOut[2], 320*2);
}
#else
/*if(enableNS){
float _nsOut[3][320];
const float* nsIn[3];
float* nsOut[3];
for(i=0;i<3;i++){
nsIn[i]=bufOut->fbuf_const()->bands(0)[i];
nsOut[i]=_nsOut[i];
}
WebRtcNs_Process((NsHandle*)ns, nsIn, 3, nsOut);
for(i=0;i<3;i++){
nsOut[i]+=160;
nsIn[i]+=160;
}
WebRtcNs_Process((NsHandle*)ns, nsIn, 3, nsOut);
memcpy(bufOut->fbuf()->bands(0)[0], _nsOut[0], 320*4);
memcpy(bufOut->fbuf()->bands(0)[1], _nsOut[1], 320*4);
memcpy(bufOut->fbuf()->bands(0)[2], _nsOut[2], 320*4);
}*/
if(enableNS){
int16_t _nsOut[3][320];
int16_t* nsIn[3];
int16_t* nsOut[3];
for(i=0;i<3;i++){
nsIn[i]=(int16_t*)bufOut->ibuf_const()->bands(0)[i];
nsOut[i]=_nsOut[i];
}
WebRtcNsx_Process((NsxHandle*)ns, (const short *const *)nsIn, 3, nsOut);
for(i=0;i<3;i++){
nsOut[i]+=160;
nsIn[i]+=160;
}
WebRtcNsx_Process((NsxHandle*)ns, (const short *const *)nsIn, 3, nsOut);
memcpy(bufOut->ibuf()->bands(0)[0], _nsOut[0], 320*2);
memcpy(bufOut->ibuf()->bands(0)[1], _nsOut[1], 320*2);
memcpy(bufOut->ibuf()->bands(0)[2], _nsOut[2], 320*2);
}
if(enableAEC){
const float* aecIn[3];
float* aecOut[3];
float _aecOut[3][320];
for(i=0;i<3;i++){
aecIn[i]=bufOut->fbuf_const()->bands(0)[i];
aecOut[i]=_aecOut[i];
}
webrtc::WebRtcAec_Process(aec, aecIn, 3, aecOut, AEC_FRAME_SIZE, audio::AudioOutput::GetEstimatedDelay()+audio::AudioInput::GetEstimatedDelay(), 0);
for(i=0;i<3;i++){
aecOut[i]+=160;
aecIn[i]+=160;
}
webrtc::WebRtcAec_Process(aec, aecIn, 3, aecOut, AEC_FRAME_SIZE, audio::AudioOutput::GetEstimatedDelay()+audio::AudioInput::GetEstimatedDelay(), 0);
//outstandingFarendFrames--;
//LOGV("Process: %d frames", outstandingFarendFrames);
memcpy(bufOut->fbuf()->bands(0)[0], _aecOut[0], 320*4);
memcpy(bufOut->fbuf()->bands(0)[1], _aecOut[1], 320*4);
memcpy(bufOut->fbuf()->bands(0)[2], _aecOut[2], 320*4);
}
#endif
if(enableAGC){
int16_t _agcOut[3][320];
int16_t* agcIn[3];
int16_t* agcOut[3];
for(i=0;i<3;i++){
agcIn[i]=(int16_t*)bufOut->ibuf_const()->bands(0)[i];
agcOut[i]=_agcOut[i];
}
uint8_t saturation;
WebRtcAgc_AddMic(agc, agcIn, 3, 160);
WebRtcAgc_Process(agc, (const int16_t *const *) agcIn, 3, 160, agcOut, agcMicLevel, &agcMicLevel, 0, &saturation);
for(i=0;i<3;i++){
agcOut[i]+=160;
agcIn[i]+=160;
}
WebRtcAgc_AddMic(agc, agcIn, 3, 160);
WebRtcAgc_Process(agc, (const int16_t *const *) agcIn, 3, 160, agcOut, agcMicLevel, &agcMicLevel, 0, &saturation);
//LOGV("AGC mic level %d", agcMicLevel);
memcpy(bufOut->ibuf()->bands(0)[0], _agcOut[0], 320*2);
memcpy(bufOut->ibuf()->bands(0)[1], _agcOut[1], 320*2);
memcpy(bufOut->ibuf()->bands(0)[2], _agcOut[2], 320*2);
}
((webrtc::SplittingFilter*)splittingFilter)->Synthesis(bufOut, bufIn);
memcpy(samplesOut, bufIn->ibuf_const()->bands(0)[0], 960*2);
#endif
}
void EchoCanceller::SetAECStrength(int strength){
#ifndef TGVOIP_NO_DSP
if(aec){
#ifndef TGVOIP_USE_DESKTOP_DSP
AecmConfig cfg;
cfg.cngMode=AecmFalse;
cfg.echoMode=(int16_t) strength;
WebRtcAecm_set_config(aec, cfg);
#endif
}
#endif
}
AudioEffect::~AudioEffect(){
}
void AudioEffect::SetPassThrough(bool passThrough){
this->passThrough=passThrough;
}
AutomaticGainControl::AutomaticGainControl(){
#ifndef TGVOIP_NO_DSP
splittingFilter=new webrtc::SplittingFilter(1, 3, 960);
splittingFilterIn=new webrtc::IFChannelBuffer(960, 1, 1);
splittingFilterOut=new webrtc::IFChannelBuffer(960, 1, 3);
agc=WebRtcAgc_Create();
WebRtcAgcConfig agcConfig;
agcConfig.compressionGaindB = 9;
agcConfig.limiterEnable = 1;
agcConfig.targetLevelDbfs = 3;
WebRtcAgc_Init(agc, 0, 255, kAgcModeAdaptiveDigital, 48000);
WebRtcAgc_set_config(agc, agcConfig);
agcMicLevel=0;
#endif
}
AutomaticGainControl::~AutomaticGainControl(){
#ifndef TGVOIP_NO_DSP
delete (webrtc::SplittingFilter*)splittingFilter;
delete (webrtc::IFChannelBuffer*)splittingFilterIn;
delete (webrtc::IFChannelBuffer*)splittingFilterOut;
WebRtcAgc_Free(agc);
#endif
}
void AutomaticGainControl::Process(int16_t *inOut, size_t numSamples){
#ifndef TGVOIP_NO_DSP
if(passThrough)
return;
if(numSamples!=960){
LOGW("AutomaticGainControl only works on 960-sample buffers (got %u samples)", (unsigned int)numSamples);
return;
}
//LOGV("processing frame through AGC");
webrtc::IFChannelBuffer* bufIn=(webrtc::IFChannelBuffer*) splittingFilterIn;
webrtc::IFChannelBuffer* bufOut=(webrtc::IFChannelBuffer*) splittingFilterOut;
memcpy(bufIn->ibuf()->bands(0)[0], inOut, 960*2);
((webrtc::SplittingFilter*)splittingFilter)->Analysis(bufIn, bufOut);
int i;
int16_t _agcOut[3][320];
int16_t* agcIn[3];
int16_t* agcOut[3];
for(i=0;i<3;i++){
agcIn[i]=(int16_t*)bufOut->ibuf_const()->bands(0)[i];
agcOut[i]=_agcOut[i];
}
uint8_t saturation;
WebRtcAgc_AddMic(agc, agcIn, 3, 160);
WebRtcAgc_Process(agc, (const int16_t *const *) agcIn, 3, 160, agcOut, agcMicLevel, &agcMicLevel, 0, &saturation);
for(i=0;i<3;i++){
agcOut[i]+=160;
agcIn[i]+=160;
}
WebRtcAgc_AddMic(agc, agcIn, 3, 160);
WebRtcAgc_Process(agc, (const int16_t *const *) agcIn, 3, 160, agcOut, agcMicLevel, &agcMicLevel, 0, &saturation);
memcpy(bufOut->ibuf()->bands(0)[0], _agcOut[0], 320*2);
memcpy(bufOut->ibuf()->bands(0)[1], _agcOut[1], 320*2);
memcpy(bufOut->ibuf()->bands(0)[2], _agcOut[2], 320*2);
((webrtc::SplittingFilter*)splittingFilter)->Synthesis(bufOut, bufIn);
memcpy(inOut, bufIn->ibuf_const()->bands(0)[0], 960*2);
#endif
}
| 13,974
| 6,865
|
// $Id: CglTwomir.cpp 1132 2013-04-25 18:57:12Z stefan $
// Copyright (C) 2002, International Business Machines
// Corporation and others. All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cfloat>
#include <cassert>
#include <iostream>
#include "CoinPragma.hpp"
#include "CoinHelperFunctions.hpp"
#include "CoinPackedVector.hpp"
#include "CoinPackedMatrix.hpp"
#include "CoinIndexedVector.hpp"
#include "OsiRowCutDebugger.hpp"
#include "CoinFactorization.hpp"
#include "CoinWarmStartBasis.hpp"
#include "CoinFinite.hpp"
#include "CoinPackedMatrix.hpp"
#include "OsiRowCutDebugger.hpp"
#include "CoinWarmStartBasis.hpp"
#include "CglTwomir.hpp"
class CoinWarmStartBasis;
#define COIN_HAS_CLP_TWOMIR
#ifdef COIN_HAS_CLP_TWOMIR
#include "OsiClpSolverInterface.hpp"
#endif
#undef DGG_DEBUG_DGG
//#define DGG_DEBUG_DGG 1
//#define CGL_DEBUG
//#define CGL_DEBUG_ZERO
#define q_max data->cparams.q_max
#define q_min data->cparams.q_min
#define t_max data->cparams.t_max
#define t_min data->cparams.t_min
#define a_max data->cparams.a_max
#define max_elements data->cparams.max_elements
#ifdef CGL_DEBUG
// Declarations and defines for debug build.
#define talk true
namespace {
const OsiSolverInterface *six ;
}
void write_cut( DGG_constraint_t *cut){ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
printf("2mir_test: cut: !!!!!!!!!!!!!!!!!!!!!!!***********************************\n");
for (int i=0; i<cut->nz; i++)
{ printf(" %12.10f x[%d] ", cut->coeff[i],cut->index[i]);}
printf(" >= %12.10f \n", cut->rhs);
}
void testus( DGG_constraint_t *cut){ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// const OsiRowCutDebugger debugg(*six, "flugpl.mps");
const OsiRowCutDebugger debugg(*six, "egout.mps");
const OsiRowCutDebugger *debugger = &debugg;
if (debugger&&!debugger->onOptimalPath(*six))
return;
OsiRowCut rowcut;
rowcut.setRow(cut->nz, cut->index, cut->coeff);
rowcut.setUb(DBL_MAX);
rowcut.setLb(cut->rhs);
if(debugger->invalidCut(rowcut)){
write_cut(cut);
//assert(0);
}
}
#else // CGL_DEBUG
#define talk false
#endif // CGL_DEBUG
//-------------------------------------------------------------------
// Generate cuts
//-------------------------------------------------------------------
void CglTwomir::generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
const CglTreeInfo info )
{
# ifdef CGL_DEBUG
//!!!!!!!!!!!!!!!!!!
six = &si;
# endif
const double * colUpper = si.getColUpper();
const double * colLower = si.getColLower();
const OsiSolverInterface * useSolver;
#ifdef COIN_HAS_CLP_TWOMIR
double * objective = NULL;
OsiClpSolverInterface * clpSolver = dynamic_cast<OsiClpSolverInterface *>(originalSolver_);
int numberOriginalRows;
int numberColumns=si.getNumCols();
int twomirType=0;
if (!clpSolver) {
#endif
useSolver=&si;
// Temp - check if free variables
int ncol = useSolver->getNumCols();
int numberFree=0;
for (int i=0;i<ncol;i++) {
if (colLower[i]<-1.0e20&&colUpper[i]>1.0e20)
numberFree++;
}
if (numberFree) {
#ifdef COIN_DEVELOP
if (!info.inTree&&!info.pass)
printf("CglTwoMir - %d free variables - returning\n",numberFree);
#endif
return;
}
#ifdef COIN_HAS_CLP_TWOMIR
} else {
useSolver = originalSolver_;
assert (twomirType_);
// check simplex is plausible
if (!clpSolver->getNumRows()||numberColumns!=clpSolver->getNumCols()) {
delete originalSolver_;
originalSolver_=si.clone();
clpSolver = dynamic_cast<OsiClpSolverInterface *>(originalSolver_);
assert (clpSolver);
useSolver = originalSolver_;
}
ClpSimplex * simplex = clpSolver->getModelPtr();
numberOriginalRows = simplex->numberRows();
int numberRows = si.getNumRows();
assert (numberOriginalRows<=numberRows);
// only do if different (unless type 2x)
twomirType = twomirType_%10;
int whenToDo = twomirType_/10;
if (whenToDo==2 ||(numberRows>numberOriginalRows && whenToDo==1
&& (info.options&512)==0) ||
((info.options&1024)!=0 && (info.options&512)==0)) {
// bounds
const double * solution = si.getColSolution();
memcpy(simplex->columnLower(),colLower,numberColumns*sizeof(double));
memcpy(simplex->columnUpper(),colUpper,numberColumns*sizeof(double));
for (int i=0;i<numberColumns;i++) {
if (colLower[i]<-1.0e20&&colUpper[i]>1.0e20) {
double lower=-COIN_DBL_MAX;
double upper=COIN_DBL_MAX;
if (solution[i]>0.0)
lower=-1.0e10;
else
upper=1.0e10;
originalSolver_->setColLower(i,lower);
originalSolver_->setColUpper(i,upper);
}
}
double * obj = simplex->objective();
objective = CoinCopyOfArray(obj,numberColumns);
const double * pi = si.getRowPrice();
const CoinPackedMatrix * rowCopy = si.getMatrixByRow();
const int * column = rowCopy->getIndices();
const CoinBigIndex * rowStart = rowCopy->getVectorStarts();
const int * rowLength = rowCopy->getVectorLengths();
const double * rowElements = rowCopy->getElements();
const double * rowLower = si.getRowLower();
const double * rowUpper = si.getRowUpper();
int numberCopy;
int numberAdd;
double * rowLower2 = NULL;
double * rowUpper2 = NULL;
int * column2 = NULL;
CoinBigIndex * rowStart2 = NULL;
double * rowElements2 = NULL;
char * copy = new char [numberRows-numberOriginalRows];
memset(copy,0,numberRows-numberOriginalRows);
if (twomirType==2) {
numberCopy=0;
numberAdd=0;
for (int iRow=numberOriginalRows;iRow<numberRows;iRow++) {
bool simple = true;
for (int k=rowStart[iRow];
k<rowStart[iRow]+rowLength[iRow];k++) {
double value = rowElements[k];
if (value!=floor(value+0.5)) {
simple=false;
break;
}
}
if (simple) {
numberCopy++;
numberAdd+=rowLength[iRow];
copy[iRow-numberOriginalRows]=1;
}
}
if (numberCopy) {
//printf("Using %d rows out of %d\n",numberCopy,numberRows-numberOriginalRows);
rowLower2 = new double [numberCopy];
rowUpper2 = new double [numberCopy];
rowStart2 = new CoinBigIndex [numberCopy+1];
rowStart2[0]=0;
column2 = new int [numberAdd];
rowElements2 = new double [numberAdd];
}
}
numberCopy=0;
numberAdd=0;
const double * rowSolution = si.getRowActivity();
double offset=0.0;
for (int iRow=numberOriginalRows;iRow<numberRows;iRow++) {
if (!copy[iRow-numberOriginalRows]) {
double value = pi[iRow];
offset += rowSolution[iRow]*value;
for (int k=rowStart[iRow];
k<rowStart[iRow]+rowLength[iRow];k++) {
int iColumn=column[k];
obj[iColumn] -= value*rowElements[k];
}
} else {
rowLower2[numberCopy]=rowLower[iRow];
rowUpper2[numberCopy]=rowUpper[iRow];
for (int k=rowStart[iRow];
k<rowStart[iRow]+rowLength[iRow];k++) {
column2[numberAdd]=column[k];
rowElements2[numberAdd++]=rowElements[k];
}
numberCopy++;
rowStart2[numberCopy]=numberAdd;
}
}
#if 0
CoinThreadRandom randomNumberGenerator;
const double * solution = si.getColSolution();
for (int i=0;i<numberColumns;i++) {
if (intVar[i]==1) {
double randomNumber = randomNumberGenerator.randomDouble();
//randomNumber = 0.001*floor(randomNumber*1000.0);
if (solution[i]>0.5)
obj[i] -= randomNumber*0.001*fabs(obj[i]);
else
obj[i] += randomNumber*0.001*fabs(obj[i]);
}
}
#endif
if (numberCopy) {
clpSolver->addRows(numberCopy,
rowStart2,column2,rowElements2,
rowLower2,rowUpper2);
delete [] rowLower2 ;
delete [] rowUpper2 ;
delete [] column2 ;
delete [] rowStart2 ;
delete [] rowElements2 ;
}
delete [] copy;
memcpy(simplex->primalColumnSolution(),si.getColSolution(),
numberColumns*sizeof(double));
CoinWarmStart * warmstart = si.getWarmStart();
CoinWarmStartBasis* warm =
dynamic_cast<CoinWarmStartBasis*>(warmstart);
warm->resize(simplex->numberRows(),numberColumns);
clpSolver->setBasis(*warm);
delete warm;
simplex->setDualObjectiveLimit(COIN_DBL_MAX);
simplex->setLogLevel(0);
clpSolver->resolve();
//printf("Trying - %d its status %d objs %g %g - with offset %g\n",
// simplex->numberIterations(),simplex->status(),
// simplex->objectiveValue(),si.getObjValue(),simplex->objectiveValue()+offset);
//simplex->setLogLevel(0);
if (simplex->status()) {
//printf("BAD status %d\n",simplex->status());
//clpSolver->writeMps("clp");
//si.writeMps("si");
delete [] objective;
objective=NULL;
useSolver=&si;
}
}
}
#endif
useSolver->getStrParam(OsiProbName,probname_) ;
int numberRowCutsBefore = cs.sizeRowCuts();
DGG_list_t cut_list;
DGG_list_init (&cut_list);
DGG_data_t* data = DGG_getData(reinterpret_cast<const void *> (useSolver));
// Note that the lhs variables are hash defines to data->cparams.*
q_max = q_max_;
q_min = q_min_;
t_max = t_max_;
t_min = t_min_;
a_max = a_max_;
max_elements = info.inTree ? max_elements_ : max_elements_root_;
data->gomory_threshold = info.inTree ? away_ : awayAtRoot_;
if (!info.inTree) {
//const CoinPackedMatrix * columnCopy = useSolver->getMatrixByCol();
//int numberColumns=columnCopy->getNumCols();
if (!info.pass||(info.options&32)!=0) {
max_elements=useSolver->getNumCols();
//} else {
//int numberRows=columnCopy.getNumRows();
//int numberElements=columnCopy->getNumElements();
//if (max_elements>500&&numberElements>10*numberColumns)
//max_elements=numberColumns;
}
}
if (!do_mir_) t_max = t_min - 1;
if (!do_2mir_) q_max = q_min - 1;
if (do_tab_ && info.level < 1 && info.pass < 6)
DGG_generateTabRowCuts( &cut_list, data, reinterpret_cast<const void *> (useSolver) );
if (do_form_)
DGG_generateFormulationCuts( &cut_list, data, reinterpret_cast<const void *> (useSolver),
info.formulation_rows,
randomNumberGenerator_);
#ifdef CGL_DEBUG
const OsiRowCutDebugger debugg(si,probname_.c_str()) ;
const OsiRowCutDebugger *debugger = &debugg;
if (debugger&&!debugger->onOptimalPath(si))
debugger = NULL;
else
{if(talk) printf ("2mir_test: debug success\n");}
#endif
int i;
for ( i=0; i<cut_list.n; i++){
DGG_constraint_t *cut = cut_list.c[i];
OsiRowCut rowcut;
if (cut->nz<max_elements) {
// See if any zero coefficients!!!!!!!
int nZero=0;
for( int i=0; i < cut->nz; i++) {
if (!cut->coeff[i])
nZero++;
}
#ifdef CGL_DEBUG_ZERO
if (nZero) {
printf("Cut ");
for( int i=0; i < cut->nz; i++) {
printf("%d %g ",cut->index[i],cut->coeff[i]);
}
printf("\n");
}
#endif
if (nZero) {
#ifdef CGL_DEBUG_ZERO
printf("TwoMir cut had %d zero coefficients!\n",nZero);
#endif
} else {
#ifdef CBC_CHECK_CUT
double rhs = cut->rhs;
int * cutIndex = cut->index;
double * packed = cut->coeff;
int i,number2=cut->nz;
int number=0;
double largest=0.0;
double smallest=1.0e30;
const double *colUpper = useSolver->getColUpper();
const double *colLower = useSolver->getColLower();
bool goodCut=true;
for (i=0;i<number2;i++) {
double value=fabs(packed[i]);
if (value<1.0e-9) {
int iColumn = cutIndex[i];
if (colUpper[iColumn]-colLower[iColumn]<100.0) {
// weaken cut
if (packed[i]>0.0)
rhs -= value*colUpper[iColumn];
else
rhs += value*colLower[iColumn];
} else {
// throw away
goodCut=false;
break;
}
} else {
int iColumn = cutIndex[i];
if (colUpper[iColumn]!=colLower[iColumn]) {
largest=CoinMax(largest,value);
smallest=CoinMin(smallest,value);
cutIndex[number]=cutIndex[i];
packed[number++]=packed[i];
} else {
// fixed so subtract out
rhs -= packed[i]*colLower[iColumn];
}
}
}
if (largest<5.0e9*smallest&&goodCut) {
rowcut.setRow(number, cutIndex, packed);
rowcut.setUb(COIN_DBL_MAX);
rowcut.setLb(rhs);
cs.insert(rowcut);
}
#else
rowcut.setRow(cut->nz, cut->index, cut->coeff);
rowcut.setUb(DBL_MAX);
rowcut.setLb(cut->rhs);
cs.insert(rowcut);
#endif
}
#ifdef CGL_DEBUG
if (debugger) {
if (debugger->invalidCut(rowcut)) {
write_cut(cut);
printf ("2mir_test: debug failed, mayday, mayday **********************************\n");}
//assert(0);
}
//assert(!debugger->invalidCut(rowcut));
#endif
}
}
for ( i=0; i<cut_list.n; i++)
DGG_freeConstraint (cut_list.c[i]);
DGG_list_free (&cut_list);
DGG_freeData (data);
if (!info.inTree&&((info.options&4)==4||((info.options&8)&&!info.pass))) {
int numberRowCutsAfter = cs.sizeRowCuts();
for (int i=numberRowCutsBefore;i<numberRowCutsAfter;i++) {
int length = cs.rowCutPtr(i)->row().getNumElements();
if (length<=max_elements_)
cs.rowCutPtr(i)->setGloballyValid();
}
}
#ifdef COIN_HAS_CLP_TWOMIR
if (objective) {
int numberRowCutsAfter = cs.sizeRowCuts();
ClpSimplex * simplex = clpSolver->getModelPtr();
memcpy(simplex->objective(),objective,numberColumns*sizeof(double));
delete [] objective;
// take out locally useless cuts
const double * solution = si.getColSolution();
double primalTolerance = 1.0e-7;
for (int k = numberRowCutsAfter - 1; k >= numberRowCutsBefore; k--) {
const OsiRowCut * thisCut = cs.rowCutPtr(k) ;
double sum = 0.0;
int n = thisCut->row().getNumElements();
const int * column = thisCut->row().getIndices();
const double * element = thisCut->row().getElements();
assert (n);
for (int i = 0; i < n; i++) {
double value = element[i];
sum += value * solution[column[i]];
}
if (sum > thisCut->ub() + primalTolerance) {
sum = sum - thisCut->ub();
} else if (sum < thisCut->lb() - primalTolerance) {
sum = thisCut->lb() - sum;
} else {
sum = 0.0;
}
if (!sum) {
// take out
cs.eraseRowCut(k);
}
}
#ifdef CLP_INVESTIGATE2
printf("OR %p pass %d inTree %c - %d cuts (but %d deleted)\n",
originalSolver_,info.pass,info.inTree?'Y':'N',
numberRowCutsAfter-numberRowCutsBefore,
numberRowCutsAfter-cs.sizeRowCuts());
#endif
}
int numberRowCutsAfter = cs.sizeRowCuts();
if (!info.inTree) {
for (int i=numberRowCutsBefore;i<numberRowCutsAfter;i++) {
cs.rowCutPtr(i)->setGloballyValid();
}
}
if (twomirType==2) {
// back to original
int numberRows = clpSolver->getNumRows();
if (numberRows>numberOriginalRows) {
int numberDelete = numberRows-numberOriginalRows;
int * delRow = new int [numberDelete];
for (int i=0;i<numberDelete;i++)
delRow[i]=i+numberOriginalRows;
clpSolver->deleteRows(numberDelete,delRow);
delete [] delRow;
}
}
#endif
}
//-------------------------------------------------------------------
// Default Constructor
//-------------------------------------------------------------------
CglTwomir::CglTwomir () :
CglCutGenerator(),
probname_(),
randomNumberGenerator_(987654321),originalSolver_(NULL),
away_(0.0005),awayAtRoot_(0.0005),twomirType_(0),
do_mir_(true), do_2mir_(true), do_tab_(true), do_form_(true),
t_min_(1), t_max_(1), q_min_(1), q_max_(1), a_max_(2),max_elements_(50000),
max_elements_root_(50000),form_nrows_(0) {}
//-------------------------------------------------------------------
// Copy constructor
//-------------------------------------------------------------------
CglTwomir::CglTwomir (const CglTwomir & source) :
CglCutGenerator(source),
randomNumberGenerator_(source.randomNumberGenerator_),
originalSolver_(NULL),
away_(source.away_),
awayAtRoot_(source.awayAtRoot_),
twomirType_(source.twomirType_),
do_mir_(source.do_mir_),
do_2mir_(source.do_2mir_),
do_tab_(source.do_tab_),
do_form_(source.do_form_),
t_min_(source.t_min_),
t_max_(source.t_max_),
q_min_(source.q_min_),
q_max_(source.q_max_),
a_max_(source.a_max_),
max_elements_(source.max_elements_),
max_elements_root_(source.max_elements_root_),
form_nrows_(source.form_nrows_)
{
probname_ = source.probname_ ;
if (source.originalSolver_)
originalSolver_ = source.originalSolver_->clone();
}
//-------------------------------------------------------------------
// Clone
//-------------------------------------------------------------------
CglCutGenerator *
CglTwomir::clone() const
{
return new CglTwomir(*this);
}
//-------------------------------------------------------------------
// Destructor
//-------------------------------------------------------------------
CglTwomir::~CglTwomir ()
{
delete originalSolver_;
}
//----------------------------------------------------------------
// Assignment operator
//-------------------------------------------------------------------
CglTwomir &
CglTwomir::operator=(const CglTwomir& rhs)
{
if (this != &rhs) {
CglCutGenerator::operator=(rhs);
randomNumberGenerator_ = rhs.randomNumberGenerator_;
away_=rhs.away_;
awayAtRoot_=rhs.awayAtRoot_;
twomirType_ = rhs.twomirType_;
delete originalSolver_;
if (rhs.originalSolver_)
originalSolver_ = rhs.originalSolver_->clone();
else
originalSolver_=NULL;
do_mir_=rhs.do_mir_;
do_2mir_=rhs.do_2mir_;
do_tab_=rhs.do_tab_;
do_form_=rhs.do_form_;
t_min_=rhs.t_min_;
t_max_=rhs.t_max_;
q_min_=rhs.q_min_;
q_max_=rhs.q_max_;
a_max_=rhs.a_max_;
max_elements_=rhs.max_elements_;
max_elements_root_ = rhs.max_elements_root_;
form_nrows_=rhs.form_nrows_;
}
return *this;
}
// Pass in a copy of original solver (clone it)
void
CglTwomir::passInOriginalSolver(OsiSolverInterface * solver)
{
delete originalSolver_;
if (solver) {
if (!twomirType_)
twomirType_=1;
originalSolver_ = solver->clone();
originalSolver_->setHintParam(OsiDoDualInResolve, false, OsiHintDo);
// Temp - check if free variables
const double *colUpper = originalSolver_->getColUpper();
const double *colLower = originalSolver_->getColLower();
int ncol = originalSolver_->getNumCols();
int numberFree=0;
for (int i=0;i<ncol;i++) {
if (colLower[i]<-1.0e20&&colUpper[i]>1.0e20)
numberFree++;
}
if (numberFree)
printf("CglTwoMir - %d free variables - take care\n",numberFree);
} else {
twomirType_=0;
originalSolver_=NULL;
}
}
int DGG_freeData( DGG_data_t *data )
{
free(data->info);
free(data->lb);
free(data->ub);
free(data->x);
free(data->rc);
free(data);
return 0;
}
DGG_data_t* DGG_getData(const void *osi_ptr )
{
DGG_data_t *data = NULL;
const OsiSolverInterface *si = reinterpret_cast<const OsiSolverInterface *> (osi_ptr);
data = reinterpret_cast<DGG_data_t*> (malloc( sizeof(DGG_data_t)) );
/* retrieve basis information */
CoinWarmStart *startbasis = si->getWarmStart();
const CoinWarmStartBasis *basis = dynamic_cast<const CoinWarmStartBasis*>(startbasis);
/* retrieve bounds information */
const double *colUpper = si->getColUpper();
const double *colLower = si->getColLower();
const double *rowUpper = si->getRowUpper();
const double *rowLower = si->getRowLower();
const double *redCost = si->getReducedCost();
const double *dualVal = si->getRowPrice();
/* retrieve current optimal solution */
const double *colSolut = si->getColSolution();
/* retrieve the matrix in row format */
const CoinPackedMatrix *rowMatrixPtr = si->getMatrixByRow();
const int *rowBeg = 0, *rowCnt = 0, *rowInd = 0;
const double *rowMat;
rowBeg = rowMatrixPtr->getVectorStarts();
rowCnt = rowMatrixPtr->getVectorLengths();
rowMat = rowMatrixPtr->getElements();
rowInd = rowMatrixPtr->getIndices();
/* set number of columns and number of rows */
data->ncol = si->getNumCols();
data->nrow = si->getNumRows();
/* set ninteger */
data->ninteger = 0;
/* allocate memory for the arrays in 'data' */
data->info = reinterpret_cast<int*> (malloc( sizeof(int)*(data->ncol+data->nrow)) );
data->lb = reinterpret_cast<double*> (malloc( sizeof(double)*(data->ncol+data->nrow)) );
data->ub = reinterpret_cast<double*> (malloc( sizeof(double)*(data->ncol+data->nrow)) );
data->x = reinterpret_cast<double*> (malloc( sizeof(double)*(data->ncol+data->nrow)) );
data->rc = reinterpret_cast<double*> (malloc( sizeof(double)*(data->ncol+data->nrow)) );
memset(data->info, 0, sizeof(int)*(data->ncol+data->nrow));
/* set parameters for column variables */
data->nbasic_col = 0;
for(int i=0; i < data->ncol; i++){
/* is variable basic */
if ( basis->getStructStatus(i) == CoinWarmStartBasis::basic ){
data->nbasic_col++;
DGG_setIsBasic(data,i);
}
#if DGG_DEBUG_DGG
{
int error = 0;
if ( basis->getStructStatus(i) != CoinWarmStartBasis::basic )
if ( fabs(colSolut[i] - colUpper[i]) > DGG_BOUND_THRESH )
if ( fabs(colSolut[i] - colLower[i]) > DGG_BOUND_THRESH ){
fprintf(stdout, "WARNING!!!! : ");
fprintf(stdout, "variable %d non-basic, lb = %f, ub = %f, x = %f\n",
i, colLower[i], colUpper[i], colSolut[i]);
error+=1;
}
if (error)
fprintf(stdout, "\nFOUND %d errors. BYE.\n", error);
}
#endif
/* set variable bounds*/
data->lb[i] = colLower[i];
data->ub[i] = colUpper[i];
/* is variable integer */
if ( si->isInteger(i) ){
data->ninteger++;
DGG_setIsInteger(data,i);
/* tighten variable bounds*/
data->lb[i] = ceil(colLower[i]);
data->ub[i] = floor(colUpper[i]);
}
/* set x value */
data->x[i] = colSolut[i];
/* WARNING: remember to set rc!! Its not set!! */
data->rc[i] = redCost[i];
}
/* set parameters for row variables */
/* slack variables (row variables) work as follows:
for a ranged constraint, b_dw < ax < b_up, define a variable s so that
1) if b_up is not infinity:
ax + s = b_up, 0 < s < b_up - b_dw
2) if b_up is infinity:
ax - s = b_dw, 0 < s < b_up - b_dw
*/
{
int i,j;
double activity;
data->nbasic_row = 0;
for(i=0, j=data->ncol; i < data->nrow; i++, j++){
/* check if the row is an equality constraint */
if ( fabs( rowUpper[i] - rowLower[i] ) <= DGG_BOUND_THRESH )
DGG_setEqualityConstraint(data,j);
/* check if the row is bounded above/below and define variable bounds */
if ( rowUpper[i] < COIN_DBL_MAX )
DGG_setIsConstraintBoundedAbove(data,j);
if ( rowLower[i] > -1*COIN_DBL_MAX )
DGG_setIsConstraintBoundedBelow(data,j);
data->lb[j] = 0.0;
if (DGG_isConstraintBoundedAbove(data,j) && DGG_isConstraintBoundedBelow(data,j))
data->ub[j] = rowUpper[i] - rowLower[i];
else
data->ub[j] = COIN_DBL_MAX;
/* compute row activity. for this we need to go to the row in question,
and multiply all the coefficients times their respective variables.
For the moment, we will store the inverse of this value in
the 'x' field (since it is in fact a partial computation of it) */
{
int k;
activity = 0.0;
for(k=rowBeg[i]; k < rowBeg[i]+rowCnt[i]; k++)
activity += rowMat[k]*colSolut[rowInd[k]];
}
/* compute x value */
if ( DGG_isConstraintBoundedAbove(data,j) )
data->x[j] = rowUpper[i] - activity;
else
data->x[j] = activity - rowLower[i];
if ( data->x[j] < -DGG_NULL_SLACK ){
#if DGG_DEBUG_DGG
int k;
double norm = 0.0, min = DBL_MAX, amin = DBL_MAX, max = DBL_MIN;
printf("** warning: row %d has negative slack!\n", i);
for(k=rowBeg[i]; k < rowBeg[i]+rowCnt[i]; k++){
norm += rowMat[k]*rowMat[k];
if ( fabs(rowMat[k]) < amin ) amin = fabs(rowMat[k]);
if ( rowMat[k] < min ) min = rowMat[k];
if ( rowMat[k] > max ) max = rowMat[k];
}
norm = sqrt(norm);
printf("min = %f amin = %f max = %f\n", min, amin, max);
printf("rlower = %f activity = %f\n", rowLower[i], activity);
printf("norm = %f (b-ax) = %f\n", norm, (rowLower[i] - activity));
printf("steepn = %f\n", (rowLower[i] - activity)/norm);
#endif
}
data->rc[j] = dualVal[i];
#if DGG_DEBUG_SOLVER
DGG_IF_EXIT( !DGG_isConstraintBoundedAbove(data,j) && !DGG_isConstraintBoundedBelow(data,j),
1, "some row is not bounded above or below");
#endif
/* is variable basic */
if ( basis->getArtifStatus(i) == CoinWarmStartBasis::basic ){
data->nbasic_row++;
DGG_setIsBasic(data,j);
}
/* is variable integer. For this we need to go to the row in question,
and check that the rhs is integer, and that all of the coefficients
and variables participating in the constraint are also integer. */
{
int k;
if( DGG_isConstraintBoundedAbove(data,j)) {
if ( frac_part(rowUpper[i]) > DGG_INTEGRALITY_THRESH )
goto DONE_ROW;
}
else
if ( frac_part(rowLower[i]) > DGG_INTEGRALITY_THRESH )
goto DONE_ROW;
for(k=rowBeg[i]; k < rowBeg[i]+rowCnt[i]; k++)
if ( frac_part(rowMat[k]) > DGG_INTEGRALITY_THRESH || !DGG_isInteger(data, rowInd[k]))
goto DONE_ROW;
DGG_setIsInteger(data, j);
data->ninteger++;
}
DONE_ROW:;
/* set variable bounds: careful!! Later, remember to adjust
the INFINITY to a DGG standard (to deal with neq solvers). */
/* WARNING: remember to set rc!! Its not set!! */
}
}
/* CLEANUP */
delete basis;
return data;
}
DGG_constraint_t*
DGG_getSlackExpression(const void *osi_ptr, DGG_data_t* data, int row_index)
{
DGG_constraint_t *row = 0;
int i,j;
/* retrieve the matrix in row format */
const OsiSolverInterface *si = reinterpret_cast<const OsiSolverInterface *> (osi_ptr);
const CoinPackedMatrix *rowMatrixPtr = si->getMatrixByRow();
const int *rowBeg = 0, *rowCnt = 0, *rowInd = 0;
const double *rowMat;
const double *rowUpper;
const double *rowLower;
row = DGG_newConstraint(data->ncol);
rowBeg = rowMatrixPtr->getVectorStarts();
rowCnt = rowMatrixPtr->getVectorLengths();
rowMat = rowMatrixPtr->getElements();
rowInd = rowMatrixPtr->getIndices();
rowUpper = si->getRowUpper();
rowLower = si->getRowLower();
#if DGG_DEBUG_DGG
if ( row_index < 0 || row_index > data->nrow )
DGG_THROW(0, "bad row index");
#endif
/* copy the information into the row ADT */
row->nz = rowCnt[row_index];
for(j=0, i=rowBeg[row_index]; i < rowBeg[row_index]+rowCnt[row_index]; i++, j++){
row->coeff[j] = rowMat[i];
row->index[j] = rowInd[i];
if (DGG_isConstraintBoundedAbove (data, data->ncol + row_index))
row->coeff[j] = -row->coeff[j];
}
row->sense = '?';
if ( DGG_isConstraintBoundedAbove(data, data->ncol + row_index) )
row->rhs = rowUpper[row_index];
else
row->rhs = -rowLower[row_index];
return row;
}
int
DGG_getTableauConstraint( int index, const void *osi_ptr, DGG_data_t *data,
DGG_constraint_t* tabrow,
const int * colIsBasic,
const int * /*rowIsBasic*/,
CoinFactorization & factorization,
int mode )
{
#if DGG_DEBUG_DGG
/* ensure that the index corresponds to a basic variable */
if ( !DGG_isBasic(data, index) )
DGG_THROW(1, "index is non-basic");
/* ensure that the index corresponds to a column variable */
if ( index < 0 || index > (data->ncol - 1) )
DGG_THROW(1, "index not a column variable");
#endif
/* obtain pointer to solver interface */
const OsiSolverInterface *si = reinterpret_cast<const OsiSolverInterface *> (osi_ptr);
DGG_TEST(!si, 1, "null OsiSolverInterfave");
/* obtain address of the LP matrix */
const CoinPackedMatrix *colMatrixPtr = si->getMatrixByCol();
const int* colBeg = colMatrixPtr->getVectorStarts();
const int* colCnt = colMatrixPtr->getVectorLengths();
const int* colInd = colMatrixPtr->getIndices();
const double* colMat = colMatrixPtr->getElements();
/* obtain row right-hand-sides */
const double *rowUpper = si->getRowUpper();
const double *rowLower = si->getRowLower();
/* allocate memory for constraint in non-sparse form */
int nz = 0;
double *value = NULL, rhs = 0.0;
value = reinterpret_cast<double*>(malloc(sizeof(double)*(data->nrow+data->ncol)));
memset(value, 0, sizeof(double)*(data->nrow+data->ncol));
/* obtain the tableau row coefficients for all variables */
/* note: we could speed this up by only computing non-basic variables */
{
int i, j, cnt = 0;
double one = 1.0;
CoinIndexedVector work;
CoinIndexedVector array;
work.reserve(data->nrow);
array.reserve(data->nrow);
array.setVector(1,&colIsBasic[index],&one);
factorization.updateColumnTranspose ( &work, &array );
int * arrayRows = array.getIndices();
double *arrayElements = array.denseVector();
cnt = array.getNumElements();
/* compute column (structural) variable coefficients */
for(j = 0; j < data->ncol; j++) {
value[j] = 0.0;
for(i=colBeg[j]; i < colBeg[j]+colCnt[j]; i++)
value[j] += colMat[i]*arrayElements[ colInd[i] ];
}
#if DGG_DEBUG_SOLVER
/* check pivot */
if ( fabs(value[index] - 1.0) > DGG_INTEGRALITY_THRESH )
DGG_THROW(1, "pivot is not one");
#endif
/* compute row variable (slack/logical) variable coefficients */
for(j = 0; j < cnt; j++){
if ( DGG_isEqualityConstraint(data,data->ncol + arrayRows[j]) && !mode )
value[ data->ncol + arrayRows[j] ] = 0.0;
else if ( DGG_isConstraintBoundedAbove(data, data->ncol + arrayRows[j]) )
value[ data->ncol + arrayRows[j] ] = arrayElements[ arrayRows[j] ];
else
value[ data->ncol + arrayRows[j] ] = -1*arrayElements[ arrayRows[j] ];
}
/* compute rhs */
rhs = 0.0;
for(i=0; i < cnt; i++){
if ( DGG_isConstraintBoundedAbove(data,data->ncol + arrayRows[i]) )
rhs += arrayElements[arrayRows[i]]*rowUpper[arrayRows[i]];
else
rhs += arrayElements[arrayRows[i]]*rowLower[arrayRows[i]];
}
/* free 'work' and 'array' ?? do the empty functions do it?? they are not
cleared in CglGomory. Is that due to a mistake? Is it done on purpose? */
/*
work.empty();
array.empty();
*/
}
/* count non-zeroes */
nz = 0;
int j;
for( j=0; j<data->ncol+data->nrow; j++){
if ( fabs(value[j]) > DGG_MIN_TABLEAU_COEFFICIENT )
nz += 1;
}
/* put in sparse constraint format */
/* technical issue: should we let max_nz == nz or should we instead
set max_nz == (nrow+ncol). The advantage of the latter approach
is that later, when we substitute the slacks, the denser column
will not require us to re-allocate memory */
tabrow->max_nz = nz;
if (tabrow->coeff)
free(tabrow->coeff);
if (tabrow->index)
free(tabrow->index);
tabrow->coeff = reinterpret_cast<double*> (malloc(sizeof(double)*nz));
tabrow->index = reinterpret_cast<int*> (malloc(sizeof(int)*nz));
tabrow->nz = 0;
for( j = 0; j < data->ncol + data->nrow; j++)
if ( fabs(value[j]) > DGG_MIN_TABLEAU_COEFFICIENT ){
tabrow->coeff[tabrow->nz] = value[j];
tabrow->index[tabrow->nz] = j;
tabrow->nz += 1;
}
tabrow->sense = 'E';
tabrow->rhs = rhs;
/* CLEANUP */
free(value);
return 0;
}
int
DGG_getFormulaConstraint( int da_row,
const void *osi_ptr,
DGG_data_t *data,
DGG_constraint_t* form_row )
{
/* ensure that the da_row corresponds to a row */
if ( data->nrow <= da_row || 0> da_row) DGG_THROW(1, "row out of range...");
/* obtain pointer to solver interface */
const OsiSolverInterface *si = reinterpret_cast<const OsiSolverInterface *> (osi_ptr);
//DGG_TEST(!si, 1, "null OsiSolverInterfave");
/* obtain address of the LP matrix */
const CoinPackedMatrix *rowMatrixPtr = si->getMatrixByRow();
const int* rowBeg = rowMatrixPtr->getVectorStarts();
const int* rowCnt = rowMatrixPtr->getVectorLengths();
const int* rowInd = rowMatrixPtr->getIndices();
const double* rowMat = rowMatrixPtr->getElements();
/* obtain row right-hand-sides */
const double *rowUpper = si->getRowUpper();
const double *rowLower = si->getRowLower();
int nz = rowCnt[da_row];
form_row->nz = nz;
form_row->max_nz = nz+1;
int i;
for( i=0; i < nz; i++) form_row->coeff[i] = rowMat[rowBeg[da_row]+i];
for( i=0; i < nz; i++) form_row->index[i] = rowInd[rowBeg[da_row]+i];
if ( DGG_isConstraintBoundedAbove(data,data->ncol + da_row) ){
form_row->rhs = rowUpper[da_row];
form_row->sense = 'L';
}
else{
form_row->rhs = rowLower[da_row];
form_row->sense = 'G';
}
if ( DGG_isEqualityConstraint(data,data->ncol + da_row) )
form_row->sense = 'E';
/* now add slack/surplus if there is one */
if ( DGG_isEqualityConstraint(data,data->ncol + da_row) == 0 ){
form_row->index[nz] = data->ncol + da_row;
if ( DGG_isConstraintBoundedAbove(data, data->ncol + da_row) )
form_row->coeff[nz] = 1;
else
form_row->coeff[nz] = -1;
form_row->nz +=1;
}
return 0;
}
//---------------------------------------------------------------
//---------------------------------------------------------------
//---------------------------------------------------------------
//---------------------------------------------------------------
//---------------------------------------------------------------
/******************** CONSTRAINT ADTs *****************************************/
DGG_constraint_t* DGG_newConstraint(int max_arrays)
{
DGG_constraint_t *c = NULL;
if (max_arrays <= 0) return NULL;
c = reinterpret_cast<DGG_constraint_t*> (malloc(sizeof(DGG_constraint_t)));
c->nz = 0;
c->max_nz = max_arrays;
c->rhs = 0.0;
c->sense = '?';
c->coeff = NULL;
c->index = NULL;
c->coeff = reinterpret_cast<double*>(malloc(sizeof(double)*max_arrays));
c->index = reinterpret_cast<int*>(malloc(sizeof(int)*max_arrays));
return c;
}
void DGG_freeConstraint(DGG_constraint_t *c)
{
if (c == NULL) return;
if (c->coeff) free(c->coeff);
if (c->index) free(c->index);
free(c);
}
DGG_constraint_t *DGG_copyConstraint(DGG_constraint_t* c)
{
DGG_constraint_t *nc = NULL;
if (!c || c->max_nz <= 0) return nc;
nc = DGG_newConstraint(c->max_nz);
if (nc == NULL) return nc;
nc->nz = c->nz;
nc->rhs = c->rhs;
nc->sense = c->sense;
memcpy(nc->coeff, c->coeff, sizeof(double)*nc->nz);
memcpy(nc->index, c->index, sizeof(int)*nc->nz);
return nc;
}
void DGG_scaleConstraint(DGG_constraint_t *c, int t)
{
int i;
c->rhs *= t;
if (t < 0){
if (c->sense == 'G') c->sense = 'L';
else if (c->sense == 'L') c->sense = 'G';
}
for(i=0; i<c->nz; i++) c->coeff[i] *= t;
}
void DGG_list_init (DGG_list_t *l)
{
l->n = 0;
l->c = NULL;
l->ctype = NULL;
l->alpha = NULL;
}
void DGG_list_free(DGG_list_t *l)
{
if (l->c != NULL) free (l->c);
if (l->ctype != NULL) free (l->ctype);
if (l->alpha != NULL) free (l->alpha);
}
int DGG_list_addcut (DGG_list_t *l, DGG_constraint_t *cut, int ctype, double alpha)
{
l->n ++;
l->c = reinterpret_cast<DGG_constraint_t **>(realloc (l->c, l->n * sizeof(DGG_constraint_t *)));
l->ctype = reinterpret_cast<int *>(realloc (l->ctype, l->n * sizeof (int)));
l->alpha = reinterpret_cast<double *>(realloc (l->alpha, l->n * sizeof (double)));
if (l->c == NULL || l->ctype == NULL || l->alpha == NULL){
printf ("No memory, bailing out\n");
return -1;
}
l->c[l->n - 1] = cut;
l->ctype[l->n - 1] = ctype;
l->alpha[l->n - 1] = alpha;
return 0;
}
void DGG_list_delcut (DGG_list_t *l, int i)
{
if (i >= l->n && i < 0) return;
DGG_freeConstraint (l->c[i]);
l->c[i] = l->c[l->n - 1];
l->ctype[i] = l->ctype[l->n - 1];
l->alpha[i] = l->alpha[l->n - 1];
l->n --;
}
/******************* CONSTRAINT MANIPULATION **********************************/
/* VARIABLES CLOSE TO UPPER BOUNDS:
we will substitute: x' = (u - x); hence the constraint will change from ax ~ b
to -ax' ~ b - au note: the new bounds of x' will be, 0 <= x' <= u - l
VARIABLES CLOSE TO LOWER BOUNDS:
we will substitute: x' = (x - l); hence, the constraint will change from
ax ~ b to ax' ~ b - al. note: some variable lower bounds may have changed
when doing the complement in the previous stage - this must be taken into
account. note: the new bounds of x' will be, 0 <= x' <= u - l */
int DGG_transformConstraint( DGG_data_t *data,
double **x_out,
double **rc_out,
char **isint_out,
DGG_constraint_t *constraint )
{
double half;
double *px = reinterpret_cast<double*> (malloc( sizeof(double)*constraint->max_nz ));
double *rc = reinterpret_cast<double*> (malloc( sizeof(double)*constraint->max_nz ));
char *pi = reinterpret_cast<char*> (malloc( sizeof(char) *constraint->max_nz ));
{
int i, idx;
for(i=0; i < constraint->nz; i++){
idx = constraint->index[i];
px[i] = data->x[idx];
rc[i] = data->rc[idx];
pi[i] = static_cast<char>(DGG_isInteger(data, idx));
half = (data->ub[idx] - data->lb[idx]) / 2;
if ( data->ub[idx] - data->x[idx] < half ){
px[i] = data->ub[idx] - data->x[idx];
if (fabs(px[i]) <= DGG_BOUND_THRESH)
px[i] = 0.0;
constraint->rhs -= constraint->coeff[i]*data->ub[idx];
constraint->coeff[i] *= -1;
}
else {
px[i] = data->x[idx] - data->lb[idx];
if (fabs(px[i]) <= DGG_BOUND_THRESH)
px[i] = 0.0;
constraint->rhs -= constraint->coeff[i]*data->lb[idx];
}
}
}
*x_out = px;
*rc_out = rc;
*isint_out = pi;
#if DGG_DEBUG_DGG
DGG_TEST(DGG_isConstraintViolated(data, constraint), 1, "bad transformation");
#endif
return 0;
}
int DGG_unTransformConstraint( DGG_data_t *data,
DGG_constraint_t *constraint )
{
int i, idx;
double half;
for(i=0; i < constraint->nz; i++){
idx = constraint->index[i];
half = (data->ub[idx] - data->lb[idx]) / 2;
if ( data->ub[idx] - data->x[idx] < half ){
constraint->rhs -= constraint->coeff[i]*data->ub[idx];
constraint->coeff[i] *= -1;
}
else
constraint->rhs += constraint->coeff[i]*data->lb[idx];
}
return 0;
}
int
DGG_substituteSlacks( const void *solver_ptr,
DGG_data_t *data,
DGG_constraint_t *cut )
{
int i,j, lnz;
double *lcut, lrhs;
DGG_constraint_t *row=NULL;
/* lcut will store all the column coefficients. allocate space and init. */
lcut = reinterpret_cast<double*>(malloc(sizeof(double)*data->ncol));
memset(lcut, 0, sizeof(double)*data->ncol);
/* initialize lrhs */
lrhs = cut->rhs;
/* set coefficients in lcut */
/* technical: we could speed this up by re-using allocated memory
for row->coeff and row->index */
for(i=0; i < cut->nz; i++){
if ( cut->index[i] < data->ncol )
lcut[ cut->index[i] ] += cut->coeff[i];
else{
row = DGG_getSlackExpression(solver_ptr, data, (cut->index[i] - data->ncol));
for(j=0; j < row->nz; j++)
lcut[ row->index[j] ] += row->coeff[j]*cut->coeff[i];
lrhs -= row->rhs*cut->coeff[i];
DGG_freeConstraint(row);
}
}
/* count nz in new constraint */
lnz = 0;
for(i=0; i < data->ncol; i++)
if ( fabs(lcut[i]) > DGG_MIN_TABLEAU_COEFFICIENT )
lnz += 1;
/* free row->coeff and row->index, and re-allocate */
free(cut->coeff); cut->coeff = 0;
free(cut->index); cut->index = 0;
cut->nz = lnz;
cut->max_nz = lnz;
if (lnz)
{
cut->coeff = reinterpret_cast<double*> (malloc( sizeof(double)*lnz ));
cut->index = reinterpret_cast<int*> (malloc( sizeof(int)*lnz ));
}
/* set new constraint */
lnz = 0;
for(i=0; i < data->ncol; i++){
if ( fabs(lcut[i]) > DGG_MIN_TABLEAU_COEFFICIENT ){
cut->coeff[lnz] = lcut[i];
cut->index[lnz] = i;
lnz += 1;
}
}
cut->rhs = lrhs;
free(lcut);
return 0;
}
int DGG_nicefyConstraint( const void * /*solver_ptr*/,
DGG_data_t *data,
DGG_constraint_t *cut)
{
double min_coef = COIN_DBL_MAX, max_coef = COIN_DBL_MIN;
DGG_TEST(cut->sense == 'L', 1, "can't nicefy an L constraint");
int i;
for( i=0; i<cut->nz; i++) // first clean out noise
if( fabs(cut->coeff[i]) < DGG_NICEFY_MIN_ABSVALUE)
cut->coeff[i] = 0;
for( i=0; i<cut->nz; i++){
if( DGG_isInteger(data, cut->index[i])){// look at integral vars.
double aht = ABOV(cut->coeff[i]);
double ub = data->ub[ cut->index[i]];
if(aht < DGG_NICEFY_MIN_FIX){// coefficient = integer + epsylon
cut->coeff[i] = floor( cut->coeff[i]);
double ahtu = aht * ub;
if(ahtu<DGG_NICEFY_MAX_PADDING)
cut->rhs -= ahtu;// safely remove the fractional part
else
cut->coeff[i] += DGG_NICEFY_MIN_FIX; // inflate the fractional part
}
else
if (1-aht < DGG_NICEFY_MIN_FIX) // coefficient = integer - epsylon
cut->coeff[i] = ceil( cut->coeff[i]);
}// done with integers
else // now look at continuous variables
if ( cut->coeff[i] < DGG_NICEFY_MIN_ABSVALUE) // delete all negative and noise
cut->coeff[i] = 0.0;
else
if(cut->coeff[i] < DGG_NICEFY_MIN_FIX) {// coefficient = epsylon
double au = cut->coeff[i] * data->ub[ cut->index[i]];
if(au<DGG_NICEFY_MAX_PADDING){ // safely remove the variable
cut->coeff[i] = 0.0;
cut->rhs -= au;
}
else
cut->coeff[i] = DGG_NICEFY_MIN_FIX; // inflate the coefficient
}// done with continuous variables too
double abs_coef = fabs(cut->coeff[i]);
min_coef = DGG_MIN(min_coef, abs_coef);
max_coef = DGG_MAX(max_coef, abs_coef);
}
cut->sense = 'G';
/*
if ( max_coef > DGG_NICEFY_MAX_RATIO*min_coef ) // kill the cut if numbers are all over the place
cut->nz = 0;
*/
return 0;
}
/******************* CUT GENERATION *******************************************/
int
DGG_generateTabRowCuts( DGG_list_t *cut_list,
DGG_data_t *data,
const void *solver_ptr )
{
int k, rval = 0;
DGG_constraint_t *base = NULL;
int nc = cut_list->n;
base = DGG_newConstraint(data->ncol + data->nrow);
if(talk) printf ("2mir_test: generating tab row cuts\n");
/* allocate memory for basic column/row indicators */
int *rowIsBasic = 0, *colIsBasic = 0;
rowIsBasic = reinterpret_cast<int*>(malloc(sizeof(int)*data->nrow));
colIsBasic = reinterpret_cast<int*>(malloc(sizeof(int)*data->ncol));
/* initialize the IsBasic arrays with -1 / 1 values indicating
where the basic rows and columns are. NOTE: WE could do this
only once and keep it in osi_data at the expense of space!! */
int i;
for( i=0; i<data->ncol; i++){
if ( DGG_isBasic(data,i) ) colIsBasic[i] = 1;
else colIsBasic[i] = -1;
}
for( i=0; i<data->nrow; i++){
if ( DGG_isBasic(data,i+data->ncol) ) rowIsBasic[i] = 1;
else rowIsBasic[i] = -1;
}
/* obtain factorization */
CoinFactorization factorization;
/* obtain address of the LP matrix */
const OsiSolverInterface *si = reinterpret_cast<const OsiSolverInterface *> (solver_ptr);
const CoinPackedMatrix *colMatrixPtr = si->getMatrixByCol();
rval = factorization.factorize(*colMatrixPtr, rowIsBasic, colIsBasic);
/* 0 = okay. -1 = singular. -2 = too many in basis. -99 = memory. */
DGG_TEST2(rval, 1, "factorization error = %d", rval);
for(k=0; k<data->ncol; k++){
if (!(DGG_isBasic(data, k) && DGG_isInteger(data,k))) continue;
double frac = frac_part (data->x[k]);
if (frac < data->gomory_threshold || frac > 1-data->gomory_threshold) continue;
base->nz = 0;
rval = DGG_getTableauConstraint(k, solver_ptr, data, base,
colIsBasic,rowIsBasic,factorization,0);
DGG_CHECKRVAL(rval, rval);
if (base->nz == 0){
printf ("2mir_test: why does constraint not exist ?\n");
continue;
}
if (base->nz > 500) continue;
rval = DGG_generateCutsFromBase(base, cut_list, data, solver_ptr);
DGG_CHECKRVAL(rval, rval);
}
free(rowIsBasic);
free(colIsBasic);
if(talk) printf ("2mir_test: generated %d tab cuts\n", cut_list->n - nc); fflush (stdout);
DGG_freeConstraint(base);
return rval;
}
int DGG_generateFormulationCuts( DGG_list_t *cut_list,
DGG_data_t *data,
const void *solver_ptr,
int nrows,
CoinThreadRandom & generator)
{
int k, rval = 0;
DGG_constraint_t *base = NULL;
int num_rows = (data->nrow < nrows) ? data->nrow : nrows;
int nc = cut_list->n;
base = DGG_newConstraint(data->ncol + data->nrow);
if(talk) printf ("2mir_test: generating form row cuts %d\n", num_rows);
for(k=0; k<num_rows; k++) {
base->nz = 0;
rval = DGG_getFormulaConstraint(k, solver_ptr, data, base);
DGG_CHECKRVAL1(rval, rval);
//printf ("generating formulation for row %d\n", k);
rval = DGG_generateFormulationCutsFromBase(base, data->x[data->ncol+k],
cut_list, data, solver_ptr,
generator);
DGG_CHECKRVAL1(rval, rval);
if (base->nz == 0){
#ifdef COIN_DEVELOP
printf ("why does constraint not exist ?\n");
#endif
continue;
}
}
CLEANUP:
if(talk) printf ("2mir_test: generated %d form cuts\n", cut_list->n - nc); fflush (stdout);
DGG_freeConstraint(base);
return rval;
}
int DGG_generateFormulationCutsFromBase( DGG_constraint_t *base,
double slack,
DGG_list_t *cut_list,
DGG_data_t *data,
const void *solver_ptr,
CoinThreadRandom & generator)
{
int i, p, rval;
int int_skala;
double skala;
int num_inlist = 0;
int* skala_list = reinterpret_cast<int*> (malloc( sizeof(int)*base->nz ));
char *isint = NULL;
double *xout = NULL, *rcout = NULL;
DGG_constraint_t *scaled_base = NULL;
int tot_int = 0;
double prob_choose = 0.0;
rval = DGG_transformConstraint(data, &xout, &rcout, &isint, base);
DGG_CHECKRVAL1(rval, rval);
for(p = 0; p < base->nz; p++) if(isint[p]) tot_int ++;
if (tot_int == 0) goto CLEANUP;
prob_choose = 5.0/tot_int;
for(p = 0; p < base->nz; p++) {
if(isint[p]) if(generator.randomDouble() < prob_choose){
if(xout[p]<0.01) continue;
skala =fabs(base->coeff[p]);
if(skala<0.01) continue;
// check if slack is too large
if (fabs(slack/skala) > 0.5) continue;
scaled_base = DGG_copyConstraint(base);
DGG_CHECKRVAL1((scaled_base == NULL),-1);
if(base->sense == 'L') {
skala = -skala;
scaled_base->sense = 'G';
}
int_skala = int(100*skala);
for(i = 0; i< num_inlist; i++)
if(int_skala == skala_list[i])
goto END_LOOP;
skala_list[num_inlist++] = int_skala;
scaled_base->rhs = base->rhs/skala;
for(i = 0; i<base->nz; i++)
scaled_base->coeff[i] = base->coeff[i] / skala;
rval = DGG_unTransformConstraint(data, scaled_base);
DGG_CHECKRVAL1(rval, rval);
rval = DGG_generateCutsFromBase(scaled_base, cut_list,
data, solver_ptr);
DGG_CHECKRVAL1(rval, rval);
END_LOOP:
DGG_freeConstraint(scaled_base);
scaled_base = NULL;
}
}
CLEANUP:
if (isint) free(isint);
if (xout) free(xout);
if (rcout) free(rcout);
if (skala_list) free(skala_list);
if (scaled_base != NULL) DGG_freeConstraint (scaled_base);
return rval;
}
int
DGG_generateCutsFromBase( DGG_constraint_t *orig_base,
DGG_list_t *cut_list,
DGG_data_t *data,
const void *solver_ptr )
{
int rval = 0;
int t;
double *x = NULL, *rc = NULL;
char *isint = NULL;
DGG_constraint_t *base = NULL;
bool not_nicefied = true;
int new_pos = cut_list->n;
// DGG_constraint_t *keep_origbase = DGG_copyConstraint(orig_base); //for debug only ------
if (orig_base->sense == 'L') return 0;
if (orig_base->nz == 0) return 0;
rval = DGG_transformConstraint(data, &x, &rc, &isint, orig_base);
double frac = frac_part(orig_base->rhs);
//printf ("frac = %.7f, r %.7f, fr %.7f\n", frac, orig_base->rhs, floor(orig_base->rhs));
if (rval || frac < data->gomory_threshold || frac > 1-data->gomory_threshold){
free (x); free (rc); free (isint);
return 0;
}
int min_t = t_min;
int min_q = q_min;
if (orig_base->sense == 'G' && min_t < 1) min_t = 1;
if (orig_base->sense == 'G' && min_q < 1) min_q = 1;
if (min_q > 0 && min_t > 0 ) {
not_nicefied = false;
rval = DGG_nicefyConstraint(solver_ptr, data, orig_base);
DGG_CHECKRVAL(rval, rval);
if (orig_base->nz == 0){
if(talk) printf ("2mir_test: Nicefy returns empty constraint\n"); rval = 0; goto CLEANUP;
}
}
for(t = min_t; t <= t_max ; t++){
if (t == 0) continue;
base = DGG_copyConstraint(orig_base);
DGG_TEST(!base, 1, "error making copy of base");
DGG_scaleConstraint (base, t);
if(not_nicefied){
rval = DGG_nicefyConstraint(solver_ptr, data, base);
DGG_CHECKRVAL(rval, rval);
if (base->nz == 0){
if(talk) printf ("2mir_test: Nicefy returns empty constraint\n"); goto MIR_DONE;
}
}
if ( DGG_isBaseTrivial(data, base) ) goto MIR_DONE;
rval = DGG_addMirToList(base, isint, x, cut_list, data, orig_base);
DGG_CHECKRVAL(rval, rval);
MIR_DONE:
DGG_freeConstraint(base);
}
for( t = min_q; t <= q_max; t++ ){
if (t == 0) continue;
base = DGG_copyConstraint(orig_base);
DGG_TEST(!base, 1, "error making copy of base");
DGG_scaleConstraint (base, t);
if(not_nicefied){
rval = DGG_nicefyConstraint(solver_ptr, data, base);
DGG_CHECKRVAL(rval, rval);
if (base->nz == 0){
if(talk) printf ("2mir_test: Nicefy returns empty constraint\n"); goto TWOMIR_DONE;
}
}
if ( DGG_isBaseTrivial(data, base) ) goto TWOMIR_DONE;
rval = DGG_add2stepToList(base, isint, x, rc, cut_list, data, orig_base);
DGG_CHECKRVAL(rval, rval);
TWOMIR_DONE:
DGG_freeConstraint(base);
}
int i;
for ( i = cut_list->n-1; i>=new_pos; i--){
DGG_constraint_t *lcut = cut_list->c[i];
rval = DGG_unTransformConstraint(data, lcut);
DGG_CHECKRVAL(rval, rval);
rval = DGG_substituteSlacks(solver_ptr, data, lcut);
DGG_CHECKRVAL(rval, rval);
if ( !DGG_isCutDesirable(lcut, data) ){
DGG_list_delcut (cut_list, i);
continue;
}
//else testus(lcut);//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/*
if ( data->opt_x && DGG_cutsOffPoint(data->opt_x, lcut) ){
//DGG_cutDisplay_sparse(data, data->opt_x, lcut, stdout);
DGG_TEST(1,1, "new cut is infeasible for optimal solution\n");
}
*/
}
CLEANUP:
if (x) free(x);
if (rc) free (rc);
if (isint) free(isint);
return 0;
}
int
DGG_addMirToList ( DGG_constraint_t *base, char *isint, double * /*x*/,
DGG_list_t *list, DGG_data_t * /*data*/,
DGG_constraint_t * /*orig_base*/ )
{
int rval = 0;
DGG_constraint_t *cut = NULL;
rval = DGG_buildMir(isint, base, &cut);
DGG_CHECKRVAL(rval, rval);
DGG_list_addcut(list, cut, DGG_TMIR_CUT, 0.0);
return 0;
}
int
DGG_add2stepToList ( DGG_constraint_t *base, char *isint, double * /*x*/,
double *rc, DGG_list_t *list, DGG_data_t *data,
DGG_constraint_t * /*orig_base*/ )
{
int rval;
DGG_constraint_t *cut = NULL;
int i;
double norm_val, best_norm_val, best_norm_alpha=-1.0;
double rc_val, best_rc_val, best_rc_alpha=-1.0;
double vht, bht, alpha;
best_rc_val = best_norm_val = COIN_DBL_MAX;
bht = ABOV(base->rhs);
double best_rc = 0;
for(i=0; i<base->nz; i++) if (isint[i]) best_rc = CoinMax(best_rc, fabs(rc[i]));
double rc_cutoff = best_rc / 10;
for(i=0; i<base->nz; i++){
if (!isint[i]) continue;
if (fabs(rc[i]) <= rc_cutoff) continue; //too unimportant
vht = ABOV(base->coeff[i]);
if(vht >= bht) continue; // too big
if(vht < bht/a_max) continue; // too small
alpha = vht;
int kk = 1;
while ( !DGG_is2stepValid(alpha, bht) && bht/alpha <= a_max) {
alpha = vht/kk;
kk++;
if (kk>1000)
break;
}
if ( !DGG_is2stepValid(alpha, bht) ) continue;
rval = DGG_build2step(alpha, isint, base, &cut);
DGG_CHECKRVAL(rval, rval);
rc_val = COIN_DBL_MAX; // this gives a lower bound on obj. fn. improvement
for(i=0; i<cut->nz; i++) if(cut->coeff[i]> 1E-6){
rc_val = CoinMin(rc_val, fabs(rc[i])/cut->coeff[i]);
}
rc_val *= cut->rhs;
norm_val = 0; // this is the square of the L2 norm
for(i=0; i<cut->nz; i++) if(cut->coeff[i]> 1E-6){
norm_val += (cut->coeff[i]*cut->coeff[i]);
}
norm_val /= cut->rhs * cut->rhs;
if (rc_val < best_rc_val ) {
best_rc_val = rc_val; best_rc_alpha = alpha; }
if (norm_val < best_norm_val ) {
best_norm_val = norm_val; best_norm_alpha = alpha; }
DGG_freeConstraint(cut);
}
if( best_rc_val> 1E-6 && best_rc_alpha != -1.0){
rval = DGG_build2step(best_rc_alpha, isint, base, &cut);
DGG_CHECKRVAL(rval, rval);
DGG_list_addcut(list, cut, DGG_2STEP_CUT, best_rc_alpha);
}
else if (best_norm_alpha != -1.0){
rval = DGG_build2step(best_norm_alpha, isint, base, &cut);
DGG_CHECKRVAL(rval, rval);
DGG_list_addcut(list, cut, DGG_2STEP_CUT, best_norm_alpha);
}
return 0;
}
int DGG_buildMir( char *isint,
DGG_constraint_t *base,
DGG_constraint_t **cut_out )
{
int i, lnz = 0;
double b = (base->rhs);
double bht = ABOV(b);
double bup = ceil(b);
DGG_constraint_t *tmir = NULL;
DGG_TEST( base->sense == 'L', 1, "this form not valid for L");
DGG_TEST( base->nz == 0, 1, "base must have some coefficients\n");
tmir = DGG_newConstraint( base->nz );
tmir->sense = 'G';
tmir->rhs = bht * bup;
for(i=0; i<base->nz; i++){
double v = base->coeff[i];
if (!isint[i]) {
if (v > 0.0) tmir->coeff[lnz] = v;
else tmir->coeff[lnz] = 0.0;
}
else {
double vht = ABOV(v);
DGG_IF_EXIT( vht<0, 1, "negative vht");
tmir->coeff[lnz] = bht * floor(v) + DGG_MIN(bht,vht);
}
tmir->index[lnz] = base->index[i];
lnz += 1;
}
tmir->nz = lnz;
*cut_out = tmir;
return 0;
}
int DGG_build2step( double alpha,
char *isint,
DGG_constraint_t *base,
DGG_constraint_t **cut_out )
{
DGG_constraint_t *tmir = 0;
int i, lnz = 0;
double vht, bht, bup, rho, tau, k;
double b = (base->rhs);
DGG_TEST( base->sense == 'L', 1, "this form not valid for L");
DGG_TEST( base->nz == 0, 1, "base must have some coefficients\n");
bht = ABOV(b);
bup = ceil(b);
tau = ceil(bht/alpha);
rho = bht - alpha*floor(bht/alpha);
/* ensure bht > alpha > 0 */
DGG_TEST3( (bht <= alpha) || (alpha <= 0.0), 1, "bad alpha (%f) / bht (%f) pair", alpha, bht);
/* ensure that we are not in a limiting case */
DGG_TEST( DGG_is_a_multiple_of_b(alpha, bht), 1, "can't generate simple 2mir in limiting case");
/* ensure that rho is not zero */
DGG_TEST2( rho < DGG_MIN_RHO, 1, "rho (%f) too small", rho);
/* initialize constraint */
tmir = DGG_newConstraint( base->nz );
tmir->rhs = bup*tau*rho;
tmir->sense = 'G';
/* compute cut coefficients */
for(i=0; i<base->nz; i++){
double v = base->coeff[i];
if (!isint[i]) {
if (v > 0.0) tmir->coeff[lnz] = v;
else tmir->coeff[lnz] = 0.0;
}
else {
vht = v - floor(v);
DGG_IF_EXIT( vht < 0.0, 1, "negative vht");
k = DGG_MIN(tau-1,floor(vht/alpha));
tmir->coeff[lnz] = floor(v)*tau*rho + k*rho + DGG_MIN(rho,vht-k*alpha);
}
tmir->index[lnz] = base->index[i];
lnz += 1;
}
tmir->nz = lnz;
*cut_out = tmir;
return 0;
}
/******************* TEST / DEBUGGING ROUTINES ********************************/
/* DGG_is2stepValid:
checks that:
bht > alpha > 0
(1/alpha) >= tau > (bht/alpha)
*/
int DGG_is2stepValid(double alpha, double bht)
{
/* d */
double tau;
/* ensure that alpha is not null or negative */
if ( alpha < DGG_MIN_ALPHA )
return 0;
/* compute tau and tau_lim */
tau = ceil( bht / alpha );
/* make sure alpha is not a divisor of bht */
if ( DGG_is_a_multiple_of_b(alpha, bht) )
return 0;
/* page 15, definition 12 */
/* check if alpha is admissible for simple-2-step-tmir */
if ( (bht > alpha) && (alpha > 0.0) )
if ( (1/alpha) >= tau )
return 1;
/* not admissible */
return 0;
}
/* checks that its worth doing a 1MIR on the constraint. More precisely,
- Is the RHS null?
- Are there any integer variables set at fractional values? */
int DGG_isBaseTrivial(DGG_data_t *d, DGG_constraint_t* c)
{
/* is rhs sufficiently fractional */
if ( frac_part(ABOV(c->rhs)) < d->gomory_threshold )
return 1;
if ( (1.0 - frac_part(ABOV(c->rhs))) < d->gomory_threshold )
return 1;
return 0;
}
/* tests lhs vs rhs of a constraint */
int DGG_isConstraintViolated(DGG_data_t *d, DGG_constraint_t *c)
{
double lhs = DGG_cutLHS(c, d->x);
double rhs = c->rhs;
/* compare LHS and RHS */
if (c->sense == 'G')
if ( lhs > (rhs - DGG_NULL_SLACK) )
return 0;
if (c->sense == 'L')
if ( lhs < (rhs + DGG_NULL_SLACK) )
return 0;
if (c->sense == 'E')
if ( fabs(lhs - rhs) < DGG_NULL_SLACK )
return 0;
return 0;
}
double DGG_cutLHS(DGG_constraint_t *c, double *x)
{
int i;
double lhs = 0.0;
for(i=0; i < c->nz; i++)
lhs += c->coeff[i]*x[c->index[i]];
return lhs;
}
int DGG_isCutDesirable(DGG_constraint_t *c, DGG_data_t *d)
{
double lhs, rhs;
lhs = DGG_cutLHS(c, d->x);
rhs = c->rhs;
if (c->nz > 500) return 0;
/* if the cut is not violated, return 0 */
if (c->sense == 'G')
if ( lhs > (rhs - DGG_NULL_SLACK) )
return 0;
if (c->sense == 'L')
if ( lhs < (rhs + DGG_NULL_SLACK) )
return 0;
if (c->sense == 'E')
if ( fabs(lhs - rhs) < DGG_NULL_SLACK )
return 0;
return 1;
}
/******************** SIMPLE MACROS AND FUNCTIONS *****************************/
int DGG_is_even(double vht, double bht, int tau, int q)
{
double v2 = V2I(bht, tau, q);
if ( vht > v2 )
return 1;
return 0;
}
double frac_part(double value)
{
return value-floor(value);
}
int DGG_is_a_multiple_of_b(double a, double b)
{
double c = b/a;
if ( (b - a*floor(c)) < DGG_MIN_RHO )
return 1;
return 0;
}
int DGG_cutsOffPoint(double *x, DGG_constraint_t *cut)
{
int i;
double LHS = 0.0;
for(i=0; i < cut->nz; i++)
LHS += cut->coeff[i]*(x[ cut->index[i] ]);
//fprintf(stdout, "LHS = %f, SENSE = %c, RHS = %f\n", LHS, cut->sense, cut->rhs);
if ( cut->sense == 'E' )
if ( fabs(LHS - cut->rhs) > DGG_NULL_SLACK )
goto BAD;
if (cut->sense == 'G' )
if ( (cut->rhs - LHS) > DGG_NULL_SLACK )
goto BAD;
if (cut->sense == 'L' )
if ( (LHS - cut->rhs) > DGG_NULL_SLACK )
goto BAD;
return 0;
BAD:
fprintf(stdout, "LHS = %f, SENSE = %c, RHS = %f\n", LHS, cut->sense, cut->rhs);
DGG_TEST(1, 1, "found a bad cut!");
return 0;
}
// Returns true if needs optimal basis to do cuts
bool
CglTwomir::needsOptimalBasis() const
{
return true;
}
// Away stuff
void CglTwomir::setAway(double value)
{
if (value>0.0&&value<=0.5)
away_=value;
}
double CglTwomir::getAway() const
{
return away_;
}
// Away stuff at root
void CglTwomir::setAwayAtRoot(double value)
{
if (value>0.0&&value<=0.5)
awayAtRoot_=value;
}
double CglTwomir::getAwayAtRoot() const
{
return awayAtRoot_;
}
// This can be used to refresh any information
void
CglTwomir::refreshSolver(OsiSolverInterface * solver)
{
if (originalSolver_) {
delete originalSolver_;
originalSolver_ = solver->clone();
}
}
// Create C++ lines to get to current state
std::string
CglTwomir::generateCpp( FILE * fp)
{
CglTwomir other;
fprintf(fp,"0#include \"CglTwomir.hpp\"\n");
fprintf(fp,"3 CglTwomir twomir;\n");
if (t_min_!=other.t_min_||t_max_!=other.t_max_)
fprintf(fp,"3 twomir.setMirScale(%d,%d);\n",t_min_,t_max_);
else
fprintf(fp,"4 twomir.setMirScale(%d,%d);\n",t_min_,t_max_);
if (q_min_!=other.q_min_||q_max_!=other.q_max_)
fprintf(fp,"3 twomir.setTwomirScale(%d,%d);\n",q_min_,q_max_);
else
fprintf(fp,"4 twomir.setTwomirScale(%d,%d);\n",q_min_,q_max_);
if (do_mir_!=other.do_mir_||do_2mir_!=other.do_2mir_||
do_tab_!=other.do_tab_||do_form_!=other.do_form_)
fprintf(fp,"3 twomir.setCutTypes(%s,%s,%s,%s);\n",
do_mir_ ? "true" : "false",
do_2mir_ ? "true" : "false",
do_tab_ ? "true" : "false",
do_form_ ? "true" : "false");
else
fprintf(fp,"4 twomir.setCutTypes(%s,%s,%s,%s);\n",
do_mir_ ? "true" : "false",
do_2mir_ ? "true" : "false",
do_tab_ ? "true" : "false",
do_form_ ? "true" : "false");
if (a_max_!=other.a_max_)
fprintf(fp,"3 twomir.setAMax(%d);\n",a_max_);
else
fprintf(fp,"4 twomir.setAMax(%d);\n",a_max_);
if (max_elements_!=other.max_elements_)
fprintf(fp,"3 twomir.setMaxElements(%d);\n",max_elements_);
else
fprintf(fp,"4 twomir.setMaxElements(%d);\n",max_elements_);
if (max_elements_root_!=other.max_elements_root_)
fprintf(fp,"3 twomir.setMaxElementsRoot(%d);\n",max_elements_root_);
else
fprintf(fp,"4 twomir.setMaxElementsRoot(%d);\n",max_elements_root_);
if (getAggressiveness()!=other.getAggressiveness())
fprintf(fp,"3 twomir.setAggressiveness(%d);\n",getAggressiveness());
else
fprintf(fp,"4 twomir.setAggressiveness(%d);\n",getAggressiveness());
return "twomir";
}
| 62,240
| 24,951
|
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <node.h>
#include <node_child_process.h>
#include <v8.h>
#include <uv.h>
#include <eio.h>
#include <assert.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <platform_win32.h>
#include <platform_win32_winsock.h>
namespace node {
using namespace v8;
static const WCHAR DEFAULT_PATH[1] = L"";
static const WCHAR DEFAULT_PATH_EXT[20] = L".COM;.EXE;.BAT;.CMD";
static Persistent<String> pid_symbol;
static Persistent<String> onexit_symbol;
static struct watcher_status_struct {
uv_async_t async_watcher;
ChildProcess *child;
HANDLE lock;
int num_active;
} watcher_status;
/*
* Path search functions
*/
/*
* Helper function for search_path
*/
static inline WCHAR* search_path_join_test(
const WCHAR* dir, int dir_len, const WCHAR* name, int name_len,
const WCHAR* ext, int ext_len, const WCHAR* cwd, int cwd_len) {
WCHAR *result, *result_pos;
if (dir_len >= 1 && (dir[0] == L'/' || dir[0] == L'\\')) {
// It's a full path without drive letter, use cwd's drive letter only
cwd_len = 2;
} else if (dir_len >= 2 && dir[1] == L':' &&
(dir_len < 3 || (dir[2] != L'/' && dir[2] != L'\\'))) {
// It's a relative path with drive letter (ext.g. D:../some/file)
// Replace drive letter in dir by full cwd if it points to the same drive,
// otherwise use the dir only.
if (cwd_len < 2 || _wcsnicmp(cwd, dir, 2) != 0) {
cwd_len = 0;
} else {
dir += 2;
dir_len -= 2;
}
} else if (dir_len > 2 && dir[1] == L':') {
// It's an absolute path with drive letter
// Don't use the cwd at all
cwd_len = 0;
}
// Allocate buffer for output
result = result_pos =
new WCHAR[cwd_len + 1 + dir_len + 1 + name_len + 1 + ext_len + 1];
// Copy cwd
wcsncpy(result_pos, cwd, cwd_len);
result_pos += cwd_len;
// Add a path separator if cwd didn't end with one
if (cwd_len && wcsrchr(L"\\/:", result_pos[-1]) == NULL) {
result_pos[0] = L'\\';
result_pos++;
}
// Copy dir
wcsncpy(result_pos, dir, dir_len);
result_pos += dir_len;
// Add a separator if the dir didn't end with one
if (dir_len && wcsrchr(L"\\/:", result_pos[-1]) == NULL) {
result_pos[0] = L'\\';
result_pos++;
}
// Copy filename
wcsncpy(result_pos, name, name_len);
result_pos += name_len;
// Copy extension
if (ext_len) {
result_pos[0] = L'.';
result_pos++;
wcsncpy(result_pos, ext, ext_len);
result_pos += ext_len;
}
// Null terminator
result_pos[0] = L'\0';
DWORD attrs = GetFileAttributesW(result);
if (attrs != INVALID_FILE_ATTRIBUTES &&
!(attrs & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT))) {
return result;
}
delete[] result;
return NULL;
}
/*
* Helper function for search_path
*/
static inline WCHAR* path_search_walk_ext(
const WCHAR *dir, int dir_len, const WCHAR *name, int name_len,
WCHAR *cwd, int cwd_len, const WCHAR *path_ext, bool name_has_ext) {
WCHAR* result = NULL;
const WCHAR *ext_start,
*ext_end = path_ext;
// If the name itself has a nonemtpy extension, try this extension first
if (name_has_ext) {
result = search_path_join_test(dir, dir_len,
name, name_len,
L"", 0,
cwd, cwd_len);
}
// Add path_ext extensions and try to find a name that matches
while (result == NULL) {
if (*ext_end == L'\0') {
break;
}
// Skip the separator that ext_end now points to
if (ext_end != path_ext) {
ext_end++;
}
// Find the next dot in path_ext
ext_start = wcschr(ext_end, L'.');
if (ext_start == NULL) {
break;
}
// Skip the dot
ext_start++;
// Slice until we found a ; or alternatively a \0
ext_end = wcschr(ext_start, L';');
if (ext_end == NULL) {
ext_end = wcschr(ext_start, '\0');
}
result = search_path_join_test(dir, dir_len,
name, name_len,
ext_start, (ext_end - ext_start),
cwd, cwd_len);
}
return result;
}
/*
* search_path searches the system path for an executable filename -
* the windows API doesn't provide this as a standalone function nor as an
* option to CreateProcess.
*
* It tries to return an absolute filename.
*
* Furthermore, it tries to follow the semantics that cmd.exe uses as closely
* as possible:
*
* - Do not search the path if the filename already contains a path (either
* relative or absolute).
* (but do use path_ext)
*
* - If there's really only a filename, check the current directory for file,
* then search all path directories.
*
* - If filename specifies has *any* extension, search for the file with the
* specified extension first.
* (not necessary an executable one or one that appears in path_ext;
* *but* no extension or just a dot is *not* allowed)
*
* - If the literal filename is not found in a directory, try *appending*
* (not replacing) extensions from path_ext in the specified order.
* (an extension consisting of just a dot *may* appear in path_ext;
* unlike what happens if the specified filename ends with a dot,
* if path_ext specifies a single dot cmd.exe *does* look for an
* extension-less file)
*
* - The path variable may contain relative paths; relative paths are relative
* to the cwd.
*
* - Directories in path may or may not end with a trailing backslash.
*
* - Extensions path_ext portions must always start with a dot.
*
* - CMD does not trim leading/trailing whitespace from path/pathex entries
* nor from the environment variables as a whole.
*
* - When cmd.exe cannot read a directory, it wil just skip it and go on
* searching. However, unlike posix-y systems, it will happily try to run a
* file that is not readable/executable; if the spawn fails it will not
* continue searching.
*
* TODO: correctly interpret UNC paths
* TODO: check with cmd what should happen when a pathext entry does not start
* with a dot
*/
static inline WCHAR* search_path(const WCHAR *file, WCHAR *cwd,
const WCHAR *path, const WCHAR *path_ext) {
WCHAR* result = NULL;
int file_len = wcslen(file);
int cwd_len = wcslen(cwd);
// If the caller supplies an empty filename,
// we're not gonna return c:\windows\.exe -- GFY!
if (file_len == 0
|| (file_len == 1 && file[0] == L'.')) {
return NULL;
}
// Find the start of the filename so we can split the directory from the name
WCHAR *file_name_start;
for (file_name_start = (WCHAR*)file + file_len;
file_name_start > file
&& file_name_start[-1] != L'\\'
&& file_name_start[-1] != L'/'
&& file_name_start[-1] != L':';
file_name_start--);
bool file_has_dir = file_name_start != file;
// Check if the filename includes an extension
WCHAR *dot = wcschr(file_name_start, L'.');
bool name_has_ext = (dot != NULL && dot[1] != L'\0');
if (file_has_dir) {
// The file has a path inside, don't use path (but do use path_ex)
result = path_search_walk_ext(
file, file_name_start - file,
file_name_start, file_len - (file_name_start - file),
cwd, cwd_len,
path_ext, name_has_ext);
} else {
const WCHAR *dir_start,
*dir_end = path;
// The file is really only a name; look in cwd first, then scan path
result = path_search_walk_ext(L"", 0,
file, file_len,
cwd, cwd_len,
path_ext, name_has_ext);
while (result == NULL) {
if (*dir_end == L'\0') {
break;
}
// Skip the separator that dir_end now points to
if (dir_end != path) {
dir_end++;
}
// Next slice starts just after where the previous one ended
dir_start = dir_end;
// Slice until the next ; or \0 is found
dir_end = wcschr(dir_start, L';');
if (dir_end == NULL) {
dir_end = wcschr(dir_start, L'\0');
}
// If the slice is zero-length, don't bother
if (dir_end - dir_start == 0) {
continue;
}
result = path_search_walk_ext(dir_start, dir_end - dir_start,
file, file_len,
cwd, cwd_len,
path_ext, name_has_ext);
}
}
return result;
}
/*
* Process exit "watcher" functions. It's not like a real libev watcher,
* it's more like a wrapper around ev_async, and RegisterWaitForSingleObject.
* And its not generalized, it only works with child processes.
* BTW there is only one exit watcher that watches all childs!
*/
// Called from either a eio, a wait thread or a callback thread created by a
// wait thread
void ChildProcess::close_stdio_handles(ChildProcess *child) {
// Before we proceed to synchronize with the main thread, first close
// the stdio sockets that the child process has used, because it may
// take some time and would deadlock if done in the main thread.
for (int i = 0; i < 3; i++) {
if (!child->got_custom_fds_[i]) {
shutdown(reinterpret_cast<SOCKET>(child->stdio_handles_[i]), SD_BOTH);
closesocket(reinterpret_cast<SOCKET>(child->stdio_handles_[i]));
}
}
}
// Called from the main thread
void ChildProcess::notify_exit(uv_async_t* watcher, int status) {
// Get the child process, then release the lock
ChildProcess *child = watcher_status.child;
ReleaseSemaphore(watcher_status.lock, 1, NULL);
DWORD exit_code = -127;
EnterCriticalSection(&child->info_lock_);
// Did the process even start anyway?
if (child->did_start_) {
// Process launched, then exited
// Drop the wait handle
UnregisterWait(child->wait_handle_);
// Fetch the process exit code
if (GetExitCodeProcess(child->process_handle_, &exit_code) == 0) {
winapi_perror("GetExitCodeProcess");
}
// Close and unset the process handle
CloseHandle(child->process_handle_);
child->process_handle_ = NULL;
child->pid_ = 0;
}
LeaveCriticalSection(&child->info_lock_);
child->OnExit(exit_code);
}
// Called from the eio thread
void ChildProcess::notify_spawn_failure(ChildProcess *child) {
close_stdio_handles(child);
DWORD result = WaitForSingleObject(watcher_status.lock, INFINITE);
assert(result == WAIT_OBJECT_0);
watcher_status.child = child;
uv_async_send(&watcher_status.async_watcher);
}
// Called from the windows-managed wait thread
void CALLBACK ChildProcess::watch_wait_callback(void *data,
BOOLEAN didTimeout) {
assert(didTimeout == FALSE);
ChildProcess *child = (ChildProcess*)data;
close_stdio_handles(child);
// If the main thread is blocked, and more than one child process returns,
// the wait thread will block as well here. It doesn't matter because the
// main thread can only do one thing at a time anyway.
DWORD result = WaitForSingleObject(watcher_status.lock, INFINITE);
assert(result == WAIT_OBJECT_0);
watcher_status.child = child;
uv_async_send(&watcher_status.async_watcher);
}
// Called from the eio thread
inline void ChildProcess::watch(ChildProcess *child) {
DWORD result = WaitForSingleObject(watcher_status.lock, INFINITE);
assert(result == WAIT_OBJECT_0);
// We must retain the lock here because we don't want the RegisterWait
// to complete before the wait handle is set to the child process.
RegisterWaitForSingleObject(&child->wait_handle_, child->process_handle_,
watch_wait_callback, (void*)child, INFINITE,
WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE);
ReleaseSemaphore(watcher_status.lock, 1, NULL);
}
/*
* Spawn helper functions
*/
/*
* Quotes command line arguments
* Returns a pointer to the end (next char to be written) of the buffer
*/
static inline WCHAR* quote_cmd_arg(WCHAR *source, WCHAR *target,
WCHAR terminator) {
int len = wcslen(source),
i;
// Check if the string must be quoted;
// if unnecessary, don't do it, it may only confuse older programs.
if (len == 0) {
goto quote;
}
for (i = 0; i < len; i++) {
if (source[i] == L' ' || source[i] == L'"') {
goto quote;
}
}
// No quotation needed
wcsncpy(target, source, len);
target += len;
*(target++) = terminator;
return target;
quote:
// Quote
*(target++) = L'"';
for (i = 0; i < len; i++) {
if (source[i] == L'"' || source[i] == L'\\') {
*(target++) = '\\';
}
*(target++) = source[i];
}
*(target++) = L'"';
*(target++) = terminator;
return target;
}
/*
* Spawns a child process from a libeio thread
*/
int ChildProcess::do_spawn(eio_req *req) {
ChildProcess* child = (ChildProcess*)req->data;
WCHAR* application_path = search_path(child->application_, child->cwd_,
child->path_, child->path_ext_);
if (application_path) {
STARTUPINFOW startup;
PROCESS_INFORMATION info;
startup.cb = sizeof(startup);
startup.lpReserved = NULL;
startup.lpDesktop = NULL;
startup.lpTitle = NULL;
startup.dwFlags = STARTF_USESTDHANDLES;
startup.cbReserved2 = 0;
startup.lpReserved2 = NULL;
startup.hStdInput = child->stdio_handles_[0];
startup.hStdOutput = child->stdio_handles_[1];
startup.hStdError = child->stdio_handles_[2];
EnterCriticalSection(&child->info_lock_);
if (!child->kill_me_) {
// Try start the process
BOOL success = CreateProcessW(
application_path,
child->arguments_,
NULL,
NULL,
1,
CREATE_UNICODE_ENVIRONMENT,
child->env_win_,
child->cwd_,
&startup,
&info
);
if (success) {
child->process_handle_ = info.hProcess;
child->pid_ = GetProcessId(info.hProcess);
child->did_start_ = true;
watch(child);
// Not interesting
CloseHandle(info.hThread);
LeaveCriticalSection(&child->info_lock_);
return 0;
}
}
LeaveCriticalSection(&child->info_lock_);
}
// not found, kill_me set or process failed to start
notify_spawn_failure(child);
return 0;
}
// Called from the main thread after spawn has finished,
// there's no need to lock the child because did_start is reliable
int ChildProcess::after_spawn(eio_req *req) {
ChildProcess* child = (ChildProcess*)req->data;
if (child->did_start_) {
child->handle_->Set(pid_symbol, Integer::New(child->pid_));
} else {
child->handle_->Set(pid_symbol, Local<Value>::New(Null()));
}
// Cleanup data structures needed only for spawn() here
delete [] child->application_;
delete [] child->arguments_;
delete [] child->env_win_;
delete [] child->cwd_;
return 0;
}
/*
* Kill helper functions
*/
// Called from the main thread while eio/wait threads may still be busy with
// the process
int ChildProcess::do_kill(ChildProcess *child, int sig) {
int rv = 0;
EnterCriticalSection(&child->info_lock_);
child->exit_signal_ = sig;
if (child->did_start_) {
// On windows killed processes normally return 1
if (!TerminateProcess(child->process_handle_, 1))
rv = -1;
} else {
child->kill_me_ = true;
}
LeaveCriticalSection(&child->info_lock_);
return rv;
}
/*
* ChildProcess non-static Methods
*/
Handle<Value> ChildProcess::New(const Arguments& args) {
HandleScope scope;
ChildProcess *p = new ChildProcess();
p->Wrap(args.Holder());
return args.This();
}
// This is an internal function. The third argument should be an array
// of key value pairs seperated with '='.
Handle<Value> ChildProcess::Spawn(const Arguments& args) {
HandleScope scope;
if (args.Length() < 3 ||
!args[0]->IsString() ||
!args[1]->IsArray() ||
!args[2]->IsString() ||
!args[3]->IsArray()) {
return ThrowException(Exception::Error(String::New("Bad argument.")));
}
// Get ChildProcess object
ChildProcess *child = ObjectWrap::Unwrap<ChildProcess>(args.Holder());
// Copy appplication name
Handle<String> app_handle = args[0]->ToString();
int app_len = app_handle->Length();
String::Value app(app_handle);
child->application_ = new WCHAR[app_len + 1];
wcsncpy(child->application_, (WCHAR*)*app, app_len + 1);
/*
* Copy second argument args[1] into a c-string called argv.
* On windows command line arguments are all quoted and concatenated to
* one string. The executable name must be prepended. This is not really
* required by windows but if you don't do this programs that rely on
* argv[0] being the executable misbehave.
* Assuming that executable plus all arguments must be wrapped in quotes,
* every character needs to be quoted with a backslash,
* and every argument is followed by either a space or a nul char,
* the maximum required buffer size is Σ[exe and args](2 * length + 3).
*/
Local<Array> cmd_args_handle = Local<Array>::Cast(args[1]);
int cmd_argc = cmd_args_handle->Length();
// Compute required buffer
int max_buf = (1 + cmd_argc) * 3 + app_len * 2,
i;
for (i = 0; i < cmd_argc; i++) {
Local<String> arg_handle =
cmd_args_handle->Get(Integer::New(i))->ToString();
max_buf += arg_handle->Length() * 2;
}
child->arguments_ = new WCHAR[max_buf];
WCHAR *pos = child->arguments_;
pos = quote_cmd_arg((WCHAR*)*app, pos, cmd_argc ? L' ' : L'\0');
for (i = 0; i < cmd_argc; i++) {
String::Value arg(cmd_args_handle->Get(Integer::New(i))->ToString());
pos = quote_cmd_arg((WCHAR*)*arg, pos, (i < cmd_argc - 1) ? L' ' : L'\0');
}
// Current working directory
Local<String>cwd_handle = Local<String>::Cast(args[2]);
int cwd_len = cwd_handle->Length();
if (cwd_len > 0) {
// Cwd was specified
String::Value cwd(cwd_handle);
child->cwd_ = new WCHAR[cwd_len + 1];
wcsncpy(child->cwd_, (WCHAR*)*cwd, cwd_len + 1);
} else {
// Cwd not specified
int chars = GetCurrentDirectoryW(0, NULL);
if (!chars) {
winapi_perror("GetCurrentDirectoryW");
child->cwd_ = new WCHAR[0];
child->cwd_[0] = '\0';
} else {
child->cwd_ = new WCHAR[chars];
GetCurrentDirectoryW(chars, child->cwd_);
}
}
/*
* args[3] holds the environment as a js array containing key=value pairs.
* The way windows takes environment variables is different than what C does;
* Windows wants a contiguous block of null-terminated strings, terminated
* with an additional null.
* Get a pointer to the pathext and path environment variables as well,
* because do_spawn needs it. These are just pointers into env_win.
*/
Local<Array> env_list_handle = Local<Array>::Cast(args[3]);
int envc = env_list_handle->Length();
Local<String> env_val_handle[envc];
int env_win_len = envc + 1; // room for \0 terminators plus closing null
for (int i = 0; i < envc; i++) {
env_val_handle[i] = env_list_handle->Get(Integer::New(i))->ToString();
env_win_len += env_val_handle[i]->Length();
}
WCHAR *env_win = new WCHAR[env_win_len],
*env_win_pos = env_win;
WCHAR *path = NULL, *path_ext = NULL;
for (int i = 0; i < envc; i++) {
int len = env_val_handle[i]->Length() + 1; // including \0
String::Value pair(env_val_handle[i]);
wcsncpy(env_win_pos, (WCHAR*)*pair, (size_t)len);
// Try to get a pointer to PATH and PATHEXT
if (_wcsnicmp(L"PATH=", env_win_pos, 5) == 0) {
path = env_win_pos + 5;
}
if (_wcsnicmp(L"PATHEXT=", env_win_pos, 8) == 0) {
path_ext = env_win_pos + 8;
}
env_win_pos += len;
}
*env_win_pos = L'\0';
child->env_win_ = env_win;
if (path != NULL) {
child->path_ = path;
} else {
child->path_ = DEFAULT_PATH;
}
if (path_ext != NULL) {
child->path_ext_ = path_ext;
} else {
child->path_ext_ = DEFAULT_PATH_EXT;
}
// Open pipes or re-use custom_fds to talk to child
Local<Array> custom_fds_handle = Local<Array>::Cast(args[4]);
int custom_fds_len = custom_fds_handle->Length();
HANDLE *child_handles = (HANDLE*)&child->stdio_handles_;
bool *has_custom_fds = (bool*)&child->got_custom_fds_;
int parent_fds[3];
for (int i = 0; i < 3; i++) {
int custom_fd = -1;
if (i < custom_fds_len && !custom_fds_handle->Get(i)->IsUndefined())
custom_fd = custom_fds_handle->Get(i)->ToInteger()->Value();
if (custom_fd == -1) {
// Create a new pipe
HANDLE parent_handle, child_handle;
if (wsa_sync_async_socketpair(AF_INET, SOCK_STREAM, IPPROTO_IP,
(SOCKET*)&child_handle, (SOCKET*)&parent_handle) == SOCKET_ERROR)
wsa_perror("wsa_sync_async_socketpair");
// Make parent handle nonblocking
unsigned long ioctl_value = 1;
if (ioctlsocket((SOCKET)parent_handle, FIONBIO, &ioctl_value) ==
SOCKET_ERROR)
wsa_perror("ioctlsocket");
// Make parent handle non-inheritable
if (!SetHandleInformation(parent_handle, HANDLE_FLAG_INHERIT, 0))
winapi_perror("SetHandleInformation");
// Make child handle inheritable
if (!SetHandleInformation(child_handle, HANDLE_FLAG_INHERIT,
HANDLE_FLAG_INHERIT))
winapi_perror("SetHandleInformation");
// Enable linger on socket so all written data gets through
BOOL opt_value = 0;
if (setsockopt((SOCKET)child_handle, SOL_SOCKET, SO_DONTLINGER,
(char*)&opt_value, sizeof(opt_value)) == SOCKET_ERROR)
wsa_perror("setsockopt");
has_custom_fds[i] = false;
child_handles[i] = child_handle;
parent_fds[i] = (int)_open_osfhandle((intptr_t)parent_handle, 0);
} else {
// Use this custom fd
HANDLE custom_handle = (HANDLE)_get_osfhandle(custom_fd);
// Make handle inheritable, don't care it it fails
// It may fail for certain types of handles - but always try to
// spawn; it'll still work for e.g. console handles
SetHandleInformation(custom_handle, HANDLE_FLAG_INHERIT,
HANDLE_FLAG_INHERIT);
has_custom_fds[i] = true;
child_handles[i] = custom_handle;
parent_fds[i] = custom_fd;
}
}
// Return the opened fds
Local<Array> result = Array::New(3);
assert(parent_fds[0] >= 0);
result->Set(0, Integer::New(parent_fds[0]));
assert(parent_fds[1] >= 0);
result->Set(1, Integer::New(parent_fds[1]));
assert(parent_fds[2] >= 0);
result->Set(2, Integer::New(parent_fds[2]));
// Grab a reference so it doesn't get GC'ed
child->Ref();
eio_custom(do_spawn, EIO_PRI_DEFAULT, after_spawn, (void*)child);
return scope.Close(result);
}
Handle<Value> ChildProcess::Kill(const Arguments& args) {
HandleScope scope;
ChildProcess *child = ObjectWrap::Unwrap<ChildProcess>(args.Holder());
assert(child);
int sig = SIGTERM;
if (args.Length() > 0) {
if (args[0]->IsNumber()) {
sig = args[0]->Int32Value();
} else {
return ThrowException(Exception::TypeError(String::New("Bad argument.")));
}
}
if (do_kill(child, sig) != 0) {
return ThrowException(ErrnoException(GetLastError()));
}
return True();
}
// Called from the main thread _after_ all eio/wait threads are done with the
// process, so there's no need to lock here.
void ChildProcess::OnExit(int status) {
HandleScope scope;
// Unref() the child, as it's no longer used by threads
Unref();
handle_->Set(pid_symbol, Null());
Local<Value> onexit_v = handle_->Get(onexit_symbol);
assert(onexit_v->IsFunction());
Local<Function> onexit = Local<Function>::Cast(onexit_v);
TryCatch try_catch;
Local<Value> argv[2];
argv[0] = Integer::New(status);
if (exit_signal_ != 0) {
argv[1] = Integer::New(exit_signal_);
} else {
argv[1] = Local<Value>::New(Null());
}
onexit->Call(handle_, 2, argv);
if (try_catch.HasCaught()) {
FatalException(try_catch);
}
}
void ChildProcess::Initialize(Handle<Object> target) {
HandleScope scope;
Local<FunctionTemplate> t = FunctionTemplate::New(ChildProcess::New);
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(String::NewSymbol("ChildProcess"));
pid_symbol = NODE_PSYMBOL("pid");
onexit_symbol = NODE_PSYMBOL("onexit");
NODE_SET_PROTOTYPE_METHOD(t, "spawn", ChildProcess::Spawn);
NODE_SET_PROTOTYPE_METHOD(t, "kill", ChildProcess::Kill);
target->Set(String::NewSymbol("ChildProcess"), t->GetFunction());
uv_async_init(&watcher_status.async_watcher, notify_exit);
watcher_status.lock = CreateSemaphore(NULL, 1, 1, NULL);
}
} // namespace node
NODE_MODULE(node_child_process, node::ChildProcess::Initialize);
| 25,908
| 8,956
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <unistd.h>
#include <getopt.h>
#include <cstdlib>
#include "txn_limiter.h"
///////////////////////////////////////////////////////////////////////////////
// These continuations are "helpers" to the TXN limiter object. Putting them
// outside the class implementation is just cleaner.
//
static int
txn_limit_cont(TSCont cont, TSEvent event, void *edata)
{
TxnRateLimiter *limiter = static_cast<TxnRateLimiter *>(TSContDataGet(cont));
switch (event) {
case TS_EVENT_HTTP_TXN_CLOSE:
limiter->release();
TSContDestroy(cont); // We are done with this continuation now
TSHttpTxnReenable(static_cast<TSHttpTxn>(edata), TS_EVENT_HTTP_CONTINUE);
return TS_EVENT_CONTINUE;
break;
case TS_EVENT_HTTP_POST_REMAP:
limiter->push(static_cast<TSHttpTxn>(edata), cont);
return TS_EVENT_NONE;
break;
case TS_EVENT_HTTP_SEND_RESPONSE_HDR: // This is only applicable when we set an error in remap
retryAfter(static_cast<TSHttpTxn>(edata), limiter->retry);
TSContDestroy(cont); // We are done with this continuation now
TSHttpTxnReenable(static_cast<TSHttpTxn>(edata), TS_EVENT_HTTP_CONTINUE);
return TS_EVENT_CONTINUE;
break;
default:
TSDebug(PLUGIN_NAME, "Unknown event %d", static_cast<int>(event));
TSError("Unknown event in %s", PLUGIN_NAME);
break;
}
return TS_EVENT_NONE;
}
static int
txn_queue_cont(TSCont cont, TSEvent event, void *edata)
{
TxnRateLimiter *limiter = static_cast<TxnRateLimiter *>(TSContDataGet(cont));
QueueTime now = std::chrono::system_clock::now(); // Only do this once per "loop"
// Try to enable some queued txns (if any) if there are slots available
while (limiter->size() > 0 && limiter->reserve()) {
auto [txnp, contp, start_time] = limiter->pop();
std::chrono::milliseconds delay = std::chrono::duration_cast<std::chrono::milliseconds>(now - start_time);
delayHeader(txnp, limiter->header, delay);
TSDebug(PLUGIN_NAME, "Enabling queued txn after %ldms", static_cast<long>(delay.count()));
// Since this was a delayed transaction, we need to add the TXN_CLOSE hook to free the slot when done
TSHttpTxnHookAdd(txnp, TS_HTTP_TXN_CLOSE_HOOK, contp);
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
}
// Kill any queued txns if they are too old
if (limiter->size() > 0 && limiter->max_age > std::chrono::milliseconds::zero()) {
now = std::chrono::system_clock::now(); // Update the "now", for some extra accuracy
while (limiter->size() > 0 && limiter->hasOldEntity(now)) {
// The oldest object on the queue is too old on the queue, so "kill" it.
auto [txnp, contp, start_time] = limiter->pop();
std::chrono::milliseconds age = std::chrono::duration_cast<std::chrono::milliseconds>(now - start_time);
delayHeader(txnp, limiter->header, age);
TSDebug(PLUGIN_NAME, "Queued TXN is too old (%ldms), erroring out", static_cast<long>(age.count()));
TSHttpTxnStatusSet(txnp, static_cast<TSHttpStatus>(limiter->error));
TSHttpTxnHookAdd(txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, contp);
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_ERROR);
}
}
return TS_EVENT_NONE;
}
///////////////////////////////////////////////////////////////////////////////
// Parse the configurations for the TXN limiter.
//
bool
TxnRateLimiter::initialize(int argc, const char *argv[])
{
static const struct option longopt[] = {
{const_cast<char *>("limit"), required_argument, nullptr, 'l'},
{const_cast<char *>("queue"), required_argument, nullptr, 'q'},
{const_cast<char *>("error"), required_argument, nullptr, 'e'},
{const_cast<char *>("retry"), required_argument, nullptr, 'r'},
{const_cast<char *>("header"), required_argument, nullptr, 'h'},
{const_cast<char *>("maxage"), required_argument, nullptr, 'm'},
// EOF
{nullptr, no_argument, nullptr, '\0'},
};
while (true) {
int opt = getopt_long(argc, (char *const *)argv, "", longopt, nullptr);
switch (opt) {
case 'l':
this->limit = strtol(optarg, nullptr, 10);
break;
case 'q':
this->max_queue = strtol(optarg, nullptr, 10);
break;
case 'e':
this->error = strtol(optarg, nullptr, 10);
break;
case 'r':
this->retry = strtol(optarg, nullptr, 10);
break;
case 'm':
this->max_age = std::chrono::milliseconds(strtol(optarg, nullptr, 10));
break;
case 'h':
this->header = optarg;
break;
}
if (opt == -1) {
break;
}
}
if (this->max_queue > 0) {
_queue_cont = TSContCreate(txn_queue_cont, TSMutexCreate());
TSReleaseAssert(_queue_cont);
TSContDataSet(_queue_cont, this);
_action = TSContScheduleEveryOnPool(_queue_cont, QUEUE_DELAY_TIME.count(), TS_THREAD_POOL_TASK);
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
// Sets up a transaction based continuation for this transaction.
//
void
TxnRateLimiter::setupTxnCont(TSHttpTxn txnp, TSHttpHookID hook)
{
TSCont cont = TSContCreate(txn_limit_cont, nullptr);
TSReleaseAssert(cont);
TSContDataSet(cont, this);
TSHttpTxnHookAdd(txnp, hook, cont);
}
| 5,989
| 2,087
|
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2008, 2012
*
* Last modified:
* $Date: 2016-04-19 17:19:45 +0200 (Tue, 19 Apr 2016) $ by $Author: schulte $
* $Revision: 14967 $
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "test/int.hh"
#include "test/float.hh"
#include <gecode/minimodel.hh>
namespace Test { namespace Float {
/// %Tests for minimal modeling constraints (linear)
namespace MiniModelLin {
/// Linear opcode
enum LinOpcode {
LO_ACE, ///< Add float and expression
LO_AEC, ///< Add expression and float
LO_AEE, ///< Add expressions
LO_SCE, ///< Subtract float and expression
LO_SEC, ///< Subtract expression and float
LO_SEE, ///< Subtract expressions
LO_SE, ///< Unary subtraction
LO_MCE, ///< Multiply constant and expression
LO_MEC, ///< Multiply constant and expression
LO_HLT ///< Stop execution
};
/// Type for representing a linear instruction
class LinInstr {
public:
LinOpcode o; ///< Which instruction to execute
unsigned char x, y, z; ///< Instruction arguments, \a y is destination (or \a z)
int c; ///< Numerical constant
};
/// Evaluate linear instructions
template<class Expr>
Expr
eval(const LinInstr* pc, Expr reg[]) {
while (true) {
switch (pc->o) {
case LO_ACE: reg[pc->y] = pc->c + reg[pc->x]; break;
case LO_AEC: reg[pc->y] = reg[pc->x] + pc->c; break;
case LO_AEE: reg[pc->z] = reg[pc->x] + reg[pc->y]; break;
case LO_SCE: reg[pc->y] = pc->c - reg[pc->x]; break;
case LO_SEC: reg[pc->y] = reg[pc->x] - pc->c; break;
case LO_SEE: reg[pc->z] = reg[pc->x] - reg[pc->y]; break;
case LO_SE: reg[pc->y] = -reg[pc->x]; break;
case LO_MCE: reg[pc->y] = pc->c * reg[pc->x]; break;
case LO_MEC: reg[pc->y] = reg[pc->x] * pc->c; break;
case LO_HLT: return reg[pc->x];
default: GECODE_NEVER;
}
pc++;
}
GECODE_NEVER;
}
/**
* \defgroup TaskTestFloatMiniModelLin Minimal modeling constraints (linear constraints)
* \ingroup TaskTestFloat
*/
//@{
/// %Test linear expressions over float variables
class LinExpr : public Int::Test {
protected:
/// Linear instruction sequence
const LinInstr* lis;
public:
/// Create and register test
LinExpr(const LinInstr* lis0, const std::string& s)
: Test("Float::","MiniModel::LinExpr::"+s,4,-3,3),
lis(lis0) {
testfix = false;
}
/// %Test whether \a x is solution
virtual bool solution(const Int::Assignment& x) const {
int reg[3] = {x[0],x[1],x[2]};
return eval(lis, reg) == x[3];
}
/// Post constraint on \a x
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
FloatVarArray y(home,4,dom.min(),dom.max());
channel(home, x[0], y[0]);
channel(home, x[1], y[1]);
channel(home, x[2], y[2]);
channel(home, x[3], y[3]);
LinFloatExpr reg[3] = {y[0],y[1],y[2]};
rel(home, y[3], FRT_EQ, expr(home, eval(lis,reg)));
}
};
/// %Test linear relations over float variables
class LinRel : public Int::Test {
protected:
/// Linear instruction sequence for left hand side
const LinInstr* l_lis;
/// Linear instruction sequence for right hand side
const LinInstr* r_lis;
/// Float relation type to propagate
Gecode::FloatRelType frt;
public:
/// Create and register test
LinRel(const LinInstr* l_lis0, const LinInstr* r_lis0,
Gecode::FloatRelType frt0, const std::string& s)
: Test("Float::","MiniModel::LinRel::"+s+"::"+
Float::Test::str(frt0),3,-3,3),
l_lis(l_lis0), r_lis(r_lis0), frt(frt0) {
testfix = false;
}
/// %Test whether \a x is solution
virtual bool solution(const Int::Assignment& x) const {
using namespace Gecode;
int l_reg[3] = {x[0],x[1],x[2]};
int l = eval(l_lis,l_reg);
int r_reg[3] = {x[0],x[1],x[2]};
int r = eval(r_lis,r_reg);
switch (frt) {
case FRT_EQ: return l == r;
case FRT_NQ: return l != r;
case FRT_LE: return l < r;
case FRT_GR: return l > r;
case FRT_LQ: return l <= r;
case FRT_GQ: return l >= r;
default: GECODE_NEVER;
}
return false;
}
/// Post constraint on \a x
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
FloatVarArray y(home,3,dom.min(),dom.max());
channel(home, x[0], y[0]);
channel(home, x[1], y[1]);
channel(home, x[2], y[2]);
LinFloatExpr l_reg[3] = {y[0],y[1],y[2]};
LinFloatExpr r_reg[3] = {y[0],y[1],y[2]};
switch (frt) {
case FRT_EQ:
Gecode::rel(home, eval(l_lis,l_reg) == eval(r_lis,r_reg));
break;
case FRT_NQ:
Gecode::rel(home, eval(l_lis,l_reg) != eval(r_lis,r_reg));
break;
case FRT_LQ:
Gecode::rel(home, eval(l_lis,l_reg) <= eval(r_lis,r_reg));
break;
case FRT_LE:
Gecode::rel(home, eval(l_lis,l_reg) < eval(r_lis,r_reg));
break;
case FRT_GQ:
Gecode::rel(home, eval(l_lis,l_reg) >= eval(r_lis,r_reg));
break;
case FRT_GR:
Gecode::rel(home, eval(l_lis,l_reg) > eval(r_lis,r_reg));
break;
default: GECODE_NEVER;
}
}
};
const LinInstr li000[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li001[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li002[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li003[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li004[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li005[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li006[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li007[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li008[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li009[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li010[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li011[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li012[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li013[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li014[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li015[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li016[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li017[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li018[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li019[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li020[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li021[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li022[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li023[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li024[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li025[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li026[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li027[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li028[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li029[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li030[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li031[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li032[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li033[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li034[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li035[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li036[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li037[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li038[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li039[] = {
{LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li040[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li041[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li042[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li043[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li044[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li045[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li046[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li047[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li048[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li049[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li050[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li051[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li052[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li053[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li054[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li055[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li056[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li057[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li058[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li059[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li060[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li061[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li062[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li063[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li064[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li065[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li066[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li067[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li068[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li069[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li070[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li071[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li072[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li073[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li074[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li075[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li076[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li077[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li078[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li079[] = {
{LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li080[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li081[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li082[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li083[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li084[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li085[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li086[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li087[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li088[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li089[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li090[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li091[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li092[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li093[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li094[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li095[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li096[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li097[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li098[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li099[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li100[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li101[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li102[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li103[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li104[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li105[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li106[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li107[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li108[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li109[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li110[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li111[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li112[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li113[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li114[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li115[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li116[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li117[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li118[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li119[] = {
{LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li120[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li121[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li122[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li123[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li124[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li125[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li126[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li127[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li128[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li129[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li130[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li131[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li132[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li133[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li134[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li135[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li136[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li137[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li138[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li139[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li140[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li141[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li142[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li143[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li144[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li145[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li146[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li147[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li148[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li149[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li150[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li151[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li152[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li153[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li154[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li155[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li156[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li157[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li158[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li159[] = {
{LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li160[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li161[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li162[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li163[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li164[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li165[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li166[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li167[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li168[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li169[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li170[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li171[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li172[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li173[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li174[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li175[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li176[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li177[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li178[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li179[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li180[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li181[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li182[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li183[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li184[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li185[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li186[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li187[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li188[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li189[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li190[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li191[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li192[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li193[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li194[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li195[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li196[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li197[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li198[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li199[] = {
{LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li200[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li201[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li202[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li203[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li204[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li205[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li206[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li207[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li208[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li209[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li210[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li211[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li212[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li213[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li214[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li215[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li216[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li217[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li218[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li219[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li220[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li221[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li222[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li223[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li224[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li225[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li226[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li227[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li228[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li229[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li230[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li231[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li232[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li233[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li234[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li235[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li236[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li237[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li238[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li239[] = {
{LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li240[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li241[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li242[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li243[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li244[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li245[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li246[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li247[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li248[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li249[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li250[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li251[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li252[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li253[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li254[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li255[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li256[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li257[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li258[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li259[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li260[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li261[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li262[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li263[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li264[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li265[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li266[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li267[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li268[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li269[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li270[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li271[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li272[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li273[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li274[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li275[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li276[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li277[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li278[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li279[] = {
{LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li280[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li281[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li282[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li283[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li284[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li285[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li286[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li287[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li288[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li289[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li290[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li291[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li292[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li293[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li294[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li295[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li296[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li297[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li298[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li299[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li300[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li301[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li302[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li303[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li304[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li305[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li306[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li307[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li308[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li309[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li310[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li311[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li312[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li313[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li314[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li315[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li316[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li317[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li318[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li319[] = {
{LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li320[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li321[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li322[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li323[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li324[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li325[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li326[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li327[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li328[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li329[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li330[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li331[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li332[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li333[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li334[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li335[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li336[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li337[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li338[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li339[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li340[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li341[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li342[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li343[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li344[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li345[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li346[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li347[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li348[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li349[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li350[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li351[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li352[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li353[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li354[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li355[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li356[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li357[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li358[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li359[] = {
{LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li360[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li361[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li362[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li363[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li364[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li365[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li366[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li367[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li368[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li369[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li370[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li371[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li372[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li373[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li374[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li375[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li376[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li377[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li378[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li379[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li380[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li381[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li382[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li383[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li384[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li385[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li386[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li387[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li388[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li389[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li390[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li391[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li392[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li393[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li394[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li395[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li396[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0}
};
const LinInstr li397[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0}
};
const LinInstr li398[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr li399[] = {
{LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0},
{LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0}
};
const LinInstr* li[] = {
&li000[0],&li001[0],&li002[0],&li003[0],&li004[0],&li005[0],
&li006[0],&li007[0],&li008[0],&li009[0],&li010[0],&li011[0],
&li012[0],&li013[0],&li014[0],&li015[0],&li016[0],&li017[0],
&li018[0],&li019[0],&li020[0],&li021[0],&li022[0],&li023[0],
&li024[0],&li025[0],&li026[0],&li027[0],&li028[0],&li029[0],
&li030[0],&li031[0],&li032[0],&li033[0],&li034[0],&li035[0],
&li036[0],&li037[0],&li038[0],&li039[0],&li040[0],&li041[0],
&li042[0],&li043[0],&li044[0],&li045[0],&li046[0],&li047[0],
&li048[0],&li049[0],&li050[0],&li051[0],&li052[0],&li053[0],
&li054[0],&li055[0],&li056[0],&li057[0],&li058[0],&li059[0],
&li060[0],&li061[0],&li062[0],&li063[0],&li064[0],&li065[0],
&li066[0],&li067[0],&li068[0],&li069[0],&li070[0],&li071[0],
&li072[0],&li073[0],&li074[0],&li075[0],&li076[0],&li077[0],
&li078[0],&li079[0],&li080[0],&li081[0],&li082[0],&li083[0],
&li084[0],&li085[0],&li086[0],&li087[0],&li088[0],&li089[0],
&li090[0],&li091[0],&li092[0],&li093[0],&li094[0],&li095[0],
&li096[0],&li097[0],&li098[0],&li099[0],&li100[0],&li101[0],
&li102[0],&li103[0],&li104[0],&li105[0],&li106[0],&li107[0],
&li108[0],&li109[0],&li110[0],&li111[0],&li112[0],&li113[0],
&li114[0],&li115[0],&li116[0],&li117[0],&li118[0],&li119[0],
&li120[0],&li121[0],&li122[0],&li123[0],&li124[0],&li125[0],
&li126[0],&li127[0],&li128[0],&li129[0],&li130[0],&li131[0],
&li132[0],&li133[0],&li134[0],&li135[0],&li136[0],&li137[0],
&li138[0],&li139[0],&li140[0],&li141[0],&li142[0],&li143[0],
&li144[0],&li145[0],&li146[0],&li147[0],&li148[0],&li149[0],
&li150[0],&li151[0],&li152[0],&li153[0],&li154[0],&li155[0],
&li156[0],&li157[0],&li158[0],&li159[0],&li160[0],&li161[0],
&li162[0],&li163[0],&li164[0],&li165[0],&li166[0],&li167[0],
&li168[0],&li169[0],&li170[0],&li171[0],&li172[0],&li173[0],
&li174[0],&li175[0],&li176[0],&li177[0],&li178[0],&li179[0],
&li180[0],&li181[0],&li182[0],&li183[0],&li184[0],&li185[0],
&li186[0],&li187[0],&li188[0],&li189[0],&li190[0],&li191[0],
&li192[0],&li193[0],&li194[0],&li195[0],&li196[0],&li197[0],
&li198[0],&li199[0],&li200[0],&li201[0],&li202[0],&li203[0],
&li204[0],&li205[0],&li206[0],&li207[0],&li208[0],&li209[0],
&li210[0],&li211[0],&li212[0],&li213[0],&li214[0],&li215[0],
&li216[0],&li217[0],&li218[0],&li219[0],&li220[0],&li221[0],
&li222[0],&li223[0],&li224[0],&li225[0],&li226[0],&li227[0],
&li228[0],&li229[0],&li230[0],&li231[0],&li232[0],&li233[0],
&li234[0],&li235[0],&li236[0],&li237[0],&li238[0],&li239[0],
&li240[0],&li241[0],&li242[0],&li243[0],&li244[0],&li245[0],
&li246[0],&li247[0],&li248[0],&li249[0],&li250[0],&li251[0],
&li252[0],&li253[0],&li254[0],&li255[0],&li256[0],&li257[0],
&li258[0],&li259[0],&li260[0],&li261[0],&li262[0],&li263[0],
&li264[0],&li265[0],&li266[0],&li267[0],&li268[0],&li269[0],
&li270[0],&li271[0],&li272[0],&li273[0],&li274[0],&li275[0],
&li276[0],&li277[0],&li278[0],&li279[0],&li280[0],&li281[0],
&li282[0],&li283[0],&li284[0],&li285[0],&li286[0],&li287[0],
&li288[0],&li289[0],&li290[0],&li291[0],&li292[0],&li293[0],
&li294[0],&li295[0],&li296[0],&li297[0],&li298[0],&li299[0],
&li300[0],&li301[0],&li302[0],&li303[0],&li304[0],&li305[0],
&li306[0],&li307[0],&li308[0],&li309[0],&li310[0],&li311[0],
&li312[0],&li313[0],&li314[0],&li315[0],&li316[0],&li317[0],
&li318[0],&li319[0],&li320[0],&li321[0],&li322[0],&li323[0],
&li324[0],&li325[0],&li326[0],&li327[0],&li328[0],&li329[0],
&li330[0],&li331[0],&li332[0],&li333[0],&li334[0],&li335[0],
&li336[0],&li337[0],&li338[0],&li339[0],&li340[0],&li341[0],
&li342[0],&li343[0],&li344[0],&li345[0],&li346[0],&li347[0],
&li348[0],&li349[0],&li350[0],&li351[0],&li352[0],&li353[0],
&li354[0],&li355[0],&li356[0],&li357[0],&li358[0],&li359[0],
&li360[0],&li361[0],&li362[0],&li363[0],&li364[0],&li365[0],
&li366[0],&li367[0],&li368[0],&li369[0],&li370[0],&li371[0],
&li372[0],&li373[0],&li374[0],&li375[0],&li376[0],&li377[0],
&li378[0],&li379[0],&li380[0],&li381[0],&li382[0],&li383[0],
&li384[0],&li385[0],&li386[0],&li387[0],&li388[0],&li389[0],
&li390[0],&li391[0],&li392[0],&li393[0],&li394[0],&li395[0],
&li396[0],&li397[0],&li398[0],&li399[0],
};
/// Help class to create and register tests
class Create {
public:
/// Perform creation and registration
Create(void) {
int n = sizeof(li)/sizeof(LinInstr*);
for (int i=0; i<n; i++) {
std::string s = Test::str(i);
if (i < 10) {
s = "00" + s;
} else if (i < 100) {
s = "0" + s;
}
(void) new LinExpr(li[i],s);
}
FloatRelTypes frts;
for (int i=0; i<n/2; i++) {
std::string s = Test::str(i);
if (i < 10) {
s = "00" + s;
} else if (i < 100) {
s = "0" + s;
}
(void) new LinRel(li[2*i],li[2*i+1],frts.frt(),s);
++frts;
if (!frts())
frts.reset();
}
}
};
Create c;
//@}
}
}}
// STATISTICS: test-minimodel
| 70,564
| 41,876
|
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "src/runtime/kernel/arm/fp16/pad_fp16.h"
#include "src/runtime/kernel/arm/fp16/common_fp16.h"
#include "src/kernel_registry.h"
using mindspore::kernel::KERNEL_ARCH;
using mindspore::lite::KernelRegistrar;
using mindspore::lite::RET_ERROR;
using mindspore::lite::RET_OK;
using mindspore::schema::PrimitiveType_PadFusion;
namespace mindspore::kernel {
namespace {
constexpr size_t kPadCommonInputSize = 2;
} // namespace
int PadFp16CPUKernel::RunImpl(int task_id) {
PadFp16(input_, output_, in_, out_, pad_param_->paddings_, task_id, op_parameter_->thread_num_);
return RET_OK;
}
int PadFp16CPUKernel::RunMirrorPadImpl(int task_id) {
auto input = in_tensors_.at(0);
CHECK_NULL_RETURN(input);
auto output = out_tensors_.at(0);
CHECK_NULL_RETURN(output);
auto input_data = reinterpret_cast<float16_t *>(input->data());
CHECK_NULL_RETURN(input_data);
auto output_data = reinterpret_cast<float16_t *>(output->data());
CHECK_NULL_RETURN(output_data);
/* Fast Mirror pad */
if (mirror_pad_block_.size() != 0) {
/* copy center part */
PadFp16(input_data, output_data, in_, out_, pad_param_->paddings_, task_id, op_parameter_->thread_num_);
/* calculate region part */
for (size_t i = task_id; i < mirror_pad_block_.size(); i += op_parameter_->thread_num_) {
auto block = mirror_pad_block_[i];
for (int a = 0; a < block.size_[0]; a++) {
int out_a_index = block.out_offset_ + a * block.out_stride_[0];
for (int b = 0; b < block.size_[1]; b++) {
int out_b_index = out_a_index + b * block.out_stride_[1];
for (int c = 0; c < block.size_[2]; ++c) {
int out_c_index = out_b_index + c * block.out_stride_[2];
for (int d = 0; d < block.size_[3]; ++d) {
int out_d_index = out_c_index + d * block.out_stride_[3];
for (int e = 0; e < block.size_[4]; ++e) {
int output_index = out_d_index + e * block.out_stride_[4];
MirrorPadFp16(input_data, output_data, in_, pad_param_, output_index, output_index + block.size_[5]);
}
}
}
}
}
}
return RET_OK;
}
MS_CHECK_FALSE(op_parameter_->thread_num_ == 0, RET_ERROR);
int unit = UP_DIV(out_tensors_.at(0)->ElementsNum(), op_parameter_->thread_num_);
int begin = unit * task_id;
int end = MSMIN(begin + unit, out_tensors_.at(0)->ElementsNum());
MirrorPadFp16(input_, output_, in_, pad_param_, begin, end);
return RET_OK;
}
int PadFp16CPUKernel::Run() {
if (in_tensors_.size() == kInputSize2) {
auto pad_value = in_tensors_.at(2);
auto value_num = pad_value->ElementsNum();
if (value_num != 1) {
MS_LOG(ERROR) << "The number of padding value should be only one, but got " << value_num;
return RET_ERROR;
}
CHECK_NULL_RETURN(pad_value->data());
pad_param_->constant_value_ = *(reinterpret_cast<float16_t *>(pad_value->data()));
}
auto input_tensor = in_tensors_.at(0);
auto output_tensor = out_tensors_.at(0);
input_ = reinterpret_cast<float16_t *>(input_tensor->data());
output_ = reinterpret_cast<float16_t *>(output_tensor->data());
CHECK_NULL_RETURN(input_);
CHECK_NULL_RETURN(output_);
int ret = 0;
if (pad_param_->pad_mode_ == static_cast<int>(schema::PaddingMode_CONSTANT)) {
if (in_tensors_.size() >= kPadCommonInputSize) {
ret = CopyPaddingFromInput();
if (ret != RET_OK) {
MS_LOG(ERROR) << "PadFp16CPUKernel CopyPaddingFromInput failed";
return RET_ERROR;
}
}
if (pad_param_->constant_value_ - 0.0f < 1e-5) {
memset(output_, 0, output_tensor->ElementsNum() * sizeof(float16_t));
} else {
for (int i = 0; i < output_tensor->ElementsNum(); ++i) {
output_[i] = pad_param_->constant_value_;
}
}
ret = ParallelLaunch(this->ms_context_, PadImpl, this, op_parameter_->thread_num_);
if (ret != RET_OK) {
MS_LOG(ERROR) << "BatchnormRun error error_code[" << ret << "]";
}
} else {
// mirror pad case
ret = HandleMirrorPad();
if (ret != RET_OK) {
MS_LOG(ERROR) << "Handle mirror pad failed, error_code[" << ret << "]";
return ret;
}
ret = ParallelLaunch(this->ms_context_, MirrorPadImpl, this, op_parameter_->thread_num_);
if (ret != RET_OK) {
MS_LOG(ERROR) << "Pad Reflect or Symmetric mode run error, error_code[" << ret << "]";
}
}
return ret;
}
REG_KERNEL(kCPU, kNumberTypeFloat16, PrimitiveType_PadFusion, LiteKernelCreator<PadFp16CPUKernel>)
} // namespace mindspore::kernel
| 5,179
| 1,917
|
#include <blah/images/image.h>
#include <blah/streams/stream.h>
#include <blah/streams/filestream.h>
#include <blah/core/log.h>
using namespace Blah;
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_JPEG
#define STBI_ONLY_PNG
#define STBI_ONLY_BMP
#include "../third_party/stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "../third_party/stb_image_write.h"
namespace
{
int Blah_STBI_Read(void* user, char* data, int size)
{
int64_t read = ((Stream*)user)->read(data, size);
return (int)read;
}
void Blah_STBI_Skip(void* user, int n)
{
((Stream*)user)->seek(((Stream*)user)->position() + n);
}
int Blah_STBI_Eof(void* user)
{
int64_t position = ((Stream*)user)->position();
int64_t length = ((Stream*)user)->length();
if (position >= length)
return 1;
return 0;
}
void Blah_STBI_Write(void* context, void* data, int size)
{
((Stream*)context)->write((char*)data, size);
}
}
Image::Image()
{
width = height = 0;
pixels = nullptr;
m_stbi_ownership = false;
}
Image::Image(Stream& stream)
{
width = height = 0;
pixels = nullptr;
m_stbi_ownership = false;
from_stream(stream);
}
Image::Image(const char* file)
{
width = height = 0;
pixels = nullptr;
m_stbi_ownership = false;
FileStream fs(file, FileMode::Read);
if (fs.is_readable())
from_stream(fs);
}
Image::Image(int w, int h)
{
BLAH_ASSERT(w >= 0 && h >= 0, "Image width and height must be larger than 0");
width = w;
height = h;
pixels = new Color[width * height];
m_stbi_ownership = false;
memset(pixels, 0, (size_t)width * (size_t)height * sizeof(Color));
}
Image::Image(const Image& src)
{
width = src.width;
height = src.height;
m_stbi_ownership = src.m_stbi_ownership;
pixels = nullptr;
if (src.pixels != nullptr && width > 0 && height > 0)
{
pixels = new Color[width * height];
memcpy(pixels, src.pixels, sizeof(Color) * width * height);
}
}
Image& Image::operator=(const Image& src)
{
width = src.width;
height = src.height;
m_stbi_ownership = src.m_stbi_ownership;
pixels = nullptr;
if (src.pixels != nullptr && width > 0 && height > 0)
{
pixels = new Color[width * height];
memcpy(pixels, src.pixels, sizeof(Color) * width * height);
}
return *this;
}
Image::Image(Image&& src) noexcept
{
width = src.width;
height = src.height;
pixels = src.pixels;
m_stbi_ownership = src.m_stbi_ownership;
src.width = src.height = 0;
src.pixels = nullptr;
src.m_stbi_ownership = false;
}
Image& Image::operator=(Image&& src) noexcept
{
width = src.width;
height = src.height;
pixels = src.pixels;
m_stbi_ownership = src.m_stbi_ownership;
src.width = src.height = 0;
src.pixels = nullptr;
src.m_stbi_ownership = false;
return *this;
}
Image::~Image()
{
dispose();
}
void Image::from_stream(Stream& stream)
{
dispose();
if (!stream.is_readable())
{
BLAH_ERROR("Unable to load image as the Stream was not readable");
return;
}
stbi_io_callbacks callbacks;
callbacks.eof = Blah_STBI_Eof;
callbacks.read = Blah_STBI_Read;
callbacks.skip = Blah_STBI_Skip;
int x, y, comps;
uint8_t* data = stbi_load_from_callbacks(&callbacks, &stream, &x, &y, &comps, 4);
if (data == nullptr)
{
BLAH_ERROR("Unable to load image as the Stream's data was not a valid image");
return;
}
m_stbi_ownership = true;
pixels = (Color*)data;
width = x;
height = y;
}
void Image::dispose()
{
if (m_stbi_ownership)
stbi_image_free(pixels);
else
delete[] pixels;
pixels = nullptr;
width = height = 0;
m_stbi_ownership = false;
}
void Image::premultiply()
{
if (pixels != nullptr)
{
for (int n = 0; n < width * height; n ++)
{
pixels[n].r = (uint8_t)(pixels[n].r * pixels[n].a / 255);
pixels[n].g = (uint8_t)(pixels[n].g * pixels[n].a / 255);
pixels[n].b = (uint8_t)(pixels[n].b * pixels[n].a / 255);
}
}
}
void Image::set_pixels(const RectI& rect, Color* data)
{
for (int y = 0; y < rect.h; y++)
{
int to = rect.x + ((rect.y + y) * width);
int from = (y * rect.w);
memcpy(pixels + to, data + from, sizeof(Color) * rect.w);
}
}
bool Image::save_png(const char* file) const
{
FileStream fs(file, FileMode::Write);
return save_png(fs);
}
bool Image::save_png(Stream& stream) const
{
BLAH_ASSERT(pixels != nullptr, "Image Pixel data cannot be null");
BLAH_ASSERT(width > 0 && height > 0, "Image Width and Height must be larger than 0");
if (stream.is_writable())
{
stbi_write_force_png_filter = 0;
stbi_write_png_compression_level = 0;
if (stbi_write_png_to_func(Blah_STBI_Write, &stream, width, height, 4, pixels, width * 4) != 0)
return true;
else
Log::error("stbi_write_png_to_func failed");
}
else
{
Log::error("Cannot save Image, the Stream is not writable");
}
return false;
}
bool Image::save_jpg(const char* file, int quality) const
{
FileStream fs(file, FileMode::Write);
return save_jpg(fs, quality);
}
bool Image::save_jpg(Stream& stream, int quality) const
{
BLAH_ASSERT(pixels != nullptr, "Image Pixel data cannot be null");
BLAH_ASSERT(width > 0 && height > 0, "Image Width and Height must be larger than 0");
if (quality < 1)
{
Log::warn("jpg quality value should be between 1 and 100; input was %i", quality);
quality = 1;
}
else if (quality > 100)
{
Log::warn("jpg quality value should be between 1 and 100; input was %i", quality);
quality = 100;
}
if (stream.is_writable())
{
if (stbi_write_jpg_to_func(Blah_STBI_Write, &stream, width, height, 4, pixels, quality) != 0)
return true;
else
Log::error("stbi_write_jpg_to_func failed");
}
else
{
Log::error("Cannot save Image, the Stream is not writable");
}
return false;
}
void Image::get_pixels(Color* dest, const Point& destPos, const Point& destSize, RectI sourceRect)
{
// can't be outside of the source image
if (sourceRect.x < 0) sourceRect.x = 0;
if (sourceRect.y < 0) sourceRect.y = 0;
if (sourceRect.x + sourceRect.w > width) sourceRect.w = width - sourceRect.x;
if (sourceRect.y + sourceRect.h > height) sourceRect.h = height - sourceRect.y;
// can't be larger than our destination
if (sourceRect.w > destSize.x - destPos.x)
sourceRect.w = destSize.x - destPos.x;
if (sourceRect.h > destSize.y - destPos.y)
sourceRect.h = destSize.y - destPos.y;
for (int y = 0; y < sourceRect.h; y++)
{
int to = destPos.x + (destPos.y + y) * destSize.x;
int from = sourceRect.x + (sourceRect.y + y) * width;
memcpy(dest + to, pixels + from, sizeof(Color) * (int)sourceRect.w);
}
}
Image Image::get_sub_image(const RectI& sourceRect)
{
Image img(sourceRect.w, sourceRect.h);
get_pixels(img.pixels, Point::zero, Point(img.width, img.height), sourceRect);
return img;
}
| 6,635
| 2,831
|
/*
*
* TezosLikeTransactionDatabaseHelper
*
* Created by El Khalil Bellakrid on 27/04/2019.
*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ledger
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#include <tezos/database/TezosLikeTransactionDatabaseHelper.hpp>
#include <tezos/api/enum_from_string.hpp>
#include <tezos/api/TezosOperationTag.hpp>
#include <core/crypto/SHA256.hpp>
#include <core/database/SociOption.hpp>
#include <core/database/SociDate.hpp>
#include <core/database/SociNumber.hpp>
#include <core/utils/Option.hpp>
#include <core/wallet/BlockDatabaseHelper.hpp>
using namespace soci;
namespace ledger {
namespace core {
bool TezosLikeTransactionDatabaseHelper::getTransactionByHash(
soci::session &sql,
const std::string &hash,
const std::string &operationUid,
TezosLikeBlockchainExplorerTransaction &tx
) {
rowset<row> rows = (sql.prepare << "SELECT tx.hash, tx.value, tx.time, "
" tx.sender, tx.receiver, tx.fees, tx.gas_limit, tx.storage_limit, tx.confirmations, tx.type, tx.public_key, tx.originated_account, tx.status, "
"block.height, block.hash, block.time, block.currency_name "
"FROM tezos_transactions AS tx "
"LEFT JOIN blocks AS block ON tx.block_uid = block.uid "
"LEFT JOIN tezos_operations AS xtz_ops ON xtz_ops.transaction_uid = tx.transaction_uid "
"WHERE tx.hash = :hash AND xtz_ops.uid = :uid", use(hash), use(operationUid));
for (auto &row : rows) {
inflateTransaction(sql, row, tx);
return true;
}
return false;
}
bool TezosLikeTransactionDatabaseHelper::inflateTransaction(soci::session &sql,
const soci::row &row,
TezosLikeBlockchainExplorerTransaction &tx) {
tx.hash = row.get<std::string>(0);
tx.value = BigInt::fromHex(row.get<std::string>(1));
tx.receivedAt = row.get<std::chrono::system_clock::time_point>(2);
tx.sender = row.get<std::string>(3);
tx.receiver = row.get<std::string>(4);
tx.fees = BigInt::fromHex(row.get<std::string>(5));
tx.gas_limit = BigInt::fromHex(row.get<std::string>(6));
tx.storage_limit = BigInt::fromHex(row.get<std::string>(7));
tx.confirmations = get_number<uint64_t>(row, 8);
tx.type = api::from_string<api::TezosOperationTag>(row.get<std::string>(9));
auto pubKey = row.get<std::string>(10);
if (!pubKey.empty()) {
tx.publicKey = pubKey;
}
auto values = strings::split(row.get<std::string>(11), ":");
if (values.size() == 3) {
tx.originatedAccount = TezosLikeBlockchainExplorerOriginatedAccount(values[0], static_cast<bool>(std::stoi(values[1])), static_cast<bool>(std::stoi(values[2])));
}
tx.status = get_number<uint64_t>(row, 12);
if (row.get_indicator(13) != i_null) {
TezosLikeBlockchainExplorer::Block block;
block.height = get_number<uint64_t>(row, 13);
block.blockHash = row.get<std::string>(14);
block.time = row.get<std::chrono::system_clock::time_point>(15);
block.currencyName = row.get<std::string>(16);
tx.block = block;
}
return true;
}
bool TezosLikeTransactionDatabaseHelper::transactionExists(soci::session &sql,
const std::string &tezosTxUid) {
int32_t count = 0;
sql << "SELECT COUNT(*) FROM tezos_transactions WHERE transaction_uid = :tezosTxUid", use(tezosTxUid), into(
count);
return count == 1;
}
std::string TezosLikeTransactionDatabaseHelper::createTezosTransactionUid(const std::string &accountUid,
const std::string &txHash,
api::TezosOperationTag type) {
auto result = SHA256::stringToHexHash(fmt::format("uid:{}+{}+{}", accountUid, txHash, api::to_string(type)));
return result;
}
std::string TezosLikeTransactionDatabaseHelper::putTransaction(soci::session &sql,
const std::string &accountUid,
const TezosLikeBlockchainExplorerTransaction &tx) {
auto blockUid = tx.block.map<std::string>([](const TezosLikeBlockchainExplorer::Block &block) {
return BlockDatabaseHelper::createBlockUid(block.blockHash, block.currencyName);
});
auto tezosTxUid = createTezosTransactionUid(accountUid, tx.hash, tx.type);
if (transactionExists(sql, tezosTxUid)) {
// UPDATE (we only update block information)
if (tx.block.nonEmpty()) {
auto type = api::to_string(tx.type);
use(blockUid), use(tx.status), use(tx.hash);
sql << "UPDATE tezos_transactions SET block_uid = :uid, status = :code WHERE hash = :tx_hash AND type = :type",
use(blockUid), use(tx.status), use(tx.hash), use(type);
}
return tezosTxUid;
} else {
// Insert
if (tx.block.nonEmpty()) {
BlockDatabaseHelper::putBlock(sql, tx.block.getValue());
}
auto hexValue = tx.value.toHexString();
auto hexFees = tx.fees.toHexString();
auto hexGasLimit = tx.gas_limit.toHexString();
auto hexStorageLimit = tx.storage_limit.toHexString();
auto type = api::to_string(tx.type);
auto pubKey = tx.publicKey.getValueOr("");
std::string sOrigAccount;
if (tx.originatedAccount.hasValue()) {
std::stringstream origAccount;
std::vector<std::string> vOrigAccount{tx.originatedAccount.getValue().address, std::to_string(tx.originatedAccount.getValue().spendable), std::to_string(tx.originatedAccount.getValue().delegatable)};
strings::join(vOrigAccount, origAccount, ":");
sOrigAccount = origAccount.str();
}
sql << "INSERT INTO tezos_transactions VALUES(:tx_uid, :hash, :value, :block_uid, :time, :sender, :receiver, :fees, :gas_limit, :storage_limit, :confirmations, :type, :public_key, :originated_account, :status)",
use(tezosTxUid),
use(tx.hash),
use(hexValue),
use(blockUid),
use(tx.receivedAt),
use(tx.sender),
use(tx.receiver),
use(hexFees),
use(hexGasLimit),
use(hexStorageLimit),
use(tx.confirmations),
use(type),
use(pubKey),
use(sOrigAccount),
use(tx.status);
return tezosTxUid;
}
}
}
}
| 8,705
| 2,471
|
#include "playscene.h"
#include <QDebug>
#include <QMenuBar>
#include <QTimer>
#include "mypushbutton.h"
#include <QPainter>
#include <QLabel>
#include <QFont>
#include <QString>
#include "chess.h"
#include "computer.h"
#include <QPair>
#include <QSound>
void PlayScene::setChess(int x, int y, QString statue)
{
if(statue != black && statue != white)
statue = black;
if(x < 0 || x > 7)
x = 0;
if(y < 0 || y > 7)
y = 0;
Chess * chess = new Chess(statue);
chess->setParent(this);
map[x][y] = chess;
chess->move(310 + x*100, 60 + y*100);
chess->show();
//qDebug() << "下棋" << chess->x() << chess->y();
}
void PlayScene::setSelectBtn(int x, int y)
{
if(x < 0 || x > 7)
x = 0;
if(y < 0 || y > 7)
y = 0;
MyPushButton * selectBtn = new MyPushButton(":/res/chessToPlace.png");
selectBtn->setParent(this);
selectBtn->move(310 + x*100, 60 + y*100);
selectBtn->show();
connect(selectBtn, &MyPushButton::clicked, [=](){
emit this->selected(x, y);
});
//清除selectBtn
connect(this, &PlayScene::selected, selectBtn, [=](){
delete selectBtn;
});
}
void PlayScene::reverse(int x, int y, QString statue)
{
bool isValid;
int statueIndex, opposite;
int cx, cy;
if(statue == white)
{
opposite = 2;
statueIndex = 1;
}
else
{
opposite = 1;
statueIndex = 2;
}
if(x > 1)
{
isValid = false;
for(int i = x - 2; i >= 0; i--)
{
if(sta[i][y] == opposite)
{
isValid = true;
break;
}
else if(sta[i][y] == 0)
break;
else
continue;
}
if(isValid)
{
for(int i = x - 1; i >= 0; i--)
{
if(sta[i][y] == statueIndex)
{
sta[i][y] = opposite;
map[i][y]->changeStatus();
}
else
{
break;
}
}
}
}
if(x < 6)
{
isValid = false;
for(int i = x + 2; i <= 7; i++)
{
if(sta[i][y] == opposite)
{
isValid = true;
break;
}
else if(sta[i][y] == 0)
break;
else
continue;
}
if(isValid)
{
for(int i = x + 1; i <= 7; i++)
{
if(sta[i][y] == statueIndex)
{
sta[i][y] = opposite;
map[i][y]->changeStatus();
}
else
{
break;
}
}
}
}
if(y > 1)
{
isValid = false;
for(int i = y - 2; i >= 0; i--)
{
if(sta[x][i] == opposite)
{
isValid = true;
break;
}
else if(sta[x][i] == 0)
break;
else
continue;
}
if(isValid)
{
for(int i = y - 1; i >= 0; i--)
{
if(sta[x][i] == statueIndex)
{
sta[x][i] = opposite;
map[x][i]->changeStatus();
}
else
{
break;
}
}
}
}
if(y < 6)
{
isValid = false;
for(int i = y + 2; i <= 7; i++)
{
if(sta[x][i] == opposite)
{
isValid = true;
break;
}
else if(sta[x][i] == 0)
break;
else
continue;
}
if(isValid)
{
for(int i = y + 1; i <= 7; i++)
{
if(sta[x][i] == statueIndex)
{
sta[x][i] = opposite;
map[x][i]->changeStatus();
}
else
{
break;
}
}
}
}
if(x > 1 && y > 1)
{
isValid = false;
cx = x - 2;
cy = y - 2;
while(cx >= 0 && cy >= 0)
{
if(sta[cx][cy] == opposite)
{
isValid = true;
break;
}
else if(sta[cx][cy] == 0)
break;
else
{}
cx--;
cy--;
}
if(isValid)
{
cx = x - 1;
cy = y - 1;
while(cx >= 0 && cy >= 0)
{
if(sta[cx][cy] == statueIndex)
{
sta[cx][cy] = opposite;
map[cx][cy]->changeStatus();
}
else
{
break;
}
cx--;
cy--;
}
}
}
if(x < 6 && y > 1)
{
isValid = false;
cx = x + 2;
cy = y - 2;
while(cx <= 7 && cy >= 0)
{
if(sta[cx][cy] == opposite)
{
isValid = true;
break;
}
else if(sta[cx][cy] == 0)
break;
else
{}
cx++;
cy--;
}
if(isValid)
{
cx = x + 1;
cy = y - 1;
while(cx <= 7 && cy >= 0)
{
if(sta[cx][cy] == statueIndex)
{
sta[cx][cy] = opposite;
map[cx][cy]->changeStatus();
}
else
{
break;
}
cx++;
cy--;
}
}
}
if(x > 1 && y < 6)
{
isValid = false;
cx = x - 2;
cy = y + 2;
while(cx >= 0 && cy <= 7)
{
if(sta[cx][cy] == opposite)
{
isValid = true;
break;
}
else if(sta[cx][cy] == 0)
break;
else
{}
cx--;
cy++;
}
if(isValid)
{
cx = x - 1;
cy = y + 1;
while(cx >= 0 && cy <= 7)
{
if(sta[cx][cy] == statueIndex)
{
sta[cx][cy] = opposite;
map[cx][cy]->changeStatus();
}
else
{
break;
}
cx--;
cy++;
}
}
}
if(x < 6 && y < 6)
{
isValid = false;
cx = x + 2;
cy = y + 2;
while(cx <= 7 && cy <= 7)
{
if(sta[cx][cy] == opposite)
{
isValid = true;
break;
}
else if(sta[cx][cy] == 0)
break;
else
{}
cx++;
cy++;
}
if(isValid)
{
cx = x + 1;
cy = y + 1;
while(cx <= 7 && cy <= 7)
{
if(sta[cx][cy] == statueIndex)
{
sta[cx][cy] = opposite;
map[cx][cy]->changeStatus();
}
else
{
break;
}
cx++;
cy++;
}
}
}
}
bool PlayScene::canChoose(int x, int y, QString statue)
{
bool isValid = false;
int statueIndex, opposite;
int cx, cy;
if(statue == white)
{
statueIndex = 1;
opposite = 2;
}
else
{
statueIndex = 2;
opposite = 1;
}
if(x > 1 && sta[x - 1][y] == statueIndex)
{
for(int i = x - 2; i >= 0; i--)
{
if(sta[i][y] == opposite)
{
isValid = true;
break;
}
else if(sta[i][y] == 0)
break;
else
continue;
}
}
if(x < 6 && sta[x + 1][y] == statueIndex)
{
for(int i = x + 2; i <= 7; i++)
{
if(sta[i][y] == opposite)
{
isValid = true;
break;
}
else if(sta[i][y] == 0)
break;
else
continue;
}
}
if(y > 1 && sta[x][y - 1] == statueIndex)
{
for(int i = y - 2; i >= 0; i--)
{
if(sta[x][i] == opposite)
{
isValid = true;
break;
}
else if(sta[x][i] == 0)
break;
else
continue;
}
}
if(y < 6 && sta[x][y + 1] == statueIndex)
{
for(int i = y + 2; i <= 7; i++)
{
if(sta[x][i] == opposite)
{
isValid = true;
break;
}
else if(sta[x][i] == 0)
break;
else
continue;
}
}
if(x > 1 && y > 1 && sta[x - 1][y - 1] == statueIndex)
{
cx = x - 2;
cy = y - 2;
while(cx >= 0 && cy >= 0)
{
if(sta[cx][cy] == opposite)
{
isValid = true;
break;
}
else if(sta[cx][cy] == 0)
break;
else
{}
cx--;
cy--;
}
}
if(x < 6 && y > 1 && sta[x + 1][y - 1] == statueIndex)
{
cx = x + 2;
cy = y - 2;
while(cx <= 7 && cy >= 0)
{
if(sta[cx][cy] == opposite)
{
isValid = true;
break;
}
else if(sta[cx][cy] == 0)
break;
else
{}
cx++;
cy--;
}
}
if(x > 1 && y < 6 && sta[x - 1][y + 1] == statueIndex)
{
cx = x - 2;
cy = y + 2;
while(cx >= 0 && cy <= 7)
{
if(sta[cx][cy] == opposite)
{
isValid = true;
break;
}
else if(sta[cx][cy] == 0)
break;
else
{}
cx--;
cy++;
}
}
if(x < 6 && y < 6 && sta[x + 1][y + 1] == statueIndex)
{
cx = x + 2;
cy = y + 2;
while(cx <= 7 && cy <= 7)
{
if(sta[cx][cy] == opposite)
{
isValid = true;
break;
}
else if(sta[cx][cy] == 0)
break;
else
{}
cx++;
cy++;
}
}
return isValid;
}
bool PlayScene::choice(QString statue)//设选择点并统计得分
{
bool isChoosed = false;
scoreBlack = 0;
scoreWhite = 0;
for(int i = 0; i < 8; i++)
{
for(int j = 0; j < 8; j++)
{
if(sta[i][j] == 0)
{
if(canChoose(i, j, statue))
{
this->setSelectBtn(i, j);
isChoosed = true;
}
}
else if(sta[i][j] == 1)
{
scoreWhite++;
}
else
{
scoreBlack++;
}
//qDebug() << i << j << sta[i][j];
}
}
this->blackLabel->setText(QString::number(scoreBlack));
this->whiteLabel->setText(QString::number(scoreWhite));
return isChoosed;
}
PlayScene::PlayScene(QString mod)
{
this->modIndex = mod;
//qDebug() << mod;
this->setFixedSize(1200, 900);
this->setWindowIcon(QPixmap(":/res/icon.png"));
if(mod == "onePlayerMod")
this->setWindowTitle("人机对战");
else
this->setWindowTitle("双人对战");
QMenuBar * bar = menuBar();
setMenuBar(bar);
QMenu * startMenu = bar->addMenu("开始");
QAction * returnAction = startMenu->addAction("返回");
QAction * quitAction = startMenu->addAction("退出");
//结束音效
QSound * endSound = new QSound(":/res/end.wav", this);
//返回键与落子音效
QSound * clickSound = new QSound(":/res/click.wav", this);
//返回键
MyPushButton * returnBtn = new MyPushButton(":/res/return.png", ":/res/returnPress.png");
returnBtn->setParent(this);
returnBtn->move(30, this->height() - returnBtn->height() - 30);
//选择"退出"
connect(quitAction, &QAction::triggered, [=](){
this->close();
});
//选择"返回"
connect(returnAction, &QAction::triggered, [=](){
emit this->chooseSceneBack();
});
//选择返回键
connect(returnBtn, &MyPushButton::clicked, [=](){
clickSound->play();
QTimer::singleShot(200, this,[=](){
emit this->chooseSceneBack();
});
});
//模式标签
QLabel * modLabel = new QLabel;
modLabel->setParent(this);
modLabel->setFixedSize(400, 150);
QFont font;
font.setPointSize(28);
font.setBold(true);
font.setFamily("方正字迹-仿颜简体");
modLabel->setFont(font);
modLabel->move(30, this->height() - modLabel->height() - 20 - returnBtn->height());
QString modStr = QString("模式:<br>%1").arg(this->windowTitle());
modLabel->setText(modStr);
//走棋标签
QLabel * moveLabel = new QLabel;
moveLabel->setParent(this);
moveLabel->setFixedSize(200, 150);
moveLabel->setFont(font);
moveLabel->move(30, 200);
QString moveStr = QString("走棋:<br>%1").arg(this->moveSide);
moveLabel->setText(moveStr);
//黑棋得分
blackLabel = new QLabel;
blackLabel->setParent(this);
blackLabel->setFixedSize(160, 120);
blackLabel->setFont(font);
blackLabel->move(160, 350);
blackLabel->setText(QString::number(scoreBlack));
//白棋得分
whiteLabel = new QLabel;
whiteLabel->setParent(this);
whiteLabel->setFixedSize(160,120);
whiteLabel->setFont(font);
whiteLabel->move(160, 500);
whiteLabel->setText(QString::number(scoreWhite));
//初始布局
this->setChess(3, 3, white);
this->setChess(4, 4, white);
this->setChess(3, 4, black);
this->setChess(4, 3, black);
this->setSelectBtn(3, 2);
this->setSelectBtn(2, 3);
this->setSelectBtn(4, 5);
this->setSelectBtn(5, 4);
for(int i = 0; i <= 63; i++)
sta[i%8][i/8] = 0;
sta[3][3] = 1;
sta[3][4] = 2;
sta[4][3] = 2;
sta[4][4] = 1;
//生成电脑
com = new Computer(this);
//落子
connect(this, &PlayScene::selected, [=](int x, int y){
bool haveChoice;
if(moveSide == blackZh)
{
moveSide = whiteZh;
this->setChess(x, y, black);
clickSound->play();
sta[x][y] = 2;
this->reverse(x, y, white);
if(mod == twoPlayerMod) //双人对战
{
haveChoice = this->choice(black);
//qDebug() << x << y << haveChoice;
if(!haveChoice)
{
moveSide = blackZh;
haveChoice = this->choice(white);
//qDebug() << x << y << haveChoice;
if(!haveChoice)
{
moveSide = "结束";
endSound->play();
}
}
}
else //人机对战
{
QPair<int, int> temp = this->com->placeChess(sta, white);
if(temp.first == -1)
{
moveSide = blackZh;
haveChoice = this->choice(white);
if(!haveChoice)
{
moveSide = "结束";
endSound->play();
}
}
else
{
moveSide = whiteZh;
QTimer::singleShot(1000, this,[=](){
emit this->selected(temp.first, temp.second);
});
}
}
}
else
{
moveSide = blackZh;
this->setChess(x, y, white);
clickSound->play();
sta[x][y] = 1;
this->reverse(x, y, black);
if(mod == twoPlayerMod) //双人对战
{
haveChoice = this->choice(white);
//qDebug() << x << y << haveChoice;
if(!haveChoice)
{
moveSide = whiteZh;
haveChoice = this->choice(black);
//qDebug() << x << y << haveChoice;
if(!haveChoice)
{
moveSide = "结束";
endSound->play();
}
}
}
else //人机对战
{
haveChoice = this->choice(white);
moveSide = blackZh;
if(!haveChoice)
{
moveSide = whiteZh;
QPair<int, int> temp = this->com->placeChess(sta, white);
if(temp.first == -1)
{
moveSide = "结束";
endSound->play();
}
else
{
QTimer::singleShot(1000, this,[=](){
emit this->selected(temp.first, temp.second);
});
}
}
}
}
QString moveStr = QString("走棋:<br>%1").arg(this->moveSide);
moveLabel->setText(moveStr);
});
//调试按钮
// MyPushButton * test = new MyPushButton(":/res/icon.png");
// test->setParent(this);
// connect(test, &MyPushButton::clicked, [=](){
// setChess(1, 1, black);
// });
}
void PlayScene::paintEvent(QPaintEvent *)
{
QPainter painter(this);
QPixmap pix;
pix.load(":/res/backgroundPlay.png");
painter.drawPixmap(0, 0, this->width(), this->height(), pix);
pix.load(":/res/title.png");
pix = pix.scaled(200, 120);
painter.drawPixmap(50, 50, pix);
pix.load(":/res/map.png");
painter.drawPixmap(300, 50, pix);//棋盘800x800
pix.load(":/res/chessBlack.png");
painter.drawPixmap(30, 350, pix);
pix.load(":/res/chessWhite.png");
painter.drawPixmap(30, 500, pix);
}
| 18,792
| 6,063
|
#pragma once
#include "ModelData.hpp"
class Light
{
private:
glm::vec3 pos = glm::vec3(0, 0, 0);
glm::vec3 color = glm::vec3(1, 1, 1);
bool isPointLight = true;
public:
Light(glm::vec3 pos, glm::vec3 color, bool isPointLight);
void Light::setPos(glm::vec3 pos2);
bool Light::getIsPointLight();
void Light::setIsPointLight(bool isPointLight);
void Light::setColor(glm::vec3 color);
glm::vec4 Light::getColor();
glm::vec4 Light::getPos();
};
| 457
| 192
|
// https://open.kattis.com/problems/alicedigital
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
vi a(n + 1, 0);
int p = 0;
int q = 0;
int M = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] < m) {
if (q) M = max(M, a[i - 1] - a[p]);
p = i;
q = 0;
} else if (a[i] == m) {
if (!q) q = i;
else {
M = max(M, a[i - 1] - a[p]);
p = q;
q = i;
}
}
a[i] += a[i - 1];
}
if (q) M = max(M, a[n] - a[p]);
cout << M << endl;
}
}
| 612
| 370
|
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
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 "thgraph.hpp"
#include "jptree.hpp"
#include "commonext.hpp"
#include "dasess.hpp"
#include "jhtree.hpp"
#include "thcodectx.hpp"
#include "thbuf.hpp"
#include "thormisc.hpp"
#include "thbufdef.hpp"
#include "thmem.hpp"
#include "rtlformat.hpp"
PointerArray createFuncs;
void registerCreateFunc(CreateFunc func)
{
createFuncs.append((void *)func);
}
///////////////////////////////////
//////
/////
class CThorGraphResult : implements IThorResult, implements IRowWriter, public CInterface
{
CActivityBase &activity;
rowcount_t rowStreamCount;
IOutputMetaData *meta;
Owned<IRowWriterMultiReader> rowBuffer;
IThorRowInterfaces *rowIf;
IEngineRowAllocator *allocator;
bool stopped, readers;
ThorGraphResultType resultType;
void init()
{
stopped = readers = false;
allocator = rowIf->queryRowAllocator();
meta = allocator->queryOutputMeta();
rowStreamCount = 0;
}
class CStreamWriter : implements IRowWriterMultiReader, public CSimpleInterface
{
CThorGraphResult &owner;
CThorExpandingRowArray rows;
public:
IMPLEMENT_IINTERFACE_USING(CSimpleInterface);
CStreamWriter(CThorGraphResult &_owner, EmptyRowSemantics emptyRowSemantics) : owner(_owner), rows(owner.activity, owner.rowIf, emptyRowSemantics)
{
}
//IRowWriterMultiReader
virtual void putRow(const void *row)
{
rows.append(row);
}
virtual void flush() { }
virtual IRowStream *getReader()
{
return rows.createRowStream(0, (rowidx_t)-1, false);
}
};
public:
IMPLEMENT_IINTERFACE;
CThorGraphResult(CActivityBase &_activity, IThorRowInterfaces *_rowIf, ThorGraphResultType _resultType, unsigned spillPriority) : activity(_activity), rowIf(_rowIf), resultType(_resultType)
{
init();
EmptyRowSemantics emptyRowSemantics;
if (isGrouped())
emptyRowSemantics = ers_eogonly;
else if (isSparse())
emptyRowSemantics = ers_allow;
else
emptyRowSemantics = ers_forbidden;
if (SPILL_PRIORITY_DISABLE == spillPriority)
rowBuffer.setown(new CStreamWriter(*this, emptyRowSemantics));
else
rowBuffer.setown(createOverflowableBuffer(activity, rowIf, emptyRowSemantics, true));
}
// IRowWriter
virtual void putRow(const void *row)
{
assertex(!readers);
++rowStreamCount;
rowBuffer->putRow(row);
}
virtual void flush() { }
virtual offset_t getPosition() { UNIMPLEMENTED; return 0; }
// IThorResult
virtual IRowWriter *getWriter()
{
return LINK(this);
}
virtual void setResultStream(IRowWriterMultiReader *stream, rowcount_t count)
{
assertex(!readers);
rowBuffer.setown(stream);
rowStreamCount = count;
}
virtual IRowStream *getRowStream()
{
readers = true;
return rowBuffer->getReader();
}
virtual IThorRowInterfaces *queryRowInterfaces() { return rowIf; }
virtual CActivityBase *queryActivity() { return &activity; }
virtual bool isDistributed() const { return resultType & thorgraphresult_distributed; }
virtual bool isSparse() const { return resultType & thorgraphresult_sparse; }
virtual bool isGrouped() const { return resultType & thorgraphresult_grouped; }
virtual void serialize(MemoryBuffer &mb)
{
Owned<IRowStream> stream = getRowStream();
bool grouped = meta->isGrouped();
if (grouped)
{
OwnedConstThorRow prev = stream->nextRow();
if (prev)
{
bool eog;
for (;;)
{
eog = false;
OwnedConstThorRow next = stream->nextRow();
if (!next)
eog = true;
size32_t sz = meta->getRecordSize(prev);
mb.append(sz, prev.get());
mb.append(eog);
if (!next)
{
next.setown(stream->nextRow());
if (!next)
break;
}
prev.set(next);
}
}
}
else
{
for (;;)
{
OwnedConstThorRow row = stream->nextRow();
if (!row)
break;
size32_t sz = meta->getRecordSize(row);
mb.append(sz, row.get());
}
}
}
virtual void getResult(size32_t &len, void * & data)
{
MemoryBuffer mb;
serialize(mb);
len = mb.length();
data = mb.detach();
}
virtual void getLinkedResult(unsigned &countResult, const byte * * & result) override
{
assertex(rowStreamCount==((unsigned)rowStreamCount)); // catch, just in case
Owned<IRowStream> stream = getRowStream();
countResult = 0;
OwnedConstThorRow _rowset = allocator->createRowset((unsigned)rowStreamCount);
const void **rowset = (const void **)_rowset.get();
while (countResult < rowStreamCount)
{
OwnedConstThorRow row = stream->nextRow();
rowset[countResult++] = row.getClear();
}
result = (const byte **)_rowset.getClear();
}
virtual const void * getLinkedRowResult()
{
assertex(rowStreamCount==1); // catch, just in case
Owned<IRowStream> stream = getRowStream();
return stream->nextRow();
}
};
/////
IThorResult *CThorGraphResults::createResult(CActivityBase &activity, unsigned id, IThorRowInterfaces *rowIf, ThorGraphResultType resultType, unsigned spillPriority)
{
Owned<IThorResult> result = ::createResult(activity, rowIf, resultType, spillPriority);
setResult(id, result);
return result;
}
/////
IThorResult *createResult(CActivityBase &activity, IThorRowInterfaces *rowIf, ThorGraphResultType resultType, unsigned spillPriority)
{
return new CThorGraphResult(activity, rowIf, resultType, spillPriority);
}
/////
class CThorBoundLoopGraph : implements IThorBoundLoopGraph, public CInterface
{
CGraphBase *graph;
activity_id activityId;
Linked<IOutputMetaData> resultMeta;
Owned<IOutputMetaData> counterMeta, loopAgainMeta;
Owned<IThorRowInterfaces> resultRowIf, countRowIf, loopAgainRowIf;
public:
IMPLEMENT_IINTERFACE;
CThorBoundLoopGraph(CGraphBase *_graph, IOutputMetaData * _resultMeta, unsigned _activityId) : graph(_graph), resultMeta(_resultMeta), activityId(_activityId)
{
counterMeta.setown(createFixedSizeMetaData(sizeof(thor_loop_counter_t)));
loopAgainMeta.setown(createFixedSizeMetaData(sizeof(bool)));
}
virtual void prepareCounterResult(CActivityBase &activity, IThorGraphResults *results, unsigned loopCounter, unsigned pos)
{
if (!countRowIf)
countRowIf.setown(activity.createRowInterfaces(counterMeta));
RtlDynamicRowBuilder counterRow(countRowIf->queryRowAllocator());
thor_loop_counter_t * res = (thor_loop_counter_t *)counterRow.ensureCapacity(sizeof(thor_loop_counter_t),NULL);
*res = loopCounter;
OwnedConstThorRow counterRowFinal = counterRow.finalizeRowClear(sizeof(thor_loop_counter_t));
IThorResult *counterResult = results->createResult(activity, pos, countRowIf, thorgraphresult_nul, SPILL_PRIORITY_DISABLE);
Owned<IRowWriter> counterResultWriter = counterResult->getWriter();
counterResultWriter->putRow(counterRowFinal.getClear());
graph->setLoopCounter(loopCounter);
}
virtual void prepareLoopAgainResult(CActivityBase &activity, IThorGraphResults *results, unsigned pos)
{
if (!loopAgainRowIf)
loopAgainRowIf.setown(activity.createRowInterfaces(loopAgainMeta));
activity.queryGraph().createResult(activity, pos, results, loopAgainRowIf, activity.queryGraph().isLocalChild() ? thorgraphresult_nul : thorgraphresult_distributed, SPILL_PRIORITY_DISABLE);
}
virtual void prepareLoopResults(CActivityBase &activity, IThorGraphResults *results)
{
if (!resultRowIf)
resultRowIf.setown(activity.createRowInterfaces(resultMeta));
ThorGraphResultType resultType = activity.queryGraph().isLocalChild() ? thorgraphresult_nul : thorgraphresult_distributed;
IThorResult *loopResult = activity.queryGraph().createResult(activity, 0, results, resultRowIf, resultType); // loop output
IThorResult *inputResult = activity.queryGraph().createResult(activity, 1, results, resultRowIf, resultType); // loop input
}
virtual CGraphBase *queryGraph() { return graph; }
};
IThorBoundLoopGraph *createBoundLoopGraph(CGraphBase *graph, IOutputMetaData *resultMeta, unsigned activityId)
{
return new CThorBoundLoopGraph(graph, resultMeta, activityId);
}
///////////////////////////////////
bool isDiskInput(ThorActivityKind kind)
{
switch (kind)
{
case TAKcsvread:
case TAKxmlread:
case TAKjsonread:
case TAKdiskread:
case TAKdisknormalize:
case TAKdiskaggregate:
case TAKdiskcount:
case TAKdiskgroupaggregate:
case TAKindexread:
case TAKindexcount:
case TAKindexnormalize:
case TAKindexaggregate:
case TAKindexgroupaggregate:
case TAKindexgroupexists:
case TAKindexgroupcount:
case TAKspillread:
return true;
default:
return false;
}
}
void CIOConnection::connect(unsigned which, CActivityBase *destActivity)
{
destActivity->setInput(which, activity->queryActivity(), index);
}
///////////////////////////////////
CGraphElementBase *createGraphElement(IPropertyTree &node, CGraphBase &owner, CGraphBase *resultsGraph)
{
CGraphElementBase *container = NULL;
ForEachItemIn(m, createFuncs)
{
CreateFunc func = (CreateFunc)createFuncs.item(m);
container = func(node, owner, resultsGraph);
if (container) break;
}
if (NULL == container)
{
ThorActivityKind tak = (ThorActivityKind)node.getPropInt("att[@name=\"_kind\"]/@value", TAKnone);
throw MakeStringException(TE_UnsupportedActivityKind, "Unsupported activity kind: %s", activityKindStr(tak));
}
container->setResultsGraph(resultsGraph);
return container;
}
CGraphElementBase::CGraphElementBase(CGraphBase &_owner, IPropertyTree &_xgmml) : owner(&_owner)
{
xgmml.setown(createPTreeFromIPT(&_xgmml));
eclText.set(xgmml->queryProp("att[@name=\"ecl\"]/@value"));
id = xgmml->getPropInt("@id", 0);
kind = (ThorActivityKind)xgmml->getPropInt("att[@name=\"_kind\"]/@value", TAKnone);
sink = isActivitySink(kind);
bool coLocal = xgmml->getPropBool("att[@name=\"coLocal\"]/@value", false);
isLocalData = xgmml->getPropBool("att[@name=\"local\"]/@value", false); // local execute + local data access only
isLocal = isLocalData || coLocal; // local execute
isGrouped = xgmml->getPropBool("att[@name=\"grouped\"]/@value", false);
resultsGraph = NULL;
ownerId = xgmml->getPropInt("att[@name=\"_parentActivity\"]/@value", 0);
onCreateCalled = prepared = haveCreateCtx = nullAct = false;
onlyUpdateIfChanged = xgmml->getPropBool("att[@name=\"_updateIfChanged\"]/@value", false);
StringBuffer helperName("fAc");
xgmml->getProp("@id", helperName);
helperFactory = (EclHelperFactory) queryJob().queryDllEntry().getEntry(helperName.str());
if (!helperFactory)
throw makeOsExceptionV(GetLastError(), "Failed to load helper factory method: %s (dll handle = %p)", helperName.str(), queryJob().queryDllEntry().getInstance());
alreadyUpdated = false;
whichBranch = (unsigned)-1;
log = true;
sentActInitData.setown(createThreadSafeBitSet());
maxCores = queryXGMML().getPropInt("hint[@name=\"max_cores\"]/@value", 0);
if (0 == maxCores)
maxCores = queryJob().queryMaxDefaultActivityCores();
baseHelper.setown(helperFactory());
}
CGraphElementBase::~CGraphElementBase()
{
activity.clear();
baseHelper.clear(); // clear before dll is unloaded
}
CJobBase &CGraphElementBase::queryJob() const
{
return owner->queryJob();
}
CJobChannel &CGraphElementBase::queryJobChannel() const
{
return owner->queryJobChannel();
}
IGraphTempHandler *CGraphElementBase::queryTempHandler() const
{
if (resultsGraph)
return resultsGraph->queryTempHandler();
else
return queryJob().queryTempHandler();
}
void CGraphElementBase::releaseIOs()
{
loopGraph.clear();
if (activity)
activity->releaseIOs();
connectedInputs.kill();
inputs.kill();
outputs.kill();
activity.clear();
}
void CGraphElementBase::addDependsOn(CGraphBase *graph, int controlId)
{
ForEachItemIn(i, dependsOn)
{
if (dependsOn.item(i).graph == graph)
return;
}
dependsOn.append(*new CGraphDependency(graph, controlId));
}
StringBuffer &CGraphElementBase::getOpt(const char *prop, StringBuffer &out) const
{
VStringBuffer path("hint[@name=\"%s\"]/@value", prop);
if (!queryXGMML().getProp(path.toLowerCase().str(), out))
queryJob().getOpt(prop, out);
return out;
}
bool CGraphElementBase::getOptBool(const char *prop, bool defVal) const
{
bool def = queryJob().getOptBool(prop, defVal);
VStringBuffer path("hint[@name=\"%s\"]/@value", prop);
return queryXGMML().getPropBool(path.toLowerCase().str(), def);
}
int CGraphElementBase::getOptInt(const char *prop, int defVal) const
{
int def = queryJob().getOptInt(prop, defVal);
VStringBuffer path("hint[@name=\"%s\"]/@value", prop);
return queryXGMML().getPropInt(path.toLowerCase().str(), def);
}
__int64 CGraphElementBase::getOptInt64(const char *prop, __int64 defVal) const
{
__int64 def = queryJob().getOptInt64(prop, defVal);
VStringBuffer path("hint[@name=\"%s\"]/@value", prop);
return queryXGMML().getPropInt64(path.toLowerCase().str(), def);
}
IThorGraphDependencyIterator *CGraphElementBase::getDependsIterator() const
{
return new ArrayIIteratorOf<const CGraphDependencyArray, CGraphDependency, IThorGraphDependencyIterator>(dependsOn);
}
void CGraphElementBase::reset()
{
alreadyUpdated = false;
if (activity)
activity->reset();
}
void CGraphElementBase::ActPrintLog(const char *format, ...)
{
va_list args;
va_start(args, format);
::ActPrintLogArgs(this, thorlog_null, MCdebugProgress, format, args);
va_end(args);
}
void CGraphElementBase::ActPrintLog(IException *e, const char *format, ...)
{
va_list args;
va_start(args, format);
::ActPrintLogArgs(this, e, thorlog_all, MCexception(e), format, args);
va_end(args);
}
void CGraphElementBase::ActPrintLog(IException *e)
{
ActPrintLog(e, "%s", "");
}
void CGraphElementBase::abort(IException *e)
{
CActivityBase *activity = queryActivity();
if (activity)
activity->abort();
}
void CGraphElementBase::doconnect()
{
ForEachItemIn(i, connectedInputs)
{
CIOConnection *io = connectedInputs.item(i);
if (io)
io->connect(i, queryActivity());
}
}
void CGraphElementBase::clearConnections()
{
connectedInputs.kill();
connectedOutputs.kill();
if (activity)
activity->clearConnections();
}
void CGraphElementBase::addInput(unsigned input, CGraphElementBase *inputAct, unsigned inputOutIdx)
{
while (inputs.ordinality()<=input) inputs.append(NULL);
inputs.replace(new COwningSimpleIOConnection(LINK(inputAct), inputOutIdx), input);
while (inputAct->outputs.ordinality()<=inputOutIdx) inputAct->outputs.append(NULL);
inputAct->outputs.replace(new CIOConnection(this, input), inputOutIdx);
}
void CGraphElementBase::connectInput(unsigned input, CGraphElementBase *inputAct, unsigned inputOutIdx)
{
ActPrintLog("CONNECTING (id=%" ACTPF "d, idx=%d) to (id=%" ACTPF "d, idx=%d)", inputAct->queryId(), inputOutIdx, queryId(), input);
while (connectedInputs.ordinality()<=input) connectedInputs.append(NULL);
connectedInputs.replace(new COwningSimpleIOConnection(LINK(inputAct), inputOutIdx), input);
while (inputAct->connectedOutputs.ordinality()<=inputOutIdx) inputAct->connectedOutputs.append(NULL);
inputAct->connectedOutputs.replace(new CIOConnection(this, input), inputOutIdx);
}
void CGraphElementBase::serializeCreateContext(MemoryBuffer &mb)
{
if (!onCreateCalled) return;
DelayedSizeMarker sizeMark(mb);
queryHelper()->serializeCreateContext(mb);
sizeMark.write();
if (isSink())
mb.append(alreadyUpdated);
}
void CGraphElementBase::deserializeCreateContext(MemoryBuffer &mb)
{
size32_t createCtxLen;
mb.read(createCtxLen);
createCtxMb.clear().append(createCtxLen, mb.readDirect(createCtxLen));
haveCreateCtx = true;
if (isSink())
mb.read(alreadyUpdated);
}
void CGraphElementBase::serializeStartContext(MemoryBuffer &mb)
{
DelayedSizeMarker sizeMark(mb);
queryHelper()->serializeStartContext(mb);
sizeMark.write();
}
void CGraphElementBase::onCreate()
{
CriticalBlock b(crit);
if (onCreateCalled)
return;
onCreateCalled = true;
if (!nullAct)
{
CGraphElementBase *ownerActivity = owner->queryOwner() ? owner->queryOwner()->queryElement(ownerId) : NULL;
if (ownerActivity)
{
ownerActivity->onCreate(); // ensure owner created, might not be if this is child query inside another child query.
baseHelper->onCreate(queryCodeContext(), ownerActivity->queryHelper(), haveCreateCtx?&createCtxMb:NULL);
}
else
baseHelper->onCreate(queryCodeContext(), NULL, haveCreateCtx?&createCtxMb:NULL);
if (isLoopActivity(*this))
{
unsigned loopId = queryXGMML().getPropInt("att[@name=\"_loopid\"]/@value");
Owned<CGraphStub> stub = owner->getChildGraph(loopId);
Owned<IThorBoundLoopGraph> boundLoopGraph = createBoundLoopGraph(&stub->queryOriginalGraph(), baseHelper->queryOutputMeta(), queryId());
setBoundGraph(boundLoopGraph);
}
}
}
void CGraphElementBase::onStart(size32_t parentExtractSz, const byte *parentExtract, MemoryBuffer *startCtx)
{
if (nullAct)
return;
CriticalBlock b(crit);
baseHelper->onStart(parentExtract, startCtx);
}
bool CGraphElementBase::executeDependencies(size32_t parentExtractSz, const byte *parentExtract, int controlId, bool async)
{
Owned<IThorGraphDependencyIterator> deps = getDependsIterator();
ForEach(*deps)
{
CGraphDependency &dep = deps->query();
if (dep.controlId == controlId)
dep.graph->execute(parentExtractSz, parentExtract, true, async);
if (owner->queryJob().queryAborted() || owner->queryAborted()) return false;
}
return true;
}
bool CGraphElementBase::prepareContext(size32_t parentExtractSz, const byte *parentExtract, bool checkDependencies, bool shortCircuit, bool async, bool connectOnly)
{
try
{
bool create = true;
if (connectOnly)
{
if (prepared)
return true;
ForEachItemIn(i, inputs)
{
if (!queryInput(i)->prepareContext(parentExtractSz, parentExtract, false, false, async, true))
return false;
}
}
else
{
bool _shortCircuit = shortCircuit;
Owned<IThorGraphDependencyIterator> deps = getDependsIterator();
bool depsDone = true;
ForEach(*deps)
{
CGraphDependency &dep = deps->query();
if (0 == dep.controlId && NotFound == owner->dependentSubGraphs.find(*dep.graph))
{
owner->dependentSubGraphs.append(*dep.graph);
if (!dep.graph->isComplete())
depsDone = false;
}
}
if (depsDone) _shortCircuit = false;
if (!depsDone && checkDependencies)
{
if (!executeDependencies(parentExtractSz, parentExtract, 0, async))
return false;
}
whichBranch = (unsigned)-1;
switch (getKind())
{
case TAKindexwrite:
case TAKdiskwrite:
case TAKcsvwrite:
case TAKxmlwrite:
case TAKjsonwrite:
case TAKspillwrite:
if (_shortCircuit) return true;
onCreate();
alreadyUpdated = checkUpdate();
if (alreadyUpdated)
return false;
break;
case TAKchildif:
case TAKif:
case TAKifaction:
{
if (_shortCircuit) return true;
onCreate();
onStart(parentExtractSz, parentExtract);
IHThorIfArg *helper = (IHThorIfArg *)baseHelper.get();
whichBranch = helper->getCondition() ? 0 : 1; // True argument precedes false...
/* NB - The executeDependencies code below is only needed if actionLinkInNewGraph=true, which is no longer the default
* It should be removed, once we are positive there are no issues with in-line conditional actions
*/
if (TAKifaction == getKind())
{
if (!executeDependencies(parentExtractSz, parentExtract, whichBranch+1, async)) //NB whenId 1 based
return false;
create = false;
}
break;
}
case TAKchildcase:
case TAKcase:
{
if (_shortCircuit) return true;
onCreate();
onStart(parentExtractSz, parentExtract);
IHThorCaseArg *helper = (IHThorCaseArg *)baseHelper.get();
whichBranch = helper->getBranch();
if (whichBranch >= inputs.ordinality())
whichBranch = inputs.ordinality()-1;
break;
}
case TAKfilter:
case TAKfiltergroup:
case TAKfilterproject:
{
if (_shortCircuit) return true;
onCreate();
onStart(parentExtractSz, parentExtract);
switch (getKind())
{
case TAKfilter:
whichBranch = ((IHThorFilterArg *)baseHelper.get())->canMatchAny() ? 0 : 1;
break;
case TAKfiltergroup:
whichBranch = ((IHThorFilterGroupArg *)baseHelper.get())->canMatchAny() ? 0 : 1;
break;
case TAKfilterproject:
whichBranch = ((IHThorFilterProjectArg *)baseHelper.get())->canMatchAny() ? 0 : 1;
break;
}
break;
}
case TAKsequential:
case TAKparallel:
{
/* NB - The executeDependencies code below is only needed if actionLinkInNewGraph=true, which is no longer the default
* It should be removed, once we are positive there are no issues with in-line sequential/parallel activities
*/
for (unsigned s=1; s<=dependsOn.ordinality(); s++)
executeDependencies(parentExtractSz, parentExtract, s, async);
create = false;
break;
}
case TAKwhen_dataset:
case TAKwhen_action:
{
if (!executeDependencies(parentExtractSz, parentExtract, WhenBeforeId, async))
return false;
if (!executeDependencies(parentExtractSz, parentExtract, WhenParallelId, async))
return false;
break;
}
}
if (checkDependencies && ((unsigned)-1 != whichBranch))
{
if (inputs.queryItem(whichBranch))
{
if (!queryInput(whichBranch)->prepareContext(parentExtractSz, parentExtract, true, false, async, connectOnly))
return false;
}
ForEachItemIn(i, inputs)
{
if (i != whichBranch)
{
if (!queryInput(i)->prepareContext(parentExtractSz, parentExtract, false, false, async, true))
return false;
}
}
}
else
{
ForEachItemIn(i, inputs)
{
if (!queryInput(i)->prepareContext(parentExtractSz, parentExtract, checkDependencies, false, async, connectOnly))
return false;
}
}
}
if (create)
{
if (prepared) // no need to recreate
return true;
prepared = true;
ForEachItemIn(i2, inputs)
{
CIOConnection *inputIO = inputs.item(i2);
connectInput(i2, inputIO->activity, inputIO->index);
}
createActivity();
}
return true;
}
catch (IException *_e)
{
IThorException *e = QUERYINTERFACE(_e, IThorException);
if (e)
{
if (!e->queryActivityId())
setExceptionActivityInfo(*this, e);
}
else
{
e = MakeActivityException(this, _e);
_e->Release();
}
throw e;
}
}
void CGraphElementBase::preStart(size32_t parentExtractSz, const byte *parentExtract)
{
activity->preStart(parentExtractSz, parentExtract);
}
void CGraphElementBase::createActivity()
{
CriticalBlock b(crit);
if (activity)
return;
activity.setown(factory());
if (isSink())
owner->addActiveSink(*this);
}
ICodeContext *CGraphElementBase::queryCodeContext()
{
return queryOwner().queryCodeContext();
}
/////
// JCSMORE loop - probably need better way to check if any act in graph is global(meaning needs some synchronization between slaves in activity execution)
bool isGlobalActivity(CGraphElementBase &container)
{
switch (container.getKind())
{
// always global, but only co-ordinate init/done
case TAKcsvwrite:
case TAKxmlwrite:
case TAKjsonwrite:
case TAKindexwrite:
case TAKkeydiff:
case TAKkeypatch:
case TAKdictionaryworkunitwrite:
return true;
case TAKdiskwrite:
{
Owned<IHThorDiskWriteArg> helper = (IHThorDiskWriteArg *)container.helperFactory();
unsigned flags = helper->getFlags();
return (0 == (TDXtemporary & flags)); // global if not temporary
}
case TAKspillwrite:
case TAKspill:
return false;
case TAKcsvread:
{
Owned<IHThorCsvReadArg> helper = (IHThorCsvReadArg *)container.helperFactory();
// if header lines, then [may] need to co-ordinate across slaves
if (container.queryOwner().queryOwner() && (!container.queryOwner().isGlobal())) // I am in a child query
return false;
return helper->queryCsvParameters()->queryHeaderLen() > 0;
}
// dependent on child acts?
case TAKlooprow:
case TAKloopcount:
case TAKgraphloop:
case TAKparallelgraphloop:
case TAKloopdataset:
case TAKexternalsink:
case TAKexternalsource:
case TAKexternalprocess:
return false;
// dependent on local/grouped
case TAKkeyeddistribute:
case TAKhashdistribute:
case TAKhashdistributemerge:
case TAKnwaydistribute:
case TAKworkunitwrite:
case TAKdistribution:
case TAKpartition:
case TAKdiskaggregate:
case TAKdiskcount:
case TAKdiskgroupaggregate:
case TAKindexaggregate:
case TAKindexcount:
case TAKindexgroupaggregate:
case TAKindexgroupexists:
case TAKindexgroupcount:
case TAKremoteresult:
case TAKcountproject:
case TAKcreaterowlimit:
case TAKskiplimit:
case TAKlimit:
case TAKsort:
case TAKdedup:
case TAKjoin:
case TAKselfjoin:
case TAKhashjoin:
case TAKsmartjoin:
case TAKkeyeddenormalize:
case TAKhashdenormalize:
case TAKdenormalize:
case TAKlookupdenormalize: //GH->JCS why are these here, and join not?
case TAKalldenormalize:
case TAKsmartdenormalize:
case TAKdenormalizegroup:
case TAKhashdenormalizegroup:
case TAKlookupdenormalizegroup:
case TAKkeyeddenormalizegroup:
case TAKalldenormalizegroup:
case TAKsmartdenormalizegroup:
case TAKaggregate:
case TAKexistsaggregate:
case TAKcountaggregate:
case TAKhashaggregate:
case TAKhashdedup:
case TAKrollup:
case TAKiterate:
case TAKselectn:
case TAKfirstn:
case TAKenth:
case TAKsample:
case TAKgroup:
case TAKchoosesets:
case TAKchoosesetsenth:
case TAKchoosesetslast:
case TAKtopn:
case TAKprocess:
case TAKchildcount:
case TAKwhen_dataset:
case TAKwhen_action:
case TAKnonempty:
if (!container.queryLocalOrGrouped())
return true;
break;
case TAKkeyedjoin:
case TAKalljoin:
case TAKlookupjoin:
if (!container.queryLocal())
return true;
// always local
case TAKfilter:
case TAKfilterproject:
case TAKfiltergroup:
case TAKsplit:
case TAKpipewrite:
case TAKdegroup:
case TAKproject:
case TAKprefetchproject:
case TAKprefetchcountproject:
case TAKnormalize:
case TAKnormalizechild:
case TAKnormalizelinkedchild:
case TAKpipethrough:
case TAKif:
case TAKchildif:
case TAKchildcase:
case TAKcase:
case TAKparse:
case TAKpiperead:
case TAKxmlparse:
case TAKjoinlight:
case TAKselfjoinlight:
case TAKdiskread:
case TAKdisknormalize:
case TAKchildaggregate:
case TAKchildgroupaggregate:
case TAKchildthroughnormalize:
case TAKchildnormalize:
case TAKspillread:
case TAKindexread:
case TAKindexnormalize:
case TAKxmlread:
case TAKjsonread:
case TAKdiskexists:
case TAKindexexists:
case TAKchildexists:
case TAKthroughaggregate:
case TAKmerge:
case TAKfunnel:
case TAKregroup:
case TAKcombine:
case TAKrollupgroup:
case TAKcombinegroup:
case TAKsoap_rowdataset:
case TAKhttp_rowdataset:
case TAKsoap_rowaction:
case TAKsoap_datasetdataset:
case TAKsoap_datasetaction:
case TAKlinkedrawiterator:
case TAKchilditerator:
case TAKstreamediterator:
case TAKworkunitread:
case TAKchilddataset:
case TAKinlinetable:
case TAKnull:
case TAKemptyaction:
case TAKlocalresultread:
case TAKlocalresultwrite:
case TAKdictionaryresultwrite:
case TAKgraphloopresultread:
case TAKgraphloopresultwrite:
case TAKnwaygraphloopresultread:
case TAKapply:
case TAKsideeffect:
case TAKsimpleaction:
case TAKsorted:
case TAKdistributed:
case TAKtrace:
break;
case TAKnwayjoin:
case TAKnwaymerge:
case TAKnwaymergejoin:
case TAKnwayinput:
case TAKnwayselect:
return false; // JCSMORE - I think and/or have to be for now
// undefined
case TAKdatasetresult:
case TAKrowresult:
case TAKremotegraph:
case TAKlibrarycall:
default:
return true; // if in doubt
}
return false;
}
bool isLoopActivity(CGraphElementBase &container)
{
switch (container.getKind())
{
case TAKlooprow:
case TAKloopcount:
case TAKloopdataset:
case TAKgraphloop:
case TAKparallelgraphloop:
return true;
}
return false;
}
static void getGlobalDeps(CGraphBase &graph, CICopyArrayOf<CGraphDependency> &deps)
{
Owned<IThorActivityIterator> iter = graph.getIterator();
ForEach(*iter)
{
CGraphElementBase &elem = iter->query();
Owned<IThorGraphDependencyIterator> dependIterator = elem.getDependsIterator();
ForEach(*dependIterator)
{
CGraphDependency &dependency = dependIterator->query();
if (dependency.graph->isGlobal() && NULL==dependency.graph->queryOwner())
deps.append(dependency);
getGlobalDeps(*dependency.graph, deps);
}
}
}
static void noteDependency(CGraphElementBase *targetActivity, CGraphElementBase *sourceActivity, CGraphBase *targetGraph, CGraphBase *sourceGraph, unsigned controlId)
{
targetActivity->addDependsOn(sourceGraph, controlId);
// NB: record dependency in source graph, serialized to slaves, used to decided if should run dependency sinks or not
Owned<IPropertyTree> dependencyFor = createPTree();
dependencyFor->setPropInt("@id", sourceActivity->queryId());
dependencyFor->setPropInt("@graphId", targetGraph->queryGraphId());
if (controlId)
dependencyFor->setPropInt("@conditionalId", controlId);
sourceGraph->queryXGMML().addPropTree("Dependency", dependencyFor.getClear());
}
static void addDependencies(IPropertyTree *xgmml, bool failIfMissing, CGraphTableCopy &graphs)
{
CGraphArrayCopy dependentchildGraphs;
CGraphElementArrayCopy targetActivities, sourceActivities;
Owned<IPropertyTreeIterator> iter = xgmml->getElements("edge");
ForEach(*iter)
{
IPropertyTree &edge = iter->query();
graph_id sourceGid = edge.getPropInt("@source");
graph_id targetGid = edge.getPropInt("@target");
Owned<CGraphBase> source = LINK(graphs.find(sourceGid));
Owned<CGraphBase> target = LINK(graphs.find(targetGid));
if (!source || !target)
{
if (failIfMissing)
throwUnexpected();
else
continue; // expected if assigning dependencies in slaves
}
CGraphElementBase *targetActivity = (CGraphElementBase *)target->queryElement(edge.getPropInt("att[@name=\"_targetActivity\"]/@value"));
CGraphElementBase *sourceActivity = (CGraphElementBase *)source->queryElement(edge.getPropInt("att[@name=\"_sourceActivity\"]/@value"));
if (!edge.getPropBool("att[@name=\"_childGraph\"]/@value"))
{
if (TAKlocalresultwrite == sourceActivity->getKind() && (TAKlocalresultread != targetActivity->getKind()))
{
if (source->isLoopSubGraph())
source->setGlobal(true);
}
}
int controlId = 0;
if (edge.getPropBool("att[@name=\"_dependsOn\"]/@value", false))
{
if (!edge.getPropBool("att[@name=\"_childGraph\"]/@value", false)) // JCSMORE - not sure if necess. roxie seem to do.
controlId = edge.getPropInt("att[@name=\"_when\"]/@value", 0);
CGraphBase &sourceGraph = sourceActivity->queryOwner();
unsigned sourceGraphContext = sourceGraph.queryParentActivityId();
CGraphBase *targetGraph = NULL;
unsigned targetGraphContext = -1;
for (;;)
{
targetGraph = &targetActivity->queryOwner();
targetGraphContext = targetGraph->queryParentActivityId();
if (sourceGraphContext == targetGraphContext)
break;
targetActivity = targetGraph->queryElement(targetGraphContext);
}
assertex(targetActivity && sourceActivity);
noteDependency(targetActivity, sourceActivity, target, source, controlId);
}
else if (edge.getPropBool("att[@name=\"_conditionSource\"]/@value", false))
{ /* Ignore it */ }
else if (edge.getPropBool("att[@name=\"_childGraph\"]/@value", false))
{
// NB: any dependencies of the child acts. are dependencies of this act.
dependentchildGraphs.append(*source);
targetActivities.append(*targetActivity);
sourceActivities.append(*sourceActivity);
}
else
{
if (!edge.getPropBool("att[@name=\"_childGraph\"]/@value", false)) // JCSMORE - not sure if necess. roxie seem to do.
controlId = edge.getPropInt("att[@name=\"_when\"]/@value", 0);
noteDependency(targetActivity, sourceActivity, target, source, controlId);
}
}
ForEachItemIn(c, dependentchildGraphs)
{
CGraphBase &childGraph = dependentchildGraphs.item(c);
CGraphElementBase &targetActivity = targetActivities.item(c);
CGraphElementBase &sourceActivity = sourceActivities.item(c);
if (!childGraph.isGlobal())
{
CICopyArrayOf<CGraphDependency> globalChildGraphDeps;
getGlobalDeps(childGraph, globalChildGraphDeps);
ForEachItemIn(gcd, globalChildGraphDeps)
{
CGraphDependency &globalDep = globalChildGraphDeps.item(gcd);
noteDependency(&targetActivity, &sourceActivity, globalDep.graph, &childGraph, globalDep.controlId);
}
}
}
SuperHashIteratorOf<CGraphBase> allIter(graphs);
ForEach(allIter)
{
CGraphBase &subGraph = allIter.query();
if (subGraph.queryOwner() && subGraph.queryParentActivityId())
{
CGraphElementBase *parentElement = subGraph.queryOwner()->queryElement(subGraph.queryParentActivityId());
if (isLoopActivity(*parentElement))
{
if (!parentElement->queryOwner().isLocalChild() && !subGraph.isLocalOnly())
subGraph.setGlobal(true);
}
}
}
}
void traceMemUsage()
{
StringBuffer memStatsStr;
roxiemem::memstats(memStatsStr);
PROGLOG("Roxiemem stats: %s", memStatsStr.str());
memsize_t heapUsage = getMapInfo("heap");
if (heapUsage) // if 0, assumed to be unavailable
{
memsize_t rmtotal = roxiemem::getTotalMemoryLimit();
PROGLOG("Heap usage (excluding Roxiemem) : %" I64F "d bytes", (unsigned __int64)(heapUsage-rmtotal));
}
}
/////
CGraphBase::CGraphBase(CJobChannel &_jobChannel) : jobChannel(_jobChannel), job(_jobChannel.queryJob()), progressUpdated(false)
{
xgmml = NULL;
parent = owner = graphResultsContainer = NULL;
complete = false;
parentActivityId = 0;
connected = started = graphDone = aborted = false;
startBarrier = waitBarrier = doneBarrier = NULL;
mpTag = waitBarrierTag = startBarrierTag = doneBarrierTag = TAG_NULL;
executeReplyTag = TAG_NULL;
parentExtractSz = 0;
counter = 0; // loop/graph counter, will be set by loop/graph activity if needed
loopBodySubgraph = false;
}
CGraphBase::~CGraphBase()
{
clean();
}
CGraphBase *CGraphBase::cloneGraph()
{
Owned<CGraphBase> subGraph = queryJobChannel().createGraph();
CGraphTableCopy newGraphs;
subGraph->createFromXGMML(node, owner, parent, graphResultsContainer, newGraphs);
addDependencies(queryJob().queryXGMML(), false, newGraphs);
return subGraph.getClear();
}
void CGraphBase::init()
{
bool log = queryJob().queryForceLogging(queryGraphId(), (NULL == queryOwner()) || isGlobal());
setLogging(log);
}
void CGraphBase::clean()
{
::Release(startBarrier);
::Release(waitBarrier);
::Release(doneBarrier);
localResults.clear();
graphLoopResults.clear();
childGraphsTable.releaseAll();
disconnectActivities();
containers.releaseAll();
sinks.kill();
activeSinks.kill();
}
void CGraphBase::serializeCreateContexts(MemoryBuffer &mb)
{
DelayedSizeMarker sizeMark(mb);
Owned<IThorActivityIterator> iter = getIterator();
ForEach (*iter)
{
CGraphElementBase &element = iter->query();
if (element.isOnCreated())
{
mb.append(element.queryId());
element.serializeCreateContext(mb);
}
}
mb.append((activity_id)0);
sizeMark.write();
}
void CGraphBase::deserializeCreateContexts(MemoryBuffer &mb)
{
activity_id id;
for (;;)
{
mb.read(id);
if (0 == id) break;
CGraphElementBase *element = queryElement(id);
assertex(element);
element->deserializeCreateContext(mb);
}
}
void CGraphBase::reset()
{
setCompleteEx(false);
clearProgressUpdated();
graphCancelHandler.reset();
if (0 == containers.count())
{
Owned<IThorGraphIterator> iter = getChildGraphIterator();
ForEach(*iter)
iter->query().reset();
}
else
{
Owned<IThorActivityIterator> iter = getIterator();
ForEach(*iter)
{
CGraphElementBase &element = iter->query();
element.reset();
}
dependentSubGraphs.kill();
}
if (!queryOwner())
clearNodeStats();
}
void CGraphBase::addChildGraph(CGraphStub *stub)
{
CriticalBlock b(crit);
childGraphsTable.replace(*LINK(stub));
if (sequential)
orderedChildGraphs.append(*stub);
}
IThorGraphStubIterator *CGraphBase::getChildStubIterator() const
{
CriticalBlock b(crit);
class CIter : private SuperHashIteratorOf<CGraphStub>, public CSimpleInterfaceOf<IThorGraphStubIterator>
{
typedef SuperHashIteratorOf<CGraphStub> PARENT;
public:
CIter(const CChildGraphTable &table) : PARENT(table) { }
// IIterator
virtual bool first() { return PARENT::first(); }
virtual bool next() { return PARENT::next(); }
virtual bool isValid() { return PARENT::isValid(); }
virtual CGraphStub &query() { return PARENT::query(); }
};
return new CIter(childGraphsTable);
}
IThorGraphIterator *CGraphBase::getChildGraphIterator() const
{
CriticalBlock b(crit);
class CIter : public CSimpleInterfaceOf<IThorGraphIterator>
{
Owned<IThorGraphStubIterator> iter;
public:
CIter(IThorGraphStubIterator *_iter) : iter(_iter)
{
}
// IIterator
virtual bool first() { return iter->first(); }
virtual bool next() { return iter->next(); }
virtual bool isValid() { return iter->isValid(); }
virtual CGraphBase &query()
{
CGraphStub &stub = iter->query();
return stub.queryOriginalGraph();
}
};
return new CIter(getChildStubIterator());
}
bool CGraphBase::fireException(IException *e)
{
return queryJobChannel().fireException(e);
}
bool CGraphBase::preStart(size32_t parentExtractSz, const byte *parentExtract)
{
Owned<IThorActivityIterator> iter = getConnectedIterator();
ForEach(*iter)
{
CGraphElementBase &element = iter->query();
element.preStart(parentExtractSz, parentExtract);
}
return true;
}
void CGraphBase::executeSubGraph(size32_t parentExtractSz, const byte *parentExtract)
{
CriticalBlock b(executeCrit);
if (job.queryPausing())
return;
Owned<IException> exception;
try
{
if (!queryOwner())
{
StringBuffer s;
toXML(&queryXGMML(), s, 2);
GraphPrintLog("Running graph [%s] : %s", isGlobal()?"global":"local", s.str());
}
if (localResults)
localResults->clear();
doExecute(parentExtractSz, parentExtract, false);
}
catch (IException *e)
{
GraphPrintLog(e);
exception.setown(e);
}
if (!queryOwner())
{
GraphPrintLog("Graph Done");
StringBuffer memStr;
getSystemTraceInfo(memStr, PerfMonStandard | PerfMonExtended);
GraphPrintLog("%s", memStr.str());
}
if (exception)
throw exception.getClear();
}
void CGraphBase::onCreate()
{
Owned<IThorActivityIterator> iter = getConnectedIterator();
ForEach(*iter)
{
CGraphElementBase &element = iter->query();
element.onCreate();
}
}
void CGraphBase::execute(size32_t _parentExtractSz, const byte *parentExtract, bool checkDependencies, bool async)
{
if (isComplete())
return;
if (async)
queryJobChannel().startGraph(*this, checkDependencies, _parentExtractSz, parentExtract); // may block if enough running
else
{
if (!prepare(_parentExtractSz, parentExtract, checkDependencies, false, false))
{
setComplete();
return;
}
executeSubGraph(_parentExtractSz, parentExtract);
}
}
void CGraphBase::doExecute(size32_t parentExtractSz, const byte *parentExtract, bool checkDependencies)
{
if (isComplete()) return;
if (queryAborted())
{
if (abortException)
throw abortException.getLink();
throw MakeGraphException(this, 0, "subgraph aborted");
}
GraphPrintLog("Processing graph");
Owned<IException> exception;
try
{
if (started)
reset();
else
started = true;
++numExecuted;
Owned<IThorActivityIterator> iter = getConnectedIterator();
ForEach(*iter)
{
CGraphElementBase &element = iter->query();
element.onStart(parentExtractSz, parentExtract);
element.initActivity();
}
initialized = true;
if (!preStart(parentExtractSz, parentExtract)) return;
start();
if (!wait(aborted?MEDIUMTIMEOUT:INFINITE)) // can't wait indefinitely, query may have aborted and stall, but prudent to wait a short time for underlying graphs to unwind.
GraphPrintLogEx(this, thorlog_null, MCuserWarning, "Graph wait cancelled, aborted=%s", aborted?"true":"false");
else
graphDone = true;
}
catch (IException *e)
{
GraphPrintLog(e);
exception.setown(e);
}
try
{
if (!exception && abortException)
exception.setown(abortException.getClear());
if (exception)
{
if (NULL == owner || isGlobal())
waitBarrier->cancel(exception);
if (!queryOwner())
{
StringBuffer str;
Owned<IThorException> e = MakeGraphException(this, exception->errorCode(), "%s", exception->errorMessage(str).str());
e->setAction(tea_abort);
fireException(e);
}
}
}
catch (IException *e)
{
GraphPrintLog(e, "during abort()");
e->Release();
}
try
{
done();
if (doneBarrier)
doneBarrier->wait(false);
}
catch (IException *e)
{
GraphPrintLog(e);
if (!exception.get())
exception.setown(e);
else
e->Release();
}
end();
if (exception)
throw exception.getClear();
if (!queryAborted())
setComplete();
}
bool CGraphBase::prepare(size32_t parentExtractSz, const byte *parentExtract, bool checkDependencies, bool shortCircuit, bool async)
{
if (isComplete()) return false;
bool needToExecute = false;
ForEachItemIn(s, sinks)
{
CGraphElementBase &sink = sinks.item(s);
if (sink.prepareContext(parentExtractSz, parentExtract, checkDependencies, shortCircuit, async, false))
needToExecute = true;
}
onCreate();
return needToExecute;
}
void CGraphBase::done()
{
if (aborted) return; // activity done methods only called on success
Owned<IThorActivityIterator> iter = getConnectedIterator();
ForEach (*iter)
{
CGraphElementBase &element = iter->query();
element.queryActivity()->done();
}
}
unsigned CGraphBase::queryJobChannelNumber() const
{
return queryJobChannel().queryChannel();
}
IMPServer &CGraphBase::queryMPServer() const
{
return jobChannel.queryMPServer();
}
bool CGraphBase::syncInitData()
{
if (loopBodySubgraph)
{
CGraphElementBase *parentElement = queryOwner() ? queryOwner()->queryElement(queryParentActivityId()) : nullptr;
assertex(parentElement);
return parentElement->queryLoopGraph()->queryGraph()->isGlobal();
}
else
return !isLocalChild();
}
void CGraphBase::end()
{
// always called, any final action clear up
Owned<IThorActivityIterator> iter = getIterator();
ForEach(*iter)
{
CGraphElementBase &element = iter->query();
try
{
if (element.queryActivity())
element.queryActivity()->kill();
}
catch (IException *e)
{
Owned<IException> e2 = MakeActivityException(element.queryActivity(), e, "Error calling kill()");
GraphPrintLog(e2);
e->Release();
}
}
}
class CGraphTraverseIteratorBase : implements IThorActivityIterator, public CInterface
{
protected:
CGraphBase &graph;
Linked<CGraphElementBase> cur;
CIArrayOf<CGraphElementBase> others;
CGraphElementArrayCopy covered;
CGraphElementBase *popNext()
{
if (!others.ordinality())
{
cur.clear();
return NULL;
}
cur.setown(&others.popGet());
return cur;
}
void setNext(bool branchOnConditional)
{
if (branchOnConditional && ((unsigned)-1) != cur->whichBranch)
{
CIOConnection *io = cur->connectedInputs.queryItem(cur->whichBranch);
if (io)
cur.set(io->activity);
else
cur.clear();
}
else
{
CIOConnectionArray &inputs = cur->connectedInputs;
cur.clear();
unsigned n = inputs.ordinality();
bool first = true;
for (unsigned i=0; i<n; i++)
{
CIOConnection *io = inputs.queryItem(i);
if (io)
{
if (first)
{
first = false;
cur.set(io->activity);
}
else
others.append(*LINK(io->activity));
}
}
}
if (!cur)
{
if (!popNext())
return;
}
// check haven't been here before
for (;;)
{
if (cur->getOutputs() < 2)
break;
else if (NotFound == covered.find(*cur))
{
if (!cur->alreadyUpdated)
{
covered.append(*cur);
break;
}
}
if (!popNext())
return;
}
}
public:
IMPLEMENT_IINTERFACE;
CGraphTraverseIteratorBase(CGraphBase &_graph) : graph(_graph)
{
}
virtual bool first()
{
covered.kill();
others.kill();
cur.clear();
Owned<IThorActivityIterator> sinkIter = graph.getSinkIterator();
if (!sinkIter->first())
return false;
for (;;)
{
cur.set(& sinkIter->query());
if (!cur->alreadyUpdated)
break;
if (!sinkIter->next())
return false;
}
while (sinkIter->next())
others.append(sinkIter->get());
return true;
}
virtual bool isValid() { return NULL != cur.get(); }
virtual CGraphElementBase & query() { return *cur; }
CGraphElementBase & get() { return *LINK(cur); }
};
class CGraphTraverseConnectedIterator : public CGraphTraverseIteratorBase
{
bool branchOnConditional;
public:
CGraphTraverseConnectedIterator(CGraphBase &graph, bool _branchOnConditional) : CGraphTraverseIteratorBase(graph), branchOnConditional(_branchOnConditional) { }
virtual bool next()
{
setNext(branchOnConditional);
return NULL!=cur.get();
}
};
IThorActivityIterator *CGraphBase::getConnectedIterator(bool branchOnConditional)
{
return new CGraphTraverseConnectedIterator(*this, branchOnConditional);
}
bool CGraphBase::wait(unsigned timeout)
{
CTimeMon tm(timeout);
unsigned remaining = timeout;
class CWaitException
{
CGraphBase *graph;
Owned<IException> exception;
public:
CWaitException(CGraphBase *_graph) : graph(_graph) { }
IException *get() { return exception; }
void set(IException *e)
{
if (!exception)
exception.setown(e);
else
e->Release();
}
void throwException()
{
if (exception)
throw exception.getClear();
throw MakeGraphException(graph, 0, "Timed out waiting for graph to end");
}
} waitException(this);
Owned<IThorActivityIterator> iter = getConnectedIterator();
ForEach (*iter)
{
CGraphElementBase &element = iter->query();
CActivityBase *activity = element.queryActivity();
if (INFINITE != timeout && tm.timedout(&remaining))
waitException.throwException();
try
{
if (!activity->wait(remaining))
waitException.throwException();
}
catch (IException *e)
{
waitException.set(e); // will discard if already set
if (timeout == INFINITE)
{
unsigned e = tm.elapsed();
if (e >= MEDIUMTIMEOUT)
waitException.throwException();
timeout = MEDIUMTIMEOUT-e;
tm.reset(timeout);
}
}
}
if (waitException.get())
waitException.throwException();
// synchronize all slaves to end of graphs
if (NULL == owner || isGlobal())
{
if (INFINITE != timeout && tm.timedout(&remaining))
waitException.throwException();
if (!waitBarrier->wait(true, remaining))
return false;
}
return true;
}
void CGraphBase::abort(IException *e)
{
if (aborted)
return;
{
CriticalBlock cb(crit);
abortException.set(e);
aborted = true;
graphCancelHandler.cancel(0);
if (0 == containers.count())
{
Owned<IThorGraphStubIterator> iter = getChildStubIterator();
ForEach(*iter)
{
CGraphStub &graph = iter->query();
graph.abort(e);
}
}
}
if (started && !graphDone)
{
Owned<IThorActivityIterator> iter = getConnectedIterator();
ForEach (*iter)
{
iter->query().abort(e); // JCSMORE - could do in parallel, they can take some time to timeout
}
if (startBarrier)
startBarrier->cancel(e);
if (waitBarrier)
waitBarrier->cancel(e);
if (doneBarrier)
doneBarrier->cancel(e);
}
}
void CGraphBase::GraphPrintLog(const char *format, ...)
{
va_list args;
va_start(args, format);
::GraphPrintLogArgs(this, thorlog_null, MCdebugProgress, format, args);
va_end(args);
}
void CGraphBase::GraphPrintLog(IException *e, const char *format, ...)
{
va_list args;
va_start(args, format);
::GraphPrintLogArgs(this, e, thorlog_null, MCdebugProgress, format, args);
va_end(args);
}
void CGraphBase::GraphPrintLog(IException *e)
{
GraphPrintLog(e, "%s", "");
}
void CGraphBase::setLogging(bool tf)
{
Owned<IThorActivityIterator> iter = getIterator();
ForEach(*iter)
iter->query().setLogging(tf);
}
void CGraphBase::createFromXGMML(IPropertyTree *_node, CGraphBase *_owner, CGraphBase *_parent, CGraphBase *resultsGraph, CGraphTableCopy &newGraphs)
{
class CChildParallelFactory : public CGraphStub
{
Linked<CGraphBase> originalChildGraph;
CriticalSection crit;
CIArrayOf<CGraphBase> stack;
CIArrayOf<CGraphBase> active;
bool originalAvailable = true;
CGraphBase *getGraph()
{
Owned<CGraphBase> childGraph;
{
CriticalBlock b(crit);
if (originalAvailable)
{
originalAvailable = false;
active.append(*originalChildGraph.getLink());
return originalChildGraph.getLink();
}
if (stack.length())
childGraph.setown(&stack.popGet());
}
if (!childGraph)
childGraph.setown(originalChildGraph->cloneGraph());
if (originalChildGraph->queryAborted())
throw MakeGraphException(originalChildGraph, 0, "Job aborted");
{
CriticalBlock b(crit);
active.append(*childGraph.getLink());
}
return childGraph.getClear();
}
void pushGraph(CGraphBase *childGraph)
{
CriticalBlock b(crit);
verifyex(active.zap(*childGraph));
if (childGraph == originalChildGraph)
originalAvailable = true;
else
stack.append(*LINK(childGraph));
}
public:
CChildParallelFactory(CGraphBase *_originalChildGraph) : originalChildGraph(_originalChildGraph)
{
graphId = originalChildGraph->queryGraphId();
}
virtual CGraphBase &queryOriginalGraph() override { return *originalChildGraph; }
virtual void abort(IException *e) override
{
for (;;)
{
Owned<CGraphBase> activeChildGraph;
{
CriticalBlock b(crit);
activeChildGraph.setown(&active.popGet());
if (!activeChildGraph)
break;
}
activeChildGraph->abort(e);
}
}
virtual bool serializeStats(MemoryBuffer &mb) override
{
// JCSMORE - need to merge other instances
return originalChildGraph->serializeStats(mb);
}
virtual IEclGraphResults * evaluate(unsigned parentExtractSz, const byte * parentExtract) override
{
Owned<CGraphBase> childGraph = getGraph();
Owned<IEclGraphResults> results = childGraph->evaluate(parentExtractSz, parentExtract);
pushGraph(childGraph);
return results.getClear();
}
};
owner = _owner;
parent = _parent?_parent:owner;
node.setown(createPTreeFromIPT(_node));
xgmml = node->queryPropTree("att/graph");
sink = xgmml->getPropBool("att[@name=\"rootGraph\"]/@value", false);
sequential = xgmml->getPropBool("@sequential");
graphId = node->getPropInt("@id");
global = false;
localOnly = -1; // unset
parentActivityId = node->getPropInt("att[@name=\"_parentActivity\"]/@value", 0);
graphResultsContainer = resultsGraph;
CGraphBase *graphContainer = this;
if (resultsGraph)
graphContainer = resultsGraph; // JCSMORE is this right?
graphCodeContext.setContext(this, graphContainer, (ICodeContextExt *)&jobChannel.queryCodeContext());
unsigned numResults = xgmml->getPropInt("att[@name=\"_numResults\"]/@value", 0);
if (numResults)
{
localResults.setown(createThorGraphResults(numResults));
resultsGraph = this;
// JCSMORE - it might more sense if this temp handler was owned by parent act., which may finish(get stopped) earlier than the owning graph
tmpHandler.setown(queryJob().createTempHandler(false));
}
localChild = false;
if (owner && parentActivityId)
{
CGraphElementBase *parentElement = owner->queryElement(parentActivityId);
if (isLoopActivity(*parentElement))
{
localChild = parentElement->queryOwner().isLocalChild();
unsigned loopId = parentElement->queryXGMML().getPropInt("att[@name=\"_loopid\"]/@value");
if ((graphId == loopId) || (owner->queryGraphId() == loopId))
loopBodySubgraph = true;
else
localChild = true;
}
else
localChild = true;
}
Owned<IPropertyTreeIterator> nodes = xgmml->getElements("node");
ForEach(*nodes)
{
IPropertyTree &e = nodes->query();
ThorActivityKind kind = (ThorActivityKind) e.getPropInt("att[@name=\"_kind\"]/@value");
if (TAKsubgraph == kind)
{
Owned<CGraphBase> subGraph = queryJobChannel().createGraph();
subGraph->createFromXGMML(&e, this, parent, resultsGraph, newGraphs);
activity_id subGraphParentActivityId = e.getPropInt("att[@name=\"_parentActivity\"]/@value", 0);
if (subGraphParentActivityId) // JCS - not sure if ever false
{
Owned<CGraphStub> stub = new CChildParallelFactory(subGraph);
addChildGraph(stub);
}
else
addChildGraph(subGraph);
if (!global)
global = subGraph->isGlobal();
newGraphs.replace(*subGraph);
}
else
{
if (localChild && !e.getPropBool("att[@name=\"coLocal\"]/@value", false))
{
IPropertyTree *att = createPTree("att");
att->setProp("@name", "coLocal");
att->setPropBool("@value", true);
e.addPropTree("att", att);
}
CGraphElementBase *act = createGraphElement(e, *this, resultsGraph);
addActivity(act);
if (!global)
global = isGlobalActivity(*act);
}
}
Owned<IPropertyTreeIterator> edges = xgmml->getElements("edge");
ForEach(*edges)
{
IPropertyTree &edge = edges->query();
//Ignore edges that represent dependencies from parent activities to child activities.
if (edge.getPropBool("att[@name=\"_childGraph\"]/@value", false))
continue;
unsigned sourceOutput = edge.getPropInt("att[@name=\"_sourceIndex\"]/@value", 0);
unsigned targetInput = edge.getPropInt("att[@name=\"_targetIndex\"]/@value", 0);
CGraphElementBase *source = queryElement(edge.getPropInt("@source"));
CGraphElementBase *target = queryElement(edge.getPropInt("@target"));
target->addInput(targetInput, source, sourceOutput);
}
Owned<IThorActivityIterator> iter = getIterator();
ForEach(*iter)
{
CGraphElementBase &element = iter->query();
if (0 == element.getOutputs())
{
/* JCSMORE - Making some outputs conditional, will require:
* a) Pass through information as to which dependent graph causes this graph (and this sink) to execute)
* b) Allow the subgraph to re-executed by other dependent subgraphs and avoid re-executing completed sinks
* c) Keep common points (splitters) around (preferably in memory), re-execution of graph will need them
*/
sinks.append(*LINK(&element));
}
}
init();
}
void CGraphBase::executeChildGraphs(size32_t parentExtractSz, const byte *parentExtract)
{
if (sequential)
{
// JCSMORE - would need to re-think how this is done if these sibling child queries could be executed in parallel
ForEachItemIn(o, orderedChildGraphs)
{
CGraphBase &graph = orderedChildGraphs.item(o).queryOriginalGraph();
if (graph.isSink())
graph.execute(parentExtractSz, parentExtract, true, false);
}
}
else
{
Owned<IThorGraphIterator> iter = getChildGraphIterator();
ForEach(*iter)
{
CGraphBase &graph = iter->query();
if (graph.isSink())
graph.execute(parentExtractSz, parentExtract, true, false);
}
}
}
void CGraphBase::doExecuteChild(size32_t parentExtractSz, const byte *parentExtract)
{
reset();
if (0 == containers.count())
executeChildGraphs(parentExtractSz, parentExtract);
else
execute(parentExtractSz, parentExtract, false, false);
queryTempHandler()->clearTemps();
}
void CGraphBase::executeChild(size32_t & retSize, void * &ret, size32_t parentExtractSz, const byte *parentExtract)
{
reset();
doExecute(parentExtractSz, parentExtract, false);
UNIMPLEMENTED;
/*
ForEachItemIn(idx1, elements)
{
EclGraphElement & cur = elements.item(idx1);
if (cur.isResult)
{
cur.extractResult(retSize, ret);
return;
}
}
*/
throwUnexpected();
}
void CGraphBase::setResults(IThorGraphResults *results) // used by master only
{
localResults.set(results);
}
void CGraphBase::executeChild(size32_t parentExtractSz, const byte *parentExtract, IThorGraphResults *results, IThorGraphResults *_graphLoopResults)
{
localResults.set(results);
graphLoopResults.set(_graphLoopResults);
doExecuteChild(parentExtractSz, parentExtract);
graphLoopResults.clear();
localResults.clear();
}
StringBuffer &getGlobals(CGraphBase &graph, StringBuffer &str)
{
bool first = true;
Owned<IThorActivityIterator> iter = graph.getIterator();
ForEach(*iter)
{
CGraphElementBase &e = iter->query();
if (isGlobalActivity(e))
{
if (first)
str.append("Graph(").append(graph.queryGraphId()).append("): [");
else
str.append(", ");
first = false;
ThorActivityKind kind = e.getKind();
str.append(activityKindStr(kind));
str.append("(").append(e.queryId()).append(")");
}
}
if (!first)
str.append("]");
Owned<IThorGraphIterator> childIter = graph.getChildGraphIterator();
ForEach(*childIter)
{
CGraphBase &childGraph = childIter->query();
getGlobals(childGraph, str);
}
return str;
}
void CGraphBase::executeChild(size32_t parentExtractSz, const byte *parentExtract)
{
assertex(localResults);
localResults->clear();
if (isGlobal()) // any slave
{
StringBuffer str("Global acts = ");
getGlobals(*this, str);
throw MakeGraphException(this, 0, "Global child graph? : %s", str.str());
}
doExecuteChild(parentExtractSz, parentExtract);
}
IThorResult *CGraphBase::getResult(unsigned id, bool distributed)
{
return localResults->getResult(id, distributed);
}
IThorResult *CGraphBase::getGraphLoopResult(unsigned id, bool distributed)
{
return graphLoopResults->getResult(id, distributed);
}
IThorResult *CGraphBase::createResult(CActivityBase &activity, unsigned id, IThorGraphResults *results, IThorRowInterfaces *rowIf, ThorGraphResultType resultType, unsigned spillPriority)
{
return results->createResult(activity, id, rowIf, resultType, spillPriority);
}
IThorResult *CGraphBase::createResult(CActivityBase &activity, unsigned id, IThorRowInterfaces *rowIf, ThorGraphResultType resultType, unsigned spillPriority)
{
return localResults->createResult(activity, id, rowIf, resultType, spillPriority);
}
IThorResult *CGraphBase::createGraphLoopResult(CActivityBase &activity, IThorRowInterfaces *rowIf, ThorGraphResultType resultType, unsigned spillPriority)
{
return graphLoopResults->createResult(activity, rowIf, resultType, spillPriority);
}
// IEclGraphResults
void CGraphBase::getDictionaryResult(unsigned & count, const byte * * & ret, unsigned id)
{
Owned<IThorResult> result = getResult(id, true); // will get collated distributed result
result->getLinkedResult(count, ret);
}
void CGraphBase::getLinkedResult(unsigned & count, const byte * * & ret, unsigned id)
{
Owned<IThorResult> result = getResult(id, true); // will get collated distributed result
result->getLinkedResult(count, ret);
}
const void * CGraphBase::getLinkedRowResult(unsigned id)
{
Owned<IThorResult> result = getResult(id, true); // will get collated distributed result
return result->getLinkedRowResult();
}
// IThorChildGraph impl.
IEclGraphResults *CGraphBase::evaluate(unsigned _parentExtractSz, const byte *parentExtract)
{
CriticalBlock block(evaluateCrit);
localResults.setown(createThorGraphResults(xgmml->getPropInt("att[@name=\"_numResults\"]/@value", 0)));
parentExtractSz = _parentExtractSz;
executeChild(parentExtractSz, parentExtract);
return localResults.getClear();
}
static bool isLocalOnly(const CGraphElementBase &activity);
static bool isLocalOnly(const CGraphBase &graph) // checks all dependencies, if something needs to be global, whole body is forced to be execution sync.
{
if (0 == graph.activityCount())
{
Owned<IThorGraphIterator> iter = graph.getChildGraphIterator();
ForEach(*iter)
{
CGraphBase &childGraph = iter->query();
if (childGraph.isSink())
{
if (!isLocalOnly(childGraph))
return false;
}
}
}
else
{
if (graph.isGlobal())
return false;
Owned<IThorActivityIterator> sinkIter = graph.getAllSinkIterator();
ForEach(*sinkIter)
{
CGraphElementBase &sink = sinkIter->query();
if (!isLocalOnly(sink))
return false;
}
}
return true;
}
static bool isLocalOnly(const CGraphElementBase &activity)
{
Owned<IThorGraphDependencyIterator> deps = activity.getDependsIterator();
ForEach(*deps)
{
if (!isLocalOnly(*(deps->query().graph)))
return false;
}
StringBuffer match("edge[@target=\"");
match.append(activity.queryId()).append("\"]");
Owned<IPropertyTreeIterator> inputs = activity.queryOwner().queryXGMML().getElements(match.str());
ForEach(*inputs)
{
IPropertyTree &edge = inputs->query();
//Ignore edges that represent dependencies from parent activities to child activities.
if (edge.getPropBool("att[@name=\"_childGraph\"]/@value", false))
continue;
CGraphElementBase *sourceAct = activity.queryOwner().queryElement(edge.getPropInt("@source"));
if (!isLocalOnly(*sourceAct))
return false;
}
return true;
}
bool CGraphBase::isLocalOnly() const // checks all dependencies, if something needs to be global, whole body is forced to be execution sync.
{
if (-1 == localOnly)
localOnly = (int)::isLocalOnly(*this);
return 1==localOnly;
}
IThorGraphResults *CGraphBase::createThorGraphResults(unsigned num)
{
return new CThorGraphResults(num);
}
////
void CGraphTempHandler::registerFile(const char *name, graph_id graphId, unsigned usageCount, bool temp, WUFileKind fileKind, StringArray *clusters)
{
assertex(temp);
LOG(MCdebugProgress, thorJob, "registerTmpFile name=%s, usageCount=%d", name, usageCount);
CriticalBlock b(crit);
if (tmpFiles.find(name))
throw MakeThorException(TE_FileAlreadyUsedAsTempFile, "File already used as temp file (%s)", name);
tmpFiles.replace(* new CFileUsageEntry(name, graphId, fileKind, usageCount));
}
void CGraphTempHandler::deregisterFile(const char *name, bool kept)
{
LOG(MCdebugProgress, thorJob, "deregisterTmpFile name=%s", name);
CriticalBlock b(crit);
CFileUsageEntry *fileUsage = tmpFiles.find(name);
if (!fileUsage)
{
if (errorOnMissing)
throw MakeThorException(TE_FileNotFound, "File not found (%s) deregistering tmp file", name);
return;
}
if (0 == fileUsage->queryUsage()) // marked 'not to be deleted' until workunit complete.
return;
else if (1 == fileUsage->queryUsage())
{
tmpFiles.remove(name);
try
{
if (!removeTemp(name))
LOG(MCwarning, unknownJob, "Failed to delete tmp file : %s (not found)", name);
}
catch (IException *e) { StringBuffer s("Failed to delete tmp file : "); FLLOG(MCwarning, thorJob, e, s.append(name).str()); }
}
else
fileUsage->decUsage();
}
void CGraphTempHandler::clearTemps()
{
CriticalBlock b(crit);
Owned<IFileUsageIterator> iter = getIterator();
ForEach(*iter)
{
CFileUsageEntry &entry = iter->query();
const char *tmpname = entry.queryName();
try
{
if (!removeTemp(tmpname))
LOG(MCwarning, thorJob, "Failed to delete tmp file : %s (not found)", tmpname);
}
catch (IException *e) { StringBuffer s("Failed to delete tmp file : "); FLLOG(MCwarning, thorJob, e, s.append(tmpname).str()); }
}
iter.clear();
tmpFiles.kill();
}
/////
class CGraphExecutor;
class CGraphExecutorGraphInfo : public CInterface
{
public:
CGraphExecutorGraphInfo(CGraphExecutor &_executor, CGraphBase *_subGraph, IGraphCallback &_callback, const byte *parentExtract, size32_t parentExtractSz) : executor(_executor), subGraph(_subGraph), callback(_callback)
{
parentExtractMb.append(parentExtractSz, parentExtract);
}
CGraphExecutor &executor;
IGraphCallback &callback;
Linked<CGraphBase> subGraph;
MemoryBuffer parentExtractMb;
};
class CGraphExecutor : implements IGraphExecutor, public CInterface
{
CJobChannel &jobChannel;
CJobBase &job;
CIArrayOf<CGraphExecutorGraphInfo> stack, running, toRun;
UnsignedArray seen;
bool stopped;
unsigned limit;
unsigned waitOnRunning;
CriticalSection crit;
Semaphore runningSem;
Owned<IThreadPool> graphPool;
class CGraphExecutorFactory : implements IThreadFactory, public CInterface
{
CGraphExecutor &executor;
public:
IMPLEMENT_IINTERFACE;
CGraphExecutorFactory(CGraphExecutor &_executor) : executor(_executor) { }
// IThreadFactory
virtual IPooledThread *createNew()
{
class CGraphExecutorThread : implements IPooledThread, public CInterface
{
Owned<CGraphExecutorGraphInfo> graphInfo;
public:
IMPLEMENT_IINTERFACE;
CGraphExecutorThread()
{
}
virtual void init(void *startInfo) override
{
graphInfo.setown((CGraphExecutorGraphInfo *)startInfo);
}
virtual void threadmain() override
{
for (;;)
{
Linked<CGraphBase> graph = graphInfo->subGraph;
Owned<IException> e;
try
{
PROGLOG("CGraphExecutor: Running graph, graphId=%" GIDPF "d", graph->queryGraphId());
graphInfo->callback.runSubgraph(*graph, graphInfo->parentExtractMb.length(), (const byte *)graphInfo->parentExtractMb.toByteArray());
}
catch (IException *_e)
{
e.setown(_e);
}
Owned<CGraphExecutorGraphInfo> nextGraphInfo;
try
{
nextGraphInfo.setown(graphInfo->executor.graphDone(*graphInfo, e));
}
catch (IException *e)
{
GraphPrintLog(graph, e, "graphDone");
e->Release();
}
graphInfo.clear(); // NB: at this point the graph will be destroyed
if (e)
throw e.getClear();
if (!nextGraphInfo)
return;
graphInfo.setown(nextGraphInfo.getClear());
}
}
virtual bool canReuse() const override { return true; }
virtual bool stop() override { return true; }
};
return new CGraphExecutorThread();
}
} *factory;
CGraphExecutorGraphInfo *findRunning(graph_id gid)
{
ForEachItemIn(r, running)
{
CGraphExecutorGraphInfo *graphInfo = &running.item(r);
if (gid == graphInfo->subGraph->queryGraphId())
return graphInfo;
}
return NULL;
}
public:
IMPLEMENT_IINTERFACE;
CGraphExecutor(CJobChannel &_jobChannel) : jobChannel(_jobChannel), job(_jobChannel.queryJob())
{
limit = (unsigned)job.getWorkUnitValueInt("concurrentSubGraphs", globals->getPropInt("@concurrentSubGraphs", 1));
PROGLOG("CGraphExecutor: limit = %d", limit);
waitOnRunning = 0;
stopped = false;
factory = new CGraphExecutorFactory(*this);
graphPool.setown(createThreadPool("CGraphExecutor pool", factory, &jobChannel, limit));
}
~CGraphExecutor()
{
stopped = true;
graphPool->joinAll();
factory->Release();
}
CGraphExecutorGraphInfo *graphDone(CGraphExecutorGraphInfo &doneGraphInfo, IException *e)
{
CriticalBlock b(crit);
running.zap(doneGraphInfo);
if (waitOnRunning)
{
runningSem.signal(waitOnRunning);
waitOnRunning = 0;
}
if (e || job.queryAborted())
{
stopped = true;
stack.kill();
return NULL;
}
if (job.queryPausing())
stack.kill();
else if (stack.ordinality())
{
CICopyArrayOf<CGraphExecutorGraphInfo> toMove;
ForEachItemIn(s, stack)
{
bool dependenciesDone = true;
CGraphExecutorGraphInfo &graphInfo = stack.item(s);
ForEachItemIn (d, graphInfo.subGraph->dependentSubGraphs)
{
CGraphBase &subGraph = graphInfo.subGraph->dependentSubGraphs.item(d);
if (!subGraph.isComplete())
{
dependenciesDone = false;
break;
}
}
if (dependenciesDone)
{
graphInfo.subGraph->dependentSubGraphs.kill();
graphInfo.subGraph->prepare(graphInfo.parentExtractMb.length(), (const byte *)graphInfo.parentExtractMb.toByteArray(), true, true, true); // now existing deps done, maybe more to prepare
ForEachItemIn (d, graphInfo.subGraph->dependentSubGraphs)
{
CGraphBase &subGraph = graphInfo.subGraph->dependentSubGraphs.item(d);
if (!subGraph.isComplete())
{
dependenciesDone = false;
break;
}
}
if (dependenciesDone)
{
graphInfo.subGraph->dependentSubGraphs.kill(); // none to track anymore
toMove.append(graphInfo);
}
}
}
ForEachItemIn(m, toMove)
{
Linked<CGraphExecutorGraphInfo> graphInfo = &toMove.item(m);
stack.zap(*graphInfo);
toRun.add(*graphInfo.getClear(), 0);
}
}
job.markWuDirty();
PROGLOG("CGraphExecutor running=%d, waitingToRun=%d, dependentsWaiting=%d", running.ordinality(), toRun.ordinality(), stack.ordinality());
while (toRun.ordinality())
{
if (job.queryPausing())
return NULL;
Linked<CGraphExecutorGraphInfo> nextGraphInfo = &toRun.item(0);
toRun.remove(0);
if (!nextGraphInfo->subGraph->isComplete() && (NULL == findRunning(nextGraphInfo->subGraph->queryGraphId())))
{
running.append(*nextGraphInfo.getLink());
return nextGraphInfo.getClear();
}
}
return NULL;
}
// IGraphExecutor
virtual void add(CGraphBase *subGraph, IGraphCallback &callback, bool checkDependencies, size32_t parentExtractSz, const byte *parentExtract)
{
bool alreadyRunning;
{
CriticalBlock b(crit);
if (job.queryPausing())
return;
if (subGraph->isComplete())
return;
alreadyRunning = NULL != findRunning(subGraph->queryGraphId());
if (alreadyRunning)
++waitOnRunning;
}
if (alreadyRunning)
{
for (;;)
{
PROGLOG("Waiting on subgraph %" GIDPF "d", subGraph->queryGraphId());
if (runningSem.wait(MEDIUMTIMEOUT) || job.queryAborted() || job.queryPausing())
break;
}
return;
}
else
{
CriticalBlock b(crit);
if (seen.contains(subGraph->queryGraphId()))
return; // already queued;
seen.append(subGraph->queryGraphId());
}
if (!subGraph->prepare(parentExtractSz, parentExtract, checkDependencies, true, true))
{
subGraph->setComplete();
return;
}
if (subGraph->dependentSubGraphs.ordinality())
{
bool dependenciesDone = true;
ForEachItemIn (d, subGraph->dependentSubGraphs)
{
CGraphBase &graph = subGraph->dependentSubGraphs.item(d);
if (!graph.isComplete())
{
dependenciesDone = false;
break;
}
}
if (dependenciesDone)
subGraph->dependentSubGraphs.kill(); // none to track anymore
}
Owned<CGraphExecutorGraphInfo> graphInfo = new CGraphExecutorGraphInfo(*this, subGraph, callback, parentExtract, parentExtractSz);
CriticalBlock b(crit);
if (0 == subGraph->dependentSubGraphs.ordinality())
{
if (running.ordinality()<limit)
{
running.append(*LINK(graphInfo));
PROGLOG("Add: Launching graph thread for graphId=%" GIDPF "d", subGraph->queryGraphId());
graphPool->start(graphInfo.getClear());
}
else
stack.add(*graphInfo.getClear(), 0); // push to front, no dependency, free to run next.
}
else
stack.append(*graphInfo.getClear()); // as dependencies finish, may move up the list
}
virtual IThreadPool &queryGraphPool() { return *graphPool; }
virtual void wait()
{
PROGLOG("CGraphExecutor exiting, waiting on graph pool");
graphPool->joinAll();
PROGLOG("CGraphExecutor graphPool finished");
}
};
////
// IContextLogger
class CThorContextLogger : implements IContextLogger, public CSimpleInterface
{
CJobBase &job;
unsigned traceLevel;
StringAttr globalIdHeader;
StringAttr callerIdHeader;
StringAttr globalId;
StringBuffer localId;
public:
IMPLEMENT_IINTERFACE_USING(CSimpleInterface);
CThorContextLogger(CJobBase &_job) : job(_job)
{
traceLevel = 1;
if (globals->hasProp("@httpGlobalIdHeader"))
setHttpIdHeaders(globals->queryProp("@httpGlobalIdHeader"), globals->queryProp("@httpCallerIdHeader"));
}
virtual void CTXLOGva(const char *format, va_list args) const __attribute__((format(printf,2,0)))
{
StringBuffer ss;
ss.valist_appendf(format, args);
LOG(MCdebugProgress, thorJob, "%s", ss.str());
}
virtual void logOperatorExceptionVA(IException *E, const char *file, unsigned line, const char *format, va_list args) const __attribute__((format(printf,5,0)))
{
StringBuffer ss;
ss.append("ERROR");
if (E)
ss.append(": ").append(E->errorCode());
if (file)
ss.appendf(": %s(%d) ", file, line);
if (E)
E->errorMessage(ss.append(": "));
if (format)
ss.append(": ").valist_appendf(format, args);
LOG(MCoperatorProgress, thorJob, "%s", ss.str());
}
virtual void noteStatistic(StatisticKind kind, unsigned __int64 value) const
{
}
virtual void mergeStats(const CRuntimeStatisticCollection &from) const
{
}
virtual unsigned queryTraceLevel() const
{
return traceLevel;
}
virtual void setGlobalId(const char *id, SocketEndpoint &ep, unsigned pid)
{
globalId.set(id);
appendLocalId(localId.clear(), ep, pid);
}
virtual const char *queryGlobalId() const
{
return globalId.get();
}
virtual const char *queryLocalId() const
{
return localId.str();
}
virtual void setHttpIdHeaders(const char *global, const char *caller)
{
if (global && *global)
globalIdHeader.set(global);
if (caller && *caller)
callerIdHeader.set(caller);
}
virtual const char *queryGlobalIdHttpHeader() const
{
return globalIdHeader.str();
}
virtual const char *queryCallerIdHttpHeader() const
{
return callerIdHeader.str();
}
};
////
CJobBase::CJobBase(ILoadedDllEntry *_querySo, const char *_graphName) : querySo(_querySo), graphName(_graphName)
{
maxDiskUsage = diskUsage = 0;
dirty = true;
aborted = false;
globalMemoryMB = globals->getPropInt("@globalMemorySize"); // in MB
channelsPerSlave = globals->getPropInt("@channelsPerSlave", 1);
numChannels = channelsPerSlave;
pluginMap = new SafePluginMap(&pluginCtx, true);
// JCSMORE - Will pass down at job creation time...
jobGroup.set(&::queryClusterGroup());
slaveGroup.setown(jobGroup->remove(0));
nodeGroup.set(&queryNodeGroup());
myNodeRank = nodeGroup->rank(::queryMyNode());
unsigned channelsPerSlave = globals->getPropInt("@channelsPerSlave", 1);
jobChannelSlaveNumbers.allocateN(channelsPerSlave, true); // filled when channels are added.
jobSlaveChannelNum.allocateN(querySlaves()); // filled when channels are added.
for (unsigned s=0; s<querySlaves(); s++)
jobSlaveChannelNum[s] = NotFound;
StringBuffer wuXML;
if (!getEmbeddedWorkUnitXML(querySo, wuXML))
throw MakeStringException(0, "Failed to locate workunit info in query : %s", querySo->queryName());
Owned<ILocalWorkUnit> localWU = createLocalWorkUnit(wuXML);
Owned<IConstWUGraph> graph = localWU->getGraph(graphName);
graphXGMML.setown(graph->getXGMMLTree(false));
if (!graphXGMML)
throwUnexpected();
}
void CJobBase::init()
{
StringBuffer tmp;
tmp.append(wuid);
tmp.append(graphName);
key.set(tmp.str());
StringBuffer user;
extractFromWorkunitDAToken(token.str(), nullptr, &user, nullptr);
userDesc = createUserDescriptor();
userDesc->set(user.str(), token.str());//use workunit token as password
forceLogGraphIdMin = (graph_id)getWorkUnitValueInt("forceLogGraphIdMin", 0);
forceLogGraphIdMax = (graph_id)getWorkUnitValueInt("forceLogGraphIdMax", 0);
logctx.setown(new CThorContextLogger(*this));
// global setting default on, can be overridden by #option
timeActivities = 0 != getWorkUnitValueInt("timeActivities", globals->getPropBool("@timeActivities", true));
maxActivityCores = (unsigned)getWorkUnitValueInt("maxActivityCores", 0); // NB: 0 means system decides
if (0 == maxActivityCores)
maxActivityCores = getAffinityCpus();
pausing = false;
resumed = false;
crcChecking = 0 != getWorkUnitValueInt("THOR_ROWCRC", globals->getPropBool("@THOR_ROWCRC", false));
usePackedAllocator = 0 != getWorkUnitValueInt("THOR_PACKEDALLOCATOR", globals->getPropBool("@THOR_PACKEDALLOCATOR", true));
memorySpillAtPercentage = (unsigned)getWorkUnitValueInt("memorySpillAt", globals->getPropInt("@memorySpillAt", 80));
sharedMemoryLimitPercentage = (unsigned)getWorkUnitValueInt("globalMemoryLimitPC", globals->getPropInt("@sharedMemoryLimit", 90));
sharedMemoryMB = globalMemoryMB*sharedMemoryLimitPercentage/100;
failOnLeaks = getOptBool("failOnLeaks");
maxLfnBlockTimeMins = getOptInt(THOROPT_MAXLFN_BLOCKTIME_MINS, DEFAULT_MAXLFN_BLOCKTIME_MINS);
PROGLOG("Global memory size = %d MB, shared memory = %d%%, memory spill at = %d%%", globalMemoryMB, sharedMemoryLimitPercentage, memorySpillAtPercentage);
StringBuffer tracing("maxActivityCores = ");
if (maxActivityCores)
tracing.append(maxActivityCores);
else
tracing.append("[unbound]");
PROGLOG("%s", tracing.str());
}
void CJobBase::beforeDispose()
{
endJob();
}
CJobChannel &CJobBase::queryJobChannel(unsigned c) const
{
return jobChannels.item(c);
}
CActivityBase &CJobBase::queryChannelActivity(unsigned c, graph_id gid, activity_id id) const
{
CJobChannel &channel = queryJobChannel(c);
Owned<CGraphBase> graph = channel.getGraph(gid);
dbgassertex(graph);
CGraphElementBase *container = graph->queryElement(id);
dbgassertex(container);
return *container->queryActivity();
}
void CJobBase::startJob()
{
LOG(MCdebugProgress, thorJob, "New Graph started : %s", graphName.get());
ClearTempDirs();
perfmonhook.setown(createThorMemStatsPerfMonHook(*this, getOptInt(THOROPT_MAX_KERNLOG, 3)));
setPerformanceMonitorHook(perfmonhook);
PrintMemoryStatusLog();
logDiskSpace();
unsigned keyNodeCacheMB = (unsigned)getWorkUnitValueInt("keyNodeCacheMB", DEFAULT_KEYNODECACHEMB * queryJobChannels());
unsigned keyLeafCacheMB = (unsigned)getWorkUnitValueInt("keyLeafCacheMB", DEFAULT_KEYLEAFCACHEMB * queryJobChannels());
unsigned keyBlobCacheMB = (unsigned)getWorkUnitValueInt("keyBlobCacheMB", DEFAULT_KEYBLOBCACHEMB * queryJobChannels());
setNodeCacheMem(keyNodeCacheMB * 0x100000);
setLeafCacheMem(keyLeafCacheMB * 0x100000);
setBlobCacheMem(keyBlobCacheMB * 0x100000);
PROGLOG("Key node caching setting: node=%u MB, leaf=%u MB, blob=%u MB", keyNodeCacheMB, keyLeafCacheMB, keyBlobCacheMB);
unsigned keyFileCacheLimit = (unsigned)getWorkUnitValueInt("keyFileCacheLimit", 0);
if (!keyFileCacheLimit)
keyFileCacheLimit = (querySlaves()+1)*2;
setKeyIndexCacheSize(keyFileCacheLimit);
PROGLOG("Key file cache size set to: %d", keyFileCacheLimit);
if (getOptBool("dumpStacks")) // mainly as an example of printAllStacks() usage
{
StringBuffer output;
if (getAllStacks(output))
PrintLogDirect(output);
else
WARNLOG("Failed to capture process stacks: %s", output.str());
}
}
void CJobBase::endJob()
{
if (jobEnded)
return;
jobEnded = true;
setPerformanceMonitorHook(nullptr);
LOG(MCdebugProgress, thorJob, "Job ended : %s", graphName.get());
clearKeyStoreCache(true);
PrintMemoryStatusLog();
Owned<IMultiException> exceptions;
ForEachItemIn(c, jobChannels)
{
try
{
jobChannels.item(c).clean();
}
catch (IException *e)
{
if (!exceptions)
exceptions.setown(makeMultiException());
exceptions->append(*LINK(e));
}
}
try
{
jobChannels.kill(); // avoiding circular references. Kill before other CJobBase components are destroyed that channels reference.
::Release(userDesc);
::Release(pluginMap);
traceMemUsage();
if (numChannels > 1) // if only 1 - then channel allocator is same as sharedAllocator, leaks will be reported by the single channel
checkAndReportLeaks(sharedAllocator->queryRowManager());
}
catch (IException *e)
{
if (!exceptions)
exceptions.setown(makeMultiException());
exceptions->append(*LINK(e));
}
if (exceptions && exceptions->ordinality())
throw exceptions.getClear();
}
void CJobBase::checkAndReportLeaks(roxiemem::IRowManager *rowManager)
{
if (!failOnLeaks) // NB: leaks reported by row manager destructor anyway
return;
if (rowManager->allocated())
{
rowManager->reportLeaks();
throw MakeThorException(TE_RowLeaksDetected, "Row leaks detected");
}
}
bool CJobBase::queryForceLogging(graph_id graphId, bool def) const
{
// JCSMORE, could add comma separated range, e.g. 1-5,10-12
if ((graphId >= forceLogGraphIdMin) && (graphId <= forceLogGraphIdMax))
return true;
return def;
}
void CJobBase::addSubGraph(IPropertyTree &xgmml)
{
CriticalBlock b(crit);
for (unsigned c=0; c<queryJobChannels(); c++)
{
CJobChannel &jobChannel = queryJobChannel(c);
Owned<CGraphBase> subGraph = jobChannel.createGraph();
subGraph->createFromXGMML(&xgmml, NULL, NULL, NULL, jobChannel.queryAllGraphs());
jobChannel.addSubGraph(*subGraph.getClear());
}
}
void CJobBase::addDependencies(IPropertyTree *xgmml, bool failIfMissing)
{
for (unsigned c=0; c<queryJobChannels(); c++)
{
CJobChannel &jobChannel = queryJobChannel(c);
jobChannel.addDependencies(xgmml, failIfMissing);
}
}
bool CJobBase::queryUseCheckpoints() const
{
return globals->getPropBool("@checkPointRecovery") || 0 != getWorkUnitValueInt("checkPointRecovery", 0);
}
void CJobBase::abort(IException *e)
{
aborted = true;
for (unsigned c=0; c<queryJobChannels(); c++)
{
CJobChannel &jobChannel = queryJobChannel(c);
jobChannel.abort(e);
}
}
void CJobBase::increase(offset_t usage, const char *key)
{
diskUsage += usage;
if (diskUsage > maxDiskUsage) maxDiskUsage = diskUsage;
}
void CJobBase::decrease(offset_t usage, const char *key)
{
diskUsage -= usage;
}
// these getX methods for property in workunit settings, then global setting, defaulting to provided 'dft' if not present
StringBuffer &CJobBase::getOpt(const char *opt, StringBuffer &out)
{
if (!opt || !*opt)
return out; // probably error
VStringBuffer gOpt("Debug/@%s", opt);
getWorkUnitValue(opt, out);
if (0 == out.length())
globals->getProp(gOpt, out);
return out;
}
bool CJobBase::getOptBool(const char *opt, bool dft)
{
if (!opt || !*opt)
return dft; // probably error
VStringBuffer gOpt("Debug/@%s", opt);
return getWorkUnitValueBool(opt, globals->getPropBool(gOpt, dft));
}
int CJobBase::getOptInt(const char *opt, int dft)
{
if (!opt || !*opt)
return dft; // probably error
VStringBuffer gOpt("Debug/@%s", opt);
return (int)getWorkUnitValueInt(opt, globals->getPropInt(gOpt, dft));
}
__int64 CJobBase::getOptInt64(const char *opt, __int64 dft)
{
if (!opt || !*opt)
return dft; // probably error
VStringBuffer gOpt("Debug/@%s", opt);
return getWorkUnitValueInt(opt, globals->getPropInt64(gOpt, dft));
}
IThorAllocator *CJobBase::getThorAllocator(unsigned channel)
{
return sharedAllocator.getLink();
}
/// CJobChannel
CJobChannel::CJobChannel(CJobBase &_job, IMPServer *_mpServer, unsigned _channel)
: job(_job), mpServer(_mpServer), channel(_channel)
{
aborted = false;
thorAllocator.setown(job.getThorAllocator(channel));
jobComm.setown(mpServer->createCommunicator(&job.queryJobGroup()));
myrank = job.queryJobGroup().rank(queryMyNode());
graphExecutor.setown(new CGraphExecutor(*this));
}
CJobChannel::~CJobChannel()
{
if (!cleaned)
clean();
}
INode *CJobChannel::queryMyNode()
{
return mpServer->queryMyNode();
}
void CJobChannel::wait()
{
if (graphExecutor)
graphExecutor->wait();
}
ICodeContext &CJobChannel::queryCodeContext() const
{
return *codeCtx;
}
ICodeContext &CJobChannel::querySharedMemCodeContext() const
{
return *sharedMemCodeCtx;
}
mptag_t CJobChannel::deserializeMPTag(MemoryBuffer &mb)
{
mptag_t tag;
deserializeMPtag(mb, tag);
if (TAG_NULL != tag)
{
PROGLOG("deserializeMPTag: tag = %d", (int)tag);
jobComm->flush(tag);
}
return tag;
}
IEngineRowAllocator *CJobChannel::getRowAllocator(IOutputMetaData * meta, activity_id activityId, roxiemem::RoxieHeapFlags flags) const
{
return thorAllocator->getRowAllocator(meta, activityId, flags);
}
roxiemem::IRowManager *CJobChannel::queryRowManager() const
{
return thorAllocator->queryRowManager();
}
void CJobChannel::addDependencies(IPropertyTree *xgmml, bool failIfMissing)
{
::addDependencies(xgmml, failIfMissing, allGraphs);
}
IThorGraphIterator *CJobChannel::getSubGraphs()
{
CriticalBlock b(crit);
return new CGraphTableIterator(subGraphs);
}
void CJobChannel::clean()
{
if (cleaned)
return;
cleaned = true;
wait();
queryRowManager()->reportMemoryUsage(false);
PROGLOG("CJobBase resetting memory manager");
if (graphExecutor)
{
graphExecutor->queryGraphPool().stopAll();
graphExecutor.clear();
}
subGraphs.kill();
job.checkAndReportLeaks(thorAllocator->queryRowManager());
thorAllocator.clear();
codeCtx.clear();
}
void CJobChannel::startGraph(CGraphBase &graph, bool checkDependencies, size32_t parentExtractSize, const byte *parentExtract)
{
graphExecutor->add(&graph, *this, checkDependencies, parentExtractSize, parentExtract);
}
IThorResult *CJobChannel::getOwnedResult(graph_id gid, activity_id ownerId, unsigned resultId)
{
Owned<CGraphBase> graph = getGraph(gid);
if (!graph)
{
Owned<IThorException> e = MakeThorException(0, "getOwnedResult: graph not found");
e->setGraphInfo(queryJob().queryGraphName(), gid);
throw e.getClear();
}
Owned<IThorResult> result;
if (ownerId)
{
CGraphElementBase *container = graph->queryElement(ownerId);
assertex(container);
CActivityBase *activity = container->queryActivity();
IThorGraphResults *results = activity->queryResults();
if (!results)
throw MakeGraphException(graph, 0, "GraphGetResult: no results created (requesting: %d)", resultId);
result.setown(activity->queryResults()->getResult(resultId));
}
else
result.setown(graph->getResult(resultId));
if (!result)
throw MakeGraphException(graph, 0, "GraphGetResult: result not found: %d", resultId);
return result.getClear();
}
void CJobChannel::abort(IException *e)
{
aborted = true;
Owned<IThorGraphIterator> iter = getSubGraphs();
ForEach (*iter)
{
CGraphBase &graph = iter->query();
graph.abort(e);
}
}
// IGraphCallback
void CJobChannel::runSubgraph(CGraphBase &graph, size32_t parentExtractSz, const byte *parentExtract)
{
graph.executeSubGraph(parentExtractSz, parentExtract);
}
static IThorResource *iThorResource = NULL;
void setIThorResource(IThorResource &r)
{
iThorResource = &r;
}
IThorResource &queryThor()
{
return *iThorResource;
}
//
//
//
//
CActivityBase::CActivityBase(CGraphElementBase *_container) : container(*_container), timeActivities(_container->queryJob().queryTimeActivities())
{
mpTag = TAG_NULL;
abortSoon = receiving = cancelledReceive = initialized = reInit = false;
baseHelper.set(container.queryHelper());
parentExtractSz = 0;
parentExtract = NULL;
}
CActivityBase::~CActivityBase()
{
}
void CActivityBase::abort()
{
if (!abortSoon) ActPrintLog("Abort condition set");
abortSoon = true;
}
void CActivityBase::kill()
{
ownedResults.clear();
}
bool CActivityBase::appendRowXml(StringBuffer & target, IOutputMetaData & meta, const void * row) const
{
if (!meta.hasXML())
{
target.append("<xml-unavailable/>");
return false;
}
try
{
CommonXmlWriter xmlWrite(XWFnoindent);
meta.toXML((byte *) row, xmlWrite);
target.append(xmlWrite.str());
return true;
}
catch (IException * e)
{
e->Release();
target.append("<invalid-row/>");
return false;
}
}
void CActivityBase::logRow(const char * prefix, IOutputMetaData & meta, const void * row) const
{
bool blindLogging = false; // MORE: should check a workunit/global option
if (meta.hasXML() && !blindLogging)
{
StringBuffer xml;
appendRowXml(xml, meta, row);
ActPrintLog("%s: %s", prefix, xml.str());
}
}
void CActivityBase::ActPrintLog(const char *format, ...) const
{
va_list args;
va_start(args, format);
::ActPrintLogArgs(&queryContainer(), thorlog_null, MCdebugProgress, format, args);
va_end(args);
}
void CActivityBase::ActPrintLog(IException *e, const char *format, ...) const
{
va_list args;
va_start(args, format);
::ActPrintLogArgs(&queryContainer(), e, thorlog_all, MCexception(e), format, args);
va_end(args);
}
void CActivityBase::ActPrintLog(IException *e) const
{
ActPrintLog(e, "%s", "");
}
IThorRowInterfaces * CActivityBase::createRowInterfaces(IOutputMetaData * meta, byte seq)
{
activity_id id = createCompoundActSeqId(queryId(), seq);
return createThorRowInterfaces(queryRowManager(), meta, id, queryHeapFlags(), queryCodeContext());
}
IThorRowInterfaces * CActivityBase::createRowInterfaces(IOutputMetaData * meta, roxiemem::RoxieHeapFlags heapFlags, byte seq)
{
activity_id id = createCompoundActSeqId(queryId(), seq);
return createThorRowInterfaces(queryRowManager(), meta, id, heapFlags, queryCodeContext());
}
bool CActivityBase::fireException(IException *e)
{
Owned<IThorException> _te;
IThorException *te = QUERYINTERFACE(e, IThorException);
if (te)
{
if (!te->queryActivityId())
setExceptionActivityInfo(container, te);
}
else
{
te = MakeActivityException(this, e);
te->setAudience(e->errorAudience());
_te.setown(te);
}
return container.queryOwner().fireException(te);
}
void CActivityBase::processAndThrowOwnedException(IException * _e)
{
IThorException *e = QUERYINTERFACE(_e, IThorException);
if (e)
{
if (!e->queryActivityId())
setExceptionActivityInfo(container, e);
}
else
{
e = MakeActivityException(this, _e);
_e->Release();
}
throw e;
}
IEngineRowAllocator * CActivityBase::queryRowAllocator()
{
if (CABallocatorlock.lock()) {
if (!rowAllocator)
{
roxiemem::RoxieHeapFlags heapFlags = queryHeapFlags();
rowAllocator.setown(getRowAllocator(queryRowMetaData(), heapFlags));
}
CABallocatorlock.unlock();
}
return rowAllocator;
}
IOutputRowSerializer * CActivityBase::queryRowSerializer()
{
if (CABserializerlock.lock()) {
if (!rowSerializer)
rowSerializer.setown(queryRowMetaData()->createDiskSerializer(queryCodeContext(),queryId()));
CABserializerlock.unlock();
}
return rowSerializer;
}
IOutputRowDeserializer * CActivityBase::queryRowDeserializer()
{
if (CABdeserializerlock.lock()) {
if (!rowDeserializer)
rowDeserializer.setown(queryRowMetaData()->createDiskDeserializer(queryCodeContext(),queryId()));
CABdeserializerlock.unlock();
}
return rowDeserializer;
}
IThorRowInterfaces *CActivityBase::getRowInterfaces()
{
// create an independent instance, to avoid circular link dependency problems
return createThorRowInterfaces(queryRowManager(), queryRowMetaData(), container.queryId(), queryHeapFlags(), queryCodeContext());
}
IEngineRowAllocator *CActivityBase::getRowAllocator(IOutputMetaData * meta, roxiemem::RoxieHeapFlags flags, byte seq) const
{
activity_id actId = createCompoundActSeqId(queryId(), seq);
return queryJobChannel().getRowAllocator(meta, actId, flags);
}
bool CActivityBase::receiveMsg(ICommunicator &comm, CMessageBuffer &mb, const rank_t rank, const mptag_t mpTag, rank_t *sender, unsigned timeout)
{
BooleanOnOff onOff(receiving);
CTimeMon t(timeout);
unsigned remaining = timeout;
// check 'cancelledReceive' every 10 secs
while (!cancelledReceive && ((MP_WAIT_FOREVER==timeout) || !t.timedout(&remaining)))
{
if (comm.recv(mb, rank, mpTag, sender, remaining>10000?10000:remaining))
return true;
}
return false;
}
bool CActivityBase::receiveMsg(CMessageBuffer &mb, const rank_t rank, const mptag_t mpTag, rank_t *sender, unsigned timeout)
{
return receiveMsg(queryJobChannel().queryJobComm(), mb, rank, mpTag, sender, timeout);
}
void CActivityBase::cancelReceiveMsg(ICommunicator &comm, const rank_t rank, const mptag_t mpTag)
{
cancelledReceive = true;
if (receiving)
comm.cancel(rank, mpTag);
}
void CActivityBase::cancelReceiveMsg(const rank_t rank, const mptag_t mpTag)
{
cancelReceiveMsg(queryJobChannel().queryJobComm(), rank, mpTag);
}
| 106,894
| 31,159
|
//
// This source file is part of appleseed.
// Visit https://appleseedhq.net/ for additional information and resources.
//
// This software is released under the MIT license.
//
// Copyright (c) 2010-2013 Francois Beaune, Jupiter Jazz Limited
// Copyright (c) 2014-2018 Francois Beaune, The appleseedhq Organization
//
// 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.
//
// Interface header.
#include "benchmarksuite.h"
// appleseed.foundation headers.
#include "foundation/math/vector.h"
#include "foundation/platform/compiler.h"
#include "foundation/platform/thread.h"
#include "foundation/platform/timers.h"
#include "foundation/platform/types.h"
#include "foundation/utility/benchmark/benchmarkresult.h"
#include "foundation/utility/benchmark/ibenchmarkcase.h"
#include "foundation/utility/benchmark/ibenchmarkcasefactory.h"
#include "foundation/utility/benchmark/timingresult.h"
#include "foundation/utility/filter.h"
#include "foundation/utility/gnuplotfile.h"
#include "foundation/utility/stopwatch.h"
#include "foundation/utility/string.h"
// Standard headers.
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <exception>
#include <limits>
#include <memory>
#include <string>
#include <vector>
namespace foundation
{
//
// BenchmarkSuite class implementation.
//
#define GENERATE_BENCHMARK_PLOTS
namespace
{
// An empty benchmark case used for measuring the overhead of calling IBenchmarkCase::run().
struct EmptyBenchmarkCase
: public IBenchmarkCase
{
const char* get_name() const override
{
return "Empty";
}
APPLESEED_NO_INLINE void run() override
{
}
};
}
struct BenchmarkSuite::Impl
{
#if APPLESEED_X86
typedef Stopwatch<X86Timer> StopwatchType;
#else
typedef Stopwatch<DefaultProcessorTimer> StopwatchType;
#endif
std::string m_name;
std::vector<IBenchmarkCaseFactory*> m_factories;
static double measure_runtime_seconds(
IBenchmarkCase* benchmark,
StopwatchType& stopwatch)
{
stopwatch.start();
benchmark->run();
stopwatch.measure();
return stopwatch.get_seconds();
}
static double measure_runtime_ticks(
IBenchmarkCase* benchmark,
StopwatchType& stopwatch)
{
stopwatch.start();
benchmark->run();
stopwatch.measure();
return static_cast<double>(stopwatch.get_ticks());
}
template <typename MeasurementFunction>
static double measure_runtime(
IBenchmarkCase* benchmark,
StopwatchType& stopwatch,
MeasurementFunction& measurement_function,
const size_t measurement_count)
{
double lowest_runtime = std::numeric_limits<double>::max();
for (size_t i = 0; i < measurement_count; ++i)
{
const double runtime = measurement_function(benchmark, stopwatch);
lowest_runtime = std::min(lowest_runtime, runtime);
}
return lowest_runtime;
}
static size_t compute_measurement_count(
IBenchmarkCase* benchmark,
StopwatchType& stopwatch)
{
// Measure the runtime using a very small number of measurements. Not accurate.
const size_t InitialMeasurementCount = 10;
const double measurement_time =
measure_runtime(
benchmark,
stopwatch,
BenchmarkSuite::Impl::measure_runtime_seconds,
InitialMeasurementCount);
// Compute the number of measurements to get an accurate runtime measure.
const size_t MaxMeasurementCount = 1000000;
const double MaxTargetTotalTime = 0.1; // seconds
return
static_cast<size_t>(std::ceil(
std::min(MaxMeasurementCount * measurement_time, MaxTargetTotalTime) / measurement_time));
}
// Measure and return the overhead (in ticks) of running an empty benchmark case.
static double measure_call_overhead_ticks(
StopwatchType& stopwatch,
const size_t measurement_count)
{
std::unique_ptr<IBenchmarkCase> empty_case(new EmptyBenchmarkCase());
return
measure_runtime(
empty_case.get(),
stopwatch,
BenchmarkSuite::Impl::measure_runtime_ticks,
measurement_count);
}
};
BenchmarkSuite::BenchmarkSuite(const char* name)
: impl(new Impl())
{
assert(name);
impl->m_name = name;
}
BenchmarkSuite::~BenchmarkSuite()
{
delete impl;
}
const char* BenchmarkSuite::get_name() const
{
return impl->m_name.c_str();
}
void BenchmarkSuite::register_case(IBenchmarkCaseFactory* factory)
{
assert(factory);
impl->m_factories.push_back(factory);
}
void BenchmarkSuite::run(BenchmarkResult& suite_result) const
{
PassThroughFilter filter;
run(filter, suite_result);
}
void BenchmarkSuite::run(
const IFilter& filter,
BenchmarkResult& suite_result) const
{
BenchmarkingThreadContext benchmarking_context;
bool has_begun_suite = false;
for (size_t i = 0; i < impl->m_factories.size(); ++i)
{
IBenchmarkCaseFactory* factory = impl->m_factories[i];
// Skip benchmark cases that aren't let through by the filter.
if (!filter.accepts(factory->get_name()))
continue;
if (!has_begun_suite)
{
// Tell the listeners that a benchmark suite is about to be executed.
suite_result.begin_suite(*this);
suite_result.signal_suite_execution();
has_begun_suite = true;
}
// Instantiate the benchmark case.
std::unique_ptr<IBenchmarkCase> benchmark(factory->create());
// Tell the listeners that a benchmark case is about to be executed.
suite_result.begin_case(*this, *benchmark.get());
#ifdef NDEBUG
try
#endif
{
suite_result.signal_case_execution();
// Recreate the stopwatch (and the underlying timer) for every benchmark
// case, since the CPU frequency will fluctuate quite a bit depending on
// the CPU load. We need an up-to-date frequency estimation in order to
// compute accurate call rates.
Impl::StopwatchType stopwatch(100000);
// Estimate benchmarking parameters.
const size_t measurement_count =
Impl::compute_measurement_count(benchmark.get(), stopwatch);
// Measure the overhead of calling IBenchmarkCase::run().
const double overhead_ticks =
Impl::measure_call_overhead_ticks(stopwatch, measurement_count);
// Run the benchmark case.
const double runtime_ticks =
Impl::measure_runtime(
benchmark.get(),
stopwatch,
BenchmarkSuite::Impl::measure_runtime_ticks,
measurement_count);
// Gather the timing results.
TimingResult timing_result;
timing_result.m_iteration_count = 1;
timing_result.m_measurement_count = measurement_count;
timing_result.m_frequency = static_cast<double>(stopwatch.get_timer().frequency());
timing_result.m_ticks = runtime_ticks > overhead_ticks ? runtime_ticks - overhead_ticks : 0.0;
// Post the timing result.
suite_result.write(
*this,
*benchmark.get(),
__FILE__,
__LINE__,
timing_result);
#ifdef GENERATE_BENCHMARK_PLOTS
std::vector<Vector2d> points;
const size_t PointCount = 100;
for (size_t j = 0; j < PointCount; ++j)
{
const double ticks =
Impl::measure_runtime(
benchmark.get(),
stopwatch,
BenchmarkSuite::Impl::measure_runtime_ticks,
std::max<size_t>(1, measurement_count / PointCount));
points.emplace_back(
static_cast<double>(j),
ticks > overhead_ticks ? ticks - overhead_ticks : 0.0);
}
const std::string filepath =
format("unit benchmarks/plots/{0}_{1}.gnuplot", get_name(), benchmark->get_name());
GnuplotFile plotfile;
plotfile.new_plot().set_points(points);
plotfile.write(filepath);
#endif
}
#ifdef NDEBUG
catch (const std::exception& e)
{
if (!is_empty_string(e.what()))
{
suite_result.write(
*this,
*benchmark.get(),
__FILE__,
__LINE__,
"an unexpected exception was caught: %s",
e.what());
}
else
{
suite_result.write(
*this,
*benchmark.get(),
__FILE__,
__LINE__,
"an unexpected exception was caught (no details available).");
}
suite_result.signal_case_failure();
}
catch (...)
{
suite_result.write(
*this,
*benchmark.get(),
__FILE__,
__LINE__,
"an unexpected exception was caught (no details available).");
suite_result.signal_case_failure();
}
#endif
// Tell the listeners that the benchmark case execution has ended.
suite_result.end_case(*this, *benchmark.get());
}
if (has_begun_suite)
{
// Report a benchmark suite failure if one or more benchmark cases failed.
if (suite_result.get_case_failure_count() > 0)
suite_result.signal_suite_failure();
// Tell the listeners that the benchmark suite execution has ended.
suite_result.end_suite(*this);
}
}
} // namespace foundation
| 11,267
| 3,167
|
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "Yoga.h"
#include "log.h"
#include <float.h>
#include <string.h>
#include <algorithm>
#include <atomic>
#include <memory>
#include "Utils.h"
#include "YGNode.h"
#include "YGNodePrint.h"
#include "Yoga-internal.h"
#include "event/event.h"
#ifdef _MSC_VER
#include <float.h>
/* define fmaxf if < VC12 */
#if _MSC_VER < 1800
__forceinline const float fmaxf(const float a, const float b) {
return (a > b) ? a : b;
}
#endif
#endif
using namespace facebook::yoga;
using detail::Log;
#ifdef ANDROID
static int YGAndroidLog(
const YGConfigRef config,
const YGNodeRef node,
YGLogLevel level,
const char* format,
va_list args);
#else
static int YGDefaultLog(
const YGConfigRef config,
const YGNodeRef node,
YGLogLevel level,
const char* format,
va_list args);
#endif
#ifdef ANDROID
#include <android/log.h>
static int YGAndroidLog(
const YGConfigRef config,
const YGNodeRef node,
YGLogLevel level,
const char* format,
va_list args) {
int androidLevel = YGLogLevelDebug;
switch (level) {
case YGLogLevelFatal:
androidLevel = ANDROID_LOG_FATAL;
break;
case YGLogLevelError:
androidLevel = ANDROID_LOG_ERROR;
break;
case YGLogLevelWarn:
androidLevel = ANDROID_LOG_WARN;
break;
case YGLogLevelInfo:
androidLevel = ANDROID_LOG_INFO;
break;
case YGLogLevelDebug:
androidLevel = ANDROID_LOG_DEBUG;
break;
case YGLogLevelVerbose:
androidLevel = ANDROID_LOG_VERBOSE;
break;
}
const int result = __android_log_vprint(androidLevel, "yoga", format, args);
return result;
}
#else
#define YG_UNUSED(x) (void) (x);
static int YGDefaultLog(
const YGConfigRef config,
const YGNodeRef node,
YGLogLevel level,
const char* format,
va_list args) {
YG_UNUSED(config);
YG_UNUSED(node);
switch (level) {
case YGLogLevelError:
case YGLogLevelFatal:
return vfprintf(stderr, format, args);
case YGLogLevelWarn:
case YGLogLevelInfo:
case YGLogLevelDebug:
case YGLogLevelVerbose:
default:
return vprintf(format, args);
}
}
#undef YG_UNUSED
#endif
static inline bool YGDoubleIsUndefined(const double value) {
return facebook::yoga::isUndefined(value);
}
YOGA_EXPORT bool YGFloatIsUndefined(const float value) {
return facebook::yoga::isUndefined(value);
}
YOGA_EXPORT void* YGNodeGetContext(YGNodeRef node) {
return node->getContext();
}
YOGA_EXPORT void YGNodeSetContext(YGNodeRef node, void* context) {
return node->setContext(context);
}
YOGA_EXPORT bool YGNodeHasMeasureFunc(YGNodeRef node) {
return node->hasMeasureFunc();
}
YOGA_EXPORT void YGNodeSetMeasureFunc(
YGNodeRef node,
YGMeasureFunc measureFunc) {
node->setMeasureFunc(measureFunc);
}
YOGA_EXPORT bool YGNodeHasBaselineFunc(YGNodeRef node) {
return node->hasBaselineFunc();
}
YOGA_EXPORT void YGNodeSetBaselineFunc(
YGNodeRef node,
YGBaselineFunc baselineFunc) {
node->setBaselineFunc(baselineFunc);
}
YOGA_EXPORT YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeRef node) {
return node->getDirtied();
}
YOGA_EXPORT void YGNodeSetDirtiedFunc(
YGNodeRef node,
YGDirtiedFunc dirtiedFunc) {
node->setDirtiedFunc(dirtiedFunc);
}
YOGA_EXPORT void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc) {
node->setPrintFunc(printFunc);
}
YOGA_EXPORT bool YGNodeGetHasNewLayout(YGNodeRef node) {
return node->getHasNewLayout();
}
YOGA_EXPORT void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled) {
config->printTree = enabled;
}
YOGA_EXPORT void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout) {
node->setHasNewLayout(hasNewLayout);
}
YOGA_EXPORT YGNodeType YGNodeGetNodeType(YGNodeRef node) {
return node->getNodeType();
}
YOGA_EXPORT void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType) {
return node->setNodeType(nodeType);
}
YOGA_EXPORT bool YGNodeIsDirty(YGNodeRef node) {
return node->isDirty();
}
YOGA_EXPORT bool YGNodeLayoutGetDidUseLegacyFlag(const YGNodeRef node) {
return node->didUseLegacyFlag();
}
YOGA_EXPORT void YGNodeMarkDirtyAndPropogateToDescendants(
const YGNodeRef node) {
return node->markDirtyAndPropogateDownwards();
}
int32_t gConfigInstanceCount = 0;
YOGA_EXPORT WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) {
const YGNodeRef node = new YGNode{config};
YGAssertWithConfig(
config, node != nullptr, "Could not allocate memory for node");
Event::publish<Event::NodeAllocation>(node, {config});
return node;
}
YOGA_EXPORT YGConfigRef YGConfigGetDefault() {
static YGConfigRef defaultConfig = YGConfigNew();
return defaultConfig;
}
YOGA_EXPORT YGNodeRef YGNodeNew(void) {
return YGNodeNewWithConfig(YGConfigGetDefault());
}
YOGA_EXPORT YGNodeRef YGNodeClone(YGNodeRef oldNode) {
YGNodeRef node = new YGNode(*oldNode);
YGAssertWithConfig(
oldNode->getConfig(),
node != nullptr,
"Could not allocate memory for node");
Event::publish<Event::NodeAllocation>(node, {node->getConfig()});
node->setOwner(nullptr);
return node;
}
static YGConfigRef YGConfigClone(const YGConfig& oldConfig) {
const YGConfigRef config = new YGConfig(oldConfig);
YGAssert(config != nullptr, "Could not allocate memory for config");
gConfigInstanceCount++;
return config;
}
static YGNodeRef YGNodeDeepClone(YGNodeRef oldNode) {
auto config = YGConfigClone(*oldNode->getConfig());
auto node = new YGNode{*oldNode, config};
node->setOwner(nullptr);
Event::publish<Event::NodeAllocation>(node, {node->getConfig()});
YGVector vec = YGVector();
vec.reserve(oldNode->getChildren().size());
YGNodeRef childNode = nullptr;
for (auto* item : oldNode->getChildren()) {
childNode = YGNodeDeepClone(item);
childNode->setOwner(node);
vec.push_back(childNode);
}
node->setChildren(vec);
return node;
}
YOGA_EXPORT void YGNodeFree(const YGNodeRef node) {
if (YGNodeRef owner = node->getOwner()) {
owner->removeChild(node);
node->setOwner(nullptr);
}
const uint32_t childCount = YGNodeGetChildCount(node);
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = YGNodeGetChild(node, i);
child->setOwner(nullptr);
}
node->clearChildren();
Event::publish<Event::NodeDeallocation>(node, {node->getConfig()});
delete node;
}
static void YGConfigFreeRecursive(const YGNodeRef root) {
if (root->getConfig() != nullptr) {
gConfigInstanceCount--;
delete root->getConfig();
}
// Delete configs recursively for childrens
for (auto* child : root->getChildren()) {
YGConfigFreeRecursive(child);
}
}
YOGA_EXPORT void YGNodeFreeRecursiveWithCleanupFunc(
const YGNodeRef root,
YGNodeCleanupFunc cleanup) {
uint32_t skipped = 0;
while (YGNodeGetChildCount(root) > skipped) {
const YGNodeRef child = YGNodeGetChild(root, skipped);
if (child->getOwner() != root) {
// Don't free shared nodes that we don't own.
skipped += 1;
} else {
YGNodeRemoveChild(root, child);
YGNodeFreeRecursive(child);
}
}
if (cleanup != nullptr) {
cleanup(root);
}
YGNodeFree(root);
}
YOGA_EXPORT void YGNodeFreeRecursive(const YGNodeRef root) {
return YGNodeFreeRecursiveWithCleanupFunc(root, nullptr);
}
YOGA_EXPORT void YGNodeReset(YGNodeRef node) {
node->reset();
}
int32_t YGConfigGetInstanceCount(void) {
return gConfigInstanceCount;
}
YOGA_EXPORT YGConfigRef YGConfigNew(void) {
#ifdef ANDROID
const YGConfigRef config = new YGConfig(YGAndroidLog);
#else
const YGConfigRef config = new YGConfig(YGDefaultLog);
#endif
gConfigInstanceCount++;
return config;
}
YOGA_EXPORT void YGConfigFree(const YGConfigRef config) {
delete config;
gConfigInstanceCount--;
}
void YGConfigCopy(const YGConfigRef dest, const YGConfigRef src) {
memcpy(dest, src, sizeof(YGConfig));
}
YOGA_EXPORT void YGNodeSetIsReferenceBaseline(
YGNodeRef node,
bool isReferenceBaseline) {
if (node->isReferenceBaseline() != isReferenceBaseline) {
node->setIsReferenceBaseline(isReferenceBaseline);
node->markDirtyAndPropogate();
}
}
YOGA_EXPORT bool YGNodeIsReferenceBaseline(YGNodeRef node) {
return node->isReferenceBaseline();
}
YOGA_EXPORT void YGNodeInsertChild(
const YGNodeRef owner,
const YGNodeRef child,
const uint32_t index) {
YGAssertWithNode(
owner,
child->getOwner() == nullptr,
"Child already has a owner, it must be removed first.");
YGAssertWithNode(
owner,
!owner->hasMeasureFunc(),
"Cannot add child: Nodes with measure functions cannot have children.");
owner->insertChild(child, index);
child->setOwner(owner);
owner->markDirtyAndPropogate();
}
YOGA_EXPORT void YGNodeSwapChild(
const YGNodeRef owner,
const YGNodeRef child,
const uint32_t index) {
owner->replaceChild(child, index);
child->setOwner(owner);
}
YOGA_EXPORT void YGNodeRemoveChild(
const YGNodeRef owner,
const YGNodeRef excludedChild) {
if (YGNodeGetChildCount(owner) == 0) {
// This is an empty set. Nothing to remove.
return;
}
// Children may be shared between parents, which is indicated by not having an
// owner. We only want to reset the child completely if it is owned
// exclusively by one node.
auto childOwner = excludedChild->getOwner();
if (owner->removeChild(excludedChild)) {
if (owner == childOwner) {
excludedChild->setLayout({}); // layout is no longer valid
excludedChild->setOwner(nullptr);
}
owner->markDirtyAndPropogate();
}
}
YOGA_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef owner) {
const uint32_t childCount = YGNodeGetChildCount(owner);
if (childCount == 0) {
// This is an empty set already. Nothing to do.
return;
}
const YGNodeRef firstChild = YGNodeGetChild(owner, 0);
if (firstChild->getOwner() == owner) {
// If the first child has this node as its owner, we assume that this child
// set is unique.
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef oldChild = YGNodeGetChild(owner, i);
oldChild->setLayout(YGNode().getLayout()); // layout is no longer valid
oldChild->setOwner(nullptr);
}
owner->clearChildren();
owner->markDirtyAndPropogate();
return;
}
// Otherwise, we are not the owner of the child set. We don't have to do
// anything to clear it.
owner->setChildren(YGVector());
owner->markDirtyAndPropogate();
}
static void YGNodeSetChildrenInternal(
YGNodeRef const owner,
const std::vector<YGNodeRef>& children) {
if (!owner) {
return;
}
if (children.size() == 0) {
if (YGNodeGetChildCount(owner) > 0) {
for (YGNodeRef const child : owner->getChildren()) {
child->setLayout(YGLayout());
child->setOwner(nullptr);
}
owner->setChildren(YGVector());
owner->markDirtyAndPropogate();
}
} else {
if (YGNodeGetChildCount(owner) > 0) {
for (YGNodeRef const oldChild : owner->getChildren()) {
// Our new children may have nodes in common with the old children. We
// don't reset these common nodes.
if (std::find(children.begin(), children.end(), oldChild) ==
children.end()) {
oldChild->setLayout(YGLayout());
oldChild->setOwner(nullptr);
}
}
}
owner->setChildren(children);
for (YGNodeRef child : children) {
child->setOwner(owner);
}
owner->markDirtyAndPropogate();
}
}
YOGA_EXPORT void YGNodeSetChildren(
const YGNodeRef owner,
const YGNodeRef c[],
const uint32_t count) {
const YGVector children = {c, c + count};
YGNodeSetChildrenInternal(owner, children);
}
YOGA_EXPORT void YGNodeSetChildren(
YGNodeRef const owner,
const std::vector<YGNodeRef>& children) {
YGNodeSetChildrenInternal(owner, children);
}
YOGA_EXPORT YGNodeRef
YGNodeGetChild(const YGNodeRef node, const uint32_t index) {
if (index < node->getChildren().size()) {
return node->getChild(index);
}
return nullptr;
}
YOGA_EXPORT uint32_t YGNodeGetChildCount(const YGNodeRef node) {
return static_cast<uint32_t>(node->getChildren().size());
}
YOGA_EXPORT YGNodeRef YGNodeGetOwner(const YGNodeRef node) {
return node->getOwner();
}
YOGA_EXPORT YGNodeRef YGNodeGetParent(const YGNodeRef node) {
return node->getOwner();
}
YOGA_EXPORT void YGNodeMarkDirty(const YGNodeRef node) {
YGAssertWithNode(
node,
node->hasMeasureFunc(),
"Only leaf nodes with custom measure functions"
"should manually mark themselves as dirty");
node->markDirtyAndPropogate();
}
YOGA_EXPORT void YGNodeCopyStyle(
const YGNodeRef dstNode,
const YGNodeRef srcNode) {
if (!(dstNode->getStyle() == srcNode->getStyle())) {
dstNode->setStyle(srcNode->getStyle());
dstNode->markDirtyAndPropogate();
}
}
YOGA_EXPORT float YGNodeStyleGetFlexGrow(const YGNodeConstRef node) {
return node->getStyle().flexGrow().isUndefined()
? kDefaultFlexGrow
: node->getStyle().flexGrow().unwrap();
}
YOGA_EXPORT float YGNodeStyleGetFlexShrink(const YGNodeConstRef node) {
return node->getStyle().flexShrink().isUndefined()
? (node->getConfig()->useWebDefaults ? kWebDefaultFlexShrink
: kDefaultFlexShrink)
: node->getStyle().flexShrink().unwrap();
}
namespace {
template <typename T, typename NeedsUpdate, typename Update>
void updateStyle(
YGNode* node,
T value,
NeedsUpdate&& needsUpdate,
Update&& update) {
if (needsUpdate(node->getStyle(), value)) {
update(node->getStyle(), value);
node->markDirtyAndPropogate();
}
}
template <typename Ref, typename T>
void updateStyle(YGNode* node, Ref (YGStyle::*prop)(), T value) {
updateStyle(
node,
value,
[prop](YGStyle& s, T x) { return (s.*prop)() != x; },
[prop](YGStyle& s, T x) { (s.*prop)() = x; });
}
template <typename Ref, typename Idx>
void updateIndexedStyleProp(
YGNode* node,
Ref (YGStyle::*prop)(),
Idx idx,
detail::CompactValue value) {
using detail::CompactValue;
updateStyle(
node,
value,
[idx, prop](YGStyle& s, CompactValue x) { return (s.*prop)()[idx] != x; },
[idx, prop](YGStyle& s, CompactValue x) { (s.*prop)()[idx] = x; });
}
} // namespace
// MSVC has trouble inferring the return type of pointer to member functions
// with const and non-const overloads, instead of preferring the non-const
// overload like clang and GCC. For the purposes of updateStyle(), we can help
// MSVC by specifying that return type explicitely. In combination with
// decltype, MSVC will prefer the non-const version.
#define MSVC_HINT(PROP) decltype(YGStyle{}.PROP())
YOGA_EXPORT void YGNodeStyleSetDirection(
const YGNodeRef node,
const YGDirection value) {
updateStyle<MSVC_HINT(direction)>(node, &YGStyle::direction, value);
}
YOGA_EXPORT YGDirection YGNodeStyleGetDirection(const YGNodeConstRef node) {
return node->getStyle().direction();
}
YOGA_EXPORT void YGNodeStyleSetFlexDirection(
const YGNodeRef node,
const YGFlexDirection flexDirection) {
updateStyle<MSVC_HINT(flexDirection)>(
node, &YGStyle::flexDirection, flexDirection);
}
YOGA_EXPORT YGFlexDirection
YGNodeStyleGetFlexDirection(const YGNodeConstRef node) {
return node->getStyle().flexDirection();
}
YOGA_EXPORT void YGNodeStyleSetJustifyContent(
const YGNodeRef node,
const YGJustify justifyContent) {
updateStyle<MSVC_HINT(justifyContent)>(
node, &YGStyle::justifyContent, justifyContent);
}
YOGA_EXPORT YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) {
return node->getStyle().justifyContent();
}
YOGA_EXPORT void YGNodeStyleSetAlignContent(
const YGNodeRef node,
const YGAlign alignContent) {
updateStyle<MSVC_HINT(alignContent)>(
node, &YGStyle::alignContent, alignContent);
}
YOGA_EXPORT YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) {
return node->getStyle().alignContent();
}
YOGA_EXPORT void YGNodeStyleSetAlignItems(
const YGNodeRef node,
const YGAlign alignItems) {
updateStyle<MSVC_HINT(alignItems)>(node, &YGStyle::alignItems, alignItems);
}
YOGA_EXPORT YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) {
return node->getStyle().alignItems();
}
YOGA_EXPORT void YGNodeStyleSetAlignSelf(
const YGNodeRef node,
const YGAlign alignSelf) {
updateStyle<MSVC_HINT(alignSelf)>(node, &YGStyle::alignSelf, alignSelf);
}
YOGA_EXPORT YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) {
return node->getStyle().alignSelf();
}
YOGA_EXPORT void YGNodeStyleSetPositionType(
const YGNodeRef node,
const YGPositionType positionType) {
updateStyle<MSVC_HINT(positionType)>(
node, &YGStyle::positionType, positionType);
}
YOGA_EXPORT YGPositionType
YGNodeStyleGetPositionType(const YGNodeConstRef node) {
return node->getStyle().positionType();
}
YOGA_EXPORT void YGNodeStyleSetFlexWrap(
const YGNodeRef node,
const YGWrap flexWrap) {
updateStyle<MSVC_HINT(flexWrap)>(node, &YGStyle::flexWrap, flexWrap);
}
YOGA_EXPORT YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) {
return node->getStyle().flexWrap();
}
YOGA_EXPORT void YGNodeStyleSetOverflow(
const YGNodeRef node,
const YGOverflow overflow) {
updateStyle<MSVC_HINT(overflow)>(node, &YGStyle::overflow, overflow);
}
YOGA_EXPORT YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) {
return node->getStyle().overflow();
}
YOGA_EXPORT void YGNodeStyleSetDisplay(
const YGNodeRef node,
const YGDisplay display) {
updateStyle<MSVC_HINT(display)>(node, &YGStyle::display, display);
}
YOGA_EXPORT YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) {
return node->getStyle().display();
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
YOGA_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
updateStyle<MSVC_HINT(flex)>(node, &YGStyle::flex, YGFloatOptional{flex});
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
YOGA_EXPORT float YGNodeStyleGetFlex(const YGNodeConstRef node) {
return node->getStyle().flex().isUndefined()
? YGUndefined
: node->getStyle().flex().unwrap();
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
YOGA_EXPORT void YGNodeStyleSetFlexGrow(
const YGNodeRef node,
const float flexGrow) {
updateStyle<MSVC_HINT(flexGrow)>(
node, &YGStyle::flexGrow, YGFloatOptional{flexGrow});
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
YOGA_EXPORT void YGNodeStyleSetFlexShrink(
const YGNodeRef node,
const float flexShrink) {
updateStyle<MSVC_HINT(flexShrink)>(
node, &YGStyle::flexShrink, YGFloatOptional{flexShrink});
}
YOGA_EXPORT YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
YGValue flexBasis = node->getStyle().flexBasis();
if (flexBasis.unit == YGUnitUndefined || flexBasis.unit == YGUnitAuto) {
// TODO(T26792433): Get rid off the use of YGUndefined at client side
flexBasis.value = YGUndefined;
}
return flexBasis;
}
YOGA_EXPORT void YGNodeStyleSetFlexBasis(
const YGNodeRef node,
const float flexBasis) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(flexBasis);
updateStyle<MSVC_HINT(flexBasis)>(node, &YGStyle::flexBasis, value);
}
YOGA_EXPORT void YGNodeStyleSetFlexBasisPercent(
const YGNodeRef node,
const float flexBasisPercent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(flexBasisPercent);
updateStyle<MSVC_HINT(flexBasis)>(node, &YGStyle::flexBasis, value);
}
YOGA_EXPORT void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
updateStyle<MSVC_HINT(flexBasis)>(
node, &YGStyle::flexBasis, detail::CompactValue::ofAuto());
}
YOGA_EXPORT void YGNodeStyleSetPosition(
YGNodeRef node,
YGEdge edge,
float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(position)>(
node, &YGStyle::position, edge, value);
}
YOGA_EXPORT void YGNodeStyleSetPositionPercent(
YGNodeRef node,
YGEdge edge,
float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(position)>(
node, &YGStyle::position, edge, value);
}
YOGA_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
return node->getStyle().position()[edge];
}
YOGA_EXPORT void YGNodeStyleSetMargin(
YGNodeRef node,
YGEdge edge,
float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(margin)>(
node, &YGStyle::margin, edge, value);
}
YOGA_EXPORT void YGNodeStyleSetMarginPercent(
YGNodeRef node,
YGEdge edge,
float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(margin)>(
node, &YGStyle::margin, edge, value);
}
YOGA_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) {
updateIndexedStyleProp<MSVC_HINT(margin)>(
node, &YGStyle::margin, edge, detail::CompactValue::ofAuto());
}
YOGA_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) {
return node->getStyle().margin()[edge];
}
YOGA_EXPORT void YGNodeStyleSetPadding(
YGNodeRef node,
YGEdge edge,
float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(padding)>(
node, &YGStyle::padding, edge, value);
}
YOGA_EXPORT void YGNodeStyleSetPaddingPercent(
YGNodeRef node,
YGEdge edge,
float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(padding)>(
node, &YGStyle::padding, edge, value);
}
YOGA_EXPORT YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) {
return node->getStyle().padding()[edge];
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
YOGA_EXPORT void YGNodeStyleSetBorder(
const YGNodeRef node,
const YGEdge edge,
const float border) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(border);
updateIndexedStyleProp<MSVC_HINT(border)>(
node, &YGStyle::border, edge, value);
}
YOGA_EXPORT float YGNodeStyleGetBorder(
const YGNodeConstRef node,
const YGEdge edge) {
auto border = node->getStyle().border()[edge];
if (border.isUndefined() || border.isAuto()) {
// TODO(T26792433): Rather than returning YGUndefined, change the api to
// return YGFloatOptional.
return YGUndefined;
}
return static_cast<YGValue>(border).value;
}
// Yoga specific properties, not compatible with flexbox specification
// TODO(T26792433): Change the API to accept YGFloatOptional.
YOGA_EXPORT float YGNodeStyleGetAspectRatio(const YGNodeConstRef node) {
const YGFloatOptional op = node->getStyle().aspectRatio();
return op.isUndefined() ? YGUndefined : op.unwrap();
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
YOGA_EXPORT void YGNodeStyleSetAspectRatio(
const YGNodeRef node,
const float aspectRatio) {
updateStyle<MSVC_HINT(aspectRatio)>(
node, &YGStyle::aspectRatio, YGFloatOptional{aspectRatio});
}
YOGA_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &YGStyle::dimensions, YGDimensionWidth, value);
}
YOGA_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &YGStyle::dimensions, YGDimensionWidth, value);
}
YOGA_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node) {
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node,
&YGStyle::dimensions,
YGDimensionWidth,
detail::CompactValue::ofAuto());
}
YOGA_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
return node->getStyle().dimensions()[YGDimensionWidth];
}
YOGA_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &YGStyle::dimensions, YGDimensionHeight, value);
}
YOGA_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &YGStyle::dimensions, YGDimensionHeight, value);
}
YOGA_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node) {
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node,
&YGStyle::dimensions,
YGDimensionHeight,
detail::CompactValue::ofAuto());
}
YOGA_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
return node->getStyle().dimensions()[YGDimensionHeight];
}
YOGA_EXPORT void YGNodeStyleSetMinWidth(
const YGNodeRef node,
const float minWidth) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(minWidth);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &YGStyle::minDimensions, YGDimensionWidth, value);
}
YOGA_EXPORT void YGNodeStyleSetMinWidthPercent(
const YGNodeRef node,
const float minWidth) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(minWidth);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &YGStyle::minDimensions, YGDimensionWidth, value);
}
YOGA_EXPORT YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
return node->getStyle().minDimensions()[YGDimensionWidth];
};
YOGA_EXPORT void YGNodeStyleSetMinHeight(
const YGNodeRef node,
const float minHeight) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(minHeight);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &YGStyle::minDimensions, YGDimensionHeight, value);
}
YOGA_EXPORT void YGNodeStyleSetMinHeightPercent(
const YGNodeRef node,
const float minHeight) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(minHeight);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &YGStyle::minDimensions, YGDimensionHeight, value);
}
YOGA_EXPORT YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
return node->getStyle().minDimensions()[YGDimensionHeight];
};
YOGA_EXPORT void YGNodeStyleSetMaxWidth(
const YGNodeRef node,
const float maxWidth) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(maxWidth);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &YGStyle::maxDimensions, YGDimensionWidth, value);
}
YOGA_EXPORT void YGNodeStyleSetMaxWidthPercent(
const YGNodeRef node,
const float maxWidth) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(maxWidth);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &YGStyle::maxDimensions, YGDimensionWidth, value);
}
YOGA_EXPORT YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
return node->getStyle().maxDimensions()[YGDimensionWidth];
};
YOGA_EXPORT void YGNodeStyleSetMaxHeight(
const YGNodeRef node,
const float maxHeight) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(maxHeight);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &YGStyle::maxDimensions, YGDimensionHeight, value);
}
YOGA_EXPORT void YGNodeStyleSetMaxHeightPercent(
const YGNodeRef node,
const float maxHeight) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(maxHeight);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &YGStyle::maxDimensions, YGDimensionHeight, value);
}
YOGA_EXPORT YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
return node->getStyle().maxDimensions()[YGDimensionHeight];
};
#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
YOGA_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node) { \
return node->getLayout().instanceName; \
}
#define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \
YOGA_EXPORT type YGNodeLayoutGet##name( \
const YGNodeRef node, const YGEdge edge) { \
YGAssertWithNode( \
node, \
edge <= YGEdgeEnd, \
"Cannot get layout properties of multi-edge shorthands"); \
\
if (edge == YGEdgeStart) { \
if (node->getLayout().direction() == YGDirectionRTL) { \
return node->getLayout().instanceName[YGEdgeRight]; \
} else { \
return node->getLayout().instanceName[YGEdgeLeft]; \
} \
} \
\
if (edge == YGEdgeEnd) { \
if (node->getLayout().direction() == YGDirectionRTL) { \
return node->getLayout().instanceName[YGEdgeLeft]; \
} else { \
return node->getLayout().instanceName[YGEdgeRight]; \
} \
} \
\
return node->getLayout().instanceName[edge]; \
}
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Left, position[YGEdgeLeft]);
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Top, position[YGEdgeTop]);
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Right, position[YGEdgeRight]);
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Bottom, position[YGEdgeBottom]);
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Width, dimensions[YGDimensionWidth]);
YG_NODE_LAYOUT_PROPERTY_IMPL(float, Height, dimensions[YGDimensionHeight]);
YG_NODE_LAYOUT_PROPERTY_IMPL(YGDirection, Direction, direction());
YG_NODE_LAYOUT_PROPERTY_IMPL(bool, HadOverflow, hadOverflow());
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Margin, margin);
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border);
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding);
YOGA_EXPORT bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(
const YGNodeRef node) {
return node->getLayout().doesLegacyStretchFlagAffectsLayout();
}
std::atomic<uint32_t> gCurrentGenerationCount(0);
bool YGLayoutNodeInternal(
const YGNodeRef node,
const float availableWidth,
const float availableHeight,
const YGDirection ownerDirection,
const YGMeasureMode widthMeasureMode,
const YGMeasureMode heightMeasureMode,
const float ownerWidth,
const float ownerHeight,
const bool performLayout,
const LayoutPassReason reason,
const YGConfigRef config,
LayoutData& layoutMarkerData,
void* const layoutContext,
const uint32_t depth,
const uint32_t generationCount);
#ifdef DEBUG
static void YGNodePrintInternal(
const YGNodeRef node,
const YGPrintOptions options) {
std::string str;
facebook::yoga::YGNodeToString(str, node, options, 0);
Log::log(node, YGLogLevelDebug, nullptr, str.c_str());
}
YOGA_EXPORT void YGNodePrint(
const YGNodeRef node,
const YGPrintOptions options) {
YGNodePrintInternal(node, options);
}
#endif
const std::array<YGEdge, 4> leading = {
{YGEdgeTop, YGEdgeBottom, YGEdgeLeft, YGEdgeRight}};
const std::array<YGEdge, 4> trailing = {
{YGEdgeBottom, YGEdgeTop, YGEdgeRight, YGEdgeLeft}};
static const std::array<YGEdge, 4> pos = {{
YGEdgeTop,
YGEdgeBottom,
YGEdgeLeft,
YGEdgeRight,
}};
static const std::array<YGDimension, 4> dim = {
{YGDimensionHeight, YGDimensionHeight, YGDimensionWidth, YGDimensionWidth}};
static inline float YGNodePaddingAndBorderForAxis(
const YGNodeConstRef node,
const YGFlexDirection axis,
const float widthSize) {
return (node->getLeadingPaddingAndBorder(axis, widthSize) +
node->getTrailingPaddingAndBorder(axis, widthSize))
.unwrap();
}
static inline YGAlign YGNodeAlignItem(const YGNode* node, const YGNode* child) {
const YGAlign align = child->getStyle().alignSelf() == YGAlignAuto
? node->getStyle().alignItems()
: child->getStyle().alignSelf();
if (align == YGAlignBaseline &&
YGFlexDirectionIsColumn(node->getStyle().flexDirection())) {
return YGAlignFlexStart;
}
return align;
}
static float YGBaseline(const YGNodeRef node, void* layoutContext) {
if (node->hasBaselineFunc()) {
Event::publish<Event::NodeBaselineStart>(node);
const float baseline = node->baseline(
node->getLayout().measuredDimensions[YGDimensionWidth],
node->getLayout().measuredDimensions[YGDimensionHeight],
layoutContext);
Event::publish<Event::NodeBaselineEnd>(node);
YGAssertWithNode(
node,
!YGFloatIsUndefined(baseline),
"Expect custom baseline function to not return NaN");
return baseline;
}
YGNodeRef baselineChild = nullptr;
const uint32_t childCount = YGNodeGetChildCount(node);
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = YGNodeGetChild(node, i);
if (child->getLineIndex() > 0) {
break;
}
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
continue;
}
if (YGNodeAlignItem(node, child) == YGAlignBaseline ||
child->isReferenceBaseline()) {
baselineChild = child;
break;
}
if (baselineChild == nullptr) {
baselineChild = child;
}
}
if (baselineChild == nullptr) {
return node->getLayout().measuredDimensions[YGDimensionHeight];
}
const float baseline = YGBaseline(baselineChild, layoutContext);
return baseline + baselineChild->getLayout().position[YGEdgeTop];
}
static bool YGIsBaselineLayout(const YGNodeRef node) {
if (YGFlexDirectionIsColumn(node->getStyle().flexDirection())) {
return false;
}
if (node->getStyle().alignItems() == YGAlignBaseline) {
return true;
}
const uint32_t childCount = YGNodeGetChildCount(node);
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = YGNodeGetChild(node, i);
if (child->getStyle().positionType() != YGPositionTypeAbsolute &&
child->getStyle().alignSelf() == YGAlignBaseline) {
return true;
}
}
return false;
}
static inline float YGNodeDimWithMargin(
const YGNodeRef node,
const YGFlexDirection axis,
const float widthSize) {
return node->getLayout().measuredDimensions[dim[axis]] +
(node->getLeadingMargin(axis, widthSize) +
node->getTrailingMargin(axis, widthSize))
.unwrap();
}
static inline bool YGNodeIsStyleDimDefined(
const YGNodeRef node,
const YGFlexDirection axis,
const float ownerSize) {
bool isUndefined =
YGFloatIsUndefined(node->getResolvedDimension(dim[axis]).value);
return !(
node->getResolvedDimension(dim[axis]).unit == YGUnitAuto ||
node->getResolvedDimension(dim[axis]).unit == YGUnitUndefined ||
(node->getResolvedDimension(dim[axis]).unit == YGUnitPoint &&
!isUndefined && node->getResolvedDimension(dim[axis]).value < 0.0f) ||
(node->getResolvedDimension(dim[axis]).unit == YGUnitPercent &&
!isUndefined &&
(node->getResolvedDimension(dim[axis]).value < 0.0f ||
YGFloatIsUndefined(ownerSize))));
}
static inline bool YGNodeIsLayoutDimDefined(
const YGNodeRef node,
const YGFlexDirection axis) {
const float value = node->getLayout().measuredDimensions[dim[axis]];
return !YGFloatIsUndefined(value) && value >= 0.0f;
}
static YGFloatOptional YGNodeBoundAxisWithinMinAndMax(
const YGNodeConstRef node,
const YGFlexDirection axis,
const YGFloatOptional value,
const float axisSize) {
YGFloatOptional min;
YGFloatOptional max;
if (YGFlexDirectionIsColumn(axis)) {
min = YGResolveValue(
node->getStyle().minDimensions()[YGDimensionHeight], axisSize);
max = YGResolveValue(
node->getStyle().maxDimensions()[YGDimensionHeight], axisSize);
} else if (YGFlexDirectionIsRow(axis)) {
min = YGResolveValue(
node->getStyle().minDimensions()[YGDimensionWidth], axisSize);
max = YGResolveValue(
node->getStyle().maxDimensions()[YGDimensionWidth], axisSize);
}
if (max >= YGFloatOptional{0} && value > max) {
return max;
}
if (min >= YGFloatOptional{0} && value < min) {
return min;
}
return value;
}
// Like YGNodeBoundAxisWithinMinAndMax but also ensures that the value doesn't
// go below the padding and border amount.
static inline float YGNodeBoundAxis(
const YGNodeRef node,
const YGFlexDirection axis,
const float value,
const float axisSize,
const float widthSize) {
return YGFloatMax(
YGNodeBoundAxisWithinMinAndMax(
node, axis, YGFloatOptional{value}, axisSize)
.unwrap(),
YGNodePaddingAndBorderForAxis(node, axis, widthSize));
}
static void YGNodeSetChildTrailingPosition(
const YGNodeRef node,
const YGNodeRef child,
const YGFlexDirection axis) {
const float size = child->getLayout().measuredDimensions[dim[axis]];
child->setLayoutPosition(
node->getLayout().measuredDimensions[dim[axis]] - size -
child->getLayout().position[pos[axis]],
trailing[axis]);
}
static void YGConstrainMaxSizeForMode(
const YGNodeConstRef node,
const enum YGFlexDirection axis,
const float ownerAxisSize,
const float ownerWidth,
YGMeasureMode* mode,
float* size) {
const YGFloatOptional maxSize =
YGResolveValue(
node->getStyle().maxDimensions()[dim[axis]], ownerAxisSize) +
YGFloatOptional(node->getMarginForAxis(axis, ownerWidth));
switch (*mode) {
case YGMeasureModeExactly:
case YGMeasureModeAtMost:
*size = (maxSize.isUndefined() || *size < maxSize.unwrap())
? *size
: maxSize.unwrap();
break;
case YGMeasureModeUndefined:
if (!maxSize.isUndefined()) {
*mode = YGMeasureModeAtMost;
*size = maxSize.unwrap();
}
break;
}
}
static void YGNodeComputeFlexBasisForChild(
const YGNodeRef node,
const YGNodeRef child,
const float width,
const YGMeasureMode widthMode,
const float height,
const float ownerWidth,
const float ownerHeight,
const YGMeasureMode heightMode,
const YGDirection direction,
const YGConfigRef config,
LayoutData& layoutMarkerData,
void* const layoutContext,
const uint32_t depth,
const uint32_t generationCount) {
const YGFlexDirection mainAxis =
YGResolveFlexDirection(node->getStyle().flexDirection(), direction);
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
const float mainAxisSize = isMainAxisRow ? width : height;
const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight;
float childWidth;
float childHeight;
YGMeasureMode childWidthMeasureMode;
YGMeasureMode childHeightMeasureMode;
const YGFloatOptional resolvedFlexBasis =
YGResolveValue(child->resolveFlexBasisPtr(), mainAxisownerSize);
const bool isRowStyleDimDefined =
YGNodeIsStyleDimDefined(child, YGFlexDirectionRow, ownerWidth);
const bool isColumnStyleDimDefined =
YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn, ownerHeight);
if (!resolvedFlexBasis.isUndefined() && !YGFloatIsUndefined(mainAxisSize)) {
if (child->getLayout().computedFlexBasis.isUndefined() ||
(YGConfigIsExperimentalFeatureEnabled(
child->getConfig(), YGExperimentalFeatureWebFlexBasis) &&
child->getLayout().computedFlexBasisGeneration != generationCount)) {
const YGFloatOptional paddingAndBorder = YGFloatOptional(
YGNodePaddingAndBorderForAxis(child, mainAxis, ownerWidth));
child->setLayoutComputedFlexBasis(
YGFloatOptionalMax(resolvedFlexBasis, paddingAndBorder));
}
} else if (isMainAxisRow && isRowStyleDimDefined) {
// The width is definite, so use that as the flex basis.
const YGFloatOptional paddingAndBorder = YGFloatOptional(
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, ownerWidth));
child->setLayoutComputedFlexBasis(YGFloatOptionalMax(
YGResolveValue(
child->getResolvedDimensions()[YGDimensionWidth], ownerWidth),
paddingAndBorder));
} else if (!isMainAxisRow && isColumnStyleDimDefined) {
// The height is definite, so use that as the flex basis.
const YGFloatOptional paddingAndBorder =
YGFloatOptional(YGNodePaddingAndBorderForAxis(
child, YGFlexDirectionColumn, ownerWidth));
child->setLayoutComputedFlexBasis(YGFloatOptionalMax(
YGResolveValue(
child->getResolvedDimensions()[YGDimensionHeight], ownerHeight),
paddingAndBorder));
} else {
// Compute the flex basis and hypothetical main size (i.e. the clamped flex
// basis).
childWidth = YGUndefined;
childHeight = YGUndefined;
childWidthMeasureMode = YGMeasureModeUndefined;
childHeightMeasureMode = YGMeasureModeUndefined;
auto marginRow =
child->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
auto marginColumn =
child->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
if (isRowStyleDimDefined) {
childWidth =
YGResolveValue(
child->getResolvedDimensions()[YGDimensionWidth], ownerWidth)
.unwrap() +
marginRow;
childWidthMeasureMode = YGMeasureModeExactly;
}
if (isColumnStyleDimDefined) {
childHeight =
YGResolveValue(
child->getResolvedDimensions()[YGDimensionHeight], ownerHeight)
.unwrap() +
marginColumn;
childHeightMeasureMode = YGMeasureModeExactly;
}
// The W3C spec doesn't say anything about the 'overflow' property, but all
// major browsers appear to implement the following logic.
if ((!isMainAxisRow && node->getStyle().overflow() == YGOverflowScroll) ||
node->getStyle().overflow() != YGOverflowScroll) {
if (YGFloatIsUndefined(childWidth) && !YGFloatIsUndefined(width)) {
childWidth = width;
childWidthMeasureMode = YGMeasureModeAtMost;
}
}
if ((isMainAxisRow && node->getStyle().overflow() == YGOverflowScroll) ||
node->getStyle().overflow() != YGOverflowScroll) {
if (YGFloatIsUndefined(childHeight) && !YGFloatIsUndefined(height)) {
childHeight = height;
childHeightMeasureMode = YGMeasureModeAtMost;
}
}
const auto& childStyle = child->getStyle();
if (!childStyle.aspectRatio().isUndefined()) {
if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) {
childHeight = marginColumn +
(childWidth - marginRow) / childStyle.aspectRatio().unwrap();
childHeightMeasureMode = YGMeasureModeExactly;
} else if (
isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) {
childWidth = marginRow +
(childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
childWidthMeasureMode = YGMeasureModeExactly;
}
}
// If child has no defined size in the cross axis and is set to stretch, set
// the cross axis to be measured exactly with the available inner width
const bool hasExactWidth =
!YGFloatIsUndefined(width) && widthMode == YGMeasureModeExactly;
const bool childWidthStretch =
YGNodeAlignItem(node, child) == YGAlignStretch &&
childWidthMeasureMode != YGMeasureModeExactly;
if (!isMainAxisRow && !isRowStyleDimDefined && hasExactWidth &&
childWidthStretch) {
childWidth = width;
childWidthMeasureMode = YGMeasureModeExactly;
if (!childStyle.aspectRatio().isUndefined()) {
childHeight =
(childWidth - marginRow) / childStyle.aspectRatio().unwrap();
childHeightMeasureMode = YGMeasureModeExactly;
}
}
const bool hasExactHeight =
!YGFloatIsUndefined(height) && heightMode == YGMeasureModeExactly;
const bool childHeightStretch =
YGNodeAlignItem(node, child) == YGAlignStretch &&
childHeightMeasureMode != YGMeasureModeExactly;
if (isMainAxisRow && !isColumnStyleDimDefined && hasExactHeight &&
childHeightStretch) {
childHeight = height;
childHeightMeasureMode = YGMeasureModeExactly;
if (!childStyle.aspectRatio().isUndefined()) {
childWidth =
(childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
childWidthMeasureMode = YGMeasureModeExactly;
}
}
YGConstrainMaxSizeForMode(
child,
YGFlexDirectionRow,
ownerWidth,
ownerWidth,
&childWidthMeasureMode,
&childWidth);
YGConstrainMaxSizeForMode(
child,
YGFlexDirectionColumn,
ownerHeight,
ownerWidth,
&childHeightMeasureMode,
&childHeight);
// Measure the child
YGLayoutNodeInternal(
child,
childWidth,
childHeight,
direction,
childWidthMeasureMode,
childHeightMeasureMode,
ownerWidth,
ownerHeight,
false,
LayoutPassReason::kMeasureChild,
config,
layoutMarkerData,
layoutContext,
depth,
generationCount);
child->setLayoutComputedFlexBasis(YGFloatOptional(YGFloatMax(
child->getLayout().measuredDimensions[dim[mainAxis]],
YGNodePaddingAndBorderForAxis(child, mainAxis, ownerWidth))));
}
child->setLayoutComputedFlexBasisGeneration(generationCount);
}
static void YGNodeAbsoluteLayoutChild(
const YGNodeRef node,
const YGNodeRef child,
const float width,
const YGMeasureMode widthMode,
const float height,
const YGDirection direction,
const YGConfigRef config,
LayoutData& layoutMarkerData,
void* const layoutContext,
const uint32_t depth,
const uint32_t generationCount) {
const YGFlexDirection mainAxis =
YGResolveFlexDirection(node->getStyle().flexDirection(), direction);
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
float childWidth = YGUndefined;
float childHeight = YGUndefined;
YGMeasureMode childWidthMeasureMode = YGMeasureModeUndefined;
YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined;
auto marginRow = child->getMarginForAxis(YGFlexDirectionRow, width).unwrap();
auto marginColumn =
child->getMarginForAxis(YGFlexDirectionColumn, width).unwrap();
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionRow, width)) {
childWidth =
YGResolveValue(child->getResolvedDimensions()[YGDimensionWidth], width)
.unwrap() +
marginRow;
} else {
// If the child doesn't have a specified width, compute the width based on
// the left/right offsets if they're defined.
if (child->isLeadingPositionDefined(YGFlexDirectionRow) &&
child->isTrailingPosDefined(YGFlexDirectionRow)) {
childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] -
(node->getLeadingBorder(YGFlexDirectionRow) +
node->getTrailingBorder(YGFlexDirectionRow)) -
(child->getLeadingPosition(YGFlexDirectionRow, width) +
child->getTrailingPosition(YGFlexDirectionRow, width))
.unwrap();
childWidth =
YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth, width, width);
}
}
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn, height)) {
childHeight = YGResolveValue(
child->getResolvedDimensions()[YGDimensionHeight], height)
.unwrap() +
marginColumn;
} else {
// If the child doesn't have a specified height, compute the height based on
// the top/bottom offsets if they're defined.
if (child->isLeadingPositionDefined(YGFlexDirectionColumn) &&
child->isTrailingPosDefined(YGFlexDirectionColumn)) {
childHeight = node->getLayout().measuredDimensions[YGDimensionHeight] -
(node->getLeadingBorder(YGFlexDirectionColumn) +
node->getTrailingBorder(YGFlexDirectionColumn)) -
(child->getLeadingPosition(YGFlexDirectionColumn, height) +
child->getTrailingPosition(YGFlexDirectionColumn, height))
.unwrap();
childHeight = YGNodeBoundAxis(
child, YGFlexDirectionColumn, childHeight, height, width);
}
}
// Exactly one dimension needs to be defined for us to be able to do aspect
// ratio calculation. One dimension being the anchor and the other being
// flexible.
const auto& childStyle = child->getStyle();
if (YGFloatIsUndefined(childWidth) ^ YGFloatIsUndefined(childHeight)) {
if (!childStyle.aspectRatio().isUndefined()) {
if (YGFloatIsUndefined(childWidth)) {
childWidth = marginRow +
(childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
} else if (YGFloatIsUndefined(childHeight)) {
childHeight = marginColumn +
(childWidth - marginRow) / childStyle.aspectRatio().unwrap();
}
}
}
// If we're still missing one or the other dimension, measure the content.
if (YGFloatIsUndefined(childWidth) || YGFloatIsUndefined(childHeight)) {
childWidthMeasureMode = YGFloatIsUndefined(childWidth)
? YGMeasureModeUndefined
: YGMeasureModeExactly;
childHeightMeasureMode = YGFloatIsUndefined(childHeight)
? YGMeasureModeUndefined
: YGMeasureModeExactly;
// If the size of the owner is defined then try to constrain the absolute
// child to that size as well. This allows text within the absolute child to
// wrap to the size of its owner. This is the same behavior as many browsers
// implement.
if (!isMainAxisRow && YGFloatIsUndefined(childWidth) &&
widthMode != YGMeasureModeUndefined && !YGFloatIsUndefined(width) &&
width > 0) {
childWidth = width;
childWidthMeasureMode = YGMeasureModeAtMost;
}
YGLayoutNodeInternal(
child,
childWidth,
childHeight,
direction,
childWidthMeasureMode,
childHeightMeasureMode,
childWidth,
childHeight,
false,
LayoutPassReason::kAbsMeasureChild,
config,
layoutMarkerData,
layoutContext,
depth,
generationCount);
childWidth = child->getLayout().measuredDimensions[YGDimensionWidth] +
child->getMarginForAxis(YGFlexDirectionRow, width).unwrap();
childHeight = child->getLayout().measuredDimensions[YGDimensionHeight] +
child->getMarginForAxis(YGFlexDirectionColumn, width).unwrap();
}
YGLayoutNodeInternal(
child,
childWidth,
childHeight,
direction,
YGMeasureModeExactly,
YGMeasureModeExactly,
childWidth,
childHeight,
true,
LayoutPassReason::kAbsLayout,
config,
layoutMarkerData,
layoutContext,
depth,
generationCount);
if (child->isTrailingPosDefined(mainAxis) &&
!child->isLeadingPositionDefined(mainAxis)) {
child->setLayoutPosition(
node->getLayout().measuredDimensions[dim[mainAxis]] -
child->getLayout().measuredDimensions[dim[mainAxis]] -
node->getTrailingBorder(mainAxis) -
child->getTrailingMargin(mainAxis, width).unwrap() -
child->getTrailingPosition(mainAxis, isMainAxisRow ? width : height)
.unwrap(),
leading[mainAxis]);
} else if (
!child->isLeadingPositionDefined(mainAxis) &&
node->getStyle().justifyContent() == YGJustifyCenter) {
child->setLayoutPosition(
(node->getLayout().measuredDimensions[dim[mainAxis]] -
child->getLayout().measuredDimensions[dim[mainAxis]]) /
2.0f,
leading[mainAxis]);
} else if (
!child->isLeadingPositionDefined(mainAxis) &&
node->getStyle().justifyContent() == YGJustifyFlexEnd) {
child->setLayoutPosition(
(node->getLayout().measuredDimensions[dim[mainAxis]] -
child->getLayout().measuredDimensions[dim[mainAxis]]),
leading[mainAxis]);
}
if (child->isTrailingPosDefined(crossAxis) &&
!child->isLeadingPositionDefined(crossAxis)) {
child->setLayoutPosition(
node->getLayout().measuredDimensions[dim[crossAxis]] -
child->getLayout().measuredDimensions[dim[crossAxis]] -
node->getTrailingBorder(crossAxis) -
child->getTrailingMargin(crossAxis, width).unwrap() -
child
->getTrailingPosition(crossAxis, isMainAxisRow ? height : width)
.unwrap(),
leading[crossAxis]);
} else if (
!child->isLeadingPositionDefined(crossAxis) &&
YGNodeAlignItem(node, child) == YGAlignCenter) {
child->setLayoutPosition(
(node->getLayout().measuredDimensions[dim[crossAxis]] -
child->getLayout().measuredDimensions[dim[crossAxis]]) /
2.0f,
leading[crossAxis]);
} else if (
!child->isLeadingPositionDefined(crossAxis) &&
((YGNodeAlignItem(node, child) == YGAlignFlexEnd) ^
(node->getStyle().flexWrap() == YGWrapWrapReverse))) {
child->setLayoutPosition(
(node->getLayout().measuredDimensions[dim[crossAxis]] -
child->getLayout().measuredDimensions[dim[crossAxis]]),
leading[crossAxis]);
}
}
static void YGNodeWithMeasureFuncSetMeasuredDimensions(
const YGNodeRef node,
float availableWidth,
float availableHeight,
const YGMeasureMode widthMeasureMode,
const YGMeasureMode heightMeasureMode,
const float ownerWidth,
const float ownerHeight,
LayoutData& layoutMarkerData,
void* const layoutContext,
const LayoutPassReason reason) {
YGAssertWithNode(
node,
node->hasMeasureFunc(),
"Expected node to have custom measure function");
if (widthMeasureMode == YGMeasureModeUndefined) {
availableWidth = YGUndefined;
}
if (heightMeasureMode == YGMeasureModeUndefined) {
availableHeight = YGUndefined;
}
const auto& padding = node->getLayout().padding;
const auto& border = node->getLayout().border;
const float paddingAndBorderAxisRow = padding[YGEdgeLeft] +
padding[YGEdgeRight] + border[YGEdgeLeft] + border[YGEdgeRight];
const float paddingAndBorderAxisColumn = padding[YGEdgeTop] +
padding[YGEdgeBottom] + border[YGEdgeTop] + border[YGEdgeBottom];
// We want to make sure we don't call measure with negative size
const float innerWidth = YGFloatIsUndefined(availableWidth)
? availableWidth
: YGFloatMax(0, availableWidth - paddingAndBorderAxisRow);
const float innerHeight = YGFloatIsUndefined(availableHeight)
? availableHeight
: YGFloatMax(0, availableHeight - paddingAndBorderAxisColumn);
if (widthMeasureMode == YGMeasureModeExactly &&
heightMeasureMode == YGMeasureModeExactly) {
// Don't bother sizing the text if both dimensions are already defined.
node->setLayoutMeasuredDimension(
YGNodeBoundAxis(
node, YGFlexDirectionRow, availableWidth, ownerWidth, ownerWidth),
YGDimensionWidth);
node->setLayoutMeasuredDimension(
YGNodeBoundAxis(
node,
YGFlexDirectionColumn,
availableHeight,
ownerHeight,
ownerWidth),
YGDimensionHeight);
} else {
Event::publish<Event::MeasureCallbackStart>(node);
// Measure the text under the current constraints.
const YGSize measuredSize = node->measure(
innerWidth,
widthMeasureMode,
innerHeight,
heightMeasureMode,
layoutContext);
layoutMarkerData.measureCallbacks += 1;
layoutMarkerData.measureCallbackReasonsCount[static_cast<size_t>(reason)] +=
1;
Event::publish<Event::MeasureCallbackEnd>(
node,
{layoutContext,
innerWidth,
widthMeasureMode,
innerHeight,
heightMeasureMode,
measuredSize.width,
measuredSize.height,
reason});
node->setLayoutMeasuredDimension(
YGNodeBoundAxis(
node,
YGFlexDirectionRow,
(widthMeasureMode == YGMeasureModeUndefined ||
widthMeasureMode == YGMeasureModeAtMost)
? measuredSize.width + paddingAndBorderAxisRow
: availableWidth,
ownerWidth,
ownerWidth),
YGDimensionWidth);
node->setLayoutMeasuredDimension(
YGNodeBoundAxis(
node,
YGFlexDirectionColumn,
(heightMeasureMode == YGMeasureModeUndefined ||
heightMeasureMode == YGMeasureModeAtMost)
? measuredSize.height + paddingAndBorderAxisColumn
: availableHeight,
ownerHeight,
ownerWidth),
YGDimensionHeight);
}
}
// For nodes with no children, use the available values if they were provided,
// or the minimum size as indicated by the padding and border sizes.
static void YGNodeEmptyContainerSetMeasuredDimensions(
const YGNodeRef node,
const float availableWidth,
const float availableHeight,
const YGMeasureMode widthMeasureMode,
const YGMeasureMode heightMeasureMode,
const float ownerWidth,
const float ownerHeight) {
const auto& padding = node->getLayout().padding;
const auto& border = node->getLayout().border;
float width = availableWidth;
if (widthMeasureMode == YGMeasureModeUndefined ||
widthMeasureMode == YGMeasureModeAtMost) {
width = padding[YGEdgeLeft] + padding[YGEdgeRight] + border[YGEdgeLeft] +
border[YGEdgeRight];
}
node->setLayoutMeasuredDimension(
YGNodeBoundAxis(node, YGFlexDirectionRow, width, ownerWidth, ownerWidth),
YGDimensionWidth);
float height = availableHeight;
if (heightMeasureMode == YGMeasureModeUndefined ||
heightMeasureMode == YGMeasureModeAtMost) {
height = padding[YGEdgeTop] + padding[YGEdgeBottom] + border[YGEdgeTop] +
border[YGEdgeBottom];
}
node->setLayoutMeasuredDimension(
YGNodeBoundAxis(
node, YGFlexDirectionColumn, height, ownerHeight, ownerWidth),
YGDimensionHeight);
}
static bool YGNodeFixedSizeSetMeasuredDimensions(
const YGNodeRef node,
const float availableWidth,
const float availableHeight,
const YGMeasureMode widthMeasureMode,
const YGMeasureMode heightMeasureMode,
const float ownerWidth,
const float ownerHeight) {
if ((!YGFloatIsUndefined(availableWidth) &&
widthMeasureMode == YGMeasureModeAtMost && availableWidth <= 0.0f) ||
(!YGFloatIsUndefined(availableHeight) &&
heightMeasureMode == YGMeasureModeAtMost && availableHeight <= 0.0f) ||
(widthMeasureMode == YGMeasureModeExactly &&
heightMeasureMode == YGMeasureModeExactly)) {
node->setLayoutMeasuredDimension(
YGNodeBoundAxis(
node,
YGFlexDirectionRow,
YGFloatIsUndefined(availableWidth) ||
(widthMeasureMode == YGMeasureModeAtMost &&
availableWidth < 0.0f)
? 0.0f
: availableWidth,
ownerWidth,
ownerWidth),
YGDimensionWidth);
node->setLayoutMeasuredDimension(
YGNodeBoundAxis(
node,
YGFlexDirectionColumn,
YGFloatIsUndefined(availableHeight) ||
(heightMeasureMode == YGMeasureModeAtMost &&
availableHeight < 0.0f)
? 0.0f
: availableHeight,
ownerHeight,
ownerWidth),
YGDimensionHeight);
return true;
}
return false;
}
static void YGZeroOutLayoutRecursivly(
const YGNodeRef node,
void* layoutContext) {
node->getLayout() = {};
node->setLayoutDimension(0, 0);
node->setLayoutDimension(0, 1);
node->setHasNewLayout(true);
node->iterChildrenAfterCloningIfNeeded(
YGZeroOutLayoutRecursivly, layoutContext);
}
static float YGNodeCalculateAvailableInnerDim(
const YGNodeConstRef node,
const YGDimension dimension,
const float availableDim,
const float paddingAndBorder,
const float ownerDim) {
float availableInnerDim = availableDim - paddingAndBorder;
// Max dimension overrides predefined dimension value; Min dimension in turn
// overrides both of the above
if (!YGFloatIsUndefined(availableInnerDim)) {
// We want to make sure our available height does not violate min and max
// constraints
const YGFloatOptional minDimensionOptional =
YGResolveValue(node->getStyle().minDimensions()[dimension], ownerDim);
const float minInnerDim = minDimensionOptional.isUndefined()
? 0.0f
: minDimensionOptional.unwrap() - paddingAndBorder;
const YGFloatOptional maxDimensionOptional =
YGResolveValue(node->getStyle().maxDimensions()[dimension], ownerDim);
const float maxInnerDim = maxDimensionOptional.isUndefined()
? FLT_MAX
: maxDimensionOptional.unwrap() - paddingAndBorder;
availableInnerDim =
YGFloatMax(YGFloatMin(availableInnerDim, maxInnerDim), minInnerDim);
}
return availableInnerDim;
}
static float YGNodeComputeFlexBasisForChildren(
const YGNodeRef node,
const float availableInnerWidth,
const float availableInnerHeight,
YGMeasureMode widthMeasureMode,
YGMeasureMode heightMeasureMode,
YGDirection direction,
YGFlexDirection mainAxis,
const YGConfigRef config,
bool performLayout,
LayoutData& layoutMarkerData,
void* const layoutContext,
const uint32_t depth,
const uint32_t generationCount) {
float totalOuterFlexBasis = 0.0f;
YGNodeRef singleFlexChild = nullptr;
const YGVector& children = node->getChildren();
YGMeasureMode measureModeMainDim =
YGFlexDirectionIsRow(mainAxis) ? widthMeasureMode : heightMeasureMode;
// If there is only one child with flexGrow + flexShrink it means we can set
// the computedFlexBasis to 0 instead of measuring and shrinking / flexing the
// child to exactly match the remaining space
if (measureModeMainDim == YGMeasureModeExactly) {
for (auto child : children) {
if (child->isNodeFlexible()) {
if (singleFlexChild != nullptr ||
YGFloatsEqual(child->resolveFlexGrow(), 0.0f) ||
YGFloatsEqual(child->resolveFlexShrink(), 0.0f)) {
// There is already a flexible child, or this flexible child doesn't
// have flexGrow and flexShrink, abort
singleFlexChild = nullptr;
break;
} else {
singleFlexChild = child;
}
}
}
}
for (auto child : children) {
child->resolveDimension();
if (child->getStyle().display() == YGDisplayNone) {
YGZeroOutLayoutRecursivly(child, layoutContext);
child->setHasNewLayout(true);
child->setDirty(false);
continue;
}
if (performLayout) {
// Set the initial position (relative to the owner).
const YGDirection childDirection = child->resolveDirection(direction);
const float mainDim = YGFlexDirectionIsRow(mainAxis)
? availableInnerWidth
: availableInnerHeight;
const float crossDim = YGFlexDirectionIsRow(mainAxis)
? availableInnerHeight
: availableInnerWidth;
child->setPosition(
childDirection, mainDim, crossDim, availableInnerWidth);
}
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
continue;
}
if (child == singleFlexChild) {
child->setLayoutComputedFlexBasisGeneration(generationCount);
child->setLayoutComputedFlexBasis(YGFloatOptional(0));
} else {
YGNodeComputeFlexBasisForChild(
node,
child,
availableInnerWidth,
widthMeasureMode,
availableInnerHeight,
availableInnerWidth,
availableInnerHeight,
heightMeasureMode,
direction,
config,
layoutMarkerData,
layoutContext,
depth,
generationCount);
}
totalOuterFlexBasis +=
(child->getLayout().computedFlexBasis +
child->getMarginForAxis(mainAxis, availableInnerWidth))
.unwrap();
}
return totalOuterFlexBasis;
}
// This function assumes that all the children of node have their
// computedFlexBasis properly computed(To do this use
// YGNodeComputeFlexBasisForChildren function). This function calculates
// YGCollectFlexItemsRowMeasurement
static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues(
const YGNodeRef& node,
const YGDirection ownerDirection,
const float mainAxisownerSize,
const float availableInnerWidth,
const float availableInnerMainDim,
const uint32_t startOfLineIndex,
const uint32_t lineCount) {
YGCollectFlexItemsRowValues flexAlgoRowMeasurement = {};
flexAlgoRowMeasurement.relativeChildren.reserve(node->getChildren().size());
float sizeConsumedOnCurrentLineIncludingMinConstraint = 0;
const YGFlexDirection mainAxis = YGResolveFlexDirection(
node->getStyle().flexDirection(), node->resolveDirection(ownerDirection));
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
// Add items to the current line until it's full or we run out of items.
uint32_t endOfLineIndex = startOfLineIndex;
for (; endOfLineIndex < node->getChildren().size(); endOfLineIndex++) {
const YGNodeRef child = node->getChild(endOfLineIndex);
if (child->getStyle().display() == YGDisplayNone ||
child->getStyle().positionType() == YGPositionTypeAbsolute) {
continue;
}
child->setLineIndex(lineCount);
const float childMarginMainAxis =
child->getMarginForAxis(mainAxis, availableInnerWidth).unwrap();
const float flexBasisWithMinAndMaxConstraints =
YGNodeBoundAxisWithinMinAndMax(
child,
mainAxis,
child->getLayout().computedFlexBasis,
mainAxisownerSize)
.unwrap();
// If this is a multi-line flow and this item pushes us over the available
// size, we've hit the end of the current line. Break out of the loop and
// lay out the current line.
if (sizeConsumedOnCurrentLineIncludingMinConstraint +
flexBasisWithMinAndMaxConstraints + childMarginMainAxis >
availableInnerMainDim &&
isNodeFlexWrap && flexAlgoRowMeasurement.itemsOnLine > 0) {
break;
}
sizeConsumedOnCurrentLineIncludingMinConstraint +=
flexBasisWithMinAndMaxConstraints + childMarginMainAxis;
flexAlgoRowMeasurement.sizeConsumedOnCurrentLine +=
flexBasisWithMinAndMaxConstraints + childMarginMainAxis;
flexAlgoRowMeasurement.itemsOnLine++;
if (child->isNodeFlexible()) {
flexAlgoRowMeasurement.totalFlexGrowFactors += child->resolveFlexGrow();
// Unlike the grow factor, the shrink factor is scaled relative to the
// child dimension.
flexAlgoRowMeasurement.totalFlexShrinkScaledFactors +=
-child->resolveFlexShrink() *
child->getLayout().computedFlexBasis.unwrap();
}
flexAlgoRowMeasurement.relativeChildren.push_back(child);
}
// The total flex factor needs to be floored to 1.
if (flexAlgoRowMeasurement.totalFlexGrowFactors > 0 &&
flexAlgoRowMeasurement.totalFlexGrowFactors < 1) {
flexAlgoRowMeasurement.totalFlexGrowFactors = 1;
}
// The total flex shrink factor needs to be floored to 1.
if (flexAlgoRowMeasurement.totalFlexShrinkScaledFactors > 0 &&
flexAlgoRowMeasurement.totalFlexShrinkScaledFactors < 1) {
flexAlgoRowMeasurement.totalFlexShrinkScaledFactors = 1;
}
flexAlgoRowMeasurement.endOfLineIndex = endOfLineIndex;
return flexAlgoRowMeasurement;
}
// It distributes the free space to the flexible items and ensures that the size
// of the flex items abide the min and max constraints. At the end of this
// function the child nodes would have proper size. Prior using this function
// please ensure that YGDistributeFreeSpaceFirstPass is called.
static float YGDistributeFreeSpaceSecondPass(
YGCollectFlexItemsRowValues& collectedFlexItemsValues,
const YGNodeRef node,
const YGFlexDirection mainAxis,
const YGFlexDirection crossAxis,
const float mainAxisownerSize,
const float availableInnerMainDim,
const float availableInnerCrossDim,
const float availableInnerWidth,
const float availableInnerHeight,
const bool flexBasisOverflows,
const YGMeasureMode measureModeCrossDim,
const bool performLayout,
const YGConfigRef config,
LayoutData& layoutMarkerData,
void* const layoutContext,
const uint32_t depth,
const uint32_t generationCount) {
float childFlexBasis = 0;
float flexShrinkScaledFactor = 0;
float flexGrowFactor = 0;
float deltaFreeSpace = 0;
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) {
childFlexBasis = YGNodeBoundAxisWithinMinAndMax(
currentRelativeChild,
mainAxis,
currentRelativeChild->getLayout().computedFlexBasis,
mainAxisownerSize)
.unwrap();
float updatedMainSize = childFlexBasis;
if (!YGFloatIsUndefined(collectedFlexItemsValues.remainingFreeSpace) &&
collectedFlexItemsValues.remainingFreeSpace < 0) {
flexShrinkScaledFactor =
-currentRelativeChild->resolveFlexShrink() * childFlexBasis;
// Is this child able to shrink?
if (flexShrinkScaledFactor != 0) {
float childSize;
if (!YGFloatIsUndefined(
collectedFlexItemsValues.totalFlexShrinkScaledFactors) &&
collectedFlexItemsValues.totalFlexShrinkScaledFactors == 0) {
childSize = childFlexBasis + flexShrinkScaledFactor;
} else {
childSize = childFlexBasis +
(collectedFlexItemsValues.remainingFreeSpace /
collectedFlexItemsValues.totalFlexShrinkScaledFactors) *
flexShrinkScaledFactor;
}
updatedMainSize = YGNodeBoundAxis(
currentRelativeChild,
mainAxis,
childSize,
availableInnerMainDim,
availableInnerWidth);
}
} else if (
!YGFloatIsUndefined(collectedFlexItemsValues.remainingFreeSpace) &&
collectedFlexItemsValues.remainingFreeSpace > 0) {
flexGrowFactor = currentRelativeChild->resolveFlexGrow();
// Is this child able to grow?
if (!YGFloatIsUndefined(flexGrowFactor) && flexGrowFactor != 0) {
updatedMainSize = YGNodeBoundAxis(
currentRelativeChild,
mainAxis,
childFlexBasis +
collectedFlexItemsValues.remainingFreeSpace /
collectedFlexItemsValues.totalFlexGrowFactors *
flexGrowFactor,
availableInnerMainDim,
availableInnerWidth);
}
}
deltaFreeSpace += updatedMainSize - childFlexBasis;
const float marginMain =
currentRelativeChild->getMarginForAxis(mainAxis, availableInnerWidth)
.unwrap();
const float marginCross =
currentRelativeChild->getMarginForAxis(crossAxis, availableInnerWidth)
.unwrap();
float childCrossSize;
float childMainSize = updatedMainSize + marginMain;
YGMeasureMode childCrossMeasureMode;
YGMeasureMode childMainMeasureMode = YGMeasureModeExactly;
const auto& childStyle = currentRelativeChild->getStyle();
if (!childStyle.aspectRatio().isUndefined()) {
childCrossSize = isMainAxisRow
? (childMainSize - marginMain) / childStyle.aspectRatio().unwrap()
: (childMainSize - marginMain) * childStyle.aspectRatio().unwrap();
childCrossMeasureMode = YGMeasureModeExactly;
childCrossSize += marginCross;
} else if (
!YGFloatIsUndefined(availableInnerCrossDim) &&
!YGNodeIsStyleDimDefined(
currentRelativeChild, crossAxis, availableInnerCrossDim) &&
measureModeCrossDim == YGMeasureModeExactly &&
!(isNodeFlexWrap && flexBasisOverflows) &&
YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch &&
currentRelativeChild->marginLeadingValue(crossAxis).unit !=
YGUnitAuto &&
currentRelativeChild->marginTrailingValue(crossAxis).unit !=
YGUnitAuto) {
childCrossSize = availableInnerCrossDim;
childCrossMeasureMode = YGMeasureModeExactly;
} else if (!YGNodeIsStyleDimDefined(
currentRelativeChild, crossAxis, availableInnerCrossDim)) {
childCrossSize = availableInnerCrossDim;
childCrossMeasureMode = YGFloatIsUndefined(childCrossSize)
? YGMeasureModeUndefined
: YGMeasureModeAtMost;
} else {
childCrossSize =
YGResolveValue(
currentRelativeChild->getResolvedDimension(dim[crossAxis]),
availableInnerCrossDim)
.unwrap() +
marginCross;
const bool isLoosePercentageMeasurement =
currentRelativeChild->getResolvedDimension(dim[crossAxis]).unit ==
YGUnitPercent &&
measureModeCrossDim != YGMeasureModeExactly;
childCrossMeasureMode =
YGFloatIsUndefined(childCrossSize) || isLoosePercentageMeasurement
? YGMeasureModeUndefined
: YGMeasureModeExactly;
}
YGConstrainMaxSizeForMode(
currentRelativeChild,
mainAxis,
availableInnerMainDim,
availableInnerWidth,
&childMainMeasureMode,
&childMainSize);
YGConstrainMaxSizeForMode(
currentRelativeChild,
crossAxis,
availableInnerCrossDim,
availableInnerWidth,
&childCrossMeasureMode,
&childCrossSize);
const bool requiresStretchLayout =
!YGNodeIsStyleDimDefined(
currentRelativeChild, crossAxis, availableInnerCrossDim) &&
YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch &&
currentRelativeChild->marginLeadingValue(crossAxis).unit !=
YGUnitAuto &&
currentRelativeChild->marginTrailingValue(crossAxis).unit != YGUnitAuto;
const float childWidth = isMainAxisRow ? childMainSize : childCrossSize;
const float childHeight = !isMainAxisRow ? childMainSize : childCrossSize;
const YGMeasureMode childWidthMeasureMode =
isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode;
const YGMeasureMode childHeightMeasureMode =
!isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode;
const bool isLayoutPass = performLayout && !requiresStretchLayout;
// Recursively call the layout algorithm for this child with the updated
// main size.
YGLayoutNodeInternal(
currentRelativeChild,
childWidth,
childHeight,
node->getLayout().direction(),
childWidthMeasureMode,
childHeightMeasureMode,
availableInnerWidth,
availableInnerHeight,
isLayoutPass,
isLayoutPass ? LayoutPassReason::kFlexLayout
: LayoutPassReason::kFlexMeasure,
config,
layoutMarkerData,
layoutContext,
depth,
generationCount);
node->setLayoutHadOverflow(
node->getLayout().hadOverflow() |
currentRelativeChild->getLayout().hadOverflow());
}
return deltaFreeSpace;
}
// It distributes the free space to the flexible items.For those flexible items
// whose min and max constraints are triggered, those flex item's clamped size
// is removed from the remaingfreespace.
static void YGDistributeFreeSpaceFirstPass(
YGCollectFlexItemsRowValues& collectedFlexItemsValues,
const YGFlexDirection mainAxis,
const float mainAxisownerSize,
const float availableInnerMainDim,
const float availableInnerWidth) {
float flexShrinkScaledFactor = 0;
float flexGrowFactor = 0;
float baseMainSize = 0;
float boundMainSize = 0;
float deltaFreeSpace = 0;
for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) {
float childFlexBasis =
YGNodeBoundAxisWithinMinAndMax(
currentRelativeChild,
mainAxis,
currentRelativeChild->getLayout().computedFlexBasis,
mainAxisownerSize)
.unwrap();
if (collectedFlexItemsValues.remainingFreeSpace < 0) {
flexShrinkScaledFactor =
-currentRelativeChild->resolveFlexShrink() * childFlexBasis;
// Is this child able to shrink?
if (!YGFloatIsUndefined(flexShrinkScaledFactor) &&
flexShrinkScaledFactor != 0) {
baseMainSize = childFlexBasis +
collectedFlexItemsValues.remainingFreeSpace /
collectedFlexItemsValues.totalFlexShrinkScaledFactors *
flexShrinkScaledFactor;
boundMainSize = YGNodeBoundAxis(
currentRelativeChild,
mainAxis,
baseMainSize,
availableInnerMainDim,
availableInnerWidth);
if (!YGFloatIsUndefined(baseMainSize) &&
!YGFloatIsUndefined(boundMainSize) &&
baseMainSize != boundMainSize) {
// By excluding this item's size and flex factor from remaining, this
// item's min/max constraints should also trigger in the second pass
// resulting in the item's size calculation being identical in the
// first and second passes.
deltaFreeSpace += boundMainSize - childFlexBasis;
collectedFlexItemsValues.totalFlexShrinkScaledFactors -=
(-currentRelativeChild->resolveFlexShrink() *
currentRelativeChild->getLayout().computedFlexBasis.unwrap());
}
}
} else if (
!YGFloatIsUndefined(collectedFlexItemsValues.remainingFreeSpace) &&
collectedFlexItemsValues.remainingFreeSpace > 0) {
flexGrowFactor = currentRelativeChild->resolveFlexGrow();
// Is this child able to grow?
if (!YGFloatIsUndefined(flexGrowFactor) && flexGrowFactor != 0) {
baseMainSize = childFlexBasis +
collectedFlexItemsValues.remainingFreeSpace /
collectedFlexItemsValues.totalFlexGrowFactors * flexGrowFactor;
boundMainSize = YGNodeBoundAxis(
currentRelativeChild,
mainAxis,
baseMainSize,
availableInnerMainDim,
availableInnerWidth);
if (!YGFloatIsUndefined(baseMainSize) &&
!YGFloatIsUndefined(boundMainSize) &&
baseMainSize != boundMainSize) {
// By excluding this item's size and flex factor from remaining, this
// item's min/max constraints should also trigger in the second pass
// resulting in the item's size calculation being identical in the
// first and second passes.
deltaFreeSpace += boundMainSize - childFlexBasis;
collectedFlexItemsValues.totalFlexGrowFactors -= flexGrowFactor;
}
}
}
}
collectedFlexItemsValues.remainingFreeSpace -= deltaFreeSpace;
}
// Do two passes over the flex items to figure out how to distribute the
// remaining space.
//
// The first pass finds the items whose min/max constraints trigger, freezes
// them at those sizes, and excludes those sizes from the remaining space.
//
// The second pass sets the size of each flexible item. It distributes the
// remaining space amongst the items whose min/max constraints didn't trigger in
// the first pass. For the other items, it sets their sizes by forcing their
// min/max constraints to trigger again.
//
// This two pass approach for resolving min/max constraints deviates from the
// spec. The spec
// (https://www.w3.org/TR/CSS-flexbox-1/#resolve-flexible-lengths) describes a
// process that needs to be repeated a variable number of times. The algorithm
// implemented here won't handle all cases but it was simpler to implement and
// it mitigates performance concerns because we know exactly how many passes
// it'll do.
//
// At the end of this function the child nodes would have the proper size
// assigned to them.
//
static void YGResolveFlexibleLength(
const YGNodeRef node,
YGCollectFlexItemsRowValues& collectedFlexItemsValues,
const YGFlexDirection mainAxis,
const YGFlexDirection crossAxis,
const float mainAxisownerSize,
const float availableInnerMainDim,
const float availableInnerCrossDim,
const float availableInnerWidth,
const float availableInnerHeight,
const bool flexBasisOverflows,
const YGMeasureMode measureModeCrossDim,
const bool performLayout,
const YGConfigRef config,
LayoutData& layoutMarkerData,
void* const layoutContext,
const uint32_t depth,
const uint32_t generationCount) {
const float originalFreeSpace = collectedFlexItemsValues.remainingFreeSpace;
// First pass: detect the flex items whose min/max constraints trigger
YGDistributeFreeSpaceFirstPass(
collectedFlexItemsValues,
mainAxis,
mainAxisownerSize,
availableInnerMainDim,
availableInnerWidth);
// Second pass: resolve the sizes of the flexible items
const float distributedFreeSpace = YGDistributeFreeSpaceSecondPass(
collectedFlexItemsValues,
node,
mainAxis,
crossAxis,
mainAxisownerSize,
availableInnerMainDim,
availableInnerCrossDim,
availableInnerWidth,
availableInnerHeight,
flexBasisOverflows,
measureModeCrossDim,
performLayout,
config,
layoutMarkerData,
layoutContext,
depth,
generationCount);
collectedFlexItemsValues.remainingFreeSpace =
originalFreeSpace - distributedFreeSpace;
}
static void YGJustifyMainAxis(
const YGNodeRef node,
YGCollectFlexItemsRowValues& collectedFlexItemsValues,
const uint32_t startOfLineIndex,
const YGFlexDirection mainAxis,
const YGFlexDirection crossAxis,
const YGMeasureMode measureModeMainDim,
const YGMeasureMode measureModeCrossDim,
const float mainAxisownerSize,
const float ownerWidth,
const float availableInnerMainDim,
const float availableInnerCrossDim,
const float availableInnerWidth,
const bool performLayout,
void* const layoutContext) {
const auto& style = node->getStyle();
const float leadingPaddingAndBorderMain =
node->getLeadingPaddingAndBorder(mainAxis, ownerWidth).unwrap();
const float trailingPaddingAndBorderMain =
node->getTrailingPaddingAndBorder(mainAxis, ownerWidth).unwrap();
// If we are using "at most" rules in the main axis, make sure that
// remainingFreeSpace is 0 when min main dimension is not given
if (measureModeMainDim == YGMeasureModeAtMost &&
collectedFlexItemsValues.remainingFreeSpace > 0) {
if (!style.minDimensions()[dim[mainAxis]].isUndefined() &&
!YGResolveValue(style.minDimensions()[dim[mainAxis]], mainAxisownerSize)
.isUndefined()) {
// This condition makes sure that if the size of main dimension(after
// considering child nodes main dim, leading and trailing padding etc)
// falls below min dimension, then the remainingFreeSpace is reassigned
// considering the min dimension
// `minAvailableMainDim` denotes minimum available space in which child
// can be laid out, it will exclude space consumed by padding and border.
const float minAvailableMainDim =
YGResolveValue(
style.minDimensions()[dim[mainAxis]], mainAxisownerSize)
.unwrap() -
leadingPaddingAndBorderMain - trailingPaddingAndBorderMain;
const float occupiedSpaceByChildNodes =
availableInnerMainDim - collectedFlexItemsValues.remainingFreeSpace;
collectedFlexItemsValues.remainingFreeSpace =
YGFloatMax(0, minAvailableMainDim - occupiedSpaceByChildNodes);
} else {
collectedFlexItemsValues.remainingFreeSpace = 0;
}
}
int numberOfAutoMarginsOnCurrentLine = 0;
for (uint32_t i = startOfLineIndex;
i < collectedFlexItemsValues.endOfLineIndex;
i++) {
const YGNodeRef child = node->getChild(i);
if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
numberOfAutoMarginsOnCurrentLine++;
}
if (child->marginTrailingValue(mainAxis).unit == YGUnitAuto) {
numberOfAutoMarginsOnCurrentLine++;
}
}
}
// In order to position the elements in the main axis, we have two controls.
// The space between the beginning and the first element and the space between
// each two elements.
float leadingMainDim = 0;
float betweenMainDim = 0;
const YGJustify justifyContent = node->getStyle().justifyContent();
if (numberOfAutoMarginsOnCurrentLine == 0) {
switch (justifyContent) {
case YGJustifyCenter:
leadingMainDim = collectedFlexItemsValues.remainingFreeSpace / 2;
break;
case YGJustifyFlexEnd:
leadingMainDim = collectedFlexItemsValues.remainingFreeSpace;
break;
case YGJustifySpaceBetween:
if (collectedFlexItemsValues.itemsOnLine > 1) {
betweenMainDim =
YGFloatMax(collectedFlexItemsValues.remainingFreeSpace, 0) /
(collectedFlexItemsValues.itemsOnLine - 1);
} else {
betweenMainDim = 0;
}
break;
case YGJustifySpaceEvenly:
// Space is distributed evenly across all elements
betweenMainDim = collectedFlexItemsValues.remainingFreeSpace /
(collectedFlexItemsValues.itemsOnLine + 1);
leadingMainDim = betweenMainDim;
break;
case YGJustifySpaceAround:
// Space on the edges is half of the space between elements
betweenMainDim = collectedFlexItemsValues.remainingFreeSpace /
collectedFlexItemsValues.itemsOnLine;
leadingMainDim = betweenMainDim / 2;
break;
case YGJustifyFlexStart:
break;
}
}
collectedFlexItemsValues.mainDim =
leadingPaddingAndBorderMain + leadingMainDim;
collectedFlexItemsValues.crossDim = 0;
float maxAscentForCurrentLine = 0;
float maxDescentForCurrentLine = 0;
bool isNodeBaselineLayout = YGIsBaselineLayout(node);
for (uint32_t i = startOfLineIndex;
i < collectedFlexItemsValues.endOfLineIndex;
i++) {
const YGNodeRef child = node->getChild(i);
const YGStyle& childStyle = child->getStyle();
const YGLayout childLayout = child->getLayout();
if (childStyle.display() == YGDisplayNone) {
continue;
}
if (childStyle.positionType() == YGPositionTypeAbsolute &&
child->isLeadingPositionDefined(mainAxis)) {
if (performLayout) {
// In case the child is position absolute and has left/top being
// defined, we override the position to whatever the user said (and
// margin/border).
child->setLayoutPosition(
child->getLeadingPosition(mainAxis, availableInnerMainDim)
.unwrap() +
node->getLeadingBorder(mainAxis) +
child->getLeadingMargin(mainAxis, availableInnerWidth).unwrap(),
pos[mainAxis]);
}
} else {
// Now that we placed the element, we need to update the variables.
// We need to do that only for relative elements. Absolute elements do not
// take part in that phase.
if (childStyle.positionType() != YGPositionTypeAbsolute) {
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
collectedFlexItemsValues.mainDim +=
collectedFlexItemsValues.remainingFreeSpace /
numberOfAutoMarginsOnCurrentLine;
}
if (performLayout) {
child->setLayoutPosition(
childLayout.position[pos[mainAxis]] +
collectedFlexItemsValues.mainDim,
pos[mainAxis]);
}
if (child->marginTrailingValue(mainAxis).unit == YGUnitAuto) {
collectedFlexItemsValues.mainDim +=
collectedFlexItemsValues.remainingFreeSpace /
numberOfAutoMarginsOnCurrentLine;
}
bool canSkipFlex =
!performLayout && measureModeCrossDim == YGMeasureModeExactly;
if (canSkipFlex) {
// If we skipped the flex step, then we can't rely on the measuredDims
// because they weren't computed. This means we can't call
// YGNodeDimWithMargin.
collectedFlexItemsValues.mainDim += betweenMainDim +
child->getMarginForAxis(mainAxis, availableInnerWidth).unwrap() +
childLayout.computedFlexBasis.unwrap();
collectedFlexItemsValues.crossDim = availableInnerCrossDim;
} else {
// The main dimension is the sum of all the elements dimension plus
// the spacing.
collectedFlexItemsValues.mainDim += betweenMainDim +
YGNodeDimWithMargin(child, mainAxis, availableInnerWidth);
if (isNodeBaselineLayout) {
// If the child is baseline aligned then the cross dimension is
// calculated by adding maxAscent and maxDescent from the baseline.
const float ascent = YGBaseline(child, layoutContext) +
child
->getLeadingMargin(
YGFlexDirectionColumn, availableInnerWidth)
.unwrap();
const float descent =
child->getLayout().measuredDimensions[YGDimensionHeight] +
child
->getMarginForAxis(
YGFlexDirectionColumn, availableInnerWidth)
.unwrap() -
ascent;
maxAscentForCurrentLine =
YGFloatMax(maxAscentForCurrentLine, ascent);
maxDescentForCurrentLine =
YGFloatMax(maxDescentForCurrentLine, descent);
} else {
// The cross dimension is the max of the elements dimension since
// there can only be one element in that cross dimension in the case
// when the items are not baseline aligned
collectedFlexItemsValues.crossDim = YGFloatMax(
collectedFlexItemsValues.crossDim,
YGNodeDimWithMargin(child, crossAxis, availableInnerWidth));
}
}
} else if (performLayout) {
child->setLayoutPosition(
childLayout.position[pos[mainAxis]] +
node->getLeadingBorder(mainAxis) + leadingMainDim,
pos[mainAxis]);
}
}
}
collectedFlexItemsValues.mainDim += trailingPaddingAndBorderMain;
if (isNodeBaselineLayout) {
collectedFlexItemsValues.crossDim =
maxAscentForCurrentLine + maxDescentForCurrentLine;
}
}
//
// This is the main routine that implements a subset of the flexbox layout
// algorithm described in the W3C CSS documentation:
// https://www.w3.org/TR/CSS3-flexbox/.
//
// Limitations of this algorithm, compared to the full standard:
// * Display property is always assumed to be 'flex' except for Text nodes,
// which are assumed to be 'inline-flex'.
// * The 'zIndex' property (or any form of z ordering) is not supported. Nodes
// are stacked in document order.
// * The 'order' property is not supported. The order of flex items is always
// defined by document order.
// * The 'visibility' property is always assumed to be 'visible'. Values of
// 'collapse' and 'hidden' are not supported.
// * There is no support for forced breaks.
// * It does not support vertical inline directions (top-to-bottom or
// bottom-to-top text).
//
// Deviations from standard:
// * Section 4.5 of the spec indicates that all flex items have a default
// minimum main size. For text blocks, for example, this is the width of the
// widest word. Calculating the minimum width is expensive, so we forego it
// and assume a default minimum main size of 0.
// * Min/Max sizes in the main axis are not honored when resolving flexible
// lengths.
// * The spec indicates that the default value for 'flexDirection' is 'row',
// but the algorithm below assumes a default of 'column'.
//
// Input parameters:
// - node: current node to be sized and layed out
// - availableWidth & availableHeight: available size to be used for sizing
// the node or YGUndefined if the size is not available; interpretation
// depends on layout flags
// - ownerDirection: the inline (text) direction within the owner
// (left-to-right or right-to-left)
// - widthMeasureMode: indicates the sizing rules for the width (see below
// for explanation)
// - heightMeasureMode: indicates the sizing rules for the height (see below
// for explanation)
// - performLayout: specifies whether the caller is interested in just the
// dimensions of the node or it requires the entire node and its subtree to
// be layed out (with final positions)
//
// Details:
// This routine is called recursively to lay out subtrees of flexbox
// elements. It uses the information in node.style, which is treated as a
// read-only input. It is responsible for setting the layout.direction and
// layout.measuredDimensions fields for the input node as well as the
// layout.position and layout.lineIndex fields for its child nodes. The
// layout.measuredDimensions field includes any border or padding for the
// node but does not include margins.
//
// The spec describes four different layout modes: "fill available", "max
// content", "min content", and "fit content". Of these, we don't use "min
// content" because we don't support default minimum main sizes (see above
// for details). Each of our measure modes maps to a layout mode from the
// spec (https://www.w3.org/TR/CSS3-sizing/#terms):
// - YGMeasureModeUndefined: max content
// - YGMeasureModeExactly: fill available
// - YGMeasureModeAtMost: fit content
//
// When calling YGNodelayoutImpl and YGLayoutNodeInternal, if the caller
// passes an available size of undefined then it must also pass a measure
// mode of YGMeasureModeUndefined in that dimension.
//
static void YGNodelayoutImpl(
const YGNodeRef node,
const float availableWidth,
const float availableHeight,
const YGDirection ownerDirection,
const YGMeasureMode widthMeasureMode,
const YGMeasureMode heightMeasureMode,
const float ownerWidth,
const float ownerHeight,
const bool performLayout,
const YGConfigRef config,
LayoutData& layoutMarkerData,
void* const layoutContext,
const uint32_t depth,
const uint32_t generationCount,
const LayoutPassReason reason) {
YGAssertWithNode(
node,
YGFloatIsUndefined(availableWidth)
? widthMeasureMode == YGMeasureModeUndefined
: true,
"availableWidth is indefinite so widthMeasureMode must be "
"YGMeasureModeUndefined");
YGAssertWithNode(
node,
YGFloatIsUndefined(availableHeight)
? heightMeasureMode == YGMeasureModeUndefined
: true,
"availableHeight is indefinite so heightMeasureMode must be "
"YGMeasureModeUndefined");
(performLayout ? layoutMarkerData.layouts : layoutMarkerData.measures) += 1;
// Set the resolved resolution in the node's layout.
const YGDirection direction = node->resolveDirection(ownerDirection);
node->setLayoutDirection(direction);
const YGFlexDirection flexRowDirection =
YGResolveFlexDirection(YGFlexDirectionRow, direction);
const YGFlexDirection flexColumnDirection =
YGResolveFlexDirection(YGFlexDirectionColumn, direction);
const YGEdge startEdge =
direction == YGDirectionLTR ? YGEdgeLeft : YGEdgeRight;
const YGEdge endEdge = direction == YGDirectionLTR ? YGEdgeRight : YGEdgeLeft;
const float marginRowLeading =
node->getLeadingMargin(flexRowDirection, ownerWidth).unwrap();
node->setLayoutMargin(marginRowLeading, startEdge);
const float marginRowTrailing =
node->getTrailingMargin(flexRowDirection, ownerWidth).unwrap();
node->setLayoutMargin(marginRowTrailing, endEdge);
const float marginColumnLeading =
node->getLeadingMargin(flexColumnDirection, ownerWidth).unwrap();
node->setLayoutMargin(marginColumnLeading, YGEdgeTop);
const float marginColumnTrailing =
node->getTrailingMargin(flexColumnDirection, ownerWidth).unwrap();
node->setLayoutMargin(marginColumnTrailing, YGEdgeBottom);
const float marginAxisRow = marginRowLeading + marginRowTrailing;
const float marginAxisColumn = marginColumnLeading + marginColumnTrailing;
node->setLayoutBorder(node->getLeadingBorder(flexRowDirection), startEdge);
node->setLayoutBorder(node->getTrailingBorder(flexRowDirection), endEdge);
node->setLayoutBorder(node->getLeadingBorder(flexColumnDirection), YGEdgeTop);
node->setLayoutBorder(
node->getTrailingBorder(flexColumnDirection), YGEdgeBottom);
node->setLayoutPadding(
node->getLeadingPadding(flexRowDirection, ownerWidth).unwrap(),
startEdge);
node->setLayoutPadding(
node->getTrailingPadding(flexRowDirection, ownerWidth).unwrap(), endEdge);
node->setLayoutPadding(
node->getLeadingPadding(flexColumnDirection, ownerWidth).unwrap(),
YGEdgeTop);
node->setLayoutPadding(
node->getTrailingPadding(flexColumnDirection, ownerWidth).unwrap(),
YGEdgeBottom);
if (node->hasMeasureFunc()) {
YGNodeWithMeasureFuncSetMeasuredDimensions(
node,
availableWidth - marginAxisRow,
availableHeight - marginAxisColumn,
widthMeasureMode,
heightMeasureMode,
ownerWidth,
ownerHeight,
layoutMarkerData,
layoutContext,
reason);
return;
}
const uint32_t childCount = YGNodeGetChildCount(node);
if (childCount == 0) {
YGNodeEmptyContainerSetMeasuredDimensions(
node,
availableWidth - marginAxisRow,
availableHeight - marginAxisColumn,
widthMeasureMode,
heightMeasureMode,
ownerWidth,
ownerHeight);
return;
}
// If we're not being asked to perform a full layout we can skip the algorithm
// if we already know the size
if (!performLayout &&
YGNodeFixedSizeSetMeasuredDimensions(
node,
availableWidth - marginAxisRow,
availableHeight - marginAxisColumn,
widthMeasureMode,
heightMeasureMode,
ownerWidth,
ownerHeight)) {
return;
}
// At this point we know we're going to perform work. Ensure that each child
// has a mutable copy.
node->cloneChildrenIfNeeded(layoutContext);
// Reset layout flags, as they could have changed.
node->setLayoutHadOverflow(false);
// STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM
const YGFlexDirection mainAxis =
YGResolveFlexDirection(node->getStyle().flexDirection(), direction);
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight;
const float crossAxisownerSize = isMainAxisRow ? ownerHeight : ownerWidth;
const float paddingAndBorderAxisMain =
YGNodePaddingAndBorderForAxis(node, mainAxis, ownerWidth);
const float leadingPaddingAndBorderCross =
node->getLeadingPaddingAndBorder(crossAxis, ownerWidth).unwrap();
const float trailingPaddingAndBorderCross =
node->getTrailingPaddingAndBorder(crossAxis, ownerWidth).unwrap();
const float paddingAndBorderAxisCross =
leadingPaddingAndBorderCross + trailingPaddingAndBorderCross;
YGMeasureMode measureModeMainDim =
isMainAxisRow ? widthMeasureMode : heightMeasureMode;
YGMeasureMode measureModeCrossDim =
isMainAxisRow ? heightMeasureMode : widthMeasureMode;
const float paddingAndBorderAxisRow =
isMainAxisRow ? paddingAndBorderAxisMain : paddingAndBorderAxisCross;
const float paddingAndBorderAxisColumn =
isMainAxisRow ? paddingAndBorderAxisCross : paddingAndBorderAxisMain;
// STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS
float availableInnerWidth = YGNodeCalculateAvailableInnerDim(
node,
YGDimensionWidth,
availableWidth - marginAxisRow,
paddingAndBorderAxisRow,
ownerWidth);
float availableInnerHeight = YGNodeCalculateAvailableInnerDim(
node,
YGDimensionHeight,
availableHeight - marginAxisColumn,
paddingAndBorderAxisColumn,
ownerHeight);
float availableInnerMainDim =
isMainAxisRow ? availableInnerWidth : availableInnerHeight;
const float availableInnerCrossDim =
isMainAxisRow ? availableInnerHeight : availableInnerWidth;
// STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM
float totalOuterFlexBasis = YGNodeComputeFlexBasisForChildren(
node,
availableInnerWidth,
availableInnerHeight,
widthMeasureMode,
heightMeasureMode,
direction,
mainAxis,
config,
performLayout,
layoutMarkerData,
layoutContext,
depth,
generationCount);
const bool flexBasisOverflows = measureModeMainDim == YGMeasureModeUndefined
? false
: totalOuterFlexBasis > availableInnerMainDim;
if (isNodeFlexWrap && flexBasisOverflows &&
measureModeMainDim == YGMeasureModeAtMost) {
measureModeMainDim = YGMeasureModeExactly;
}
// STEP 4: COLLECT FLEX ITEMS INTO FLEX LINES
// Indexes of children that represent the first and last items in the line.
uint32_t startOfLineIndex = 0;
uint32_t endOfLineIndex = 0;
// Number of lines.
uint32_t lineCount = 0;
// Accumulated cross dimensions of all lines so far.
float totalLineCrossDim = 0;
// Max main dimension of all the lines.
float maxLineMainDim = 0;
YGCollectFlexItemsRowValues collectedFlexItemsValues;
for (; endOfLineIndex < childCount;
lineCount++, startOfLineIndex = endOfLineIndex) {
collectedFlexItemsValues = YGCalculateCollectFlexItemsRowValues(
node,
ownerDirection,
mainAxisownerSize,
availableInnerWidth,
availableInnerMainDim,
startOfLineIndex,
lineCount);
endOfLineIndex = collectedFlexItemsValues.endOfLineIndex;
// If we don't need to measure the cross axis, we can skip the entire flex
// step.
const bool canSkipFlex =
!performLayout && measureModeCrossDim == YGMeasureModeExactly;
// STEP 5: RESOLVING FLEXIBLE LENGTHS ON MAIN AXIS
// Calculate the remaining available space that needs to be allocated. If
// the main dimension size isn't known, it is computed based on the line
// length, so there's no more space left to distribute.
bool sizeBasedOnContent = false;
// If we don't measure with exact main dimension we want to ensure we don't
// violate min and max
if (measureModeMainDim != YGMeasureModeExactly) {
const auto& minDimensions = node->getStyle().minDimensions();
const auto& maxDimensions = node->getStyle().maxDimensions();
const float minInnerWidth =
YGResolveValue(minDimensions[YGDimensionWidth], ownerWidth).unwrap() -
paddingAndBorderAxisRow;
const float maxInnerWidth =
YGResolveValue(maxDimensions[YGDimensionWidth], ownerWidth).unwrap() -
paddingAndBorderAxisRow;
const float minInnerHeight =
YGResolveValue(minDimensions[YGDimensionHeight], ownerHeight)
.unwrap() -
paddingAndBorderAxisColumn;
const float maxInnerHeight =
YGResolveValue(maxDimensions[YGDimensionHeight], ownerHeight)
.unwrap() -
paddingAndBorderAxisColumn;
const float minInnerMainDim =
isMainAxisRow ? minInnerWidth : minInnerHeight;
const float maxInnerMainDim =
isMainAxisRow ? maxInnerWidth : maxInnerHeight;
if (!YGFloatIsUndefined(minInnerMainDim) &&
collectedFlexItemsValues.sizeConsumedOnCurrentLine <
minInnerMainDim) {
availableInnerMainDim = minInnerMainDim;
} else if (
!YGFloatIsUndefined(maxInnerMainDim) &&
collectedFlexItemsValues.sizeConsumedOnCurrentLine >
maxInnerMainDim) {
availableInnerMainDim = maxInnerMainDim;
} else {
if (!node->getConfig()->useLegacyStretchBehaviour &&
((YGFloatIsUndefined(
collectedFlexItemsValues.totalFlexGrowFactors) &&
collectedFlexItemsValues.totalFlexGrowFactors == 0) ||
(YGFloatIsUndefined(node->resolveFlexGrow()) &&
node->resolveFlexGrow() == 0))) {
// If we don't have any children to flex or we can't flex the node
// itself, space we've used is all space we need. Root node also
// should be shrunk to minimum
availableInnerMainDim =
collectedFlexItemsValues.sizeConsumedOnCurrentLine;
}
if (node->getConfig()->useLegacyStretchBehaviour) {
node->setLayoutDidUseLegacyFlag(true);
}
sizeBasedOnContent = !node->getConfig()->useLegacyStretchBehaviour;
}
}
if (!sizeBasedOnContent && !YGFloatIsUndefined(availableInnerMainDim)) {
collectedFlexItemsValues.remainingFreeSpace = availableInnerMainDim -
collectedFlexItemsValues.sizeConsumedOnCurrentLine;
} else if (collectedFlexItemsValues.sizeConsumedOnCurrentLine < 0) {
// availableInnerMainDim is indefinite which means the node is being sized
// based on its content. sizeConsumedOnCurrentLine is negative which means
// the node will allocate 0 points for its content. Consequently,
// remainingFreeSpace is 0 - sizeConsumedOnCurrentLine.
collectedFlexItemsValues.remainingFreeSpace =
-collectedFlexItemsValues.sizeConsumedOnCurrentLine;
}
if (!canSkipFlex) {
YGResolveFlexibleLength(
node,
collectedFlexItemsValues,
mainAxis,
crossAxis,
mainAxisownerSize,
availableInnerMainDim,
availableInnerCrossDim,
availableInnerWidth,
availableInnerHeight,
flexBasisOverflows,
measureModeCrossDim,
performLayout,
config,
layoutMarkerData,
layoutContext,
depth,
generationCount);
}
node->setLayoutHadOverflow(
node->getLayout().hadOverflow() |
(collectedFlexItemsValues.remainingFreeSpace < 0));
// STEP 6: MAIN-AXIS JUSTIFICATION & CROSS-AXIS SIZE DETERMINATION
// At this point, all the children have their dimensions set in the main
// axis. Their dimensions are also set in the cross axis with the exception
// of items that are aligned "stretch". We need to compute these stretch
// values and set the final positions.
YGJustifyMainAxis(
node,
collectedFlexItemsValues,
startOfLineIndex,
mainAxis,
crossAxis,
measureModeMainDim,
measureModeCrossDim,
mainAxisownerSize,
ownerWidth,
availableInnerMainDim,
availableInnerCrossDim,
availableInnerWidth,
performLayout,
layoutContext);
float containerCrossAxis = availableInnerCrossDim;
if (measureModeCrossDim == YGMeasureModeUndefined ||
measureModeCrossDim == YGMeasureModeAtMost) {
// Compute the cross axis from the max cross dimension of the children.
containerCrossAxis =
YGNodeBoundAxis(
node,
crossAxis,
collectedFlexItemsValues.crossDim + paddingAndBorderAxisCross,
crossAxisownerSize,
ownerWidth) -
paddingAndBorderAxisCross;
}
// If there's no flex wrap, the cross dimension is defined by the container.
if (!isNodeFlexWrap && measureModeCrossDim == YGMeasureModeExactly) {
collectedFlexItemsValues.crossDim = availableInnerCrossDim;
}
// Clamp to the min/max size specified on the container.
collectedFlexItemsValues.crossDim =
YGNodeBoundAxis(
node,
crossAxis,
collectedFlexItemsValues.crossDim + paddingAndBorderAxisCross,
crossAxisownerSize,
ownerWidth) -
paddingAndBorderAxisCross;
// STEP 7: CROSS-AXIS ALIGNMENT
// We can skip child alignment if we're just measuring the container.
if (performLayout) {
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
const YGNodeRef child = node->getChild(i);
if (child->getStyle().display() == YGDisplayNone) {
continue;
}
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
// If the child is absolutely positioned and has a
// top/left/bottom/right set, override all the previously computed
// positions to set it correctly.
const bool isChildLeadingPosDefined =
child->isLeadingPositionDefined(crossAxis);
if (isChildLeadingPosDefined) {
child->setLayoutPosition(
child->getLeadingPosition(crossAxis, availableInnerCrossDim)
.unwrap() +
node->getLeadingBorder(crossAxis) +
child->getLeadingMargin(crossAxis, availableInnerWidth)
.unwrap(),
pos[crossAxis]);
}
// If leading position is not defined or calculations result in Nan,
// default to border + margin
if (!isChildLeadingPosDefined ||
YGFloatIsUndefined(child->getLayout().position[pos[crossAxis]])) {
child->setLayoutPosition(
node->getLeadingBorder(crossAxis) +
child->getLeadingMargin(crossAxis, availableInnerWidth)
.unwrap(),
pos[crossAxis]);
}
} else {
float leadingCrossDim = leadingPaddingAndBorderCross;
// For a relative children, we're either using alignItems (owner) or
// alignSelf (child) in order to determine the position in the cross
// axis
const YGAlign alignItem = YGNodeAlignItem(node, child);
// If the child uses align stretch, we need to lay it out one more
// time, this time forcing the cross-axis size to be the computed
// cross size for the current line.
if (alignItem == YGAlignStretch &&
child->marginLeadingValue(crossAxis).unit != YGUnitAuto &&
child->marginTrailingValue(crossAxis).unit != YGUnitAuto) {
// If the child defines a definite size for its cross axis, there's
// no need to stretch.
if (!YGNodeIsStyleDimDefined(
child, crossAxis, availableInnerCrossDim)) {
float childMainSize =
child->getLayout().measuredDimensions[dim[mainAxis]];
const auto& childStyle = child->getStyle();
float childCrossSize = !childStyle.aspectRatio().isUndefined()
? child->getMarginForAxis(crossAxis, availableInnerWidth)
.unwrap() +
(isMainAxisRow
? childMainSize / childStyle.aspectRatio().unwrap()
: childMainSize * childStyle.aspectRatio().unwrap())
: collectedFlexItemsValues.crossDim;
childMainSize +=
child->getMarginForAxis(mainAxis, availableInnerWidth)
.unwrap();
YGMeasureMode childMainMeasureMode = YGMeasureModeExactly;
YGMeasureMode childCrossMeasureMode = YGMeasureModeExactly;
YGConstrainMaxSizeForMode(
child,
mainAxis,
availableInnerMainDim,
availableInnerWidth,
&childMainMeasureMode,
&childMainSize);
YGConstrainMaxSizeForMode(
child,
crossAxis,
availableInnerCrossDim,
availableInnerWidth,
&childCrossMeasureMode,
&childCrossSize);
const float childWidth =
isMainAxisRow ? childMainSize : childCrossSize;
const float childHeight =
!isMainAxisRow ? childMainSize : childCrossSize;
auto alignContent = node->getStyle().alignContent();
auto crossAxisDoesNotGrow =
alignContent != YGAlignStretch && isNodeFlexWrap;
const YGMeasureMode childWidthMeasureMode =
YGFloatIsUndefined(childWidth) ||
(!isMainAxisRow && crossAxisDoesNotGrow)
? YGMeasureModeUndefined
: YGMeasureModeExactly;
const YGMeasureMode childHeightMeasureMode =
YGFloatIsUndefined(childHeight) ||
(isMainAxisRow && crossAxisDoesNotGrow)
? YGMeasureModeUndefined
: YGMeasureModeExactly;
YGLayoutNodeInternal(
child,
childWidth,
childHeight,
direction,
childWidthMeasureMode,
childHeightMeasureMode,
availableInnerWidth,
availableInnerHeight,
true,
LayoutPassReason::kStretch,
config,
layoutMarkerData,
layoutContext,
depth,
generationCount);
}
} else {
const float remainingCrossDim = containerCrossAxis -
YGNodeDimWithMargin(child, crossAxis, availableInnerWidth);
if (child->marginLeadingValue(crossAxis).unit == YGUnitAuto &&
child->marginTrailingValue(crossAxis).unit == YGUnitAuto) {
leadingCrossDim += YGFloatMax(0.0f, remainingCrossDim / 2);
} else if (
child->marginTrailingValue(crossAxis).unit == YGUnitAuto) {
// No-Op
} else if (
child->marginLeadingValue(crossAxis).unit == YGUnitAuto) {
leadingCrossDim += YGFloatMax(0.0f, remainingCrossDim);
} else if (alignItem == YGAlignFlexStart) {
// No-Op
} else if (alignItem == YGAlignCenter) {
leadingCrossDim += remainingCrossDim / 2;
} else {
leadingCrossDim += remainingCrossDim;
}
}
// And we apply the position
child->setLayoutPosition(
child->getLayout().position[pos[crossAxis]] + totalLineCrossDim +
leadingCrossDim,
pos[crossAxis]);
}
}
}
totalLineCrossDim += collectedFlexItemsValues.crossDim;
maxLineMainDim =
YGFloatMax(maxLineMainDim, collectedFlexItemsValues.mainDim);
}
// STEP 8: MULTI-LINE CONTENT ALIGNMENT
// currentLead stores the size of the cross dim
if (performLayout && (isNodeFlexWrap || YGIsBaselineLayout(node))) {
float crossDimLead = 0;
float currentLead = leadingPaddingAndBorderCross;
if (!YGFloatIsUndefined(availableInnerCrossDim)) {
const float remainingAlignContentDim =
availableInnerCrossDim - totalLineCrossDim;
switch (node->getStyle().alignContent()) {
case YGAlignFlexEnd:
currentLead += remainingAlignContentDim;
break;
case YGAlignCenter:
currentLead += remainingAlignContentDim / 2;
break;
case YGAlignStretch:
if (availableInnerCrossDim > totalLineCrossDim) {
crossDimLead = remainingAlignContentDim / lineCount;
}
break;
case YGAlignSpaceAround:
if (availableInnerCrossDim > totalLineCrossDim) {
currentLead += remainingAlignContentDim / (2 * lineCount);
if (lineCount > 1) {
crossDimLead = remainingAlignContentDim / lineCount;
}
} else {
currentLead += remainingAlignContentDim / 2;
}
break;
case YGAlignSpaceBetween:
if (availableInnerCrossDim > totalLineCrossDim && lineCount > 1) {
crossDimLead = remainingAlignContentDim / (lineCount - 1);
}
break;
case YGAlignAuto:
case YGAlignFlexStart:
case YGAlignBaseline:
break;
}
}
uint32_t endIndex = 0;
for (uint32_t i = 0; i < lineCount; i++) {
const uint32_t startIndex = endIndex;
uint32_t ii;
// compute the line's height and find the endIndex
float lineHeight = 0;
float maxAscentForCurrentLine = 0;
float maxDescentForCurrentLine = 0;
for (ii = startIndex; ii < childCount; ii++) {
const YGNodeRef child = node->getChild(ii);
if (child->getStyle().display() == YGDisplayNone) {
continue;
}
if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
if (child->getLineIndex() != i) {
break;
}
if (YGNodeIsLayoutDimDefined(child, crossAxis)) {
lineHeight = YGFloatMax(
lineHeight,
child->getLayout().measuredDimensions[dim[crossAxis]] +
child->getMarginForAxis(crossAxis, availableInnerWidth)
.unwrap());
}
if (YGNodeAlignItem(node, child) == YGAlignBaseline) {
const float ascent = YGBaseline(child, layoutContext) +
child
->getLeadingMargin(
YGFlexDirectionColumn, availableInnerWidth)
.unwrap();
const float descent =
child->getLayout().measuredDimensions[YGDimensionHeight] +
child
->getMarginForAxis(
YGFlexDirectionColumn, availableInnerWidth)
.unwrap() -
ascent;
maxAscentForCurrentLine =
YGFloatMax(maxAscentForCurrentLine, ascent);
maxDescentForCurrentLine =
YGFloatMax(maxDescentForCurrentLine, descent);
lineHeight = YGFloatMax(
lineHeight, maxAscentForCurrentLine + maxDescentForCurrentLine);
}
}
}
endIndex = ii;
lineHeight += crossDimLead;
if (performLayout) {
for (ii = startIndex; ii < endIndex; ii++) {
const YGNodeRef child = node->getChild(ii);
if (child->getStyle().display() == YGDisplayNone) {
continue;
}
if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
switch (YGNodeAlignItem(node, child)) {
case YGAlignFlexStart: {
child->setLayoutPosition(
currentLead +
child->getLeadingMargin(crossAxis, availableInnerWidth)
.unwrap(),
pos[crossAxis]);
break;
}
case YGAlignFlexEnd: {
child->setLayoutPosition(
currentLead + lineHeight -
child->getTrailingMargin(crossAxis, availableInnerWidth)
.unwrap() -
child->getLayout().measuredDimensions[dim[crossAxis]],
pos[crossAxis]);
break;
}
case YGAlignCenter: {
float childHeight =
child->getLayout().measuredDimensions[dim[crossAxis]];
child->setLayoutPosition(
currentLead + (lineHeight - childHeight) / 2,
pos[crossAxis]);
break;
}
case YGAlignStretch: {
child->setLayoutPosition(
currentLead +
child->getLeadingMargin(crossAxis, availableInnerWidth)
.unwrap(),
pos[crossAxis]);
// Remeasure child with the line height as it as been only
// measured with the owners height yet.
if (!YGNodeIsStyleDimDefined(
child, crossAxis, availableInnerCrossDim)) {
const float childWidth = isMainAxisRow
? (child->getLayout()
.measuredDimensions[YGDimensionWidth] +
child->getMarginForAxis(mainAxis, availableInnerWidth)
.unwrap())
: lineHeight;
const float childHeight = !isMainAxisRow
? (child->getLayout()
.measuredDimensions[YGDimensionHeight] +
child->getMarginForAxis(crossAxis, availableInnerWidth)
.unwrap())
: lineHeight;
if (!(YGFloatsEqual(
childWidth,
child->getLayout()
.measuredDimensions[YGDimensionWidth]) &&
YGFloatsEqual(
childHeight,
child->getLayout()
.measuredDimensions[YGDimensionHeight]))) {
YGLayoutNodeInternal(
child,
childWidth,
childHeight,
direction,
YGMeasureModeExactly,
YGMeasureModeExactly,
availableInnerWidth,
availableInnerHeight,
true,
LayoutPassReason::kMultilineStretch,
config,
layoutMarkerData,
layoutContext,
depth,
generationCount);
}
}
break;
}
case YGAlignBaseline: {
child->setLayoutPosition(
currentLead + maxAscentForCurrentLine -
YGBaseline(child, layoutContext) +
child
->getLeadingPosition(
YGFlexDirectionColumn, availableInnerCrossDim)
.unwrap(),
YGEdgeTop);
break;
}
case YGAlignAuto:
case YGAlignSpaceBetween:
case YGAlignSpaceAround:
break;
}
}
}
}
currentLead += lineHeight;
}
}
// STEP 9: COMPUTING FINAL DIMENSIONS
node->setLayoutMeasuredDimension(
YGNodeBoundAxis(
node,
YGFlexDirectionRow,
availableWidth - marginAxisRow,
ownerWidth,
ownerWidth),
YGDimensionWidth);
node->setLayoutMeasuredDimension(
YGNodeBoundAxis(
node,
YGFlexDirectionColumn,
availableHeight - marginAxisColumn,
ownerHeight,
ownerWidth),
YGDimensionHeight);
// If the user didn't specify a width or height for the node, set the
// dimensions based on the children.
if (measureModeMainDim == YGMeasureModeUndefined ||
(node->getStyle().overflow() != YGOverflowScroll &&
measureModeMainDim == YGMeasureModeAtMost)) {
// Clamp the size to the min/max size, if specified, and make sure it
// doesn't go below the padding and border amount.
node->setLayoutMeasuredDimension(
YGNodeBoundAxis(
node, mainAxis, maxLineMainDim, mainAxisownerSize, ownerWidth),
dim[mainAxis]);
} else if (
measureModeMainDim == YGMeasureModeAtMost &&
node->getStyle().overflow() == YGOverflowScroll) {
node->setLayoutMeasuredDimension(
YGFloatMax(
YGFloatMin(
availableInnerMainDim + paddingAndBorderAxisMain,
YGNodeBoundAxisWithinMinAndMax(
node,
mainAxis,
YGFloatOptional{maxLineMainDim},
mainAxisownerSize)
.unwrap()),
paddingAndBorderAxisMain),
dim[mainAxis]);
}
if (measureModeCrossDim == YGMeasureModeUndefined ||
(node->getStyle().overflow() != YGOverflowScroll &&
measureModeCrossDim == YGMeasureModeAtMost)) {
// Clamp the size to the min/max size, if specified, and make sure it
// doesn't go below the padding and border amount.
node->setLayoutMeasuredDimension(
YGNodeBoundAxis(
node,
crossAxis,
totalLineCrossDim + paddingAndBorderAxisCross,
crossAxisownerSize,
ownerWidth),
dim[crossAxis]);
} else if (
measureModeCrossDim == YGMeasureModeAtMost &&
node->getStyle().overflow() == YGOverflowScroll) {
node->setLayoutMeasuredDimension(
YGFloatMax(
YGFloatMin(
availableInnerCrossDim + paddingAndBorderAxisCross,
YGNodeBoundAxisWithinMinAndMax(
node,
crossAxis,
YGFloatOptional{
totalLineCrossDim + paddingAndBorderAxisCross},
crossAxisownerSize)
.unwrap()),
paddingAndBorderAxisCross),
dim[crossAxis]);
}
// As we only wrapped in normal direction yet, we need to reverse the
// positions on wrap-reverse.
if (performLayout && node->getStyle().flexWrap() == YGWrapWrapReverse) {
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = YGNodeGetChild(node, i);
if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
child->setLayoutPosition(
node->getLayout().measuredDimensions[dim[crossAxis]] -
child->getLayout().position[pos[crossAxis]] -
child->getLayout().measuredDimensions[dim[crossAxis]],
pos[crossAxis]);
}
}
}
if (performLayout) {
// STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN
for (auto child : node->getChildren()) {
if (child->getStyle().display() == YGDisplayNone ||
child->getStyle().positionType() != YGPositionTypeAbsolute) {
continue;
}
YGNodeAbsoluteLayoutChild(
node,
child,
availableInnerWidth,
isMainAxisRow ? measureModeMainDim : measureModeCrossDim,
availableInnerHeight,
direction,
config,
layoutMarkerData,
layoutContext,
depth,
generationCount);
}
// STEP 11: SETTING TRAILING POSITIONS FOR CHILDREN
const bool needsMainTrailingPos = mainAxis == YGFlexDirectionRowReverse ||
mainAxis == YGFlexDirectionColumnReverse;
const bool needsCrossTrailingPos = crossAxis == YGFlexDirectionRowReverse ||
crossAxis == YGFlexDirectionColumnReverse;
// Set trailing position if necessary.
if (needsMainTrailingPos || needsCrossTrailingPos) {
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = node->getChild(i);
if (child->getStyle().display() == YGDisplayNone) {
continue;
}
if (needsMainTrailingPos) {
YGNodeSetChildTrailingPosition(node, child, mainAxis);
}
if (needsCrossTrailingPos) {
YGNodeSetChildTrailingPosition(node, child, crossAxis);
}
}
}
}
}
bool gPrintChanges = false;
bool gPrintSkips = false;
static const char* spacer =
" ";
static const char* YGSpacer(const unsigned long level) {
const size_t spacerLen = strlen(spacer);
if (level > spacerLen) {
return &spacer[0];
} else {
return &spacer[spacerLen - level];
}
}
static const char* YGMeasureModeName(
const YGMeasureMode mode,
const bool performLayout) {
constexpr auto N = enums::count<YGMeasureMode>();
const char* kMeasureModeNames[N] = {"UNDEFINED", "EXACTLY", "AT_MOST"};
const char* kLayoutModeNames[N] = {
"LAY_UNDEFINED", "LAY_EXACTLY", "LAY_AT_MOST"};
if (mode >= N) {
return "";
}
return performLayout ? kLayoutModeNames[mode] : kMeasureModeNames[mode];
}
static inline bool YGMeasureModeSizeIsExactAndMatchesOldMeasuredSize(
YGMeasureMode sizeMode,
float size,
float lastComputedSize) {
return sizeMode == YGMeasureModeExactly &&
YGFloatsEqual(size, lastComputedSize);
}
static inline bool YGMeasureModeOldSizeIsUnspecifiedAndStillFits(
YGMeasureMode sizeMode,
float size,
YGMeasureMode lastSizeMode,
float lastComputedSize) {
return sizeMode == YGMeasureModeAtMost &&
lastSizeMode == YGMeasureModeUndefined &&
(size >= lastComputedSize || YGFloatsEqual(size, lastComputedSize));
}
static inline bool YGMeasureModeNewMeasureSizeIsStricterAndStillValid(
YGMeasureMode sizeMode,
float size,
YGMeasureMode lastSizeMode,
float lastSize,
float lastComputedSize) {
return lastSizeMode == YGMeasureModeAtMost &&
sizeMode == YGMeasureModeAtMost && !YGFloatIsUndefined(lastSize) &&
!YGFloatIsUndefined(size) && !YGFloatIsUndefined(lastComputedSize) &&
lastSize > size &&
(lastComputedSize <= size || YGFloatsEqual(size, lastComputedSize));
}
YOGA_EXPORT float YGRoundValueToPixelGrid(
const double value,
const double pointScaleFactor,
const bool forceCeil,
const bool forceFloor) {
double scaledValue = value * pointScaleFactor;
// We want to calculate `fractial` such that `floor(scaledValue) = scaledValue
// - fractial`.
double fractial = fmod(scaledValue, 1.0);
if (fractial < 0) {
// This branch is for handling negative numbers for `value`.
//
// Regarding `floor` and `ceil`. Note that for a number x, `floor(x) <= x <=
// ceil(x)` even for negative numbers. Here are a couple of examples:
// - x = 2.2: floor( 2.2) = 2, ceil( 2.2) = 3
// - x = -2.2: floor(-2.2) = -3, ceil(-2.2) = -2
//
// Regarding `fmodf`. For fractional negative numbers, `fmodf` returns a
// negative number. For example, `fmodf(-2.2) = -0.2`. However, we want
// `fractial` to be the number such that subtracting it from `value` will
// give us `floor(value)`. In the case of negative numbers, adding 1 to
// `fmodf(value)` gives us this. Let's continue the example from above:
// - fractial = fmodf(-2.2) = -0.2
// - Add 1 to the fraction: fractial2 = fractial + 1 = -0.2 + 1 = 0.8
// - Finding the `floor`: -2.2 - fractial2 = -2.2 - 0.8 = -3
++fractial;
}
if (YGDoubleEqual(fractial, 0)) {
// First we check if the value is already rounded
scaledValue = scaledValue - fractial;
} else if (YGDoubleEqual(fractial, 1.0)) {
scaledValue = scaledValue - fractial + 1.0;
} else if (forceCeil) {
// Next we check if we need to use forced rounding
scaledValue = scaledValue - fractial + 1.0;
} else if (forceFloor) {
scaledValue = scaledValue - fractial;
} else {
// Finally we just round the value
scaledValue = scaledValue - fractial +
(!YGDoubleIsUndefined(fractial) &&
(fractial > 0.5 || YGDoubleEqual(fractial, 0.5))
? 1.0
: 0.0);
}
return (YGDoubleIsUndefined(scaledValue) ||
YGDoubleIsUndefined(pointScaleFactor))
? YGUndefined
: (float) (scaledValue / pointScaleFactor);
}
YOGA_EXPORT bool YGNodeCanUseCachedMeasurement(
const YGMeasureMode widthMode,
const float width,
const YGMeasureMode heightMode,
const float height,
const YGMeasureMode lastWidthMode,
const float lastWidth,
const YGMeasureMode lastHeightMode,
const float lastHeight,
const float lastComputedWidth,
const float lastComputedHeight,
const float marginRow,
const float marginColumn,
const YGConfigRef config) {
if ((!YGFloatIsUndefined(lastComputedHeight) && lastComputedHeight < 0) ||
(!YGFloatIsUndefined(lastComputedWidth) && lastComputedWidth < 0)) {
return false;
}
bool useRoundedComparison =
config != nullptr && config->pointScaleFactor != 0;
const float effectiveWidth = useRoundedComparison
? YGRoundValueToPixelGrid(width, config->pointScaleFactor, false, false)
: width;
const float effectiveHeight = useRoundedComparison
? YGRoundValueToPixelGrid(height, config->pointScaleFactor, false, false)
: height;
const float effectiveLastWidth = useRoundedComparison
? YGRoundValueToPixelGrid(
lastWidth, config->pointScaleFactor, false, false)
: lastWidth;
const float effectiveLastHeight = useRoundedComparison
? YGRoundValueToPixelGrid(
lastHeight, config->pointScaleFactor, false, false)
: lastHeight;
const bool hasSameWidthSpec = lastWidthMode == widthMode &&
YGFloatsEqual(effectiveLastWidth, effectiveWidth);
const bool hasSameHeightSpec = lastHeightMode == heightMode &&
YGFloatsEqual(effectiveLastHeight, effectiveHeight);
const bool widthIsCompatible =
hasSameWidthSpec ||
YGMeasureModeSizeIsExactAndMatchesOldMeasuredSize(
widthMode, width - marginRow, lastComputedWidth) ||
YGMeasureModeOldSizeIsUnspecifiedAndStillFits(
widthMode, width - marginRow, lastWidthMode, lastComputedWidth) ||
YGMeasureModeNewMeasureSizeIsStricterAndStillValid(
widthMode,
width - marginRow,
lastWidthMode,
lastWidth,
lastComputedWidth);
const bool heightIsCompatible =
hasSameHeightSpec ||
YGMeasureModeSizeIsExactAndMatchesOldMeasuredSize(
heightMode, height - marginColumn, lastComputedHeight) ||
YGMeasureModeOldSizeIsUnspecifiedAndStillFits(
heightMode,
height - marginColumn,
lastHeightMode,
lastComputedHeight) ||
YGMeasureModeNewMeasureSizeIsStricterAndStillValid(
heightMode,
height - marginColumn,
lastHeightMode,
lastHeight,
lastComputedHeight);
return widthIsCompatible && heightIsCompatible;
}
//
// This is a wrapper around the YGNodelayoutImpl function. It determines whether
// the layout request is redundant and can be skipped.
//
// Parameters:
// Input parameters are the same as YGNodelayoutImpl (see above)
// Return parameter is true if layout was performed, false if skipped
//
bool YGLayoutNodeInternal(
const YGNodeRef node,
const float availableWidth,
const float availableHeight,
const YGDirection ownerDirection,
const YGMeasureMode widthMeasureMode,
const YGMeasureMode heightMeasureMode,
const float ownerWidth,
const float ownerHeight,
const bool performLayout,
const LayoutPassReason reason,
const YGConfigRef config,
LayoutData& layoutMarkerData,
void* const layoutContext,
uint32_t depth,
const uint32_t generationCount) {
YGLayout* layout = &node->getLayout();
depth++;
const bool needToVisitNode =
(node->isDirty() && layout->generationCount != generationCount) ||
layout->lastOwnerDirection != ownerDirection;
if (needToVisitNode) {
// Invalidate the cached results.
layout->nextCachedMeasurementsIndex = 0;
layout->cachedLayout.availableWidth = -1;
layout->cachedLayout.availableHeight = -1;
layout->cachedLayout.widthMeasureMode = YGMeasureModeUndefined;
layout->cachedLayout.heightMeasureMode = YGMeasureModeUndefined;
layout->cachedLayout.computedWidth = -1;
layout->cachedLayout.computedHeight = -1;
}
YGCachedMeasurement* cachedResults = nullptr;
// Determine whether the results are already cached. We maintain a separate
// cache for layouts and measurements. A layout operation modifies the
// positions and dimensions for nodes in the subtree. The algorithm assumes
// that each node gets layed out a maximum of one time per tree layout, but
// multiple measurements may be required to resolve all of the flex
// dimensions. We handle nodes with measure functions specially here because
// they are the most expensive to measure, so it's worth avoiding redundant
// measurements if at all possible.
if (node->hasMeasureFunc()) {
const float marginAxisRow =
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
const float marginAxisColumn =
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
// First, try to use the layout cache.
if (YGNodeCanUseCachedMeasurement(
widthMeasureMode,
availableWidth,
heightMeasureMode,
availableHeight,
layout->cachedLayout.widthMeasureMode,
layout->cachedLayout.availableWidth,
layout->cachedLayout.heightMeasureMode,
layout->cachedLayout.availableHeight,
layout->cachedLayout.computedWidth,
layout->cachedLayout.computedHeight,
marginAxisRow,
marginAxisColumn,
config)) {
cachedResults = &layout->cachedLayout;
} else {
// Try to use the measurement cache.
for (uint32_t i = 0; i < layout->nextCachedMeasurementsIndex; i++) {
if (YGNodeCanUseCachedMeasurement(
widthMeasureMode,
availableWidth,
heightMeasureMode,
availableHeight,
layout->cachedMeasurements[i].widthMeasureMode,
layout->cachedMeasurements[i].availableWidth,
layout->cachedMeasurements[i].heightMeasureMode,
layout->cachedMeasurements[i].availableHeight,
layout->cachedMeasurements[i].computedWidth,
layout->cachedMeasurements[i].computedHeight,
marginAxisRow,
marginAxisColumn,
config)) {
cachedResults = &layout->cachedMeasurements[i];
break;
}
}
}
} else if (performLayout) {
if (YGFloatsEqual(layout->cachedLayout.availableWidth, availableWidth) &&
YGFloatsEqual(layout->cachedLayout.availableHeight, availableHeight) &&
layout->cachedLayout.widthMeasureMode == widthMeasureMode &&
layout->cachedLayout.heightMeasureMode == heightMeasureMode) {
cachedResults = &layout->cachedLayout;
}
} else {
for (uint32_t i = 0; i < layout->nextCachedMeasurementsIndex; i++) {
if (YGFloatsEqual(
layout->cachedMeasurements[i].availableWidth, availableWidth) &&
YGFloatsEqual(
layout->cachedMeasurements[i].availableHeight, availableHeight) &&
layout->cachedMeasurements[i].widthMeasureMode == widthMeasureMode &&
layout->cachedMeasurements[i].heightMeasureMode ==
heightMeasureMode) {
cachedResults = &layout->cachedMeasurements[i];
break;
}
}
}
if (!needToVisitNode && cachedResults != nullptr) {
layout->measuredDimensions[YGDimensionWidth] = cachedResults->computedWidth;
layout->measuredDimensions[YGDimensionHeight] =
cachedResults->computedHeight;
(performLayout ? layoutMarkerData.cachedLayouts
: layoutMarkerData.cachedMeasures) += 1;
if (gPrintChanges && gPrintSkips) {
Log::log(
node,
YGLogLevelVerbose,
nullptr,
"%s%d.{[skipped] ",
YGSpacer(depth),
depth);
node->print(layoutContext);
Log::log(
node,
YGLogLevelVerbose,
nullptr,
"wm: %s, hm: %s, aw: %f ah: %f => d: (%f, %f) %s\n",
YGMeasureModeName(widthMeasureMode, performLayout),
YGMeasureModeName(heightMeasureMode, performLayout),
availableWidth,
availableHeight,
cachedResults->computedWidth,
cachedResults->computedHeight,
LayoutPassReasonToString(reason));
}
} else {
if (gPrintChanges) {
Log::log(
node,
YGLogLevelVerbose,
nullptr,
"%s%d.{%s",
YGSpacer(depth),
depth,
needToVisitNode ? "*" : "");
node->print(layoutContext);
Log::log(
node,
YGLogLevelVerbose,
nullptr,
"wm: %s, hm: %s, aw: %f ah: %f %s\n",
YGMeasureModeName(widthMeasureMode, performLayout),
YGMeasureModeName(heightMeasureMode, performLayout),
availableWidth,
availableHeight,
LayoutPassReasonToString(reason));
}
YGNodelayoutImpl(
node,
availableWidth,
availableHeight,
ownerDirection,
widthMeasureMode,
heightMeasureMode,
ownerWidth,
ownerHeight,
performLayout,
config,
layoutMarkerData,
layoutContext,
depth,
generationCount,
reason);
if (gPrintChanges) {
Log::log(
node,
YGLogLevelVerbose,
nullptr,
"%s%d.}%s",
YGSpacer(depth),
depth,
needToVisitNode ? "*" : "");
node->print(layoutContext);
Log::log(
node,
YGLogLevelVerbose,
nullptr,
"wm: %s, hm: %s, d: (%f, %f) %s\n",
YGMeasureModeName(widthMeasureMode, performLayout),
YGMeasureModeName(heightMeasureMode, performLayout),
layout->measuredDimensions[YGDimensionWidth],
layout->measuredDimensions[YGDimensionHeight],
LayoutPassReasonToString(reason));
}
layout->lastOwnerDirection = ownerDirection;
if (cachedResults == nullptr) {
if (layout->nextCachedMeasurementsIndex + 1 >
(uint32_t) layoutMarkerData.maxMeasureCache) {
layoutMarkerData.maxMeasureCache =
layout->nextCachedMeasurementsIndex + 1;
}
if (layout->nextCachedMeasurementsIndex == YG_MAX_CACHED_RESULT_COUNT) {
if (gPrintChanges) {
Log::log(node, YGLogLevelVerbose, nullptr, "Out of cache entries!\n");
}
layout->nextCachedMeasurementsIndex = 0;
}
YGCachedMeasurement* newCacheEntry;
if (performLayout) {
// Use the single layout cache entry.
newCacheEntry = &layout->cachedLayout;
} else {
// Allocate a new measurement cache entry.
newCacheEntry =
&layout->cachedMeasurements[layout->nextCachedMeasurementsIndex];
layout->nextCachedMeasurementsIndex++;
}
newCacheEntry->availableWidth = availableWidth;
newCacheEntry->availableHeight = availableHeight;
newCacheEntry->widthMeasureMode = widthMeasureMode;
newCacheEntry->heightMeasureMode = heightMeasureMode;
newCacheEntry->computedWidth =
layout->measuredDimensions[YGDimensionWidth];
newCacheEntry->computedHeight =
layout->measuredDimensions[YGDimensionHeight];
}
}
if (performLayout) {
node->setLayoutDimension(
node->getLayout().measuredDimensions[YGDimensionWidth],
YGDimensionWidth);
node->setLayoutDimension(
node->getLayout().measuredDimensions[YGDimensionHeight],
YGDimensionHeight);
node->setHasNewLayout(true);
node->setDirty(false);
}
layout->generationCount = generationCount;
LayoutType layoutType;
if (performLayout) {
layoutType = !needToVisitNode && cachedResults == &layout->cachedLayout
? LayoutType::kCachedLayout
: LayoutType::kLayout;
} else {
layoutType = cachedResults != nullptr ? LayoutType::kCachedMeasure
: LayoutType::kMeasure;
}
Event::publish<Event::NodeLayout>(node, {layoutType, layoutContext});
return (needToVisitNode || cachedResults == nullptr);
}
YOGA_EXPORT void YGConfigSetPointScaleFactor(
const YGConfigRef config,
const float pixelsInPoint) {
YGAssertWithConfig(
config,
pixelsInPoint >= 0.0f,
"Scale factor should not be less than zero");
// We store points for Pixel as we will use it for rounding
if (pixelsInPoint == 0.0f) {
// Zero is used to skip rounding
config->pointScaleFactor = 0.0f;
} else {
config->pointScaleFactor = pixelsInPoint;
}
}
static void YGRoundToPixelGrid(
const YGNodeRef node,
const double pointScaleFactor,
const double absoluteLeft,
const double absoluteTop) {
if (pointScaleFactor == 0.0f) {
return;
}
const double nodeLeft = node->getLayout().position[YGEdgeLeft];
const double nodeTop = node->getLayout().position[YGEdgeTop];
const double nodeWidth = node->getLayout().dimensions[YGDimensionWidth];
const double nodeHeight = node->getLayout().dimensions[YGDimensionHeight];
const double absoluteNodeLeft = absoluteLeft + nodeLeft;
const double absoluteNodeTop = absoluteTop + nodeTop;
const double absoluteNodeRight = absoluteNodeLeft + nodeWidth;
const double absoluteNodeBottom = absoluteNodeTop + nodeHeight;
// If a node has a custom measure function we never want to round down its
// size as this could lead to unwanted text truncation.
const bool textRounding = node->getNodeType() == YGNodeTypeText;
node->setLayoutPosition(
YGRoundValueToPixelGrid(nodeLeft, pointScaleFactor, false, textRounding),
YGEdgeLeft);
node->setLayoutPosition(
YGRoundValueToPixelGrid(nodeTop, pointScaleFactor, false, textRounding),
YGEdgeTop);
// We multiply dimension by scale factor and if the result is close to the
// whole number, we don't have any fraction To verify if the result is close
// to whole number we want to check both floor and ceil numbers
const bool hasFractionalWidth =
!YGDoubleEqual(fmod(nodeWidth * pointScaleFactor, 1.0), 0) &&
!YGDoubleEqual(fmod(nodeWidth * pointScaleFactor, 1.0), 1.0);
const bool hasFractionalHeight =
!YGDoubleEqual(fmod(nodeHeight * pointScaleFactor, 1.0), 0) &&
!YGDoubleEqual(fmod(nodeHeight * pointScaleFactor, 1.0), 1.0);
node->setLayoutDimension(
YGRoundValueToPixelGrid(
absoluteNodeRight,
pointScaleFactor,
(textRounding && hasFractionalWidth),
(textRounding && !hasFractionalWidth)) -
YGRoundValueToPixelGrid(
absoluteNodeLeft, pointScaleFactor, false, textRounding),
YGDimensionWidth);
node->setLayoutDimension(
YGRoundValueToPixelGrid(
absoluteNodeBottom,
pointScaleFactor,
(textRounding && hasFractionalHeight),
(textRounding && !hasFractionalHeight)) -
YGRoundValueToPixelGrid(
absoluteNodeTop, pointScaleFactor, false, textRounding),
YGDimensionHeight);
const uint32_t childCount = YGNodeGetChildCount(node);
for (uint32_t i = 0; i < childCount; i++) {
YGRoundToPixelGrid(
YGNodeGetChild(node, i),
pointScaleFactor,
absoluteNodeLeft,
absoluteNodeTop);
}
}
static void unsetUseLegacyFlagRecursively(YGNodeRef node) {
node->getConfig()->useLegacyStretchBehaviour = false;
for (auto child : node->getChildren()) {
unsetUseLegacyFlagRecursively(child);
}
}
YOGA_EXPORT void YGNodeCalculateLayoutWithContext(
const YGNodeRef node,
const float ownerWidth,
const float ownerHeight,
const YGDirection ownerDirection,
void* layoutContext) {
Event::publish<Event::LayoutPassStart>(node, {layoutContext});
LayoutData markerData = {};
// Increment the generation count. This will force the recursive routine to
// visit all dirty nodes at least once. Subsequent visits will be skipped if
// the input parameters don't change.
gCurrentGenerationCount.fetch_add(1, std::memory_order_relaxed);
node->resolveDimension();
float width = YGUndefined;
YGMeasureMode widthMeasureMode = YGMeasureModeUndefined;
const auto& maxDimensions = node->getStyle().maxDimensions();
if (YGNodeIsStyleDimDefined(node, YGFlexDirectionRow, ownerWidth)) {
width =
(YGResolveValue(
node->getResolvedDimension(dim[YGFlexDirectionRow]), ownerWidth) +
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth))
.unwrap();
widthMeasureMode = YGMeasureModeExactly;
} else if (!YGResolveValue(maxDimensions[YGDimensionWidth], ownerWidth)
.isUndefined()) {
width =
YGResolveValue(maxDimensions[YGDimensionWidth], ownerWidth).unwrap();
widthMeasureMode = YGMeasureModeAtMost;
} else {
width = ownerWidth;
widthMeasureMode = YGFloatIsUndefined(width) ? YGMeasureModeUndefined
: YGMeasureModeExactly;
}
float height = YGUndefined;
YGMeasureMode heightMeasureMode = YGMeasureModeUndefined;
if (YGNodeIsStyleDimDefined(node, YGFlexDirectionColumn, ownerHeight)) {
height = (YGResolveValue(
node->getResolvedDimension(dim[YGFlexDirectionColumn]),
ownerHeight) +
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth))
.unwrap();
heightMeasureMode = YGMeasureModeExactly;
} else if (!YGResolveValue(maxDimensions[YGDimensionHeight], ownerHeight)
.isUndefined()) {
height =
YGResolveValue(maxDimensions[YGDimensionHeight], ownerHeight).unwrap();
heightMeasureMode = YGMeasureModeAtMost;
} else {
height = ownerHeight;
heightMeasureMode = YGFloatIsUndefined(height) ? YGMeasureModeUndefined
: YGMeasureModeExactly;
}
if (YGLayoutNodeInternal(
node,
width,
height,
ownerDirection,
widthMeasureMode,
heightMeasureMode,
ownerWidth,
ownerHeight,
true,
LayoutPassReason::kInitial,
node->getConfig(),
markerData,
layoutContext,
0, // tree root
gCurrentGenerationCount.load(std::memory_order_relaxed))) {
node->setPosition(
node->getLayout().direction(), ownerWidth, ownerHeight, ownerWidth);
YGRoundToPixelGrid(node, node->getConfig()->pointScaleFactor, 0.0f, 0.0f);
#ifdef DEBUG
if (node->getConfig()->printTree) {
YGNodePrint(
node,
(YGPrintOptions)(
YGPrintOptionsLayout | YGPrintOptionsChildren |
YGPrintOptionsStyle));
}
#endif
}
Event::publish<Event::LayoutPassEnd>(node, {layoutContext, &markerData});
// We want to get rid off `useLegacyStretchBehaviour` from YGConfig. But we
// aren't sure whether client's of yoga have gotten rid off this flag or not.
// So logging this in YGLayout would help to find out the call sites depending
// on this flag. This check would be removed once we are sure no one is
// dependent on this flag anymore. The flag
// `shouldDiffLayoutWithoutLegacyStretchBehaviour` in YGConfig will help to
// run experiments.
if (node->getConfig()->shouldDiffLayoutWithoutLegacyStretchBehaviour &&
node->didUseLegacyFlag()) {
const YGNodeRef nodeWithoutLegacyFlag = YGNodeDeepClone(node);
nodeWithoutLegacyFlag->resolveDimension();
// Recursively mark nodes as dirty
nodeWithoutLegacyFlag->markDirtyAndPropogateDownwards();
gCurrentGenerationCount.fetch_add(1, std::memory_order_relaxed);
// Rerun the layout, and calculate the diff
unsetUseLegacyFlagRecursively(nodeWithoutLegacyFlag);
LayoutData layoutMarkerData = {};
if (YGLayoutNodeInternal(
nodeWithoutLegacyFlag,
width,
height,
ownerDirection,
widthMeasureMode,
heightMeasureMode,
ownerWidth,
ownerHeight,
true,
LayoutPassReason::kInitial,
nodeWithoutLegacyFlag->getConfig(),
layoutMarkerData,
layoutContext,
0, // tree root
gCurrentGenerationCount.load(std::memory_order_relaxed))) {
nodeWithoutLegacyFlag->setPosition(
nodeWithoutLegacyFlag->getLayout().direction(),
ownerWidth,
ownerHeight,
ownerWidth);
YGRoundToPixelGrid(
nodeWithoutLegacyFlag,
nodeWithoutLegacyFlag->getConfig()->pointScaleFactor,
0.0f,
0.0f);
// Set whether the two layouts are different or not.
auto neededLegacyStretchBehaviour =
!nodeWithoutLegacyFlag->isLayoutTreeEqualToNode(*node);
node->setLayoutDoesLegacyFlagAffectsLayout(neededLegacyStretchBehaviour);
#ifdef DEBUG
if (nodeWithoutLegacyFlag->getConfig()->printTree) {
YGNodePrint(
nodeWithoutLegacyFlag,
(YGPrintOptions)(
YGPrintOptionsLayout | YGPrintOptionsChildren |
YGPrintOptionsStyle));
}
#endif
}
YGConfigFreeRecursive(nodeWithoutLegacyFlag);
YGNodeFreeRecursive(nodeWithoutLegacyFlag);
}
}
YOGA_EXPORT void YGNodeCalculateLayout(
const YGNodeRef node,
const float ownerWidth,
const float ownerHeight,
const YGDirection ownerDirection) {
YGNodeCalculateLayoutWithContext(
node, ownerWidth, ownerHeight, ownerDirection, nullptr);
}
YOGA_EXPORT void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) {
if (logger != nullptr) {
config->setLogger(logger);
} else {
#ifdef ANDROID
config->setLogger(&YGAndroidLog);
#else
config->setLogger(&YGDefaultLog);
#endif
}
}
YOGA_EXPORT void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
const YGConfigRef config,
const bool shouldDiffLayout) {
config->shouldDiffLayoutWithoutLegacyStretchBehaviour = shouldDiffLayout;
}
void YGAssert(const bool condition, const char* message) {
if (!condition) {
Log::log(YGNodeRef{nullptr}, YGLogLevelFatal, nullptr, "%s\n", message);
throwLogicalErrorWithMessage(message);
}
}
void YGAssertWithNode(
const YGNodeRef node,
const bool condition,
const char* message) {
if (!condition) {
Log::log(node, YGLogLevelFatal, nullptr, "%s\n", message);
throwLogicalErrorWithMessage(message);
}
}
void YGAssertWithConfig(
const YGConfigRef config,
const bool condition,
const char* message) {
if (!condition) {
Log::log(config, YGLogLevelFatal, nullptr, "%s\n", message);
throwLogicalErrorWithMessage(message);
}
}
YOGA_EXPORT void YGConfigSetExperimentalFeatureEnabled(
const YGConfigRef config,
const YGExperimentalFeature feature,
const bool enabled) {
config->experimentalFeatures[feature] = enabled;
}
inline bool YGConfigIsExperimentalFeatureEnabled(
const YGConfigRef config,
const YGExperimentalFeature feature) {
return config->experimentalFeatures[feature];
}
YOGA_EXPORT void YGConfigSetUseWebDefaults(
const YGConfigRef config,
const bool enabled) {
config->useWebDefaults = enabled;
}
YOGA_EXPORT void YGConfigSetUseLegacyStretchBehaviour(
const YGConfigRef config,
const bool useLegacyStretchBehaviour) {
config->useLegacyStretchBehaviour = useLegacyStretchBehaviour;
}
bool YGConfigGetUseWebDefaults(const YGConfigRef config) {
return config->useWebDefaults;
}
YOGA_EXPORT void YGConfigSetContext(const YGConfigRef config, void* context) {
config->context = context;
}
YOGA_EXPORT void* YGConfigGetContext(const YGConfigRef config) {
return config->context;
}
YOGA_EXPORT void YGConfigSetCloneNodeFunc(
const YGConfigRef config,
const YGCloneNodeFunc callback) {
config->setCloneNodeCallback(callback);
}
static void YGTraverseChildrenPreOrder(
const YGVector& children,
const std::function<void(YGNodeRef node)>& f) {
for (YGNodeRef node : children) {
f(node);
YGTraverseChildrenPreOrder(node->getChildren(), f);
}
}
void YGTraversePreOrder(
YGNodeRef const node,
std::function<void(YGNodeRef node)>&& f) {
if (!node) {
return;
}
f(node);
YGTraverseChildrenPreOrder(node->getChildren(), f);
}
| 157,621
| 46,952
|
/*
MobileRobots Advanced Robotics Interface for Applications (ARIA)
Copyright (C) 2004, 2005 ActivMedia Robotics LLC
Copyright (C) 2006, 2007, 2008, 2009 MobileRobots Inc.
Copyright (C) 2010, 2011 Adept Technology, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
If you wish to redistribute ARIA under different terms, contact
Adept MobileRobots for information about a commercial version of ARIA at
robots@mobilerobots.com or
Adept MobileRobots, 10 Columbia Drive, Amherst, NH 03031; 800-639-9481
*/
#define _GNU_SOURCE 1 // for isnormal() and other newer (non-ansi) C functions
#include "ArExport.h"
#include "ariaOSDef.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#ifdef WIN32
#include <windows.h> // for timeGetTime() and mmsystem.h
#include <mmsystem.h> // for timeGetTime()
#else
#include <sys/time.h>
#include <stdarg.h>
#include <unistd.h>
#include <utime.h>
#include <sys/types.h>
#include <dirent.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#endif
#include "ariaInternal.h"
#include "ariaTypedefs.h"
#include "ariaUtil.h"
#ifndef ARINTERFACE
#include "ArSick.h"
#include "ArUrg.h"
#include "ArLMS1XX.h"
#include "ArUrg_2_0.h"
#endif // ARINTERFACE
#include "ArSerialConnection.h"
#include "ArTcpConnection.h"
#ifdef WIN32
#include <io.h>
AREXPORT const char *ArUtil::COM1 = "COM1";
AREXPORT const char *ArUtil::COM2 = "COM2";
AREXPORT const char *ArUtil::COM3 = "COM3";
AREXPORT const char *ArUtil::COM4 = "COM4";
AREXPORT const char *ArUtil::COM5 = "COM5";
AREXPORT const char *ArUtil::COM6 = "COM6";
AREXPORT const char *ArUtil::COM7 = "COM7";
AREXPORT const char *ArUtil::COM8 = "COM8";
AREXPORT const char *ArUtil::COM9 = "COM9";
AREXPORT const char *ArUtil::COM10 = "COM10";
AREXPORT const char *ArUtil::COM11 = "COM11";
AREXPORT const char *ArUtil::COM12 = "COM12";
AREXPORT const char *ArUtil::COM13 = "COM13";
AREXPORT const char *ArUtil::COM14 = "COM14";
AREXPORT const char *ArUtil::COM15 = "COM15";
AREXPORT const char *ArUtil::COM16 = "COM16";
#else // ifndef WIN32
AREXPORT const char *ArUtil::COM1 = "/dev/ttyS0";
AREXPORT const char *ArUtil::COM2 = "/dev/ttyS1";
AREXPORT const char *ArUtil::COM3 = "/dev/ttyS2";
AREXPORT const char *ArUtil::COM4 = "/dev/ttyS3";
AREXPORT const char *ArUtil::COM5 = "/dev/ttyS4";
AREXPORT const char *ArUtil::COM6 = "/dev/ttyS5";
AREXPORT const char *ArUtil::COM7 = "/dev/ttyS6";
AREXPORT const char *ArUtil::COM8 = "/dev/ttyS7";
AREXPORT const char *ArUtil::COM9 = "/dev/ttyS8";
AREXPORT const char *ArUtil::COM10 = "/dev/ttyS9";
AREXPORT const char *ArUtil::COM11 = "/dev/ttyS10";
AREXPORT const char *ArUtil::COM12 = "/dev/ttyS11";
AREXPORT const char *ArUtil::COM13 = "/dev/ttyS12";
AREXPORT const char *ArUtil::COM14 = "/dev/ttyS13";
AREXPORT const char *ArUtil::COM15 = "/dev/ttyS14";
AREXPORT const char *ArUtil::COM16 = "/dev/ttyS15";
#endif // WIN32
AREXPORT const char *ArUtil::TRUESTRING = "true";
AREXPORT const char *ArUtil::FALSESTRING = "false";
// const double eps = std::numeric_limits<double>::epsilon();
const double ArMath::ourEpsilon = 0.00000001;
#ifdef WIN32
// max returned by rand()
const long ArMath::ourRandMax = RAND_MAX;
#else
// max returned by lrand48()
const long ArMath::ourRandMax = 2147483648;// 2^31, per lrand48 man page
#endif
#ifdef WIN32
const char ArUtil::SEPARATOR_CHAR = '\\';
const char *ArUtil::SEPARATOR_STRING = "\\";
const char ArUtil::OTHER_SEPARATOR_CHAR = '/';
#else
const char ArUtil::SEPARATOR_CHAR = '/';
const char *ArUtil::SEPARATOR_STRING = "/";
const char ArUtil::OTHER_SEPARATOR_CHAR = '\\';
#endif
#ifdef WIN32
ArMutex ArUtil::ourLocaltimeMutex;
#endif
/**
This sleeps for the given number of milliseconds... Note in linux it
tries to sleep for 10 ms less than the amount given, which should wind up
close to correct...
Linux is broken in this regard and sleeps for too long...
it sleeps for the ceiling of the current 10 ms range,
then for an additional 10 ms... so:
11 to 20 ms sleeps for 30 ms...
21 to 30 ms sleeps for 40 ms...
31 to 40 ms sleeps for 50 ms...
this continues on up to the values we care about of..
81 to 90 ms sleeps for 100 ms...
91 to 100 ms sleeps for 110 ms...
so we'll sleep for 10 ms less than we want to, which should put us about
right... guh
@param ms the number of milliseconds to sleep for
*/
AREXPORT void ArUtil::sleep(unsigned int ms)
{
#ifdef WIN32
Sleep(ms);
#else // ifndef win32
if (ms > 10)
ms -= 10;
usleep(ms * 1000);
#endif // linux
}
/**
Get the time in milliseconds, counting from some arbitrary point.
This time is only valid within this run of the program.
@return millisecond time
*/
AREXPORT unsigned int ArUtil::getTime(void)
{
// the good unix way
#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
struct timespec tp;
if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
return tp.tv_nsec / 1000000 + (tp.tv_sec % 1000000)*1000;
// the old unix way as a fallback
#endif // if it isn't the good way
#if !defined(WIN32)
struct timeval tv;
if (gettimeofday(&tv,NULL) == 0)
return tv.tv_usec/1000 + (tv.tv_sec % 1000000)*1000;//windows
else
return 0;
#elif defined(WIN32)
return timeGetTime();
#endif
}
/*
Takes a string and splits it into a list of words. It appends the words
to the outList. If there is nothing found, it will not touch the outList.
@param inString the input string to split
@param outList the list in which to store the words that are found
*/
/*
AREXPORT void ArUtil::splitString(std::string inString,
std::list<std::string> &outList)
{
const char *start, *end;
// Strip off leading white space
for (end=inString.c_str(); *end && isspace(*end); ++end)
;
while (*end)
{
// Mark start of the word then find end
for (start=end; *end && !isspace(*end); ++end)
;
// Store the word
if (*start && ((*end && isspace(*end)) || !*end))
outList.push_back(std::string(start, (int)(end-start)));
for (; *end && isspace(*end); ++end)
;
}
}
*/
#ifdef WIN32
/**
@return size in bytes. -1 on error.
@param fileName name of the file to size
*/
AREXPORT long ArUtil::sizeFile(std::string fileName)
{
struct _stat buf;
if (_stat(fileName.c_str(), &buf) < 0)
return(-1);
if (!(buf.st_mode | _S_IFREG))
return(-1);
return(buf.st_size);
}
/**
@return size in bytes. -1 on error.
@param fileName name of the file to size
*/
AREXPORT long ArUtil::sizeFile(const char * fileName)
{
struct _stat buf;
if (_stat(fileName, &buf) < 0)
return(-1);
if (!(buf.st_mode | _S_IFREG))
return(-1);
return(buf.st_size);
}
#else // !WIN32
AREXPORT long ArUtil::sizeFile(std::string fileName)
{
struct stat buf;
if (stat(fileName.c_str(), &buf) < 0)
{
ArLog::logErrorFromOS(ArLog::Normal, "ArUtil::sizeFile: stat failed");
return(-1);
}
if (!S_ISREG(buf.st_mode))
return(-1);
return(buf.st_size);
}
/**
@return size in bytes. -1 on error.
@param fileName name of the file to size
*/
AREXPORT long ArUtil::sizeFile(const char * fileName)
{
struct stat buf;
if (stat(fileName, &buf) < 0)
{
ArLog::logErrorFromOS(ArLog::Normal, "ArUtil::sizeFile: stat failed");
return(-1);
}
if (!S_ISREG(buf.st_mode))
return(-1);
return(buf.st_size);
}
#endif // else !WIN32
/**
@return true if file is found
@param fileName name of the file to size
*/
AREXPORT bool ArUtil::findFile(const char *fileName)
{
FILE *fp;
if ((fp=ArUtil::fopen(fileName, "r")))
{
fclose(fp);
return(true);
}
else
return(false);
}
/*
Works for \ and /. Returns true if something was actualy done. Sets
fileOut to be what ever the answer is.
@return true if the path contains a file
@param fileIn input path/fileName
@param fileOut output fileName
*/
/*AREXPORT bool ArUtil::stripDir(std::string fileIn, std::string &fileOut)
{
const char *ptr;
for (ptr=fileIn.c_str(); *ptr; ++ptr)
;
for (--ptr; (ptr > fileIn.c_str()) && (*ptr != '/') && (*ptr != '\\'); --ptr)
;
if ((*ptr == '/') || (*ptr == '\\'))
{
fileOut=ptr+1;
return(true);
}
else
{
fileOut=fileIn;
return(false);
}
}
*/
/*
Works for \ and /. Returns true if something was actualy done. Sets
fileOut to be what ever the answer is.
@return true if the file contains a path
@param fileIn input path/fileName
@param fileOut output path
*/
/*
AREXPORT bool ArUtil::stripFile(std::string fileIn, std::string &fileOut)
{
const char *start, *end;
for (start=end=fileIn.c_str(); *end; ++end)
{
if ((*end == '/') || (*end == '\\'))
{
start=end;
for (; *end && ((*end == '/') || (*end == '\\')); ++end)
;
}
}
if (start < end)
{
fileOut.assign(fileIn, 0, start-fileIn.c_str());
return(true);
}
fileOut=fileIn;
return(false);
}
*/
AREXPORT bool ArUtil::stripQuotes(char *dest, const char *src, size_t destLen)
{
size_t srcLen = strlen(src);
if (destLen < srcLen + 1)
{
ArLog::log(ArLog::Normal, "ArUtil::stripQuotes: destLen isn't long enough to fit copy its %d should be %d", destLen, srcLen + 1);
return false;
}
// if there are no quotes to strip just copy and return
if (srcLen < 2 ||
(src[0] != '"' || src[srcLen - 1] != '"'))
{
strcpy(dest, src);
return true;
}
// we have quotes so chop of the first and last char
strncpy(dest, &src[1], srcLen - 1);
dest[srcLen - 2] = '\0';
return true;
}
/** Append a directory separator character to the given path string, depending on the
* platform. On Windows, a backslash ('\\') is added. On other platforms, a
* forward slash ('/') is appended. If there is no more allocated space in the
* path string, no character will be appended.
@param path the path string to append a slash to
@param pathLength maximum length allocated for path string
*/
AREXPORT void ArUtil::appendSlash(char *path, size_t pathLength)
{
// first check boundary
size_t len;
len = strlen(path);
if (len > pathLength - 2)
return;
if (len == 0 || (path[len - 1] != '\\' && path[len - 1] != '/'))
{
#ifdef WIN32
path[len] = '\\';
#else
path[len] = '/';
#endif
path[len + 1] = '\0';
}
}
AREXPORT void ArUtil::appendSlash(std::string &path)
{
// first check boundary
size_t len = path.length();
if ((len == 0) ||
(path[len - 1] != SEPARATOR_CHAR && path[len - 1] != OTHER_SEPARATOR_CHAR)) {
path += SEPARATOR_STRING;
}
} // end method appendSlash
/**
@param path the path in which to fix the orientation of the slashes
@param pathLength the maximum length of path
*/
AREXPORT void ArUtil::fixSlashes(char *path, size_t pathLength)
{
#ifdef WIN32
fixSlashesBackward(path, pathLength);
#else
fixSlashesForward(path, pathLength);
#endif
}
/**
@param path the path in which to fix the orientation of the slashes
@param pathLength how long that path is at max
*/
AREXPORT void ArUtil::fixSlashesBackward(char *path, size_t pathLength)
{
for (size_t i=0; path[i] != '\0' && i < pathLength; i++)
{
if (path[i] == '/')
path[i]='\\';
}
}
/**
@param path the path in which to fix the orientation of the slashes
@param pathLength how long that path is at max
*/
AREXPORT void ArUtil::fixSlashesForward(char *path, size_t pathLength)
{
for (size_t i=0; path[i] != '\0' && i < pathLength; i++)
{
if (path[i] == '\\')
path[i]='/';
}
}
/**
@param path the path in which to fix the orientation of the slashes
*/
AREXPORT void ArUtil::fixSlashes(std::string &path)
{
for (size_t i = 0; i < path.length(); i++)
{
if (path[i] == OTHER_SEPARATOR_CHAR)
path[i]= SEPARATOR_CHAR;
}
}
AREXPORT char ArUtil::getSlash()
{
return SEPARATOR_CHAR;
}
/**
This function will take the 'baseDir' and put the 'insideDir' after
it so that it winds up with 'baseDir/insideDir/'. It will take
care of slashes, making sure there is one between them and one at
the end, and the slashes will match what the operating system
expects.
@param dest the place to put the result
@param destLength the length of the place to put the results
@param baseDir the directory to start with
@param insideDir the directory to place after the baseDir
**/
AREXPORT void ArUtil::addDirectories(char *dest, size_t destLength,
const char *baseDir,
const char *insideDir)
{
// start it off
strncpy(dest, baseDir, destLength - 1);
// make sure we have a null term
dest[destLength - 1] = '\0';
// toss on that slash
appendSlash(dest, destLength);
// put on the inside dir
strncat(dest, insideDir, destLength - strlen(dest) - 1);
// now toss on that slash
appendSlash(dest, destLength);
// and now fix up all the slashes
fixSlashes(dest, destLength);
}
/**
This compares two strings, it returns an integer less than, equal to,
or greater than zero if str is found, respectively, to be less than, to
match, or be greater than str2.
@param str the string to compare
@param str2 the second string to compare
@return an integer less than, equal to, or greater than zero if str is
found, respectively, to be less than, to match, or be greater than str2.
*/
AREXPORT int ArUtil::strcmp(std::string str, std::string str2)
{
return ::strcmp(str.c_str(), str2.c_str());
}
/**
This compares two strings, it returns an integer less than, equal to,
or greater than zero if str is found, respectively, to be less than, to
match, or be greater than str2.
@param str the string to compare
@param str2 the second string to compare
@return an integer less than, equal to, or greater than zero if str is
found, respectively, to be less than, to match, or be greater than str2.
*/
AREXPORT int ArUtil::strcmp(std::string str, const char *str2)
{
return ::strcmp(str.c_str(), str2);
}
/**
This compares two strings, it returns an integer less than, equal to,
or greater than zero if str is found, respectively, to be less than, to
match, or be greater than str2.
@param str the string to compare
@param str2 the second string to compare
@return an integer less than, equal to, or greater than zero if str is
found, respectively, to be less than, to match, or be greater than str2.
*/
AREXPORT int ArUtil::strcmp(const char *str, std::string str2)
{
return ::strcmp(str, str2.c_str());
}
/**
This compares two strings, it returns an integer less than, equal to,
or greater than zero if str is found, respectively, to be less than, to
match, or be greater than str2.
@param str the string to compare
@param str2 the second string to compare
@return an integer less than, equal to, or greater than zero if str is
found, respectively, to be less than, to match, or be greater than str2.
*/
AREXPORT int ArUtil::strcmp(const char *str, const char *str2)
{
return ::strcmp(str, str2);
}
/**
This compares two strings ignoring case, it returns an integer
less than, equal to, or greater than zero if str is found,
respectively, to be less than, to match, or be greater than str2.
@param str the string to compare @param str2 the second string to
compare @return an integer less than, equal to, or greater than
zero if str is found, respectively, to be less than, to match, or
be greater than str2. */
AREXPORT int ArUtil::strcasecmp(std::string str, std::string str2)
{
return ::strcasecmp(str.c_str(), str2.c_str());
}
/**
This compares two strings ignoring case, it returns an integer
less than, equal to, or greater than zero if str is found,
respectively, to be less than, to match, or be greater than str2.
@param str the string to compare @param str2 the second string to
compare @return an integer less than, equal to, or greater than
zero if str is found, respectively, to be less than, to match, or
be greater than str2. */
AREXPORT int ArUtil::strcasecmp(std::string str, const char *str2)
{
return ::strcasecmp(str.c_str(), str2);
}
/**
This compares two strings ignoring case, it returns an integer
less than, equal to, or greater than zero if str is found,
respectively, to be less than, to match, or be greater than str2.
@param str the string to compare @param str2 the second string to
compare @return an integer less than, equal to, or greater than
zero if str is found, respectively, to be less than, to match, or
be greater than str2. */
AREXPORT int ArUtil::strcasecmp(const char *str, std::string str2)
{
return ::strcasecmp(str, str2.c_str());
}
/**
This compares two strings ignoring case, it returns an integer
less than, equal to, or greater than zero if str is found,
respectively, to be less than, to match, or be greater than str2.
@param str the string to compare @param str2 the second string to
compare @return an integer less than, equal to, or greater than
zero if str is found, respectively, to be less than, to match, or
be greater than str2. */
AREXPORT int ArUtil::strcasecmp(const char *str, const char *str2)
{
return ::strcasecmp(str, str2);
}
AREXPORT int ArUtil::strcasequotecmp(const std::string &str1,
const std::string &str2)
{
int len1 = str1.length();
size_t pos1 = 0;
if ((len1 >= 2) && (str1[0] == '\"') && (str1[len1 - 1] == '\"')) {
pos1 = 1;
}
int len2 = str2.length();
size_t pos2 = 0;
if ((len2 >= 2) && (str2[0] == '\"') && (str2[len2 - 1] == '\"')) {
pos2 = 1;
}
/* Unfortunately gcc2 does't support the 5 argument version of std::string::compare()...
* (Furthermore, note that it's 3-argument compare has the arguments in the wrong order.)
*/
#if defined(__GNUC__) && (__GNUC__ <= 2) && (__GNUC_MINOR__ <= 96)
#warning Using GCC 2.96 or less so must use nonstandard std::string::compare method.
int cmp = str1.compare(str2.substr(pos2, len2 - 2 * pos2), pos1, len1 - 2 * pos1);
#else
int cmp = str1.compare(pos1,
len1 - 2 * pos1,
str2,
pos2,
len2 - 2 * pos2);
#endif
return cmp;
} // end method strcasequotecmp
/**
This copies src into dest but puts a \ before any spaces in src,
escaping them... its mostly for use with ArArgumentBuilder...
make sure you have at least maxLen spaces in the arrays that you're passing
as dest... this allocates no memory
**/
AREXPORT void ArUtil::escapeSpaces(char *dest, const char *src, size_t maxLen)
{
size_t i, adj, len;
len = strlen(src);
// walk it, when we find one toss in the slash and incr adj so the
// next characters go in the right space
for (i = 0, adj = 0; i < len && i + adj < maxLen; i++)
{
if (src[i] == ' ')
{
dest[i+adj] = '\\';
adj++;
}
dest[i+adj] = src[i];
}
// make sure its null terminated
dest[i+adj] = '\0';
}
/**
This copies src into dest but makes it lower case make sure you
have at least maxLen arrays that you're passing as dest... this
allocates no memory
**/
AREXPORT void ArUtil::lower(char *dest, const char *src, size_t maxLen)
{
size_t i;
size_t len;
len = strlen(src);
for (i = 0; i < len && i < maxLen; i++)
dest[i] = tolower(src[i]);
dest[i] = '\0';
}
AREXPORT bool ArUtil::isOnlyAlphaNumeric(const char *str)
{
unsigned int ui;
unsigned int len;
if (str == NULL)
return true;
for (ui = 0, len = strlen(str); ui < len; ui++)
{
if (!isalpha(str[ui]) && !isdigit(str[ui]) && str[ui] != '\0')
return false;
}
return true;
}
AREXPORT bool ArUtil::isOnlyNumeric(const char *str)
{
if (str == NULL)
return true;
for (unsigned i = 0, len = strlen(str); i < len; i++)
{
if (!isdigit(str[i]) && str[i] != '\0')
return false;
}
return true;
}
AREXPORT bool ArUtil::isStrEmpty(const char *str)
{
if (str == NULL) {
return true;
}
if (str[0] == '\0') {
return true;
}
return false;
} // end method isStrEmpty
AREXPORT bool ArUtil::isStrInList(const char *str,
const std::list<std::string> &list,
bool isIgnoreCase)
{
if (str == NULL) {
return false;
}
for (std::list<std::string>::const_iterator aIter = list.begin();
aIter != list.end();
aIter++) {
if (!isIgnoreCase) {
if (strcmp((*aIter).c_str(), str) == 0) {
return true;
}
}
else { // ignore case
if (strcasecmp((*aIter).c_str(), str) == 0) {
return true;
}
} // end else ignore case
} // end for each string
return false;
} // end method isStrInList
AREXPORT const char *ArUtil::convertBool(int val)
{
if (val)
return TRUESTRING;
else
return FALSESTRING;
}
AREXPORT double ArUtil::atof(const char *nptr)
{
if (strcasecmp(nptr, "inf") == 0)
return HUGE_VAL;
else if (strcasecmp(nptr, "-inf") == 0)
return -HUGE_VAL;
else
return ::atof(nptr);
}
AREXPORT void ArUtil::functorPrintf(ArFunctor1<const char *> *functor,
char *str, ...)
{
char buf[10000];
va_list ptr;
va_start(ptr, str);
//vsprintf(buf, str, ptr);
vsnprintf(buf, sizeof(buf) - 1, str, ptr);
buf[sizeof(buf) - 1] = '\0';
functor->invoke(buf);
va_end(ptr);
}
AREXPORT void ArUtil::writeToFile(const char *str, FILE *file)
{
fputs(str, file);
}
/**
This function reads a string from a file.
The file can contain spaces or tabs, but a '\\r'
or '\\n' will be treated as the end of the string, and the string
cannot have more characters than the value given by strLen. This is mostly for internal use
with Linux to determine the Aria directory from a file in /etc, but
will work with Linux or Windows.
@param fileName name of the file in which to look
@param str the string to copy the file contents into
@param strLen the maximum allocated length of str
**/
AREXPORT bool ArUtil::getStringFromFile(const char *fileName,
char *str, size_t strLen)
{
FILE *strFile;
unsigned int i;
str[0] = '\0';
if ((strFile = ArUtil::fopen(fileName, "r")) != NULL)
{
fgets(str, strLen, strFile);
for (i = 0; i < strLen; i++)
{
if (str[i] == '\r' || str[i] == '\n' || str[i] == '\0')
{
str[i] = '\0';
fclose(strFile);
break;
}
}
}
else
{
str[0] = '\0';
return false;
}
return true;
}
/**
* Look up the given value under the given key, within the given registry root
* key.
@param root the root key to use, one of the REGKEY enum values
@param key the name of the key to find
@param value the value name in which to find the string
@param str where to put the string found, or if it could not be
found, an empty (length() == 0) string
@param len the length of the allocated memory in str
@return true if the string was found, false if it was not found or if there was a problem such as the string not being long enough
**/
AREXPORT bool ArUtil::getStringFromRegistry(REGKEY root,
const char *key,
const char *value,
char *str,
int len)
{
#ifndef WIN32
return false;
#else // WIN32
HKEY hkey;
int err;
unsigned long numKeys;
unsigned long longestKey;
unsigned long numValues;
unsigned long longestValue;
unsigned long longestDataLength;
char *valueName;
unsigned long valueLength;
unsigned long type;
char *data;
unsigned long dataLength;
HKEY rootKey;
switch (root)
{
case REGKEY_CLASSES_ROOT:
rootKey = HKEY_CLASSES_ROOT;
break;
case REGKEY_CURRENT_CONFIG:
rootKey = HKEY_CURRENT_CONFIG;
break;
case REGKEY_CURRENT_USER:
rootKey = HKEY_CURRENT_USER;
break;
case REGKEY_LOCAL_MACHINE:
rootKey = HKEY_LOCAL_MACHINE;
break;
case REGKEY_USERS:
rootKey=HKEY_USERS;
break;
default:
ArLog::log(ArLog::Terse,
"ArUtil::getStringFromRegistry: Bad root key given.");
return false;
}
if ((err = RegOpenKeyEx(rootKey, key, 0, KEY_READ, &hkey)) == ERROR_SUCCESS)
{
//printf("Got a key\n");
if (RegQueryInfoKey(hkey, NULL, NULL, NULL, &numKeys, &longestKey, NULL,
&numValues, &longestValue, &longestDataLength, NULL, NULL) == ERROR_SUCCESS)
{
/*
printf("Have %d keys longest is %d, have %d values longest name is %d, longest data is %d\n",
numKeys, longestKey, numValues, longestValue, longestDataLength);
*/
data = new char[longestDataLength+2];
valueName = new char[longestValue+2];
for (unsigned long i = 0; i < numValues; ++i)
{
dataLength = longestDataLength+1;
valueLength = longestValue+1;
if ((err = RegEnumValue(hkey, i, valueName, &valueLength, NULL,
&type, (unsigned char *)data, &dataLength)) == ERROR_SUCCESS)
{
//printf("Enumed value %d, name is %s, value is %s\n", i, valueName, data);
if (strcmp(value, valueName) == 0)
{
if (len < dataLength)
{
ArLog::log(ArLog::Terse,"ArUtil::getStringFromRegistry: str passed in not long enough for data.");
delete data;
delete valueName;
return false;
}
strncpy(str, data, len);
delete data;
delete valueName;
return true;
}
}
/*
else
printf("Couldn't enum value %d cause %d\n",i, err);
*/
}
delete data;
delete valueName;
}
/*
else
printf("QueryInfoKey failed\n");
*/
}
/*
else
printf("No key %d\n", err);
*/
return false;
#endif
}
#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
bool ArTime::ourMonotonicClock = true;
#endif
AREXPORT void ArTime::setToNow(void)
{
// if we have the best way of finding time use that
#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
if (ourMonotonicClock)
{
struct timespec timeNow;
if (clock_gettime(CLOCK_MONOTONIC, &timeNow) == 0)
{
mySec = timeNow.tv_sec;
myMSec = timeNow.tv_nsec / 1000000;
return;
}
else
{
ourMonotonicClock = false;
ArLog::logNoLock(ArLog::Terse, "ArTime::setToNow: invalid return from clock_gettime.");
}
}
#endif
// if our good way didn't work use the old ways
#ifndef WIN32
struct timeval timeNow;
if (gettimeofday(&timeNow, NULL) == 0)
{
mySec = timeNow.tv_sec;
myMSec = timeNow.tv_usec / 1000;
}
else
ArLog::logNoLock(ArLog::Terse, "ArTime::setToNow: invalid return from gettimeofday.");
// thats probably not available in windows, so this is the one we've been using
#else
/* this should be the better way, but it doesn't really work...
this would be seconds from 1970, but it is based on the
hardware timer or something and so winds up not being updated
all the time and winds up being some number of ms < 20 ms off
struct _timeb startTime;
_ftime(&startTime);
mySec = startTime.time;
myMSec = startTime.millitm;*/
// so we're going with just their normal function, msec since boot
long timeNow;
timeNow = timeGetTime();
mySec = timeNow / 1000;
myMSec = timeNow % 1000;
// but if the good way isn't available use the old way...
#endif
}
AREXPORT ArRunningAverage::ArRunningAverage(size_t numToAverage)
{
myNumToAverage = numToAverage;
myTotal = 0;
myNum = 0;
myUseRootMeanSquare = false;
}
AREXPORT ArRunningAverage::~ArRunningAverage()
{
}
AREXPORT double ArRunningAverage::getAverage(void) const
{
if (myNum == 0)
return 0.0;
if (myUseRootMeanSquare)
return sqrt(myTotal / myNum);
else
return myTotal / myNum;
}
AREXPORT void ArRunningAverage::add(double val)
{
if (myUseRootMeanSquare)
myTotal += (val * val);
else
myTotal += val;
myNum++;
myVals.push_front(val);
if (myVals.size() > myNumToAverage || myNum > myNumToAverage)
{
if (myUseRootMeanSquare)
myTotal -= (myVals.back() * myVals.back());
else
myTotal -= myVals.back();
myNum--;
myVals.pop_back();
}
}
AREXPORT void ArRunningAverage::clear(void)
{
while (myVals.size() > 0)
myVals.pop_back();
myNum = 0;
myTotal = 0;
}
AREXPORT size_t ArRunningAverage::getNumToAverage(void) const
{
return myNumToAverage;
}
AREXPORT void ArRunningAverage::setNumToAverage(size_t numToAverage)
{
myNumToAverage = numToAverage;
while (myVals.size() > myNumToAverage)
{
if (myUseRootMeanSquare)
myTotal -= (myVals.back() * myVals.back());
else
myTotal -= myVals.back();
myNum--;
myVals.pop_back();
}
}
AREXPORT size_t ArRunningAverage::getCurrentNumAveraged(void)
{
return myNum;
}
AREXPORT void ArRunningAverage::setUseRootMeanSquare(bool useRootMeanSquare)
{
if (myUseRootMeanSquare != useRootMeanSquare)
{
myTotal = 0;
std::list<double>::iterator it;
for (it = myVals.begin(); it != myVals.end(); it++)
{
if (useRootMeanSquare)
myTotal += ((*it) * (*it));
else
myTotal += (*it);
}
}
myUseRootMeanSquare = useRootMeanSquare;
}
AREXPORT bool ArRunningAverage::getUseRootMeanSquare(void)
{
return myUseRootMeanSquare;
}
AREXPORT ArRootMeanSquareCalculator::ArRootMeanSquareCalculator()
{
clear();
myName = "ArRootMeanSquareCalculator";
}
AREXPORT ArRootMeanSquareCalculator::~ArRootMeanSquareCalculator()
{
}
AREXPORT double ArRootMeanSquareCalculator::getRootMeanSquare (void) const
{
if (myNum == 0)
return 0;
else
return sqrt((double) myTotal / (double)myNum);
}
AREXPORT void ArRootMeanSquareCalculator::add(int val)
{
myTotal += val * val;
myNum++;
if (myTotal < 0)
{
ArLog::log(ArLog::Normal, "%s: total wrapped, resetting", myName.c_str());
clear();
// this isn't a clean fix, but won't let it infinitely loop on a bad value
//add(val);
}
}
AREXPORT void ArRootMeanSquareCalculator::clear(void)
{
myTotal = 0;
myNum = 0;
}
AREXPORT size_t ArRootMeanSquareCalculator::getCurrentNumAveraged(void)
{
return myNum;
}
AREXPORT void ArRootMeanSquareCalculator::setName(const char *name)
{
if (name != NULL)
myName = name;
else
myName = "ArRootMeanSquareCalculator";
}
AREXPORT const char *ArRootMeanSquareCalculator::getName(void)
{
return myName.c_str();
}
#ifndef WIN32
AREXPORT ArDaemonizer::ArDaemonizer(int *argc, char **argv,
bool closeStdErrAndStdOut) :
myParser(argc, argv),
myLogOptionsCB(this, &ArDaemonizer::logOptions)
{
myIsDaemonized = false;
myCloseStdErrAndStdOut = closeStdErrAndStdOut;
Aria::addLogOptionsCB(&myLogOptionsCB);
}
AREXPORT ArDaemonizer::~ArDaemonizer()
{
}
AREXPORT bool ArDaemonizer::daemonize(void)
{
if (myParser.checkArgument("-daemonize") ||
myParser.checkArgument("-d"))
{
return forceDaemonize();
}
else
return true;
}
/**
This returns true if daemonizing worked, returns false if it
didn't... the parent process exits here if forking worked.
**/
AREXPORT bool ArDaemonizer::forceDaemonize(void)
{
switch (fork())
{
case 0: // child process just return
myIsDaemonized = true;
if (myCloseStdErrAndStdOut)
{
fclose(stdout);
fclose(stderr);
}
return true;
case -1: // error.... fail
printf("Can't fork");
ArLog::log(ArLog::Terse, "ArDaemonizer: Can't fork");
return false;
default: // parent process
printf("Daemon started\n");
exit(0);
}
}
AREXPORT void ArDaemonizer::logOptions(void) const
{
ArLog::log(ArLog::Terse, "Options for Daemonizing:");
ArLog::log(ArLog::Terse, "-daemonize");
ArLog::log(ArLog::Terse, "-d");
ArLog::log(ArLog::Terse, "");
}
#endif // WIN32
std::map<ArPriority::Priority, std::string> ArPriority::ourPriorityNames;
std::string ArPriority::ourUnknownPriorityName;
bool ArPriority::ourStringsInited = false;
AREXPORT const char *ArPriority::getPriorityName(Priority priority)
{
if (!ourStringsInited)
{
ourPriorityNames[IMPORTANT] = "Basic";
ourPriorityNames[NORMAL] = "Intermediate";
ourPriorityNames[TRIVIAL] = "Advanced";
ourPriorityNames[DETAILED] = "Advanced";
ourPriorityNames[EXPERT] = "Expert";
ourPriorityNames[FACTORY] = "Factory";
ourUnknownPriorityName = "Unknown";
ourStringsInited = true;
}
std::map<ArPriority::Priority, std::string>::iterator iter =
ourPriorityNames.find(priority);
if (iter != ourPriorityNames.end()) {
return iter->second.c_str();
}
else {
return ourUnknownPriorityName.c_str();
}
}
AREXPORT void ArUtil::putCurrentYearInString(char* s, size_t len)
{
struct tm t;
ArUtil::localtime(&t);
snprintf(s, len, "%4d", 1900 + t.tm_year);
s[len-1] = '\0';
}
AREXPORT void ArUtil::putCurrentMonthInString(char* s, size_t len)
{
struct tm t;
ArUtil::localtime(&t);
snprintf(s, len, "%02d", t.tm_mon + 1);
s[len-1] = '\0';
}
AREXPORT void ArUtil::putCurrentDayInString(char* s, size_t len)
{
struct tm t;
ArUtil::localtime(&t);
snprintf(s, len, "%02d", t.tm_mday);
s[len-1] = '\0';
}
AREXPORT void ArUtil::putCurrentHourInString(char* s, size_t len)
{
struct tm t;
ArUtil::localtime(&t);
snprintf(s, len, "%02d", t.tm_hour);
s[len-1] = '\0';
}
AREXPORT void ArUtil::putCurrentMinuteInString(char* s, size_t len)
{
struct tm t;
ArUtil::localtime(&t);
snprintf(s, len, "%02d", t.tm_min);
s[len-1] = '\0';
}
AREXPORT void ArUtil::putCurrentSecondInString(char* s, size_t len)
{
struct tm t;
ArUtil::localtime(&t);
snprintf(s, len, "%02d", t.tm_sec);
s[len-1] = '\0';
}
AREXPORT time_t ArUtil::parseTime(const char *str, bool *ok, bool toToday)
{
struct tm tmOut;
if (toToday)
{
struct tm now;
if (!localtime(&now))
{
*ok = false;
return 0;
}
memcpy(&tmOut, &now, sizeof(now));
}
else
{
memset(&tmOut, 0, sizeof(tmOut));
// The day-of-the-month starts at 1 (not 0)...
tmOut.tm_mday = 1;
// Setting the year to 70 because if it is left at 0 or 1, then
// the call to mktime() returns an apparently bogus value. Think
// that 70 makes sense since times are generally measured from
// 1/1/1970 (but still, it's all a little strange).
tmOut.tm_year = 70;
tmOut.tm_isdst = -1; // Negative value means unknown
}
bool isValid = true;
int hrs = -1;
int min = -1;
int sec = 0;
ArArgumentBuilder separator(512, ':');
separator.add(str);
// if there's the wrong number of args, or any of the args aren't
// integers then it's invalid and we won't parse it
if ((separator.getArgc() != 2 && separator.getArgc() != 3) ||
!separator.isArgInt(0) || !separator.isArgInt(1) ||
(separator.getArgc() == 3 && !separator.isArgInt(2)))
{
//printf("Invalid... %d\n", separator.getArgc());
//separator.log();
isValid = false;
}
else
{
hrs = separator.getArgInt(0);
min = separator.getArgInt(1);
if (separator.getArgc() == 3)
sec = separator.getArgInt(2);
//printf("Was %02d:%02d:%02d", hrs, min, sec);
}
/*
char *tempBuf = new char[strlen(str) + 1];
strncpy(tempBuf, str, sizeof(tempBuf));
// Attempted to use strptime, but it doesn't seem to be universally
// available.
char *pch = strtok(tempBuf, ":");
if (pch != NULL) {
hrs = atoi(pch);
}
pch = strtok(NULL, ":");
if (pch != NULL) {
min = atoi(pch);
}
*/
// make sure the actual numbers are valid
if (!((hrs >= 0) && (hrs < 24) && (min >= 0) && (min < 60) &&
(sec >= 0) && (sec < 60)))
isValid = false;
if (isValid)
{
tmOut.tm_hour = hrs;
tmOut.tm_min = min;
tmOut.tm_sec = sec;
}
time_t newTime = mktime(&tmOut);
if (ok != NULL)
{
*ok = (isValid && (newTime != -1));
}
//delete [] tempBuf;
return newTime;
} // end method parseTime
AREXPORT bool ArUtil::localtime(const time_t *timep, struct tm *result)
{
#ifdef WIN32
ourLocaltimeMutex.lock();
struct tm *r = ::localtime(timep);
if(r == NULL) {
ourLocaltimeMutex.unlock();
return false;
}
*result = *r; // copy the 'struct tm' object before unlocking.
ourLocaltimeMutex.unlock();
return true;
#else
return (::localtime_r(timep, result) != NULL);
#endif
}
/** Call ArUtil::localtime() with the current time obtained by calling
* time(NULL).
* @return false on error (e.g. invalid input), otherwise true.
*/
AREXPORT bool ArUtil::localtime(struct tm *result)
{
time_t now = time(NULL);
return ArUtil::localtime(&now, result);
}
AREXPORT ArCallbackList::ArCallbackList(
const char *name, ArLog::LogLevel logLevel, bool singleShot)
{
myName = name;
mySingleShot = singleShot;
setLogLevel(logLevel);
std::string mutexName;
mutexName = "ArCallbackList::";
mutexName += name;
mutexName += "::myDataMutex";
myDataMutex.setLogName(mutexName.c_str());
}
AREXPORT ArCallbackList::~ArCallbackList()
{
}
AREXPORT void ArCallbackList::addCallback(
ArFunctor *functor, int position)
{
myDataMutex.lock();
myList.insert(
std::pair<int, ArFunctor *>(-position,
functor));
myDataMutex.unlock();
}
AREXPORT void ArCallbackList::remCallback(ArFunctor *functor)
{
myDataMutex.lock();
std::multimap<int, ArFunctor *>::iterator it;
for (it = myList.begin(); it != myList.end(); it++)
{
if ((*it).second == functor)
{
myList.erase(it);
myDataMutex.unlock();
remCallback(functor);
return;
}
}
myDataMutex.unlock();
}
AREXPORT void ArCallbackList::setName(const char *name)
{
myDataMutex.lock();
myName = name;
myDataMutex.unlock();
}
AREXPORT void ArCallbackList::setNameVar(const char *name, ...)
{
char arg[2048];
va_list ptr;
va_start(ptr, name);
vsnprintf(arg, sizeof(arg), name, ptr);
arg[sizeof(arg) - 1] = '\0';
va_end(ptr);
return setName(arg);
}
AREXPORT void ArCallbackList::setSingleShot(bool singleShot)
{
myDataMutex.lock();
mySingleShot = singleShot;
myDataMutex.unlock();
}
AREXPORT void ArCallbackList::setLogLevel(ArLog::LogLevel logLevel)
{
myDataMutex.lock();
myLogLevel = logLevel;
myDataMutex.unlock();
}
AREXPORT void ArCallbackList::invoke(void)
{
myDataMutex.lock();
std::multimap<int, ArFunctor *>::iterator it;
ArFunctor *functor;
ArLog::log(myLogLevel, "%s: Starting calls", myName.c_str());
for (it = myList.begin();
it != myList.end();
it++)
{
functor = (*it).second;
if (functor == NULL)
continue;
if (functor->getName() != NULL && functor->getName()[0] != '\0')
ArLog::log(myLogLevel, "%s: Calling functor '%s' at %d",
myName.c_str(), functor->getName(), -(*it).first);
else
ArLog::log(myLogLevel, "%s: Calling unnamed functor at %d",
myName.c_str(), -(*it).first);
functor->invoke();
}
ArLog::log(myLogLevel, "%s: Ended calls", myName.c_str());
if (mySingleShot)
{
ArLog::log(myLogLevel, "%s: Clearing callbacks", myName.c_str());
myList.clear();
}
myDataMutex.unlock();
}
#ifndef WIN32
/**
@param baseDir the base directory to work from
@param fileName the fileName to squash the case from
@param result where to put the result
@param resultLen length of the result
@return true if it could find the file, the result is in result,
false if it couldn't find the file
**/
AREXPORT bool ArUtil::matchCase(const char *baseDir,
const char *fileName,
char *result,
size_t resultLen)
{
/***
ArLog::log(ArLog::Normal,
"ArUtil::matchCase() baseDir = \"%s\" fileName = \"%s\"",
baseDir,
fileName);
***/
DIR *dir;
struct dirent *ent;
char separator;
#ifndef WIN32
separator = '/';
#else
separator = '\\';
#endif
result[0] = '\0';
std::list<std::string> split = splitFileName(fileName);
std::list<std::string>::iterator it = split.begin();
std::string finding = (*it);
/*
for (it = split.begin(); it != split.end(); it++)
{
printf("@@@@@@@@ %s\n", (*it).c_str());
}
*/
// how this works is we start at the base dir then read through
// until we find what the next name we need, if entry is a directory
// and we're not at the end of our string list then we change into
// that dir and the while loop keeps going, if the entry isn't a
// directory and matchs and its the last in our string list we've
// found what we want
if ((dir = opendir(baseDir)) == NULL)
{
ArLog::log(ArLog::Normal,
"ArUtil: No such directory '%s' for base",
baseDir);
return false;
}
if (finding == ".")
{
it++;
if (it != split.end())
{
finding = (*it);
}
else
{
ArLog::log(ArLog::Normal,
"ArUtil: No file or directory given (base = %s file = %s)",
baseDir,
fileName);
closedir(dir);
// KMC NEED TO DETERMINE WHICH IS CORRECT.
// The following change appears to be necessary for maps, but is still
// undergoing testing....
// Just return the given ".". (This is necessary to find maps in the local
// directory under some circumstances.)
// snprintf(result, resultLen, finding.c_str());
// return true;
return false;
}
}
while ((ent = readdir(dir)) != NULL)
{
// ignore some of these
if (ent->d_name[0] == '.')
{
//printf("Ignoring %s\n", ent->d_name[0]);
continue;
}
//printf("NAME %s finding %s\n", ent->d_name, finding.c_str());
// we've found what we were looking for
if (ArUtil::strcasecmp(ent->d_name, finding) == 0)
{
size_t lenOfResult;
lenOfResult = strlen(result);
// make sure we can put the filename in
if (strlen(ent->d_name) > resultLen - lenOfResult - 2)
{
ArLog::log(ArLog::Normal,
"ArUtil::matchCase: result not long enough");
closedir(dir);
return false;
}
//printf("Before %s", result);
if (lenOfResult != 0)
{
result[lenOfResult] = separator;
result[lenOfResult+1] = '\0';
}
// put the filename in
strcpy(&result[strlen(result)], ent->d_name);
//printf("after %s\n", result);
// see if we're at the end
it++;
if (it != split.end())
{
//printf("Um.........\n");
finding = (*it);
std::string wholeDir;
wholeDir = baseDir;
wholeDir += result;
closedir(dir);
//printf("'%s' '%s' '%s'\n", baseDir, result, wholeDir.c_str());
if ((dir = opendir(wholeDir.c_str())) == NULL)
{
ArLog::log(ArLog::Normal,
"ArUtil::matchCase: Error going into %s",
result);
return false;
}
}
else
{
//printf("\n########## Got it %s\n", result);
closedir(dir);
return true;
}
}
}
ArLog::log(ArLog::Normal,
"ArUtil::matchCase: %s doesn't exist in %s", fileName,
baseDir);
//printf("!!!!!!!! %s", finding.c_str());
closedir(dir);
return false;
}
#endif // !WIN32
AREXPORT bool ArUtil::getDirectory(const char *fileName,
char *result, size_t resultLen)
{
char separator;
#ifndef WIN32
separator = '/';
#else
separator = '\\';
#endif
if (fileName == NULL || fileName[0] == '\0' || resultLen == 0)
{
ArLog::log(ArLog::Normal, "ArUtil: getDirectory, bad setup");
return false;
}
// just play in the result buffer
strncpy(result, fileName, resultLen - 1);
// make sure its nulled
result[resultLen - 1] = '\0';
char *toPos;
ArUtil::fixSlashes(result, resultLen);
// see where the last directory is
toPos = strrchr(result, separator);
// if there's no divider it must just be a file name
if (toPos == NULL)
{
result[0] = '\0';
return true;
}
// otherwise just toss a null into the last separator and we're done
else
{
*toPos = '\0';
return true;
}
}
AREXPORT bool ArUtil::getFileName(const char *fileName,
char *result, size_t resultLen)
{
char separator;
#ifndef WIN32
separator = '/';
#else
separator = '\\';
#endif
if (fileName == NULL || fileName[0] == '\0' || resultLen == 0)
{
ArLog::log(ArLog::Normal, "ArUtil: getFileName, bad setup");
return false;
}
char *str;
size_t fileNameLen = strlen(fileName);
str = new char[fileNameLen + 1];
//printf("0 %s\n", fileName);
// just play in the result buffer
strncpy(str, fileName, fileNameLen);
// make sure its nulled
str[fileNameLen] = '\0';
//printf("1 %s\n", str);
char *toPos;
ArUtil::fixSlashes(str, fileNameLen + 1);
//printf("2 %s\n", str);
// see where the last directory is
toPos = strrchr(str, separator);
// if there's no divider it must just be a file name
if (toPos == NULL)
{
// copy the filename in and make sure it has a null
strncpy(result, str, resultLen - 1);
result[resultLen - 1] = '\0';
//printf("3 %s\n", result);
delete[] str;
return true;
}
// otherwise take the section from that separator to the end
else
{
strncpy(result, &str[toPos - str + 1], resultLen - 2);
result[resultLen - 1] = '\0';
//printf("4 %s\n", result);
delete[] str;
return true;
}
}
#ifndef WIN32
/**
This function assumes the slashes are all heading the right way already.
**/
std::list<std::string> ArUtil::splitFileName(const char *fileName)
{
std::list<std::string> split;
if (fileName == NULL)
return split;
char separator;
#ifndef WIN32
separator = '/';
#else
separator = '\\';
#endif
size_t len;
size_t i;
size_t last;
bool justSepped;
char entry[2048];
for (i = 0, justSepped = false, last = 0, len = strlen(fileName);
;
i++)
{
if ((fileName[i] == separator && !justSepped)
|| fileName[i] == '\0' || i >= len)
{
if (i - last > 2047)
{
ArLog::log(ArLog::Normal, "ArUtil::splitFileName: some directory or file too long");
}
if (!justSepped)
{
strncpy(entry, &fileName[last], i - last);
entry[i-last] = '\0';
split.push_back(entry);
justSepped = true;
}
if (fileName[i] == '\0' || i >= len)
return split;
}
else if (fileName[i] == separator && justSepped)
{
justSepped = true;
last = i;
}
else if (fileName[i] != separator && justSepped)
{
justSepped = false;
last = i;
}
}
ArLog::log(ArLog::Normal, "ArUtil::splitFileName: file str ('%s') happened weird", fileName);
return split;
}
#endif // !WIN32
AREXPORT bool ArUtil::changeFileTimestamp(const char *fileName,
time_t timestamp)
{
if (ArUtil::isStrEmpty(fileName)) {
ArLog::log(ArLog::Normal,
"Cannot change date on file with empty name");
return false;
}
#ifdef WIN32
FILETIME fileTime;
HANDLE hFile = CreateFile(fileName,
GENERIC_READ | GENERIC_WRITE,
0,NULL,
OPEN_EXISTING,
0,NULL);
if (hFile == NULL) {
return false;
}
// The following is extracted from the MSDN article "Converting a time_t Value
// to a File Time".
LONGLONG temp = Int32x32To64(timestamp, 10000000) + 116444736000000000;
fileTime.dwLowDateTime = (DWORD) temp;
fileTime.dwHighDateTime = temp >> 32;
SetFileTime(hFile,
&fileTime,
(LPFILETIME) NULL, // don't change last access time (?)
&fileTime);
CloseHandle(hFile);
#else // unix
char timeBuf[500];
strftime(timeBuf, sizeof(timeBuf), "%c", ::localtime(×tamp));
ArLog::log(ArLog::Normal,
"Changing file %s modified time to %s",
fileName,
timeBuf);
// time_t newTime = mktime(×tamp);
struct utimbuf fileTime;
fileTime.actime = timestamp;
fileTime.modtime = timestamp;
utime(fileName, &fileTime);
#endif // else unix
return true;
} // end method changeFileTimestamp
AREXPORT void ArUtil::setFileCloseOnExec(int fd, bool closeOnExec)
{
#ifndef WIN32
if (fd <= 0)
return;
int flags;
if ((flags = fcntl(fd, F_GETFD)) < 0)
{
ArLog::log(ArLog::Normal, "ArUtil::setFileCloseOnExec: Cannot use F_GETFD in fnctl on fd %d", fd);
return;
}
if (closeOnExec)
flags |= FD_CLOEXEC;
else
flags &= ~FD_CLOEXEC;
if (fcntl(fd, F_SETFD, flags) < 0)
{
ArLog::log(ArLog::Normal, "ArUtil::setFileCloseOnExec: Cannot use F_GETFD in fnctl on fd %d", fd);
return;
}
#endif
}
AREXPORT void ArUtil::setFileCloseOnExec(FILE *file, bool closeOnExec)
{
if (file != NULL)
setFileCloseOnExec(fileno(file));
}
AREXPORT FILE *ArUtil::fopen(const char *path, const char *mode,
bool closeOnExec)
{
FILE *file;
file = ::fopen(path, mode);
setFileCloseOnExec(file, closeOnExec);
return file;
}
AREXPORT int ArUtil::open(const char *pathname, int flags,
bool closeOnExec)
{
int fd;
fd = ::open(pathname, flags);
setFileCloseOnExec(fd, closeOnExec);
return fd;
}
AREXPORT int ArUtil::open(const char *pathname, int flags, mode_t mode,
bool closeOnExec)
{
int fd;
fd = ::open(pathname, flags, mode);
setFileCloseOnExec(fd, closeOnExec);
return fd;
}
AREXPORT int ArUtil::creat(const char *pathname, mode_t mode,
bool closeOnExec)
{
int fd;
fd = ::creat(pathname, mode);
setFileCloseOnExec(fd, closeOnExec);
return fd;
}
AREXPORT FILE *ArUtil::popen(const char *command, const char *type,
bool closeOnExec)
{
FILE *file;
#ifndef WIN32
file = ::popen(command, type);
#else
file = _popen(command, type);
#endif
setFileCloseOnExec(file, closeOnExec);
return file;
}
AREXPORT bool ArUtil::floatIsNormal(double f)
{
#ifdef WIN32
return (!::_isnan(f) && ::_finite(f));
#else
return isnormal(f);
#endif
}
AREXPORT long ArMath::randomInRange(long m, long n)
{
// simple method
return m + random() / (ourRandMax / (n - m + 1) + 1);
// alternate method is to use drand48, multiply and round (does Windows have
// drand48?), or keep trying numbers until we get one in range.
}
AREXPORT double ArMath::epsilon() { return ourEpsilon; }
AREXPORT long ArMath::getRandMax() { return ourRandMax; }
#ifndef ARINTERFACE
ArGlobalRetFunctor2<ArLaser *, int, const char *>
ArLaserCreatorHelper::ourLMS2xxCB(&ArLaserCreatorHelper::createLMS2xx);
ArGlobalRetFunctor2<ArLaser *, int, const char *>
ArLaserCreatorHelper::ourUrgCB(&ArLaserCreatorHelper::createUrg);
ArGlobalRetFunctor2<ArLaser *, int, const char *>
ArLaserCreatorHelper::ourLMS1XXCB(&ArLaserCreatorHelper::createLMS1XX);
ArGlobalRetFunctor2<ArLaser *, int, const char *>
ArLaserCreatorHelper::ourUrg_2_0CB(&ArLaserCreatorHelper::createUrg_2_0);
ArLaser *ArLaserCreatorHelper::createLMS2xx(int laserNumber,
const char *logPrefix)
{
return new ArLMS2xx(laserNumber);
}
ArRetFunctor2<ArLaser *, int, const char *> *ArLaserCreatorHelper::getCreateLMS2xxCB(void)
{
return &ourLMS2xxCB;
}
ArLaser *ArLaserCreatorHelper::createUrg(int laserNumber, const char *logPrefix)
{
return new ArUrg(laserNumber);
}
ArRetFunctor2<ArLaser *, int, const char *> *ArLaserCreatorHelper::getCreateUrgCB(void)
{
return &ourUrgCB;
}
ArLaser *ArLaserCreatorHelper::createLMS1XX(int laserNumber,
const char *logPrefix)
{
return new ArLMS1XX(laserNumber);
}
ArRetFunctor2<ArLaser *, int, const char *> *ArLaserCreatorHelper::getCreateLMS1XXCB(void)
{
return &ourLMS1XXCB;
}
ArLaser *ArLaserCreatorHelper::createUrg_2_0(int laserNumber,
const char *logPrefix)
{
return new ArUrg_2_0(laserNumber);
}
ArRetFunctor2<ArLaser *, int, const char *> *ArLaserCreatorHelper::getCreateUrg_2_0CB(void)
{
return &ourUrg_2_0CB;
}
#endif // ARINTERFACE
ArGlobalRetFunctor3<ArDeviceConnection *, const char *, const char *, const char *>
ArDeviceConnectionCreatorHelper::ourSerialCB(
&ArDeviceConnectionCreatorHelper::createSerialConnection);
ArGlobalRetFunctor3<ArDeviceConnection *, const char *, const char *, const char *>
ArDeviceConnectionCreatorHelper::ourTcpCB(
&ArDeviceConnectionCreatorHelper::createTcpConnection);
ArLog::LogLevel ArDeviceConnectionCreatorHelper::ourSuccessLogLevel;
ArDeviceConnection *ArDeviceConnectionCreatorHelper::createSerialConnection(
const char *port, const char *defaultInfo, const char *logPrefix)
{
ArDeviceConnection *devConn;
devConn = internalCreateSerialConnection(port, defaultInfo, logPrefix);
return devConn;
}
ArDeviceConnection *ArDeviceConnectionCreatorHelper::internalCreateSerialConnection(
const char *port, const char *defaultInfo, const char *logPrefix)
{
ArSerialConnection *serConn = new ArSerialConnection();
std::string serPort;
if (strcasecmp(port, "COM1") == 0)
serPort = ArUtil::COM1;
else if (strcasecmp(port, "COM2") == 0)
serPort = ArUtil::COM2;
else if (strcasecmp(port, "COM3") == 0)
serPort = ArUtil::COM3;
else if (strcasecmp(port, "COM4") == 0)
serPort = ArUtil::COM4;
else if (strcasecmp(port, "COM5") == 0)
serPort = ArUtil::COM5;
else if (strcasecmp(port, "COM6") == 0)
serPort = ArUtil::COM6;
else if (strcasecmp(port, "COM7") == 0)
serPort = ArUtil::COM7;
else if (strcasecmp(port, "COM8") == 0)
serPort = ArUtil::COM8;
else if (strcasecmp(port, "COM9") == 0)
serPort = ArUtil::COM9;
else if (strcasecmp(port, "COM10") == 0)
serPort = ArUtil::COM10;
else if (strcasecmp(port, "COM11") == 0)
serPort = ArUtil::COM11;
else if (strcasecmp(port, "COM12") == 0)
serPort = ArUtil::COM12;
else if (strcasecmp(port, "COM13") == 0)
serPort = ArUtil::COM13;
else if (strcasecmp(port, "COM14") == 0)
serPort = ArUtil::COM14;
else if (strcasecmp(port, "COM15") == 0)
serPort = ArUtil::COM15;
else if (strcasecmp(port, "COM16") == 0)
serPort = ArUtil::COM16;
else if (port != NULL)
serPort = port;
ArLog::log(ourSuccessLogLevel, "%Set serial port to open %s",
logPrefix, serPort.c_str());
serConn->setPort(serPort.c_str());
return serConn;
/*
This code is commented out because it created problems with demo
(or any other program that used ArLaserConnector::connectLasers
with addAllLasersToRobot as true)
int ret;
if ((ret = serConn->open(serPort.c_str())) == 0)
{
ArLog::log(ourSuccessLogLevel, "%sOpened serial port %s",
logPrefix, serPort.c_str());
return serConn;
}
else
{
ArLog::log(ArLog::Normal, "%sCould not open serial port %s (from %s), because %s",
logPrefix, serPort.c_str(), port,
serConn->getOpenMessage(ret));
delete serConn;
return NULL;
}
*/
}
ArRetFunctor3<ArDeviceConnection *, const char *, const char *, const char *> *
ArDeviceConnectionCreatorHelper::getCreateSerialCB(void)
{
return &ourSerialCB;
}
ArDeviceConnection *ArDeviceConnectionCreatorHelper::createTcpConnection(
const char *port, const char *defaultInfo, const char *logPrefix)
{
ArTcpConnection *tcpConn = new ArTcpConnection;
int ret;
tcpConn->setPort(port, atoi(defaultInfo));
ArLog::log(ourSuccessLogLevel,
"%sSet tcp connection to open %s (and port %d)",
logPrefix, port, atoi(defaultInfo));
return tcpConn;
/*
This code is commented out because it created problems with demo
(or any other program that used ArLaserConnector::connectLasers
with addAllLasersToRobot as true)
if ((ret = tcpConn->open(port, atoi(defaultInfo))) == 0)
{
ArLog::log(ourSuccessLogLevel,
"%sOpened tcp connection from %s (and port %d)",
logPrefix, port, atoi(defaultInfo));
return tcpConn;
}
else
{
ArLog::log(ArLog::Normal, "%sCould not open a tcp connection to host '%s' with default port %d (from '%s'), because %s",
logPrefix, port, atoi(defaultInfo), defaultInfo,
tcpConn->getOpenMessage(ret));
delete tcpConn;
return NULL;
}
*/
}
ArRetFunctor3<ArDeviceConnection *, const char *, const char *, const char *> *
ArDeviceConnectionCreatorHelper::getCreateTcpCB(void)
{
return &ourTcpCB;
}
void ArDeviceConnectionCreatorHelper::setSuccessLogLevel(
ArLog::LogLevel successLogLevel)
{
ourSuccessLogLevel = successLogLevel;
}
ArLog::LogLevel ArDeviceConnectionCreatorHelper::setSuccessLogLevel(void)
{
return ourSuccessLogLevel;
}
| 56,981
| 21,118
|
// Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
// 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)
#ifdef BOOST_QVM_TEST_SINGLE_HEADER
# include BOOST_QVM_TEST_SINGLE_HEADER
#else
# include <boost/qvm/deduce_scalar.hpp>
# include <boost/qvm/mat.hpp>
# include <boost/qvm/mat_operations.hpp>
# include <boost/qvm/vec.hpp>
# include <boost/qvm/vec_mat_operations3.hpp>
#endif
#include <boost/core/lightweight_test.hpp>
template <class T>
struct
wrap
{
T t;
wrap() { }
explicit wrap(T t):t(t) { }
};
template <class S, class T>
wrap<T>
operator*(S s, wrap<T> w)
{
return wrap<T>(s * w.t);
}
template <class T>
wrap<T> operator+(wrap<T> a, wrap<T> b)
{
return wrap<T>(a.t + b.t);
}
namespace
boost
{
namespace
qvm
{
template <class T>
struct
is_scalar<wrap<T> >
{
static bool const value=true;
};
template <class S, class T>
struct
deduce_scalar<S, wrap<T> >
{
typedef wrap<typename deduce_scalar<S, T>::type> type;
};
}
}
int
main()
{
using namespace boost::qvm;
mat<double, 3, 3> m = rotz_mat<3>(3.14159);
vec<wrap<double>, 3> v;
v.a[0] = wrap<double>(1.0);
v.a[1] = wrap<double>(0);
v.a[2] = wrap<double>(0);
vec<wrap<double>, 3> r = m * v;
BOOST_TEST_LT(fabs(r.a[0].t+1), 0.0001);
BOOST_TEST_LT(fabs(r.a[1].t), 0.0001);
BOOST_TEST_LT(fabs(r.a[2].t), 0.0001);
return boost::report_errors();
}
| 1,679
| 700
|
#include <boost/python.hpp>
#include "OpenPGP/Subpackets/Tag2Sub28.h"
void Tag2Sub28_init()
{
boost::python::class_<Tag2Sub28, boost::python::bases<Tag2Subpacket>>("Tag2Sub28")
.def(boost::python::init<std::string &>())
.def("read", &Tag2Sub28::read)
.def("show", &Tag2Sub28::show)
.def("raw", &Tag2Sub28::raw)
.def("get_signer", &Tag2Sub28::get_signer)
.def("set_signer", &Tag2Sub28::set_signer)
.def("clone", &Tag2Sub28::clone)
;
}
| 468
| 209
|
#include "PhysicsTools/JetMCAlgos/interface/BasePartonSelector.h"
BasePartonSelector::BasePartonSelector() {}
BasePartonSelector::~BasePartonSelector() {}
void BasePartonSelector::run(const edm::Handle<reco::GenParticleCollection>& particles,
std::unique_ptr<reco::GenParticleRefVector>& partons) {}
| 332
| 99
|
/*The count-and-say sequence is the sequence of integers with the first five
terms as following:
1. 1
2. 11
3. 21
4. 1211
5. 111221
1 is read off as "one 1" or 11.
11 is read off as "two 1s" or 21.
21 is read off as "one 2, then one 1" or 1211.
Given an integer n where 1 ≤ n ≤ 30, generate the nth term of the count-and-say
sequence.
Note: Each term of the sequence of integers will be represented as a string.
Example 1:
Input: 1
Output: "1"
Example 2:
Input: 4
Output: "1211"*/
class Solution {
public:
string countAndSay(int n) {
if (n == 1) {
return "1";
} else if (n == 2) {
return "11";
} else {
string s = countAndSay(n - 1);
string n{};
int c = 1;
for (int i = 0; i < s.size(); i++) {
if (i + 1 < s.size() and s[i] == s[i + 1]) {
c++;
} else {
char num = c + '0';
n += string{num} + string{s[i]};
c = 1;
}
}
return n;
}
}
};
| 1,047
| 434
|
/* IQIF neuron object
* Chen-Fu Yeh, 2019/11/09
*/
#include "iq_neuron.h"
using namespace std;
iq_neuron::iq_neuron(int rest, int threshold,
int reset, int a, int b, int noise)
{
x = rest; // initialize with rest potential
t_neuron = 0;
f_min = (a*rest + b*threshold) / (a+b); // dV/dt and others
_a = a;
_b = b;
_rest = rest;
_threshold = threshold;
_reset = reset;
if(noise == 0) noise++; // set noise strength
else if(noise < 0) noise = -noise;
_noise = noise;
_is_set = true;
return;
}
bool iq_neuron::is_set()
{
return _is_set;
}
void iq_neuron::set(int rest, int threshold,
int reset, int a, int b, int noise)
{
x = rest;
t_neuron = 0;
f_min = (a*rest + b*threshold) / (a+b);
_a = a;
_b = b;
_rest = rest;
_threshold = threshold;
_reset = reset;
if(noise == 0) noise++;
else if(noise < 0) noise = -noise;
_noise = noise;
_is_set = true;
return;
}
void iq_neuron::set_vmax(int vmax)
{
VMAX = vmax;
return;
}
void iq_neuron::set_vmin(int vmin)
{
VMIN = vmin;
return;
}
void iq_neuron::iq(int external_current)
{
int f;
/* solving dV/dt */
if(x < f_min)
f = _a * (_rest - x);
else
f = _b * (x - _threshold);
x += (f >> 3) + external_current + rand()%_noise - (_noise >> 1);
/* fire if exceeding action potential */
_is_firing = false;
if(x > VMAX) {
_spike_count++;
_is_firing = true;
x = _reset;
}
else if(x < VMIN) x = VMIN;
t_neuron++;
return;
}
int iq_neuron::potential()
{
return x;
}
bool iq_neuron::is_firing()
{
return _is_firing;
}
int iq_neuron::spike_count()
{
int count = _spike_count;
_spike_count = 0;
return count;
}
float iq_neuron::spike_rate()
{
float r = _spike_count / (float) t_neuron;
t_neuron = 0;
_spike_count = 0;
return r;
}
| 2,006
| 831
|
//------------------------------------------------------------------------------
/*
This file is part of divvyd: https://github.com/xdv/divvyd
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <BeastConfig.h>
#include <divvy/protocol/Quality.h>
#include <divvy/app/paths/Credit.h>
#include <divvy/app/paths/cursor/DivvyLiquidity.h>
#include <divvy/basics/Log.h>
namespace divvy {
namespace path {
// Calculate saPrvRedeemReq, saPrvIssueReq, saPrvDeliver from saCur, based on
// required deliverable, propagate redeem, issue (for accounts) and deliver
// requests (for order books) to the previous node.
//
// Inflate amount requested by required fees.
// Reedems are limited based on IOUs previous has on hand.
// Issues are limited based on credit limits and amount owed.
//
// Currency cannot be XDV because we are rippling.
//
// No permanent account balance adjustments as we don't know how much is going
// to actually be pushed through yet - changes are only in the scratch pad
// ledger.
//
// <-- tesSUCCESS or tecPATH_DRY
TER PathCursor::reverseLiquidityForAccount () const
{
TER terResult = tesSUCCESS;
auto const lastNodeIndex = nodeSize () - 1;
auto const isFinalNode = (nodeIndex_ == lastNodeIndex);
// 0 quality means none has yet been determined.
std::uint64_t uRateMax = 0
;
// Current is allowed to redeem to next.
const bool previousNodeIsAccount = !nodeIndex_ ||
previousNode().isAccount();
const bool nextNodeIsAccount = isFinalNode || nextNode().isAccount();
AccountID const& previousAccountID = previousNodeIsAccount
? previousNode().account_ : node().account_;
AccountID const& nextAccountID = nextNodeIsAccount ? nextNode().account_
: node().account_; // Offers are always issue.
// This is the quality from from the previous node to this one.
const std::uint32_t uQualityIn
= (nodeIndex_ != 0)
? quality_in (ledger(),
node().account_,
previousAccountID,
node().issue_.currency)
: QUALITY_ONE;
// And this is the quality from the next one to this one.
const std::uint32_t uQualityOut
= (nodeIndex_ != lastNodeIndex)
? quality_out (ledger(),
node().account_,
nextAccountID,
node().issue_.currency)
: QUALITY_ONE;
// For previousNodeIsAccount:
// Previous account is already owed.
const STAmount saPrvOwed = (previousNodeIsAccount && nodeIndex_ != 0)
? creditBalance (ledger(),
node().account_,
previousAccountID,
node().issue_.currency)
: STAmount (node().issue_);
// The limit amount that the previous account may owe.
const STAmount saPrvLimit = (previousNodeIsAccount && nodeIndex_ != 0)
? creditLimit (ledger(),
node().account_,
previousAccountID,
node().issue_.currency)
: STAmount (node().issue_);
// Next account is owed.
const STAmount saNxtOwed = (nextNodeIsAccount && nodeIndex_ != lastNodeIndex)
? creditBalance (ledger(),
node().account_,
nextAccountID,
node().issue_.currency)
: STAmount (node().issue_);
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount>"
<< " nodeIndex_=" << nodeIndex_ << "/" << lastNodeIndex
<< " previousAccountID=" << previousAccountID
<< " node.account_=" << node().account_
<< " nextAccountID=" << nextAccountID
<< " currency=" << node().issue_.currency
<< " uQualityIn=" << uQualityIn
<< " uQualityOut=" << uQualityOut
<< " saPrvOwed=" << saPrvOwed
<< " saPrvLimit=" << saPrvLimit;
// Requests are computed to be the maximum flow possible.
// Previous can redeem the owed IOUs it holds.
const STAmount saPrvRedeemReq = (saPrvOwed > zero)
? saPrvOwed
: STAmount (saPrvOwed.issue ());
// Previous can issue up to limit minus whatever portion of limit already
// used (not including redeemable amount) - another "maximum flow".
const STAmount saPrvIssueReq = (saPrvOwed < zero)
? saPrvLimit + saPrvOwed : saPrvLimit;
// Precompute these values in case we have an order book.
auto deliverCurrency = previousNode().saRevDeliver.getCurrency ();
const STAmount saPrvDeliverReq (
{deliverCurrency, previousNode().saRevDeliver.getIssuer ()}, -1);
// -1 means unlimited delivery.
// Set to zero, because we're trying to hit the previous node.
auto saCurRedeemAct = node().saRevRedeem.zeroed();
// Track the amount we actually redeem.
auto saCurIssueAct = node().saRevIssue.zeroed();
// For !nextNodeIsAccount
auto saCurDeliverAct = node().saRevDeliver.zeroed();
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount:"
<< " saPrvRedeemReq:" << saPrvRedeemReq
<< " saPrvIssueReq:" << saPrvIssueReq
<< " previousNode.saRevDeliver:" << previousNode().saRevDeliver
<< " saPrvDeliverReq:" << saPrvDeliverReq
<< " node.saRevRedeem:" << node().saRevRedeem
<< " node.saRevIssue:" << node().saRevIssue
<< " saNxtOwed:" << saNxtOwed;
// VFALCO-FIXME this generates errors
//WriteLog (lsTRACE, DivvyCalc) << pathState_.getJson ();
// Current redeem req can't be more than IOUs on hand.
assert (!node().saRevRedeem || -saNxtOwed >= node().saRevRedeem);
assert (!node().saRevIssue // If not issuing, fine.
|| saNxtOwed >= zero
// saNxtOwed >= 0: Sender not holding next IOUs, saNxtOwed < 0:
// Sender holding next IOUs.
|| -saNxtOwed == node().saRevRedeem);
// If issue req, then redeem req must consume all owed.
if (nodeIndex_ == 0)
{
// ^ --> ACCOUNT --> account|offer
// Nothing to do, there is no previous to adjust.
//
// TODO(tom): we could have skipped all that setup and just left
// or even just never call this whole routine on nodeIndex_ = 0!
}
// The next four cases correspond to the table at the bottom of this Wiki
// page section: https://xdv.io/wiki/Transit_Fees#Implementation
else if (previousNodeIsAccount && nextNodeIsAccount)
{
if (isFinalNode)
{
// account --> ACCOUNT --> $
// Overall deliverable.
const STAmount saCurWantedReq = std::min (
pathState_.outReq() - pathState_.outAct(),
saPrvLimit + saPrvOwed);
auto saCurWantedAct = saCurWantedReq.zeroed ();
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount: account --> "
<< "ACCOUNT --> $ :"
<< " saCurWantedReq=" << saCurWantedReq;
// Calculate redeem
if (saPrvRedeemReq) // Previous has IOUs to redeem.
{
// Redeem your own IOUs at 1:1
saCurWantedAct = std::min (saPrvRedeemReq, saCurWantedReq);
previousNode().saRevRedeem = saCurWantedAct;
uRateMax = STAmount::uRateOne;
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount: Redeem at 1:1"
<< " saPrvRedeemReq=" << saPrvRedeemReq
<< " (available) previousNode.saRevRedeem="
<< previousNode().saRevRedeem
<< " uRateMax="
<< amountFromRate (uRateMax).getText ();
}
else
{
previousNode().saRevRedeem.clear (saPrvRedeemReq);
}
// Calculate issuing.
previousNode().saRevIssue.clear (saPrvIssueReq);
if (saCurWantedReq != saCurWantedAct // Need more.
&& saPrvIssueReq) // Will accept IOUs from previous.
{
// Rate: quality in : 1.0
// If we previously redeemed and this has a poorer rate, this
// won't be included the current increment.
divvyLiquidity (
divvyCalc_,
uQualityIn,
QUALITY_ONE,
saPrvIssueReq,
saCurWantedReq,
previousNode().saRevIssue,
saCurWantedAct,
uRateMax);
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount: Issuing: Rate: "
<< "quality in : 1.0"
<< " previousNode.saRevIssue:" << previousNode().saRevIssue
<< " saCurWantedAct:" << saCurWantedAct;
}
if (!saCurWantedAct)
{
// Must have processed something.
terResult = tecPATH_DRY;
}
}
else
{
// Not final node.
// account --> ACCOUNT --> account
previousNode().saRevRedeem.clear (saPrvRedeemReq);
previousNode().saRevIssue.clear (saPrvIssueReq);
// redeem (part 1) -> redeem
if (node().saRevRedeem
// Next wants IOUs redeemed from current account.
&& saPrvRedeemReq)
// Previous has IOUs to redeem to the current account.
{
// TODO(tom): add English.
// Rate : 1.0 : quality out - we must accept our own IOUs
// as 1:1.
divvyLiquidity (
divvyCalc_,
QUALITY_ONE,
uQualityOut,
saPrvRedeemReq,
node().saRevRedeem,
previousNode().saRevRedeem,
saCurRedeemAct,
uRateMax);
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount: "
<< "Rate : 1.0 : quality out"
<< " previousNode.saRevRedeem:" << previousNode().saRevRedeem
<< " saCurRedeemAct:" << saCurRedeemAct;
}
// issue (part 1) -> redeem
if (node().saRevRedeem != saCurRedeemAct
// The current node has more IOUs to redeem.
&& previousNode().saRevRedeem == saPrvRedeemReq)
// The previous node has no IOUs to redeem remaining, so issues.
{
// Rate: quality in : quality out
divvyLiquidity (
divvyCalc_,
uQualityIn,
uQualityOut,
saPrvIssueReq,
node().saRevRedeem,
previousNode().saRevIssue,
saCurRedeemAct,
uRateMax);
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount: "
<< "Rate: quality in : quality out:"
<< " previousNode.saRevIssue:" << previousNode().saRevIssue
<< " saCurRedeemAct:" << saCurRedeemAct;
}
// redeem (part 2) -> issue.
if (node().saRevIssue // Next wants IOUs issued.
// TODO(tom): this condition seems redundant.
&& saCurRedeemAct == node().saRevRedeem
// Can only issue if completed redeeming.
&& previousNode().saRevRedeem != saPrvRedeemReq)
// Did not complete redeeming previous IOUs.
{
// Rate : 1.0 : transfer_rate
divvyLiquidity (
divvyCalc_,
QUALITY_ONE,
divvyTransferRate (ledger(), node().account_),
saPrvRedeemReq,
node().saRevIssue,
previousNode().saRevRedeem,
saCurIssueAct,
uRateMax);
WriteLog (lsDEBUG, DivvyCalc)
<< "reverseLiquidityForAccount: "
<< "Rate : 1.0 : transfer_rate:"
<< " previousNode.saRevRedeem:" << previousNode().saRevRedeem
<< " saCurIssueAct:" << saCurIssueAct;
}
// issue (part 2) -> issue
if (node().saRevIssue != saCurIssueAct
// Need wants more IOUs issued.
&& saCurRedeemAct == node().saRevRedeem
// Can only issue if completed redeeming.
&& saPrvRedeemReq == previousNode().saRevRedeem
// Previously redeemed all owed IOUs.
&& saPrvIssueReq)
// Previous can issue.
{
// Rate: quality in : 1.0
divvyLiquidity (
divvyCalc_,
uQualityIn,
QUALITY_ONE,
saPrvIssueReq,
node().saRevIssue,
previousNode().saRevIssue,
saCurIssueAct,
uRateMax);
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount: "
<< "Rate: quality in : 1.0:"
<< " previousNode.saRevIssue:" << previousNode().saRevIssue
<< " saCurIssueAct:" << saCurIssueAct;
}
if (!saCurRedeemAct && !saCurIssueAct)
{
// Did not make progress.
terResult = tecPATH_DRY;
}
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount: "
<< "^|account --> ACCOUNT --> account :"
<< " node.saRevRedeem:" << node().saRevRedeem
<< " node.saRevIssue:" << node().saRevIssue
<< " saPrvOwed:" << saPrvOwed
<< " saCurRedeemAct:" << saCurRedeemAct
<< " saCurIssueAct:" << saCurIssueAct;
}
}
else if (previousNodeIsAccount && !nextNodeIsAccount)
{
// account --> ACCOUNT --> offer
// Note: deliver is always issue as ACCOUNT is the issuer for the offer
// input.
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount: "
<< "account --> ACCOUNT --> offer";
previousNode().saRevRedeem.clear (saPrvRedeemReq);
previousNode().saRevIssue.clear (saPrvIssueReq);
// We have three cases: the nxt offer can be owned by current account,
// previous account or some third party account.
//
// Also, the current account may or may not have a redeemable balance
// with the account for the next offer, so we don't yet know if we're
// redeeming or issuing.
//
// TODO(tom): Make sure deliver was cleared, or check actual is zero.
// redeem -> deliver/issue.
if (saPrvOwed > zero // Previous has IOUs to redeem.
&& node().saRevDeliver) // Need some issued.
{
// Rate : 1.0 : transfer_rate
divvyLiquidity (
divvyCalc_,
QUALITY_ONE,
divvyTransferRate (ledger(), node().account_),
saPrvRedeemReq,
node().saRevDeliver,
previousNode().saRevRedeem,
saCurDeliverAct,
uRateMax);
}
// issue -> deliver/issue
if (saPrvRedeemReq == previousNode().saRevRedeem
// Previously redeemed all owed.
&& node().saRevDeliver != saCurDeliverAct) // Still need some issued.
{
// Rate: quality in : 1.0
divvyLiquidity (
divvyCalc_,
uQualityIn,
QUALITY_ONE,
saPrvIssueReq,
node().saRevDeliver,
previousNode().saRevIssue,
saCurDeliverAct,
uRateMax);
}
if (!saCurDeliverAct)
{
// Must want something.
terResult = tecPATH_DRY;
}
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount: "
<< " node.saRevDeliver:" << node().saRevDeliver
<< " saCurDeliverAct:" << saCurDeliverAct
<< " saPrvOwed:" << saPrvOwed;
}
else if (!previousNodeIsAccount && nextNodeIsAccount)
{
if (isFinalNode)
{
// offer --> ACCOUNT --> $
// Previous is an offer, no limit: redeem own IOUs.
//
// This is the final node; we can't look to the right to get values;
// we have to go up to get the out value for the entire path state.
STAmount const& saCurWantedReq =
pathState_.outReq() - pathState_.outAct();
STAmount saCurWantedAct = saCurWantedReq.zeroed();
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount: "
<< "offer --> ACCOUNT --> $ :"
<< " saCurWantedReq:" << saCurWantedReq
<< " saOutAct:" << pathState_.outAct()
<< " saOutReq:" << pathState_.outReq();
if (saCurWantedReq <= zero)
{
// TEMPORARY emergency fix
//
// TODO(tom): why can't saCurWantedReq be -1 if you want to
// compute maximum liquidity? This might be unimplemented
// functionality. TODO(tom): should the same check appear in
// other paths or even be pulled up?
WriteLog (lsFATAL, DivvyCalc) << "CurWantReq was not positive";
return tefEXCEPTION;
}
assert (saCurWantedReq > zero); // FIXME: We got one of these
// The previous node is an offer; we are receiving our own currency.
// The previous order book's entries might hold our issuances; might
// not hold our issuances; might be our own offer.
//
// Assume the worst case, the case which costs the most to go
// through, which is that it is not our own offer or our own
// issuances. Later on the forward pass we may be able to do
// better.
//
// TODO: this comment applies generally to this section - move it up
// to a document.
// Rate: quality in : 1.0
divvyLiquidity (
divvyCalc_,
uQualityIn,
QUALITY_ONE,
saPrvDeliverReq,
saCurWantedReq,
previousNode().saRevDeliver,
saCurWantedAct,
uRateMax);
if (!saCurWantedAct)
{
// Must have processed something.
terResult = tecPATH_DRY;
}
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount:"
<< " previousNode().saRevDeliver:" << previousNode().saRevDeliver
<< " saPrvDeliverReq:" << saPrvDeliverReq
<< " saCurWantedAct:" << saCurWantedAct
<< " saCurWantedReq:" << saCurWantedReq;
}
else
{
// offer --> ACCOUNT --> account
// Note: offer is always delivering(redeeming) as account is issuer.
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount: "
<< "offer --> ACCOUNT --> account :"
<< " node.saRevRedeem:" << node().saRevRedeem
<< " node.saRevIssue:" << node().saRevIssue;
// deliver -> redeem
// TODO(tom): now we have more checking in nodeDivvy, these checks
// might be redundant.
if (node().saRevRedeem) // Next wants us to redeem.
{
// cur holds IOUs from the account to the right, the nxt
// account. If someone is making the current account get rid of
// the nxt account's IOUs, then charge the input for quality
// out.
//
// Rate : 1.0 : quality out
divvyLiquidity (
divvyCalc_,
QUALITY_ONE,
uQualityOut,
saPrvDeliverReq,
node().saRevRedeem,
previousNode().saRevDeliver,
saCurRedeemAct,
uRateMax);
}
// deliver -> issue.
if (node().saRevRedeem == saCurRedeemAct
// Can only issue if previously redeemed all.
&& node().saRevIssue)
// Need some issued.
{
// Rate : 1.0 : transfer_rate
divvyLiquidity (
divvyCalc_,
QUALITY_ONE,
divvyTransferRate (ledger(), node().account_),
saPrvDeliverReq,
node().saRevIssue,
previousNode().saRevDeliver,
saCurIssueAct,
uRateMax);
}
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount:"
<< " saCurRedeemAct:" << saCurRedeemAct
<< " node.saRevRedeem:" << node().saRevRedeem
<< " previousNode.saRevDeliver:" << previousNode().saRevDeliver
<< " node.saRevIssue:" << node().saRevIssue;
if (!previousNode().saRevDeliver)
{
// Must want something.
terResult = tecPATH_DRY;
}
}
}
else
{
// offer --> ACCOUNT --> offer
// deliver/redeem -> deliver/issue.
WriteLog (lsTRACE, DivvyCalc)
<< "reverseLiquidityForAccount: offer --> ACCOUNT --> offer";
// Rate : 1.0 : transfer_rate
divvyLiquidity (
divvyCalc_,
QUALITY_ONE,
divvyTransferRate (ledger(), node().account_),
saPrvDeliverReq,
node().saRevDeliver,
previousNode().saRevDeliver,
saCurDeliverAct,
uRateMax);
if (!saCurDeliverAct)
{
// Must want something.
terResult = tecPATH_DRY;
}
}
return terResult;
}
} // path
} // divvy
| 23,412
| 6,860
|
/*
* BSD 2-Clause License
*
* Copyright (c) 2020, Christoph Neuhauser
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <iostream>
#include <cmath>
#ifdef __linux__
#include <sys/inotify.h>
#include <poll.h>
#endif
#include <GL/glew.h>
#include <glm/glm.hpp>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <ImGui/imgui.h>
#include <ImGui/imgui_internal.h>
#include <ImGui/imgui_custom.h>
#include <ImGui/imgui_stdlib.h>
#include <Utils/AppSettings.hpp>
#include <Utils/XML.hpp>
#include <Utils/File/Logfile.hpp>
#include <Utils/File/FileUtils.hpp>
#include <Math/Math.hpp>
#include <Graphics/Renderer.hpp>
#include <Graphics/Texture/TextureManager.hpp>
#ifdef SUPPORT_VULKAN
#include <Graphics/Vulkan/Buffers/Buffer.hpp>
#endif
#include "MultiVarTransferFunctionWindow.hpp"
using namespace tinyxml2;
const size_t TRANSFER_FUNCTION_TEXTURE_SIZE = 256;
GuiVarData::GuiVarData(
MultiVarTransferFunctionWindow* window, const std::string& tfPresetFile,
sgl::Color16* transferFunctionMap_sRGB,
sgl::Color16* transferFunctionMap_linearRGB) {
this->window = window;
this->transferFunctionMap_sRGB = transferFunctionMap_sRGB;
this->transferFunctionMap_linearRGB = transferFunctionMap_linearRGB;
std::string tfFileName = window->saveDirectory + tfPresetFile;
const std::string stdFileName = window->saveDirectory + "Standard.xml";
if (tfFileName.empty() || !sgl::FileUtils::get()->exists(tfFileName)) {
tfFileName = stdFileName;
}
if (sgl::FileUtils::get()->exists(tfFileName)) {
loadTfFromFile(tfFileName);
} else {
colorPoints = {
sgl::ColorPoint_sRGB(sgl::Color(59, 76, 192), 0.0f),
sgl::ColorPoint_sRGB(sgl::Color(144, 178, 254), 0.25f),
sgl::ColorPoint_sRGB(sgl::Color(220, 220, 220), 0.5f),
sgl::ColorPoint_sRGB(sgl::Color(245, 156, 125), 0.75f),
sgl::ColorPoint_sRGB(sgl::Color(180, 4, 38), 1.0f)
};
opacityPoints = { sgl::OpacityPoint(1.0f, 0.0f), sgl::OpacityPoint(1.0f, 1.0f) };
}
}
bool GuiVarData::saveTfToFile(const std::string& filename) {
FILE* file = fopen(filename.c_str(), "w");
if (file == NULL) {
sgl::Logfile::get()->writeError(
std::string() + "ERROR: MultiVarTransferFunctionWindow::saveFunctionToFile: Couldn't create file \""
+ filename + "\"!");
return false;
}
XMLPrinter printer(file);
printer.OpenElement("TransferFunction");
printer.PushAttribute("colorspace", "sRGB"); // Currently only sRGB supported for points
printer.PushAttribute("interpolation_colorspace", sgl::COLOR_SPACE_NAMES[interpolationColorSpace]);
printer.OpenElement("OpacityPoints");
// Traverse all opacity points
for (size_t i = 0; i < opacityPoints.size(); i++) {
printer.OpenElement("OpacityPoint");
printer.PushAttribute("position", opacityPoints.at(i).position);
printer.PushAttribute("opacity", opacityPoints.at(i).opacity);
printer.CloseElement();
}
printer.CloseElement();
printer.OpenElement("ColorPoints");
printer.PushAttribute("color_data", sgl::COLOR_DATA_MODE_NAMES[int(sgl::COLOR_DATA_MODE_UNSIGNED_SHORT)]);
// Traverse all color points
for (size_t i = 0; i < colorPoints.size(); i++) {
printer.OpenElement("ColorPoint");
printer.PushAttribute("position", colorPoints.at(i).position);
printer.PushAttribute("r", (int)colorPoints.at(i).color.getR());
printer.PushAttribute("g", (int)colorPoints.at(i).color.getG());
printer.PushAttribute("b", (int)colorPoints.at(i).color.getB());
printer.CloseElement();
}
printer.CloseElement();
printer.CloseElement();
fclose(file);
return true;
}
bool GuiVarData::loadTfFromFile(const std::string& filename) {
XMLDocument doc;
if (doc.LoadFile(filename.c_str()) != 0) {
sgl::Logfile::get()->writeError(
std::string() + "MultiVarTransferFunctionWindow::loadFunctionFromFile: Couldn't open file \""
+ filename + "\"!");
return false;
}
XMLElement* tfNode = doc.FirstChildElement("TransferFunction");
if (tfNode == nullptr) {
sgl::Logfile::get()->writeError(
"MultiVarTransferFunctionWindow::loadFunctionFromFile: No \"TransferFunction\" node found!");
return false;
}
interpolationColorSpace = sgl::COLOR_SPACE_SRGB; // Standard
const char* interpolationColorSpaceName = tfNode->Attribute("colorspace_interpolation");
if (interpolationColorSpaceName != nullptr) {
for (int i = 0; i < 2; i++) {
if (strcmp(interpolationColorSpaceName, sgl::COLOR_SPACE_NAMES[interpolationColorSpace]) == 0) {
interpolationColorSpace = (sgl::ColorSpace)i;
}
}
}
colorPoints.clear();
opacityPoints.clear();
// Traverse all opacity points
auto opacityPointsNode = tfNode->FirstChildElement("OpacityPoints");
if (opacityPointsNode != nullptr) {
for (sgl::XMLIterator it(opacityPointsNode, sgl::XMLNameFilter("OpacityPoint")); it.isValid(); ++it) {
XMLElement* childElement = *it;
float position = childElement->FloatAttribute("position");
float opacity = sgl::clamp(childElement->FloatAttribute("opacity"), 0.0f, 1.0f);
opacityPoints.emplace_back(opacity, position);
}
}
// Traverse all color points
auto colorPointsNode = tfNode->FirstChildElement("ColorPoints");
if (colorPointsNode != nullptr) {
sgl::ColorDataMode colorDataMode = sgl::COLOR_DATA_MODE_UNSIGNED_BYTE;
const char* colorDataModeName = colorPointsNode->Attribute("color_data");
if (colorDataModeName != nullptr) {
colorDataMode = sgl::parseColorDataModeName(colorDataModeName);
}
for (sgl::XMLIterator it(colorPointsNode, sgl::XMLNameFilter("ColorPoint")); it.isValid(); ++it) {
XMLElement* childElement = *it;
sgl::Color16 color;
float position = childElement->FloatAttribute("position");
if (colorDataMode == sgl::COLOR_DATA_MODE_UNSIGNED_BYTE) {
int red = sgl::clamp(childElement->IntAttribute("r"), 0, 255);
int green = sgl::clamp(childElement->IntAttribute("g"), 0, 255);
int blue = sgl::clamp(childElement->IntAttribute("b"), 0, 255);
color = sgl::Color(red, green, blue);
} else if (colorDataMode == sgl::COLOR_DATA_MODE_UNSIGNED_SHORT) {
int red = sgl::clamp(childElement->IntAttribute("r"), 0, 65535);
int green = sgl::clamp(childElement->IntAttribute("g"), 0, 65535);
int blue = sgl::clamp(childElement->IntAttribute("b"), 0, 65535);
color = sgl::Color16(red, green, blue);
} else if (colorDataMode == sgl::COLOR_DATA_MODE_FLOAT_NORMALIZED) {
float red = sgl::clamp(childElement->FloatAttribute("r"), 0.0f, 1.0f);
float green = sgl::clamp(childElement->FloatAttribute("g"), 0.0f, 1.0f);
float blue = sgl::clamp(childElement->FloatAttribute("b"), 0.0f, 1.0f);
color = sgl::Color16(glm::vec3(red, green, blue));
} else if (colorDataMode == sgl::COLOR_DATA_MODE_FLOAT_255) {
float red = sgl::clamp(childElement->FloatAttribute("r"), 0.0f, 255.0f) / 255.0f;
float green = sgl::clamp(childElement->FloatAttribute("g"), 0.0f, 255.0f) / 255.0f;
float blue = sgl::clamp(childElement->FloatAttribute("b"), 0.0f, 255.0f) / 255.0f;
color = sgl::Color16(glm::vec3(red, green, blue));
}
colorPoints.emplace_back(color, position);
}
}
selectedPointType = sgl::SELECTED_POINT_TYPE_NONE;
rebuildTransferFunctionMap();
return true;
}
void GuiVarData::setAttributeValues(const std::string& name, const std::vector<float>& attributes) {
attributeName = name;
this->attributes = attributes;
float minAttr = std::numeric_limits<float>::max();
float maxAttr = std::numeric_limits<float>::lowest();
#if _OPENMP >= 201107
#pragma omp parallel for reduction(min: minAttr) reduction(max: maxAttr) shared(attributes) default(none)
#endif
for (size_t i = 0; i < attributes.size(); i++) {
float value = attributes.at(i);
minAttr = std::min(minAttr, value);
maxAttr = std::max(maxAttr, value);
}
this->dataRange = glm::vec2(minAttr, maxAttr);
this->selectedRange = glm::vec2(minAttr, maxAttr);
computeHistogram();
}
void GuiVarData::computeHistogram() {
float histogramsMax = 0;
histogram = std::vector<float>(histogramResolution, 0.0f);
for (const float& value : attributes) {
int32_t index = glm::clamp(
static_cast<int>((value - selectedRange.x) / (selectedRange.y - selectedRange.x)
* static_cast<float>(histogramResolution)), 0, histogramResolution - 1);
histogram.at(index)++;
}
// Normalize values of histogram.
for (const float& binNumber : histogram) {
histogramsMax = std::max(histogramsMax, binNumber);
}
for (float& numBin : histogram) {
numBin /= histogramsMax;
}
}
// For OpenGL: Has TRANSFER_FUNCTION_TEXTURE_SIZE entries.
// Get mapped color for normalized attribute by accessing entry at "attr*255".
void GuiVarData::rebuildTransferFunctionMap() {
rebuildTransferFunctionMapLocal();
window->rebuildTransferFunctionMap();
}
void GuiVarData::rebuildTransferFunctionMapLocal() {
// Create linear RGB color points
colorPoints_LinearRGB.clear();
for (sgl::ColorPoint_sRGB& colorPoint : colorPoints) {
glm::vec3 linearRGBColor = sgl::TransferFunctionWindow::sRGBToLinearRGB(colorPoint.color.getFloatColorRGB());
colorPoints_LinearRGB.push_back(sgl::ColorPoint_LinearRGB(linearRGBColor, colorPoint.position));
}
if (interpolationColorSpace == sgl::COLOR_SPACE_LINEAR_RGB) {
rebuildTransferFunctionMap_LinearRGB();
} else {
rebuildTransferFunctionMap_sRGB();
}
}
// For OpenGL: Has 256 entries. Get mapped color for normalized attribute by accessing entry at "attr*255".
void GuiVarData::rebuildTransferFunctionMap_LinearRGB() {
int colorPointsIdx = 0;
int opacityPointsIdx = 0;
for (size_t i = 0; i < TRANSFER_FUNCTION_TEXTURE_SIZE; i++) {
glm::vec3 linearRGBColorAtIdx;
float opacityAtIdx;
float currentPosition = static_cast<float>(i) / float(TRANSFER_FUNCTION_TEXTURE_SIZE-1);
// colorPoints.at(colorPointsIdx) should be to the right of/equal to currentPosition
while (colorPoints_LinearRGB.at(colorPointsIdx).position < currentPosition) {
colorPointsIdx++;
}
while (opacityPoints.at(opacityPointsIdx).position < currentPosition) {
opacityPointsIdx++;
}
// Now compute the color...
if (colorPoints_LinearRGB.at(colorPointsIdx).position == currentPosition) {
linearRGBColorAtIdx = colorPoints_LinearRGB.at(colorPointsIdx).color;
} else {
glm::vec3 color0 = colorPoints_LinearRGB.at(colorPointsIdx-1).color;
glm::vec3 color1 = colorPoints_LinearRGB.at(colorPointsIdx).color;
float pos0 = colorPoints_LinearRGB.at(colorPointsIdx-1).position;
float pos1 = colorPoints_LinearRGB.at(colorPointsIdx).position;
float factor = 1.0f - (pos1 - currentPosition) / (pos1 - pos0);
linearRGBColorAtIdx = glm::mix(color0, color1, factor);
}
// ... and the opacity.
if (opacityPoints.at(opacityPointsIdx).position == currentPosition) {
opacityAtIdx = opacityPoints.at(opacityPointsIdx).opacity;
} else {
float opacity0 = opacityPoints.at(opacityPointsIdx-1).opacity;
float opacity1 = opacityPoints.at(opacityPointsIdx).opacity;
float pos0 = opacityPoints.at(opacityPointsIdx-1).position;
float pos1 = opacityPoints.at(opacityPointsIdx).position;
float factor = 1.0f - (pos1 - currentPosition) / (pos1 - pos0);
opacityAtIdx = sgl::interpolateLinear(opacity0, opacity1, factor);
}
transferFunctionMap_linearRGB[i] = sgl::Color16(glm::vec4(linearRGBColorAtIdx, opacityAtIdx));
transferFunctionMap_sRGB[i] = sgl::Color16(glm::vec4(
sgl::TransferFunctionWindow::linearRGBTosRGB(linearRGBColorAtIdx), opacityAtIdx));
}
}
// For OpenGL: Has 256 entries. Get mapped color for normalized attribute by accessing entry at "attr*255".
void GuiVarData::rebuildTransferFunctionMap_sRGB() {
int colorPointsIdx = 0;
int opacityPointsIdx = 0;
for (size_t i = 0; i < TRANSFER_FUNCTION_TEXTURE_SIZE; i++) {
glm::vec3 sRGBColorAtIdx;
float opacityAtIdx;
float currentPosition = static_cast<float>(i) / float(TRANSFER_FUNCTION_TEXTURE_SIZE-1);
// colorPoints.at(colorPointsIdx) should be to the right of/equal to currentPosition
while (colorPoints.at(colorPointsIdx).position < currentPosition) {
colorPointsIdx++;
}
while (opacityPoints.at(opacityPointsIdx).position < currentPosition) {
opacityPointsIdx++;
}
// Now compute the color...
if (colorPoints.at(colorPointsIdx).position == currentPosition) {
sRGBColorAtIdx = colorPoints.at(colorPointsIdx).color.getFloatColorRGB();
} else {
glm::vec3 color0 = colorPoints.at(colorPointsIdx-1).color.getFloatColorRGB();
glm::vec3 color1 = colorPoints.at(colorPointsIdx).color.getFloatColorRGB();
float pos0 = colorPoints.at(colorPointsIdx-1).position;
float pos1 = colorPoints.at(colorPointsIdx).position;
float factor = 1.0f - (pos1 - currentPosition) / (pos1 - pos0);
sRGBColorAtIdx = glm::mix(color0, color1, factor);
}
// ... and the opacity.
if (opacityPoints.at(opacityPointsIdx).position == currentPosition) {
opacityAtIdx = opacityPoints.at(opacityPointsIdx).opacity;
} else {
float opacity0 = opacityPoints.at(opacityPointsIdx-1).opacity;
float opacity1 = opacityPoints.at(opacityPointsIdx).opacity;
float pos0 = opacityPoints.at(opacityPointsIdx-1).position;
float pos1 = opacityPoints.at(opacityPointsIdx).position;
float factor = 1.0f - (pos1 - currentPosition) / (pos1 - pos0);
opacityAtIdx = sgl::interpolateLinear(opacity0, opacity1, factor);
}
transferFunctionMap_linearRGB[i] = sgl::Color16(glm::vec4(
sgl::TransferFunctionWindow::sRGBToLinearRGB(sRGBColorAtIdx), opacityAtIdx));
transferFunctionMap_sRGB[i] = sgl::Color16(glm::vec4(sRGBColorAtIdx, opacityAtIdx));
}
}
bool GuiVarData::renderGui() {
renderOpacityGraph();
renderColorBar();
if (selectedPointType == sgl::SELECTED_POINT_TYPE_OPACITY) {
if (ImGui::DragFloat("Opacity", &opacitySelection, 0.001f, 0.0f, 1.0f)) {
opacityPoints.at(currentSelectionIndex).opacity = opacitySelection;
rebuildTransferFunctionMap();
reRender = true;
}
} else if (selectedPointType == sgl::SELECTED_POINT_TYPE_COLOR) {
if (ImGui::ColorEdit3("Color", (float*)&colorSelection)) {
colorPoints.at(currentSelectionIndex).color = sgl::color16FromFloat(
colorSelection.x, colorSelection.y, colorSelection.z, colorSelection.w);
rebuildTransferFunctionMap();
reRender = true;
}
}
if (ImGui::Combo(
"Color Space", (int*)&interpolationColorSpace,
sgl::COLOR_SPACE_NAMES, IM_ARRAYSIZE(sgl::COLOR_SPACE_NAMES))) {
rebuildTransferFunctionMap();
reRender = true;
}
if (ImGui::SliderFloat2("Range", &selectedRange.x, dataRange.x, dataRange.y)) {
computeHistogram();
window->rebuildRangeSsbo();
reRender = true;
}
ImGui::SameLine();
if (ImGui::Button("Reset")) {
selectedRange = dataRange;
computeHistogram();
window->rebuildRangeSsbo();
reRender = true;
}
if (ImGui::SliderInt("Histogram Res.", &histogramResolution, 1, 256)) {
computeHistogram();
}
renderFileDialog();
if (reRender) {
reRender = false;
return true;
}
return false;
}
void GuiVarData::renderFileDialog() {
// Load file data
if (ImGui::ListBox("##availablefiles", &selectedFileIndex, [this](void* data, int idx, const char** out_text) -> bool {
*out_text = window->availableFiles.at(idx).c_str();
return true;
}, nullptr, int(window->availableFiles.size()), 4)) {
saveFileString = window->availableFiles.at(selectedFileIndex);
} ImVec2 cursorPosEnd = ImGui::GetCursorPos(); ImGui::SameLine();
ImVec2 cursorPos = ImGui::GetCursorPos();
ImGui::Text("Available files"); ImGui::SameLine(); ImGui::SetCursorPos(cursorPos + ImVec2(0.0f, 42.0f));
if (ImGui::Button("Load file") && selectedFileIndex >= 0) {
loadTfFromFile(window->saveDirectory + window->availableFiles.at(selectedFileIndex));
reRender = true;
} ImGui::SetCursorPos(cursorPosEnd);
// Save file data
ImGui::InputText("##savefilelabel", &saveFileString); ImGui::SameLine();
if (ImGui::Button("Save file")) {
saveTfToFile(window->saveDirectory + saveFileString);
window->updateAvailableFiles();
}
}
void GuiVarData::renderOpacityGraph() {
ImDrawList* drawList = ImGui::GetWindowDrawList();
float scaleFactor = sgl::ImGuiWrapper::get()->getScaleFactor();
float regionWidth = ImGui::GetContentRegionAvailWidth();
float graphHeight = 300 * scaleFactor / 1.875f;
float border = 2*scaleFactor;
float areaWidth = regionWidth - 2.0f*border;
float areaHeight = graphHeight - 2.0f*border;
opacityGraphBox.min = glm::vec2(ImGui::GetCursorScreenPos().x + border, ImGui::GetCursorScreenPos().y + border);
opacityGraphBox.max = opacityGraphBox.min + glm::vec2(areaWidth, areaHeight);
sgl::Color& clearColor = window->clearColor;
ImColor backgroundColor(clearColor.getFloatR(), clearColor.getFloatG(), clearColor.getFloatB());
ImColor borderColor(
1.0f - clearColor.getFloatR(), 1.0f - clearColor.getFloatG(), 1.0f - clearColor.getFloatB());
// First render the graph box
ImVec2 startPos = ImGui::GetCursorScreenPos();
ImVec2 cursorPosHistogram = ImGui::GetCursorPos();
drawList->AddRectFilled(
ImVec2(startPos.x, startPos.y),
ImVec2(startPos.x + regionWidth, startPos.y + graphHeight),
borderColor, ImGui::GetStyle().FrameRounding);
drawList->AddRectFilled(
ImVec2(startPos.x + border, startPos.y + border),
ImVec2(startPos.x + regionWidth - border, startPos.y + graphHeight - border),
backgroundColor, ImGui::GetStyle().FrameRounding);
if (ImGui::ClickArea("##grapharea", ImVec2(regionWidth, graphHeight + 2), mouseReleased)) {
onOpacityGraphClick();
}
//ImGui::SetItemAllowOverlap();
ImGui::SetCursorPos(cursorPosHistogram + ImVec2(border, border));
ImVec2 oldPadding = ImGui::GetStyle().FramePadding;
ImGui::GetStyle().FramePadding = ImVec2(1, 1);
ImGui::PlotHistogram(
"##histogram", histogram.data(), int(histogram.size()), 0,
nullptr, 0.0f, 1.0f,
ImVec2(regionWidth - border * 2, graphHeight - border * 2));
ImGui::GetStyle().FramePadding = oldPadding;
// Then render the graph itself
for (int i = 0; i < (int)opacityPoints.size()-1; i++) {
float positionX0 = opacityPoints.at(i).position * areaWidth + border;
float positionX1 = opacityPoints.at(i+1).position * areaWidth + border;
float positionY0 = (1.0f - opacityPoints.at(i).opacity) * areaHeight + border;
float positionY1 = (1.0f - opacityPoints.at(i+1).opacity) * areaHeight + border;
drawList->AddLine(
ImVec2(startPos.x + positionX0, startPos.y + positionY0),
ImVec2(startPos.x + positionX1, startPos.y + positionY1),
borderColor, 1.5f * scaleFactor);
}
// Finally, render the points
for (int i = 0; i < (int)opacityPoints.size(); i++) {
ImVec2 centerPt = ImVec2(
startPos.x + border + opacityPoints.at(i).position * areaWidth,
startPos.y + border + (1.0f - opacityPoints.at(i).opacity) * areaHeight);
float radius = 4*scaleFactor;
if (selectedPointType == sgl::SELECTED_POINT_TYPE_OPACITY && i == currentSelectionIndex) {
radius = 6*scaleFactor;
}
drawList->AddCircleFilled(centerPt, radius, backgroundColor, 24);
drawList->AddCircle(centerPt, radius, borderColor, 24, 1.5f);
}
}
void GuiVarData::renderColorBar() {
ImDrawList* drawList = ImGui::GetWindowDrawList();
float scaleFactor = sgl::ImGuiWrapper::get()->getScaleFactor();
float regionWidth = ImGui::GetContentRegionAvailWidth() - 2.0f;
float barHeight = 30 * scaleFactor / 1.875f;
colorBarBox.min = glm::vec2(ImGui::GetCursorScreenPos().x + 1, ImGui::GetCursorScreenPos().y + 1);
colorBarBox.max = colorBarBox.min + glm::vec2(regionWidth - 2, barHeight - 2);
// Draw bar
ImVec2 startPos = ImGui::GetCursorScreenPos();
ImVec2 pos = ImVec2(startPos.x + 1, startPos.y + 1);
for (size_t i = 0; i < TRANSFER_FUNCTION_TEXTURE_SIZE; i++) {
sgl::Color16 color = transferFunctionMap_sRGB[i];
ImU32 colorImgui = ImColor(color.getFloatR(), color.getFloatG(), color.getFloatB());
drawList->AddLine(ImVec2(pos.x, pos.y), ImVec2(pos.x, pos.y + barHeight), colorImgui, 2.0f * regionWidth / 255.0f);
pos.x += regionWidth / 255.0f;
}
// Draw points
pos = ImVec2(startPos.x + 2, startPos.y + 2);
for (int i = 0; i < (int)colorPoints.size(); i++) {
sgl::Color16 color = colorPoints.at(i).color;
ImU32 colorImgui = ImColor(color.getFloatR(), color.getFloatG(), color.getFloatB());
ImU32 colorInvertedImgui = ImColor(1.0f - color.getFloatR(), 1.0f - color.getFloatG(), 1.0f - color.getFloatB());
ImVec2 centerPt = ImVec2(pos.x + colorPoints.at(i).position * regionWidth, pos.y + barHeight/2);
float radius = 4*scaleFactor;
if (selectedPointType == sgl::SELECTED_POINT_TYPE_COLOR && i == currentSelectionIndex) {
radius = 6*scaleFactor;
}
drawList->AddCircleFilled(centerPt, radius, colorImgui, 24);
drawList->AddCircle(centerPt, radius, colorInvertedImgui, 24);
}
if (ImGui::ClickArea("##bararea", ImVec2(regionWidth + 2, barHeight), mouseReleased)) {
onColorBarClick();
}
}
void GuiVarData::onOpacityGraphClick() {
glm::vec2 mousePosWidget = glm::vec2(ImGui::GetMousePos().x, ImGui::GetMousePos().y) - opacityGraphBox.min;
glm::vec2 normalizedPosition = mousePosWidget / opacityGraphBox.getDimensions();
normalizedPosition.y = 1.0f - normalizedPosition.y;
normalizedPosition = glm::clamp(normalizedPosition, glm::vec2(0), glm::vec2(1));
dragging = false;
if (selectNearestOpacityPoint(currentSelectionIndex, mousePosWidget)) {
// A) Point near to normalized position
if (ImGui::GetIO().MouseClicked[0]) {
// A.1 Left clicked? Select/drag-and-drop
opacitySelection = opacityPoints.at(currentSelectionIndex).opacity;
selectedPointType = sgl::SELECTED_POINT_TYPE_OPACITY;
dragging = true;
} else if (ImGui::GetIO().MouseClicked[1] && currentSelectionIndex != 0
&& currentSelectionIndex != int(opacityPoints.size())-1) {
// A.2 Middle clicked? Delete point
opacityPoints.erase(opacityPoints.begin() + currentSelectionIndex);
selectedPointType = sgl::SELECTED_POINT_TYPE_NONE;
reRender = true;
}
} else {
// B) If no point near and left clicked: Create new point at position
if (ImGui::GetIO().MouseClicked[0]) {
// Compute insert position for new point
int insertPosition = 0;
for (insertPosition = 0; insertPosition < (int)opacityPoints.size(); insertPosition++) {
if (normalizedPosition.x < opacityPoints.at(insertPosition).position
|| insertPosition == int(opacityPoints.size())-1) {
break;
}
}
// Add new opacity point
glm::vec2 newPosition = normalizedPosition;
float newOpacity = newPosition.y;
opacityPoints.insert(opacityPoints.begin() + insertPosition, sgl::OpacityPoint(newOpacity, newPosition.x));
currentSelectionIndex = insertPosition;
opacitySelection = opacityPoints.at(currentSelectionIndex).opacity;
selectedPointType = sgl::SELECTED_POINT_TYPE_OPACITY;
dragging = true;
reRender = true;
}
}
rebuildTransferFunctionMap();
}
void GuiVarData::onColorBarClick() {
glm::vec2 mousePosWidget = glm::vec2(ImGui::GetMousePos().x, ImGui::GetMousePos().y) - colorBarBox.min;
float normalizedPosition = mousePosWidget.x / colorBarBox.getWidth();
dragging = false;
if (selectNearestColorPoint(currentSelectionIndex, mousePosWidget)) {
// A) Point near to normalized position
if (ImGui::GetIO().MouseClicked[0]) {
// A.1 Left clicked? Select/drag-and-drop
sgl::Color16& color16 = colorPoints.at(currentSelectionIndex).color;
colorSelection = ImColor(color16.getFloatR(), color16.getFloatG(), color16.getFloatB());
selectedPointType = sgl::SELECTED_POINT_TYPE_COLOR;
if (currentSelectionIndex != 0 && currentSelectionIndex != int(colorPoints.size())-1) {
dragging = true;
}
} else if (ImGui::GetIO().MouseClicked[1] && currentSelectionIndex != 0
&& currentSelectionIndex != int(colorPoints.size())-1) {
// A.2 Middle clicked? Delete point
colorPoints.erase(colorPoints.begin() + currentSelectionIndex);
colorPoints_LinearRGB.erase(colorPoints_LinearRGB.begin() + currentSelectionIndex);
selectedPointType = sgl::SELECTED_POINT_TYPE_NONE;
reRender = true;
}
} else {
// B) If no point near and left clicked: Create new point at position
if (ImGui::GetIO().MouseClicked[0]) {
// Compute insert position for new point
int insertPosition = 0;
for (insertPosition = 0; insertPosition < (int)colorPoints.size(); insertPosition++) {
if (normalizedPosition < colorPoints.at(insertPosition).position
|| insertPosition == int(colorPoints.size())-1) {
break;
}
}
// Add new color point
float newPosition = normalizedPosition;
if (interpolationColorSpace == sgl::COLOR_SPACE_LINEAR_RGB) {
// Linear RGB interplation
glm::vec3 newColor_linearRGB = glm::mix(
colorPoints_LinearRGB.at(insertPosition-1).color,
colorPoints_LinearRGB.at(insertPosition).color,
1.0 - (colorPoints_LinearRGB.at(insertPosition).position - newPosition)
/ (colorPoints_LinearRGB.at(insertPosition).position
- colorPoints_LinearRGB.at(insertPosition-1).position));
sgl::Color16 newColorsRGB(sgl::TransferFunctionWindow::linearRGBTosRGB(newColor_linearRGB));
colorPoints_LinearRGB.insert(
colorPoints_LinearRGB.begin() + insertPosition,
sgl::ColorPoint_LinearRGB(newColor_linearRGB, newPosition));
colorPoints.insert(
colorPoints.begin() + insertPosition,
sgl::ColorPoint_sRGB(newColorsRGB, newPosition));
} else {
// sRGB interpolation
sgl::Color16 newColor = sgl::color16Lerp(
colorPoints.at(insertPosition-1).color,
colorPoints.at(insertPosition).color,
1.0f - (colorPoints.at(insertPosition).position - newPosition)
/ (colorPoints.at(insertPosition).position - colorPoints.at(insertPosition-1).position));
colorPoints.insert(
colorPoints.begin() + insertPosition,
sgl::ColorPoint_sRGB(newColor, newPosition));
// colorPoints_LinearRGB computed in @ref rebuildTransferFunctionMap
}
currentSelectionIndex = insertPosition;
sgl::Color16& color16 = colorPoints.at(currentSelectionIndex).color;
colorSelection = ImColor(color16.getFloatR(), color16.getFloatG(), color16.getFloatB());
selectedPointType = sgl::SELECTED_POINT_TYPE_COLOR;
reRender = true;
}
}
rebuildTransferFunctionMap();
}
void GuiVarData::dragPoint() {
if (mouseReleased) {
dragging = false;
}
glm::vec2 mousePosWidget = glm::vec2(ImGui::GetMousePos().x, ImGui::GetMousePos().y) - opacityGraphBox.min;
if (!dragging || mousePosWidget == oldMousePosWidget) {
oldMousePosWidget = mousePosWidget;
return;
}
oldMousePosWidget = mousePosWidget;
if (selectedPointType == sgl::SELECTED_POINT_TYPE_OPACITY) {
glm::vec2 normalizedPosition = mousePosWidget / opacityGraphBox.getDimensions();
normalizedPosition.y = 1.0f - normalizedPosition.y;
normalizedPosition = glm::clamp(normalizedPosition, 0.0f, 1.0f);
if (currentSelectionIndex == 0) {
normalizedPosition.x = 0.0f;
}
if (currentSelectionIndex == int(opacityPoints.size())-1) {
normalizedPosition.x = 1.0f;
}
// Clip to neighbors!
if (currentSelectionIndex != 0
&& normalizedPosition.x < opacityPoints.at(currentSelectionIndex-1).position) {
normalizedPosition.x = opacityPoints.at(currentSelectionIndex-1).position;
}
if (currentSelectionIndex != int(opacityPoints.size())-1
&& normalizedPosition.x > opacityPoints.at(currentSelectionIndex+1).position) {
normalizedPosition.x = opacityPoints.at(currentSelectionIndex+1).position;
}
opacityPoints.at(currentSelectionIndex).position = normalizedPosition.x;
opacityPoints.at(currentSelectionIndex).opacity = normalizedPosition.y;
opacitySelection = opacityPoints.at(currentSelectionIndex).opacity;
}
if (selectedPointType == sgl::SELECTED_POINT_TYPE_COLOR) {
float normalizedPosition = mousePosWidget.x / colorBarBox.getWidth();
normalizedPosition = glm::clamp(normalizedPosition, 0.0f, 1.0f);
// Clip to neighbors!
if (currentSelectionIndex != 0
&& normalizedPosition < colorPoints.at(currentSelectionIndex-1).position) {
normalizedPosition = colorPoints.at(currentSelectionIndex-1).position;
}
if (currentSelectionIndex != int(colorPoints.size())-1
&& normalizedPosition > colorPoints.at(currentSelectionIndex+1).position) {
normalizedPosition = colorPoints.at(currentSelectionIndex+1).position;
}
colorPoints.at(currentSelectionIndex).position = normalizedPosition;
}
rebuildTransferFunctionMap();
reRender = true;
}
bool GuiVarData::selectNearestOpacityPoint(int& currentSelectionIndex, const glm::vec2& mousePosWidget) {
float scaleFactor = sgl::ImGuiWrapper::get()->getScaleFactor();
for (int i = 0; i < (int)opacityPoints.size(); i++) {
glm::vec2 centerPt = glm::vec2(
opacityPoints.at(i).position * opacityGraphBox.getWidth(),
(1.0f - opacityPoints.at(i).opacity) * opacityGraphBox.getHeight());
if (glm::length(centerPt - mousePosWidget) < scaleFactor * 10.0f) {
currentSelectionIndex = i;
return true;
}
}
return false;
}
bool GuiVarData::selectNearestColorPoint(int& currentSelectionIndex, const glm::vec2& mousePosWidget) {
float scaleFactor = sgl::ImGuiWrapper::get()->getScaleFactor();
for (int i = 0; i < (int)colorPoints.size(); i++) {
ImVec2 centerPt = ImVec2(
colorPoints.at(i).position * colorBarBox.getWidth(),
colorBarBox.getHeight()/2);
if (glm::abs(centerPt.x - mousePosWidget.x) < scaleFactor * 10.0f) {
currentSelectionIndex = i;
return true;
}
}
return false;
}
// ---------------------------------------------------------------------------------------------------------------------
MultiVarTransferFunctionWindow::MultiVarTransferFunctionWindow(
const std::string& saveDirectoryPrefix,
const std::vector<std::string>& tfPresetFiles) {
parentDirectory = sgl::AppSettings::get()->getDataDirectory();
saveDirectory = sgl::AppSettings::get()->getDataDirectory() + "TransferFunctions/";
if (!saveDirectoryPrefix.empty()) {
directoryName = saveDirectoryPrefix;
parentDirectory = saveDirectory;
saveDirectory = saveDirectory + saveDirectoryPrefix + "/";
}
this->tfPresetFiles = tfPresetFiles;
directoryContentWatch.setPath(saveDirectory, true);
directoryContentWatch.initialize();
#ifdef SUPPORT_OPENGL
if (sgl::AppSettings::get()->getRenderSystem() == sgl::RenderSystem::OPENGL) {
tfMapTextureSettings.type = sgl::TEXTURE_1D_ARRAY;
tfMapTextureSettings.internalFormat = GL_RGBA16;
}
#endif
#ifdef USE_VULKAN_INTEROP
if (sgl::AppSettings::get()->getPrimaryDevice()) {
tfMapImageSettingsVulkan.imageType = VK_IMAGE_TYPE_1D;
tfMapImageSettingsVulkan.format = VK_FORMAT_R16G16B16A16_UNORM;
}
#endif
updateAvailableFiles();
}
MultiVarTransferFunctionWindow::~MultiVarTransferFunctionWindow() {
}
void MultiVarTransferFunctionWindow::setAttributesValues(
const std::vector<std::string>& names,
const std::vector<std::vector<float>>& allAttributes) {
assert(names.size() == allAttributes.size());
varNames = names;
transferFunctionMap_sRGB.resize(TRANSFER_FUNCTION_TEXTURE_SIZE * names.size());
transferFunctionMap_linearRGB.resize(TRANSFER_FUNCTION_TEXTURE_SIZE * names.size());
selectedVarIndex = 0;
if (guiVarData.size() != names.size()){
guiVarData.clear();
guiVarData.reserve(names.size());
#ifdef SUPPORT_OPENGL
if (sgl::AppSettings::get()->getRenderSystem() == sgl::RenderSystem::OPENGL) {
tfMapTexture = sgl::TextureManager->createEmptyTexture(
TRANSFER_FUNCTION_TEXTURE_SIZE, int(names.size()), tfMapTextureSettings);
minMaxSsbo = sgl::Renderer->createGeometryBuffer(
names.size() * sizeof(glm::vec2), sgl::SHADER_STORAGE_BUFFER);
}
#endif
#ifdef USE_VULKAN_INTEROP
if (sgl::AppSettings::get()->getPrimaryDevice()) {
tfMapImageSettingsVulkan.width = TRANSFER_FUNCTION_TEXTURE_SIZE;
tfMapImageSettingsVulkan.arrayLayers = uint32_t(names.size());
tfMapTextureVulkan = std::make_shared<sgl::vk::Texture>(
sgl::AppSettings::get()->getPrimaryDevice(), tfMapImageSettingsVulkan,
VK_IMAGE_VIEW_TYPE_1D_ARRAY);
minMaxSsboVulkan = std::make_shared<sgl::vk::Buffer>(
sgl::AppSettings::get()->getPrimaryDevice(), names.size() * sizeof(glm::vec2),
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
VMA_MEMORY_USAGE_GPU_ONLY);
}
#endif
minMaxData.clear();
minMaxData.resize(names.size() * 2, 0);
for (size_t varIdx = 0; varIdx < names.size(); varIdx++) {
guiVarData.push_back(GuiVarData(
this, tfPresetFiles.size() > 0 ? tfPresetFiles.at(varIdx % tfPresetFiles.size()) : "",
&transferFunctionMap_sRGB.at(TRANSFER_FUNCTION_TEXTURE_SIZE * varIdx),
&transferFunctionMap_linearRGB.at(TRANSFER_FUNCTION_TEXTURE_SIZE * varIdx)
));
}
}
for (size_t varIdx = 0; varIdx < names.size(); varIdx++) {
GuiVarData& varData = guiVarData.at(varIdx);
varData.setAttributeValues(names.at(varIdx), allAttributes.at(varIdx));
}
currVarData = &guiVarData.at(selectedVarIndex);
updateAvailableFiles();
rebuildTransferFunctionMapComplete();
rebuildRangeSsbo();
}
bool MultiVarTransferFunctionWindow::loadFromTfNameList(const std::vector<std::string>& tfNames) {
if (tfNames.size() != guiVarData.size()) {
sgl::Logfile::get()->writeError(
"MultiVarTransferFunctionWindow::loadFromTfNameList: tfNames.size() != guiVarData.size()");
return false;
}
for (size_t varIdx = 0; varIdx < tfNames.size(); varIdx++) {
GuiVarData& varData = guiVarData.at(varIdx);
varData.loadTfFromFile(saveDirectory + tfNames.at(varIdx));
}
return true;
}
void MultiVarTransferFunctionWindow::updateAvailableFiles() {
sgl::FileUtils::get()->ensureDirectoryExists(saveDirectory);
std::vector<std::string> availableFilesAll = sgl::FileUtils::get()->getFilesInDirectoryVector(saveDirectory);
availableFiles.clear();
availableFiles.reserve(availableFilesAll.size());
for (const std::string& filename : availableFilesAll) {
if (sgl::FileUtils::get()->hasExtension(filename.c_str(), ".xml")) {
availableFiles.push_back(filename);
}
}
sgl::FileUtils::get()->sortPathStrings(availableFiles);
// Update currently selected filename
for (size_t i = 0; i < availableFiles.size(); i++) {
availableFiles.at(i) = sgl::FileUtils::get()->getPureFilename(availableFiles.at(i));
for (GuiVarData& varData : guiVarData) {
if (availableFiles.at(i) == varData.getSaveFileString()) {
varData.selectedFileIndex = (int)i;
}
}
}
}
void MultiVarTransferFunctionWindow::setClearColor(const sgl::Color& clearColor) {
this->clearColor = clearColor;
}
#ifdef SUPPORT_OPENGL
sgl::TexturePtr& MultiVarTransferFunctionWindow::getTransferFunctionMapTexture() {
return tfMapTexture;
}
#endif
#ifdef USE_VULKAN_INTEROP
sgl::vk::TexturePtr& MultiVarTransferFunctionWindow::getTransferFunctionMapTextureVulkan() {
return tfMapTextureVulkan;
}
#endif
bool MultiVarTransferFunctionWindow::getTransferFunctionMapRebuilt() {
if (transferFunctionMapRebuilt) {
// Reset the flag
transferFunctionMapRebuilt = false;
return true;
}
return false;
}
std::vector<sgl::Color16> MultiVarTransferFunctionWindow::getTransferFunctionMap_sRGB(int varIdx) {
return std::vector<sgl::Color16>(
transferFunctionMap_sRGB.cbegin() + TRANSFER_FUNCTION_TEXTURE_SIZE * varIdx,
transferFunctionMap_sRGB.cbegin() + TRANSFER_FUNCTION_TEXTURE_SIZE * (varIdx + 1));
}
void MultiVarTransferFunctionWindow::update(float dt) {
directoryContentWatch.update([this] { this->updateAvailableFiles(); });
if (currVarData) {
currVarData->dragPoint();
}
}
void MultiVarTransferFunctionWindow::setUseLinearRGB(bool useLinearRGB) {
this->useLinearRGB = useLinearRGB;
rebuildTransferFunctionMapComplete();
}
void MultiVarTransferFunctionWindow::rebuildTransferFunctionMapComplete() {
for (GuiVarData& varData : guiVarData) {
varData.rebuildTransferFunctionMapLocal();
}
rebuildTransferFunctionMap();
}
void MultiVarTransferFunctionWindow::rebuildRangeSsbo() {
for (size_t varIdx = 0; varIdx < guiVarData.size(); varIdx++) {
GuiVarData& varData = guiVarData.at(varIdx);
const glm::vec2& range = varData.getSelectedRange();
minMaxData[varIdx * 2] = range.x;
minMaxData[varIdx * 2 + 1] = range.y;
}
#ifdef SUPPORT_OPENGL
if (sgl::AppSettings::get()->getRenderSystem() == sgl::RenderSystem::OPENGL) {
minMaxSsbo->subData(0, minMaxData.size() * sizeof(float), minMaxData.data());
}
#endif
#ifdef USE_VULKAN_INTEROP
if (sgl::AppSettings::get()->getPrimaryDevice()) {
minMaxSsboVulkan->uploadData(minMaxData.size() * sizeof(float), minMaxData.data());
}
#endif
}
void MultiVarTransferFunctionWindow::rebuildTransferFunctionMap() {
#ifdef SUPPORT_OPENGL
if (sgl::AppSettings::get()->getRenderSystem() == sgl::RenderSystem::OPENGL) {
sgl::PixelFormat pixelFormat;
pixelFormat.pixelType = GL_UNSIGNED_SHORT;
if (useLinearRGB) {
tfMapTexture->uploadPixelData(
TRANSFER_FUNCTION_TEXTURE_SIZE, int(varNames.size()),
transferFunctionMap_linearRGB.data(), pixelFormat);
} else {
tfMapTexture->uploadPixelData(
TRANSFER_FUNCTION_TEXTURE_SIZE, int(varNames.size()),
transferFunctionMap_sRGB.data(), pixelFormat);
}
}
#endif
#ifdef USE_VULKAN_INTEROP
if (sgl::AppSettings::get()->getPrimaryDevice()) {
if (useLinearRGB) {
tfMapTextureVulkan->getImage()->uploadData(
TRANSFER_FUNCTION_TEXTURE_SIZE * uint32_t(varNames.size()) * 8,
transferFunctionMap_linearRGB.data());
} else {
tfMapTextureVulkan->getImage()->uploadData(
TRANSFER_FUNCTION_TEXTURE_SIZE * uint32_t(varNames.size()) * 8,
transferFunctionMap_sRGB.data());
}
}
#endif
transferFunctionMapRebuilt = true;
}
bool MultiVarTransferFunctionWindow::renderGui() {
sgl::ImGuiWrapper::get()->setNextWindowStandardPosSize(2, 1278, 634, 818);
if (showWindow && ImGui::Begin("Multi-Var Transfer Function", &showWindow)) {
if (ImGui::BeginCombo("Variable", varNames.at(selectedVarIndex).c_str())) {
for (size_t i = 0; i < varNames.size(); ++i) {
if (ImGui::Selectable(varNames.at(i).c_str(), selectedVarIndex == i)) {
selectedVarIndex = i;
currVarData = &guiVarData.at(selectedVarIndex);
}
}
ImGui::EndCombo();
}
if (currVarData) {
reRender = currVarData->renderGui() || reRender;
}
ImGui::End();
}
if (reRender) {
reRender = false;
return true;
}
return false;
}
| 44,258
| 13,867
|
/*
oscpack -- Open Sound Control packet manipulation library
http://www.audiomulch.com/~rossb/oscpack
Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
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.
Any person wishing to distribute modifications to the Software is
requested to send the modifications to the original developer so that
they can be incorporated into the canonical version.
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 "IpEndpointName.h"
#include <stdio.h>
#include "NetworkingUtils.h"
unsigned long IpEndpointName::GetHostByName( const char *s )
{
return ::GetHostByName(s);
}
void IpEndpointName::AddressAsString( char *s ) const
{
if( address == ANY_ADDRESS ){
sprintf( s, "<any>" );
}else{
sprintf( s, "%d.%d.%d.%d",
(int)((address >> 24) & 0xFF),
(int)((address >> 16) & 0xFF),
(int)((address >> 8) & 0xFF),
(int)(address & 0xFF) );
}
}
void IpEndpointName::AddressAndPortAsString( char *s ) const
{
if( port == ANY_PORT ){
if( address == ANY_ADDRESS ){
sprintf( s, "<any>:<any>" );
}else{
sprintf( s, "%d.%d.%d.%d:<any>",
(int)((address >> 24) & 0xFF),
(int)((address >> 16) & 0xFF),
(int)((address >> 8) & 0xFF),
(int)(address & 0xFF) );
}
}else{
if( address == ANY_ADDRESS ){
sprintf( s, "<any>:%d", port );
}else{
sprintf( s, "%d.%d.%d.%d:%d",
(int)((address >> 24) & 0xFF),
(int)((address >> 16) & 0xFF),
(int)((address >> 8) & 0xFF),
(int)(address & 0xFF),
(int)port );
}
}
}
| 2,556
| 1,053
|
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2008-2013, Image Engine Design Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of Image Engine Design nor the names of any
// other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////
#include "IECore/MemoryIndexedIO.h"
#include "IECore/FileIndexedIO.h"
#include "IECore/VectorTypedData.h"
using namespace IECore;
IE_CORE_DEFINERUNTIMETYPEDDESCRIPTION( MemoryIndexedIO )
///////////////////////////////////////////////
//
// FileIndexedIO::StreamFile (begin)
//
///////////////////////////////////////////////
class MemoryIndexedIO::StreamFile : public StreamIndexedIO::StreamFile
{
public:
StreamFile( const char *buf, size_t size, IndexedIO::OpenMode mode );
CharVectorDataPtr buffer();
~StreamFile() override;
void flush( size_t endPosition ) override;
private:
size_t m_endPosition;
};
MemoryIndexedIO::StreamFile::StreamFile( const char *buf, size_t size, IndexedIO::OpenMode mode ) : StreamIndexedIO::StreamFile(mode), m_endPosition(0)
{
if (mode & IndexedIO::Write)
{
std::stringstream *f = new std::stringstream( std::ios::trunc | std::ios::binary | std::ios::in | std::ios::out );
setInput( f, true, "" );
}
else if (mode & IndexedIO::Append)
{
if ( !buf || !size )
{
/// Create new file
std::stringstream *f = new std::stringstream( std::ios::trunc | std::ios::binary | std::ios::in | std::ios::out );
setInput( f, true, "" );
}
else
{
/// Read existing file
assert( buf );
/// Read existing file
std::stringstream *f = new std::stringstream( std::string(buf, size), std::ios::binary | std::ios::in | std::ios::out );
setInput( f, false, "" );
}
}
else
{
assert( buf );
assert( mode & IndexedIO::Read );
std::stringstream *f = new std::stringstream( std::string(buf, size), std::ios::binary | std::ios::in | std::ios::out );
setInput( f, false, "" );
}
}
void MemoryIndexedIO::StreamFile::flush( size_t endPosition )
{
m_endPosition = endPosition;
}
CharVectorDataPtr MemoryIndexedIO::StreamFile::buffer()
{
std::stringstream *s = static_cast< std::stringstream *>( m_stream );
assert( s );
CharVectorData::ValueType d;
const std::string &str = s->str();
d.assign( str.begin(), str.end() );
d.resize( m_endPosition );
assert( d.size() == m_endPosition );
return new CharVectorData( d );
}
MemoryIndexedIO::StreamFile::~StreamFile()
{
}
///////////////////////////////////////////////
//
// MemoryIndexedIO::StreamFile (end)
//
///////////////////////////////////////////////
MemoryIndexedIO::MemoryIndexedIO( ConstCharVectorDataPtr buf, const IndexedIO::EntryIDList &root, IndexedIO::OpenMode mode)
{
const char *bufPtr = nullptr;
size_t size = 0;
if ( buf )
{
bufPtr = &(buf->readable()[0]);
size = buf->readable().size();
}
open( new StreamFile( bufPtr, size, mode ), root );
}
MemoryIndexedIO::MemoryIndexedIO( StreamIndexedIO::Node &rootNode ) : StreamIndexedIO( rootNode )
{
}
MemoryIndexedIO::~MemoryIndexedIO()
{
}
CharVectorDataPtr MemoryIndexedIO::buffer()
{
flush();
StreamFile &stream = static_cast<StreamFile&>( streamFile() );
return stream.buffer();
}
IndexedIO * MemoryIndexedIO::duplicate(Node &rootNode) const
{
// duplicate the IO interface changing the current node
MemoryIndexedIO *other = new MemoryIndexedIO( rootNode );
return other;
}
| 4,925
| 1,673
|
/*
**==============================================================================
**
** Copyright (c) 2003, 2004, 2005, 2006, Michael Brasher, Karl Schopmeyer
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
** to deal in the Software without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Software, and to permit persons to whom the
** Software is furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
** SOFTWARE.
**
**==============================================================================
*/
#include <cassert>
#include <cimple/cimple.h>
using namespace cimple;
void test(const char* name, Type expected_type)
{
Type type;
int status = type_name_to_type(name, type);
assert(status == 0);
assert(type == expected_type);
}
int main(int /* argc */, char** argv)
{
printf("Test+++ %s\n",argv[0]);
test("boolean", BOOLEAN);
test("uint8", UINT8);
test("sint8", SINT8);
test("uint16", UINT16);
test("sint16", SINT16);
test("uint32", UINT32);
test("sint32", SINT32);
test("uint64", UINT64);
test("sint64", SINT64);
test("real32", REAL32);
test("real64", REAL64);
test("char16", CHAR16);
test("string", STRING);
test("datetime", DATETIME);
test("BOOLEAN", BOOLEAN);
test("UINT8", UINT8);
test("SINT8", SINT8);
test("UINT16", UINT16);
test("SINT16", SINT16);
test("UINT32", UINT32);
test("SINT32", SINT32);
test("UINT64", UINT64);
test("SINT64", SINT64);
test("REAL32", REAL32);
test("REAL64", REAL64);
test("CHAR16", CHAR16);
test("STRING", STRING);
test("DATETIME", DATETIME);
printf("+++++ passed all tests (%s)\n", argv[0]);
return 0;
}
| 2,509
| 919
|
/*
* BiasedRandomWalk.hpp
*
* Created on: 03.07.2020
* Author: Klaus Ahrens <ahrens@informatik.hu-berlin.de>
*
* adapted and reimplemented from node2vec
* part of snap [https://github.com/snap-stanford/snap]
* Copyright (c) 2007-2019, Jure Leskovec (under BSD license)
*
* see [https://arxiv.org/pdf/1607.00653v1.pdf]
*
*/
#ifndef BIASEDRANDOMWALK_HPP
#define BIASEDRANDOMWALK_HPP
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <networkit/graph/Graph.hpp>
namespace NetworKit {
namespace Embedding {
class BiasedRandomWalk {
public:
using Walk = std::vector<node>; // one walk
using AllWalks = std::vector<Walk>; // n walks for all nodes: 2 dimensions in one big chunk
/// preprocesses transition probabilities for random walks. Has to be called once before doWalks
/// calls
void preprocessTransitionProbs(double paramP, double paramQ);
/// Simulates walks from every node and writes it into walks vector
AllWalks doWalks(count walkLen, count numberOfWalks);
BiasedRandomWalk(const Graph *graph);
private:
const Graph *graph;
using NeighborSet = std::unordered_set<node>;
using NeighborMap = std::unordered_map<node, AliasSampler>;
struct GraphData {
// assuming contiguous node numbers 0..n-1, they serve as indices
using Data = std::vector<NeighborMap>;
Data data;
GraphData(size_t nn) : data{nn, NeighborMap()} {}
};
std::unique_ptr<GraphData> graphData;
std::vector<std::vector<node>> index2node;
Walk oneWalk(node start, count walkLen);
void preprocessNode(node t, double paramP, double paramQ);
}; // class BiasedRandomWalk
} // namespace Embedding
} // namespace NetworKit
#endif // BIASEDRANDOMWALK_HPP
| 1,802
| 637
|
#include <string>
#include <string_view>
#include <iostream>
#include <regex>
#include <algorithm>
#include <map>
// #include <range/v3/all.hpp>
namespace {
using SatelliteGraph = std::map<std::string, std::vector<std::string>>;
SatelliteGraph map2graph(std::istream& map) {
SatelliteGraph result;
const std::regex regex(R"(([A-Z0-9]+)\)([A-Z0-9]+))");
for (std::string line; std::getline(map, line);) {
std::smatch match;
if (not std::regex_match(line, match, regex)) continue;
const auto& center = match[1];
const auto& satellite = match[2];
result[center].push_back(satellite);
static_cast<void>(result[satellite]);
}
return result;
}
using SatelliteDistances = std::map<std::string, unsigned>;
void checksum_(const SatelliteGraph& graph,
const std::string& satellite,
SatelliteDistances& satellite_distances,
unsigned distance) {
satellite_distances[satellite] = distance;
for (const auto next_satellite : graph.at(satellite)) {
checksum_(graph, next_satellite, satellite_distances, distance + 1);
}
}
unsigned checksum(const SatelliteGraph& graph) {
SatelliteDistances satellite_distances;
checksum_(graph, "COM", satellite_distances, 0);
unsigned tot_dist = 0;
for (auto [satellite, distance] : satellite_distances) tot_dist += distance;
return tot_dist;
}
} // namespace
#if not defined(DO_UNIT_TEST)
#include <filesystem>
#include <fstream>
int main() {
using std::filesystem::path;
std::ifstream input(path(BINARY_DIR) / path("..") / path("input"));
const auto graph = map2graph(input);
const auto chksum = checksum(graph);
std::cout << chksum << std::endl;
}
#else // DO_UNIT_TEST
#include <gtest/gtest.h>
#include <sstream>
TEST(DAY06_PART01, TEST01) {
const std::string map = R"(
COM)B
B)C
C)D
D)E
E)F
B)G
G)H
D)I
E)J
J)K
K)L)";
std::istringstream iss(map);
const auto graph = map2graph(iss);
const auto chksum = checksum(graph);
ASSERT_EQ(chksum, 42);
}
#endif // DO_UNIT_TEST
| 2,098
| 740
|
#pragma once
#include <httplib/detail/common.hpp>
#include <httplib/http/headers.hpp>
#include <httplib/http/version.hpp>
#include <string>
HTTPLIB_OPEN_NAMESPACE
struct http_response_t {
unsigned int code = 0;
std::string reason;
http_version_t version;
http_headers_t headers;
};
std::ostream &operator<<(std::ostream &stream, const http_response_t &response);
HTTPLIB_CLOSE_NAMESPACE
| 413
| 150
|
#pragma once
#include <tudocomp/config.h>
#ifndef SDSL_FOUND
#pragma message "SDSL required, but not available!"
#else
//std includes:
#include <vector>
#include <tuple>
//general includes:
#include <tudocomp/util.hpp>
#include <tudocomp/ds/IntVector.hpp>
#include <tudocomp/Compressor.hpp>
#include <tudocomp/Error.hpp>
#include <tudocomp/Tags.hpp>
#include <tudocomp_stat/StatPhase.hpp>
//sdsl include stree:
#include <sdsl/suffix_trees.hpp>
//includes encoding:
#include <tudocomp/io/BitOStream.hpp>
#include <tudocomp/coders/EliasGammaCoder.hpp>
#include <tudocomp/coders/HuffmanCoder.hpp>
//decompressor:
#include <tudocomp/decompressors/LFS2Decompressor.hpp>
namespace tdc {
namespace lfs {
template<
typename literal_coder_t = HuffmanCoder,
typename len_coder_t = EliasGammaCoder
>
class LFS2Compressor : public Compressor {
private:
//Suffix Tree type + st
typedef sdsl::cst_sct3< sdsl::csa_bitcompressed<> > cst_t;
cst_t stree;
using node_type = typename cst_t::node_type;
//Stores nts_symbols of first layer
IntVector<uint> first_layer_nts;
// offset to begin of last nts +1. if ==0 no substitution
IntVector<uint> fl_offsets;
// stores subs in first layer symbols
IntVector<uint> second_layer_nts;
// dead pos in first layer
BitVector second_layer_dead;
//pair contains begin pos, length
std::vector<std::pair<uint, uint> > non_terminal_symbols;
//stores node_ids of corresponding factor length
std::vector<std::vector<uint> > bins;
//stores beginning positions corresponding to node_ids
std::vector<std::vector<uint> > node_begins;
bool exact;
uint size;
public:
inline static Meta meta() {
Meta m(Compressor::type_desc(), "lfs2", "lfs2 with simst");
m.param("min_lrf").primitive(5);
m.param("exact").primitive(0);
m.param("lfs2_lit_coder").strategy<literal_coder_t>(
Coder::type_desc(), Meta::Default<HuffmanCoder>());
m.param("lfs2_len_coder").strategy<len_coder_t>(
Coder::type_desc(), Meta::Default<EliasGammaCoder>());
m.add_tag(tags::require_sentinel);
return m;
}
using Compressor::Compressor;
inline virtual void compress(Input& input, Output& output) override {
uint min_lrf = config().param("min_lrf").as_uint();
exact = config().param("exact").as_bool();
auto in = input.as_view();
MissingSentinelError::check(in);
//create vectors:
first_layer_nts = IntVector<uint>(input.size(), 0);
fl_offsets = IntVector<uint>(input.size(), 0);
second_layer_nts = IntVector<uint>(input.size(), 0);
second_layer_dead = BitVector(input.size(), 0);
if(in.size() >= min_lrf){
StatPhase::wrap("Constructing ST", [&]{
size = in.size();
//remove sentinel because sdsl cant handle that
while(in[size-1] == 0){
size--;
}
std::string in_string ((const char*) in.data(), size);
sdsl::construct_im(stree, in_string , 1);
});
StatPhase::wrap("Computing LRF", [&]{
bins.resize(200);
uint node_counter = 0;
typedef sdsl::cst_bfs_iterator<cst_t> iterator;
iterator begin = iterator(&stree, stree.root());
iterator end = iterator(&stree, stree.root(), true, true);
StatPhase::wrap("Iterate over ST", [&]{
DLOG(INFO)<<"iterate st";
for (iterator it = begin; it != end; ++it) {
if(!stree.is_leaf(*it)){
if(bins.size() <= stree.depth(*it)) {
uint resize = bins.size()*2;
while (resize<= stree.depth(*it)) {
resize*=2;
}
bins.resize(resize);
}
bins[stree.depth(*it)].push_back(stree.id(*it));
node_counter++;
}
}
});
node_begins.resize(node_counter);
uint nts_number = 1 ;
StatPhase::wrap("Iterate over Node Bins", [&]{
//iterate node bins top down
DLOG(INFO)<<"iterate over Node Bins";
for(uint i = bins.size()-1; i>=min_lrf; i--){
//iterate over ids in bin:
while(!bins[i].empty()){
uint id = bins[i].back();
bins[i].pop_back();
node_type node = stree.inv_id(id);
uint no_leaf_id = id - stree.size();
//get bps of node
if(node_begins[no_leaf_id].empty()){
//get leaves or merge child vectors
std::vector<uint> offsets;
std::vector<uint> leaf_bps;
for (auto & child : stree.children(node)) {
if(stree.is_leaf(child)){
leaf_bps.push_back(stree.csa[stree.lb(child)]);
} else {
int child_id = stree.id(child) - stree.size();
if(!node_begins[child_id ].empty()){
//append child list, remember offset
offsets.push_back(node_begins[no_leaf_id].size());
node_begins[no_leaf_id].insert(node_begins[no_leaf_id].end(),node_begins[child_id ].begin(), node_begins[child_id].end());
node_begins[child_id] = std::vector<uint>();
}
}
}
std::sort(leaf_bps.begin(), leaf_bps.end());
offsets.push_back(node_begins[no_leaf_id].size());
node_begins[no_leaf_id].insert(node_begins[no_leaf_id].end(),leaf_bps.begin(), leaf_bps.end());
//inplace merge with offset
for(uint k = 0; k < offsets.size()-1; k++){
std::inplace_merge(node_begins[no_leaf_id].begin(), node_begins[no_leaf_id].begin()+ offsets[k], node_begins[no_leaf_id].begin()+ offsets[k+1]);
}
//now inplace merge to end
std::inplace_merge(node_begins[no_leaf_id].begin(), node_begins[no_leaf_id].begin()+ offsets.back(), node_begins[no_leaf_id].end());
}
//if still empty, because everything is substituted...
if(node_begins[no_leaf_id].empty()){
continue;
}
//check if viable lrf, else sort higher!
if((node_begins[no_leaf_id].size()>=2)){
if (( (uint)( node_begins[no_leaf_id].back() - node_begins[no_leaf_id].front() )) >= i ){
//greedily iterate over occurences
signed long last = 0 - (long) i;
std::vector<uint> first_layer_viable;
std::vector<uint> second_layer_viable;
for(uint occurence : node_begins[no_leaf_id]){
//check for viability
if( (last+i <= (long) occurence)){
if(fl_offsets[occurence] == 0){
if(fl_offsets[occurence + i -1] == 0){
//Position is firs layer viable
first_layer_viable.push_back(occurence);
last= occurence;
}
} else {
//find nts number of symbol that corresponds to substitued occ
uint parent_nts= first_layer_nts[ occurence - (fl_offsets[occurence] -1) ];
auto nts = non_terminal_symbols[parent_nts-1];
//if length of parent nts is greater than current len + offset
if(nts.second >=fl_offsets[occurence]-1 + i ){
second_layer_viable.push_back(occurence);
}
}
}
}
//and substitute
//if at least 2 first level layer occs viable:
if(first_layer_viable.size() >=1 &&(first_layer_viable.size() + second_layer_viable.size() >= 2) ) {
std::pair<uint,uint> nts = std::make_pair(first_layer_viable.front(), i);
non_terminal_symbols.push_back(nts);
//iterate over vector, make first layer unviable:
for(uint occ : first_layer_viable){
first_layer_nts[occ]= nts_number;
for(uint nts_length =0; nts_length < i; nts_length++){
fl_offsets[occ + nts_length] = nts_length+1;
}
}
for(uint sl_occ :second_layer_viable){
uint parent_nts= first_layer_nts[ sl_occ - (fl_offsets[sl_occ] -1) ];
auto parent_sym = non_terminal_symbols[parent_nts-1];
uint parent_start= parent_sym.first;
uint sl_start = (parent_start + fl_offsets[sl_occ] -1);
uint sl_end = sl_start+i-1;
if(second_layer_dead[sl_start] == (uint)0 && second_layer_dead[sl_end] == (uint)0){
second_layer_nts[sl_start]=nts_number;
for(uint dead = sl_start; dead<=sl_end;dead++){
second_layer_dead[dead]=1;
}
}
}
//raise nts number:
nts_number++;
}
} else {
if(exact){
//readd node if lrf shorter
uint min_shorter = node_begins[no_leaf_id].back() - node_begins[no_leaf_id].front();
//check if parent subs this lrf
node_type parent = stree.parent(node);
uint depth = stree.depth(parent);
if(depth < (min_shorter)){
//just re-add node, if the possible replaceable lrf is longer than dpeth of parent node
bins[min_shorter].push_back(stree.id(node));
}
}
continue;
}
}
}
}
});
});
DLOG(INFO)<<"Computing symbol depth";
IntVector<uint> nts_depth(non_terminal_symbols.size(), 0);
for(uint nts_num =0; nts_num<non_terminal_symbols.size(); nts_num++){
auto symbol = non_terminal_symbols[nts_num];
uint cur_depth = nts_depth[nts_num];
for(uint pos = symbol.first; pos < symbol.second + symbol.first ; pos++){
if(second_layer_nts[pos]>0){
uint symbol_num = second_layer_nts[pos] -1;
if(nts_depth[symbol_num]< cur_depth+1){
nts_depth[symbol_num]= cur_depth+1;
}
}
}
}
DLOG(INFO)<<"Computing done";
std::sort(nts_depth.begin(), nts_depth.end());
if(nts_depth.size()>0){
uint max_depth = nts_depth[nts_depth.size()-1];
DLOG(INFO)<<"Max CFG Depth: "<< max_depth;
DLOG(INFO)<<"Number of CFG rules: "<< non_terminal_symbols.size();
if(nts_depth.size()>=4){
uint quarter = nts_depth.size() /4;
StatPhase::log("25 \% quantil CFG Depth", nts_depth[quarter -1]);
StatPhase::log("50 \% quantil CFG Depth", nts_depth[(2*quarter) -1]);
StatPhase::log("75 \% quantil CFG Depth", nts_depth[(3*quarter) -1]);
}
StatPhase::log("Max CFG Depth", max_depth);
}
//input size end
}
StatPhase::log("Number of CFG rules", non_terminal_symbols.size());
std::stringstream literals;
for(uint position = 0; position< in.size(); position++){
if(fl_offsets[position]==0){
literals << in[position];
}
}
for(uint nts_num = 0; nts_num<non_terminal_symbols.size(); nts_num++){
auto symbol = non_terminal_symbols[nts_num];
for(uint pos = symbol.first; pos < symbol.second + symbol.first; pos++){
if(second_layer_nts[pos] == 0 && pos < in.size()){
literals<< in[pos];
}
}
}
StatPhase::wrap("Encoding Comp", [&]{
// encode dictionary:
DLOG(INFO) << "encoding dictionary symbol sizes ";
std::shared_ptr<BitOStream> bitout = std::make_shared<BitOStream>(output);
typename literal_coder_t::Encoder lit_coder(
config().sub_config("lfs2_lit_coder"),
bitout,
ViewLiterals(literals.str())
);
typename len_coder_t::Encoder len_coder(
config().sub_config("lfs2_len_coder"),
bitout,
NoLiterals()
);
//encode lengths:
DLOG(INFO)<<"number nts: " << non_terminal_symbols.size();
Range intrange (0, UINT_MAX);
//encode first length:
if(non_terminal_symbols.size()>=1){
auto symbol = non_terminal_symbols[0];
uint last_length=symbol.second;
//Range for encoding nts number
Range s_length_r (0,last_length);
len_coder.encode(last_length,intrange);
//encode delta length of following symbols
for(uint nts_num = 1; nts_num < non_terminal_symbols.size(); nts_num++){
symbol = non_terminal_symbols[nts_num];
len_coder.encode(last_length-symbol.second,s_length_r);
last_length=symbol.second;
}
//encode last length, to have zero length last
len_coder.encode(symbol.second,s_length_r);
}else {
len_coder.encode(0ULL,intrange);
}
Range dict_r(0, non_terminal_symbols.size());
long buf_size = bitout->stream().tellp();
StatPhase::log("Bytes Length Encoding", buf_size);
DLOG(INFO)<<"Bytes Length Encoding: "<< buf_size;
DLOG(INFO) << "encoding dictionary symbols";
uint dict_literals=0;
// encode dictionary strings, backwards, to directly decode strings:
if(non_terminal_symbols.size()>=1){
std::pair<uint,uint> symbol;
for(long nts_num =non_terminal_symbols.size()-1; nts_num >= 0; nts_num--){
symbol = non_terminal_symbols[nts_num];
for(uint pos = symbol.first; pos < symbol.second + symbol.first ; pos++){
if(second_layer_nts[pos] > 0){
lit_coder.encode(1, bit_r);
lit_coder.encode(second_layer_nts[pos], dict_r);
auto symbol = non_terminal_symbols[second_layer_nts[pos] -1];
pos += symbol.second - 1;
} else {
lit_coder.encode(0, bit_r);
lit_coder.encode(in[pos],literal_r);
dict_literals++;
}
}
}
}
uint literals=0;
buf_size = long(bitout->stream().tellp()) - buf_size;
StatPhase::log("Bytes Non-Terminal Symbol Encoding", buf_size);
DLOG(INFO)<<"Bytes Non-Terminal Symbol Encoding: "<< buf_size;
//encode start symbol
DLOG(INFO)<<"encode start symbol";
for(uint pos = 0; pos < in.size(); pos++){
if(first_layer_nts[pos]>0){
lit_coder.encode(1, bit_r);
lit_coder.encode(first_layer_nts[pos], dict_r);
auto symbol = non_terminal_symbols[first_layer_nts[pos] -1];
pos += symbol.second - 1;
} else {
lit_coder.encode(0, bit_r);
lit_coder.encode(in[pos],literal_r);
literals++;
}
}
buf_size = long(bitout->stream().tellp()) - buf_size;
StatPhase::log("Bytes Start Symbol Encoding", buf_size);
DLOG(INFO)<<"Bytes Start Symbol Encoding: "<< buf_size;
StatPhase::log("Literals in Dictionary", dict_literals);
StatPhase::log("Literals in Start Symbol", literals);
StatPhase::log("Literals in Input", in.size());
double literal_percent = ((double)dict_literals + (double)literals)/ (double)in.size();
StatPhase::log("Literals Encoding / Literals Input", literal_percent);
DLOG(INFO)<<"encoding done";
});
}
inline std::unique_ptr<Decompressor> decompressor() const override {
return Algorithm::instance<
LFS2Decompressor<literal_coder_t, len_coder_t>>();
}
};
//namespaces closing
}}
#endif
| 19,005
| 5,384
|
/*ckwg +29
* Copyright 2019 by Kitware, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither name of Kitware, Inc. nor the names of any 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 AUTHORS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \file
* \brief Register images using ITK.
*/
#include "RegistrationProcess.h"
#include "RegisterOpticalAndThermal.h"
#include <itkOpenCVImageBridge.h>
#include <vital/vital_types.h>
#include <vital/types/timestamp.h>
#include <vital/types/timestamp_config.h>
#include <vital/types/image_container.h>
#include <vital/types/homography.h>
#include <arrows/ocv/image_container.h>
using namespace viame::core;
namespace viame
{
namespace itk
{
// =============================================================================
itk_eo_ir_registration_process
::itk_eo_ir_registration_process( kwiver::vital::config_block_sptr const& config )
: align_multimodal_imagery_process( config )
{
}
itk_eo_ir_registration_process
::~itk_eo_ir_registration_process()
{
}
void
itk_eo_ir_registration_process
::attempt_registration( const buffered_frame& optical,
const buffered_frame& thermal,
const bool optical_dom )
{
viame::itk::NetTransformType::Pointer output_transform;
auto itk_optical_image =
::itk::OpenCVImageBridge::CVMatToITKImage< viame::itk::OpticalImageType >(
kwiver::arrows::ocv::image_container::vital_to_ocv(
optical.image->get_image(),
kwiver::arrows::ocv::image_container::BGR_COLOR ) );
auto itk_thermal_image =
::itk::OpenCVImageBridge::CVMatToITKImage< viame::itk::ThermalImageType >(
kwiver::arrows::ocv::image_container::vital_to_ocv(
thermal.image->get_image(),
kwiver::arrows::ocv::image_container::BGR_COLOR ) );
if( PerformRegistration( *itk_optical_image, *itk_thermal_image, output_transform ) )
{
// Convert matrix to kwiver
kwiver::vital::homography_sptr optical_to_thermal(
new kwiver::vital::homography_< double >() );
kwiver::vital::matrix_3x3d& net_output =
dynamic_cast< kwiver::vital::homography_< double >* >(
optical_to_thermal.get() )->get_matrix();
net_output = kwiver::vital::matrix_3x3d::Identity();
for( unsigned n = 0; n < output_transform->GetNumberOfTransforms(); n++ )
{
viame::itk::AffineTransformType* itk_affine_transform =
dynamic_cast< viame::itk::AffineTransformType* >(
output_transform->GetNthTransform( n ).GetPointer() );
if( !itk_affine_transform )
{
throw std::runtime_error( "Unknown transformation type received" );
}
const auto& in_values = itk_affine_transform->GetMatrix();
kwiver::vital::matrix_3x3d next_homog;
for( unsigned r = 0; r < viame::itk::Dimension; ++r )
{
for( unsigned c = 0; c < viame::itk::Dimension; ++c )
{
next_homog( r, c ) = in_values( r, c );
}
}
if( viame::itk::Dimension == 2 )
{
next_homog( 2, 0 ) = 0;
next_homog( 2, 1 ) = 0;
next_homog( 2, 2 ) = 1;
next_homog( 1, 2 ) = itk_affine_transform->GetOffset()[ 1 ];
next_homog( 0, 2 ) = itk_affine_transform->GetOffset()[ 0 ];
}
net_output = net_output * next_homog;
}
// Output required elements depending on connections
push_to_port_using_trait( optical_image, optical.image );
push_to_port_using_trait( optical_file_name, optical.name );
push_to_port_using_trait( thermal_image, thermal.image );
push_to_port_using_trait( thermal_file_name, thermal.name );
push_to_port_using_trait( timestamp, ( optical_dom ? optical.ts : thermal.ts ) );
push_to_port_using_trait( success_flag, true );
push_to_port_using_trait( optical_to_thermal_homog, optical_to_thermal );
if( count_output_port_edges_using_trait( thermal_to_optical_homog ) > 0 )
{
push_to_port_using_trait( thermal_to_optical_homog,
optical_to_thermal->inverse() );
}
// Warp image if required
if( count_output_port_edges_using_trait( warped_thermal_image ) > 0 )
{
WarpedThermalImageType::Pointer warped_image;
if( WarpThermalToOpticalImage(
*itk_optical_image, *itk_thermal_image, *output_transform, warped_image ) )
{
push_to_port_using_trait( warped_thermal_image,
kwiver::vital::image_container_sptr(
new kwiver::arrows::ocv::image_container(
::itk::OpenCVImageBridge::ITKImageToCVMat<
viame::itk::WarpedThermalImageType >( warped_image ),
kwiver::arrows::ocv::image_container::BGR_COLOR ) ) );
}
else
{
push_to_port_using_trait( warped_thermal_image,
kwiver::vital::image_container_sptr() );
}
}
if( count_output_port_edges_using_trait( warped_optical_image ) > 0 )
{
WarpedOpticalImageType::Pointer warped_image;
if( WarpOpticalToThermalImage(
*itk_optical_image, *itk_thermal_image, *output_transform, warped_image ) )
{
push_to_port_using_trait( warped_optical_image,
kwiver::vital::image_container_sptr(
new kwiver::arrows::ocv::image_container(
::itk::OpenCVImageBridge::ITKImageToCVMat<
viame::itk::WarpedOpticalImageType >( warped_image ),
kwiver::arrows::ocv::image_container::BGR_COLOR ) ) );
}
else
{
push_to_port_using_trait( warped_optical_image,
kwiver::vital::image_container_sptr() );
}
}
}
else
{
if( optical_dom )
{
output_no_match( optical, 0 );
}
else
{
output_no_match( thermal, 1 );
}
}
}
} // end namespace itk
} // end namespace viame
| 7,098
| 2,522
|
#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace std;
using namespace cv;
Mat myMask;
Mat myFrame;
Mat origFrame;
int frameCols = 0, frameRows = 0;
Mat refine(Mat frame, Mat mask);
static void help()
{
cout << "\nThis program demonstrates GrabCut segmentation -- select an object in a region\n"
"and then grabcut will attempt to segment it out.\n"
"Call:\n"
"./grabcut <image_name>\n"
"\nSelect a rectangular area around the object you want to segment\n" <<
"\nHot keys: \n"
"\tESC - quit the program\n"
"\tr - restore the original image\n"
"\tn - next iteration\n"
"\n"
"\tleft mouse button - set rectangle\n"
"\n"
"\tCTRL+left mouse button - set GC_BGD pixels\n"
"\tSHIFT+left mouse button - set GC_FGD pixels\n"
"\n"
"\tCTRL+right mouse button - set GC_PR_BGD pixels\n"
"\tSHIFT+right mouse button - set GC_PR_FGD pixels\n" << endl;
}
const Scalar RED = Scalar(0,0,255);
const Scalar PINK = Scalar(230,130,255);
const Scalar BLUE = Scalar(255,0,0);
const Scalar LIGHTBLUE = Scalar(255,255,160);
const Scalar GREEN = Scalar(0,255,0);
const int BGD_KEY = EVENT_FLAG_CTRLKEY;
const int FGD_KEY = EVENT_FLAG_SHIFTKEY;
static void getBinMask( const Mat& comMask, Mat& binMask )
{
if( binMask.empty() || binMask.rows!=comMask.rows || binMask.cols!=comMask.cols )
binMask.create( comMask.size(), CV_8UC1 );
binMask = comMask & 1;
}
class GCApplication
{
public:
enum{ NOT_SET = 0, IN_PROCESS = 1, SET = 2 };
static const int radius = 2;
static const int thickness = -1;
void reset();
void setImageAndWinName( const Mat& _image, const string& _winName );
void showImage() const;
void mouseClick( int event, int x, int y, int flags, void* param );
int nextIter();
int getIterCount() const { return iterCount; }
private:
void setRectInMask();
void setLblsInMask( int flags, Point p, bool isPr );
const string* winName;
const Mat* image;
Mat mask;
Mat bgdModel, fgdModel;
uchar rectState, lblsState, prLblsState;
bool isInitialized;
Rect rect;
vector<Point> fgdPxls, bgdPxls, prFgdPxls, prBgdPxls;
int iterCount;
};
void GCApplication::reset()
{
if( !mask.empty() )
mask.setTo(Scalar::all(GC_BGD));
bgdPxls.clear(); fgdPxls.clear();
prBgdPxls.clear(); prFgdPxls.clear();
isInitialized = false;
rectState = NOT_SET;
lblsState = NOT_SET;
prLblsState = NOT_SET;
iterCount = 0;
}
void GCApplication::setImageAndWinName( const Mat& _image, const string& _winName )
{
if( _image.empty() || _winName.empty() )
return;
image = &_image;
winName = &_winName;
mask.create( image->size(), CV_8UC1);
reset();
}
void GCApplication::showImage() const
{
if( image->empty() || winName->empty() )
return;
Mat res;
Mat binMask;
if( !isInitialized )
image->copyTo( res );
else
{
getBinMask( mask, binMask );
image->copyTo( res, binMask );
}
vector<Point>::const_iterator it;
for( it = bgdPxls.begin(); it != bgdPxls.end(); ++it )
circle( res, *it, radius, BLUE, thickness );
for( it = fgdPxls.begin(); it != fgdPxls.end(); ++it )
circle( res, *it, radius, RED, thickness );
for( it = prBgdPxls.begin(); it != prBgdPxls.end(); ++it )
circle( res, *it, radius, LIGHTBLUE, thickness );
for( it = prFgdPxls.begin(); it != prFgdPxls.end(); ++it )
circle( res, *it, radius, PINK, thickness );
if( rectState == IN_PROCESS || rectState == SET )
rectangle( res, Point( rect.x, rect.y ), Point(rect.x + rect.width, rect.y + rect.height ), GREEN, 2);
imshow( *winName, res );
if(!binMask.empty())
{
myFrame = res.clone();
normalize(binMask, myMask, 0, 255, NORM_MINMAX, -1, Mat() );
}
}
void GCApplication::setRectInMask()
{
CV_Assert( !mask.empty() );
mask.setTo( GC_BGD );
rect.x = max(0, rect.x);
rect.y = max(0, rect.y);
rect.width = min(rect.width, image->cols-rect.x);
rect.height = min(rect.height, image->rows-rect.y);
(mask(rect)).setTo( Scalar(GC_PR_FGD) );
}
void GCApplication::setLblsInMask( int flags, Point p, bool isPr )
{
vector<Point> *bpxls, *fpxls;
uchar bvalue, fvalue;
if( !isPr )
{
bpxls = &bgdPxls;
fpxls = &fgdPxls;
bvalue = GC_BGD;
fvalue = GC_FGD;
}
else
{
bpxls = &prBgdPxls;
fpxls = &prFgdPxls;
bvalue = GC_PR_BGD;
fvalue = GC_PR_FGD;
}
if( flags & BGD_KEY )
{
bpxls->push_back(p);
circle( mask, p, radius, bvalue, thickness );
}
if( flags & FGD_KEY )
{
fpxls->push_back(p);
circle( mask, p, radius, fvalue, thickness );
}
}
void GCApplication::mouseClick( int event, int x, int y, int flags, void* )
{
if( rectState == NOT_SET )
{
rect = Rect( Point(0, 0), Point(frameCols,frameRows) );
rectState = SET;
setRectInMask();
CV_Assert( bgdPxls.empty() && fgdPxls.empty() && prBgdPxls.empty() && prFgdPxls.empty() );
//showImage();
}
// TODO add bad args check
switch( event )
{
case EVENT_LBUTTONDOWN: // set rect or GC_BGD(GC_FGD) labels
{
bool isb = (flags & BGD_KEY) != 0,
isf = (flags & FGD_KEY) != 0;
if( rectState == NOT_SET && !isb && !isf )
{
rectState = IN_PROCESS;
rect = Rect( x, y, 1, 1 );
}
if ( (isb || isf) && rectState == SET )
lblsState = IN_PROCESS;
}
break;
case EVENT_RBUTTONDOWN: // set GC_PR_BGD(GC_PR_FGD) labels
{
bool isb = (flags & BGD_KEY) != 0,
isf = (flags & FGD_KEY) != 0;
if ( (isb || isf) && rectState == SET )
prLblsState = IN_PROCESS;
}
break;
case EVENT_LBUTTONUP:
if( rectState == IN_PROCESS )
{
rect = Rect( Point(rect.x, rect.y), Point(x,y) );
rectState = SET;
setRectInMask();
CV_Assert( bgdPxls.empty() && fgdPxls.empty() && prBgdPxls.empty() && prFgdPxls.empty() );
showImage();
}
if( lblsState == IN_PROCESS )
{
setLblsInMask(flags, Point(x,y), false);
lblsState = SET;
showImage();
}
break;
case EVENT_RBUTTONUP:
if( prLblsState == IN_PROCESS )
{
setLblsInMask(flags, Point(x,y), true);
prLblsState = SET;
showImage();
}
break;
case EVENT_MOUSEMOVE:
if( rectState == IN_PROCESS )
{
rect = Rect( Point(rect.x, rect.y), Point(x,y) );
CV_Assert( bgdPxls.empty() && fgdPxls.empty() && prBgdPxls.empty() && prFgdPxls.empty() );
showImage();
}
else if( lblsState == IN_PROCESS )
{
setLblsInMask(flags, Point(x,y), false);
showImage();
}
else if( prLblsState == IN_PROCESS )
{
setLblsInMask(flags, Point(x,y), true);
showImage();
}
break;
}
}
int GCApplication::nextIter()
{
if( isInitialized )
grabCut( *image, mask, rect, bgdModel, fgdModel, 1 );
else
{
if( rectState != SET )
return iterCount;
if( lblsState == SET || prLblsState == SET )
grabCut( *image, mask, rect, bgdModel, fgdModel, 1, GC_INIT_WITH_MASK );
else
grabCut( *image, mask, rect, bgdModel, fgdModel, 1, GC_INIT_WITH_RECT );
isInitialized = true;
}
iterCount++;
bgdPxls.clear(); fgdPxls.clear();
prBgdPxls.clear(); prFgdPxls.clear();
return iterCount;
}
GCApplication gcapp;
static void on_mouse( int event, int x, int y, int flags, void* param )
{
gcapp.mouseClick( event, x, y, flags, param );
}
int main( int argc, char** argv )
{
string filename = argv[1];
if( filename.empty() )
{
cout << "\nDurn, empty filename" << endl;
return 1;
}
Mat image = imread( filename, 1 );
origFrame = image.clone();
if(image.cols>1200)
{
resize(image, image, Size(), 0.3, 0.3);
}
if( image.empty() )
{
cout << "\n Durn, couldn't read image filename " << filename << endl;
return 1;
}
help();
frameCols = image.cols;
frameRows = image.rows;
const string winName = "image";
namedWindow( winName, WINDOW_AUTOSIZE );
setMouseCallback( winName, on_mouse, 0 );
gcapp.setImageAndWinName( image, winName );
gcapp.showImage();
for(;;)
{
int c = waitKey(0);
switch( (char) c )
{
case '\x1b':
cout << "Exiting ..." << endl;
goto exit_main;
case 'r':
cout << endl;
gcapp.reset();
gcapp.showImage();
break;
case 'n':
int iterCount = gcapp.getIterCount();
// cout << "<" << iterCount << "... ";
int newIterCount = gcapp.nextIter();
if( newIterCount > iterCount )
{
gcapp.showImage();
// cout << iterCount << ">" << endl;
}
else
cout << "rect must be determined>" << endl;
break;
}
if(!myMask.empty())
{
myFrame = origFrame.clone();
resize(myMask,myMask, origFrame.size());
Mat temp = myFrame.clone();
Mat White = Mat(myFrame.rows, myFrame.cols, CV_8UC3, Scalar(255,255,255));
myMask.convertTo(myMask, CV_8UC1);
Mat smooth;
Mat dilated;
Mat blurBin;
Mat myFrame2 = myFrame.clone();
dilate(myMask, dilated, Mat());
for(int i=1; i<myFrame.cols/300; i++)
{
dilate(dilated, dilated, Mat());
}
blur(myFrame, smooth, Size(myFrame.cols/100, myFrame.cols/100));
smooth.copyTo(myFrame, dilated);
myFrame2.copyTo(myFrame, myMask);
//dilate(myMask, myMask, Mat());
blur(myMask, blurBin, Size(myFrame.cols/200, myFrame.cols/200));
blurBin=blurBin;
cvtColor(blurBin, blurBin, CV_GRAY2BGR);
// cout<<blurBin.size()<<" "<<blurBin.channels()<<endl;
Mat background = imread(argv[2]);
double scale = myFrame.rows*1.0/background.rows;
resize(background, background, Size(), scale, scale);
background = background(Rect(0,0,myFrame.cols, myFrame.rows));
// Background image
for(int i=0; i<origFrame.cols; i++)
{
for(int j=0; j<origFrame.rows; j++)
{
myFrame.at<Vec3b>(j,i)[0] = ((blurBin.at<Vec3b>(j,i)[0])/255.0)*myFrame.at<Vec3b>(j,i)[0]+((255-blurBin.at<Vec3b>(j,i)[0])/255.0)*background.at<Vec3b>(j,i)[0];
myFrame.at<Vec3b>(j,i)[1] = ((blurBin.at<Vec3b>(j,i)[1])/255.0)*myFrame.at<Vec3b>(j,i)[1]+((255-blurBin.at<Vec3b>(j,i)[0])/255.0)*background.at<Vec3b>(j,i)[1];
myFrame.at<Vec3b>(j,i)[2] = ((blurBin.at<Vec3b>(j,i)[2])/255.0)*myFrame.at<Vec3b>(j,i)[2]+((255-blurBin.at<Vec3b>(j,i)[0])/255.0)*background.at<Vec3b>(j,i)[2];
}
}
imshow("Result", myFrame);
imwrite("Result.jpg", myFrame);
}
}
exit_main:
destroyWindow( winName );
return 0;
}
| 11,486
| 4,442
|
/*
* This file is part of ALVAR, A Library for Virtual and Augmented Reality.
*
* Copyright 2007-2012 VTT Technical Research Centre of Finland
*
* Contact: VTT Augmented Reality Team <alvar.info@vtt.fi>
* <http://www.vtt.fi/multimedia/alvar.html>
*
* ALVAR is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ALVAR; if not, see
* <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>.
*/
#include "FernPoseEstimator.h"
namespace alvar {
FernPoseEstimator::FernPoseEstimator()
: mPose()
, mCamera()
, mCameraEC()
{
}
FernPoseEstimator::~FernPoseEstimator()
{
}
Pose FernPoseEstimator::pose() const
{
return mPose;
}
Camera FernPoseEstimator::camera() const
{
return mCamera;
}
bool FernPoseEstimator::setCalibration(const std::string &filename, int width, int height)
{
bool r1 = mCamera.SetCalib(filename.c_str(), width, height);
bool r2 = mCameraEC.SetCalib(filename.c_str(), width, height);
return r1 && r2;
}
void FernPoseEstimator::setResolution(int width, int height)
{
mCamera.SetRes(width, height);
mCameraEC.SetRes(width, height);
}
void FernPoseEstimator::calculateFromPointCorrespondences(FernPoseEstimator::ModelPointVector &mpts, FernPoseEstimator::ImagePointVector &ipts)
{
mCamera.CalcExteriorOrientation(mpts, ipts, &mPose); // TODO replace camera->cameraec
}
void FernPoseEstimator::updateFromTrackedPoints(FernPoseEstimator::ExternalContainerMap &container)
{
mCameraEC.UpdatePose(container, &mPose);
}
void FernPoseEstimator::extractPlaneCoordinates(FernPoseEstimator::ExternalContainerMap &container)
{
ExternalContainerMap::iterator iter = container.begin();
ExternalContainerMap::iterator iter_end = container.end();
for(; iter != iter_end; ++iter) {
alvar::ExternalContainer &f = iter->second;
mCameraEC.Get3dOnPlane(&mPose, f.p2d, f.p3d);
f.has_p3d = true;
}
}
} // namespace alvar
| 2,420
| 838
|
/*
* HaloDataOrganizer.hpp
*
* Created on: Jun 13, 2019
* Author: stu
*/
#ifndef INCLUDE_HALODATAORGANIZER_HPP_
#define INCLUDE_HALODATAORGANIZER_HPP_
#include <map>
#include <set>
#include <algorithm>
//#include "TLBM_definitions.h"
#include "HaloDataObject.hpp"
template <class T>
class HaloDataOrganizer
{
public:
HaloDataOrganizer();
//HaloDataOrganizer(int ngb);
~HaloDataOrganizer();
void add_neighbor(int ngbNum);
int get_num_neighbors();
int get_cut_size();
int get_num_halo_nodes();
HaloDataObject<T>& operator[](int k);
void print_halo();
std::set<int> get_halo_nodes() const;
void allocate_halo_arrays();
void fill_arrays(std::map<int,int> & globalToLocal);
static inline unsigned getIDx(int nSpd, int nIdx, int spd){
return nIdx*nSpd + spd;
// return spd*nnods + nIdx; // use this if it performs faster.
}
void extract_halo_data(const T* fOut, const int numSpd);
void insert_halo_data(T* fOut, const int numSpd);
private:
// map keys: neighboring partition rank.
// map values: a Halo Data Object that contains a data structure describing the data to be exchanged
std::map<int,HaloDataObject<T>> Halo;
};
template <class T>
HaloDataOrganizer<T>::HaloDataOrganizer()
{
}
template <class T>
HaloDataOrganizer<T>::~HaloDataOrganizer()
{
}
template <class T>
void HaloDataOrganizer<T>::extract_halo_data(const T* fOut, const int numSpd)
{
for(auto & ngbIT : Halo)
{
ngbIT.second.extract_halo_data(fOut,numSpd);
}
}
template <class T>
void HaloDataOrganizer<T>::insert_halo_data(T* fOut, const int numSpd)
{
for(auto & ngbIT: Halo)
{
ngbIT.second.insert_halo_data(fOut,numSpd);
}
}
template <class T>
void HaloDataOrganizer<T>::allocate_halo_arrays()
{
for(auto & haloIt : Halo)
{
haloIt.second.allocate_arrays();
}
}
template <class T>
void HaloDataOrganizer<T>::fill_arrays(std::map<int,int> & globalToLocal)
{
for(auto & haloIt : Halo)
{
haloIt.second.fill_nums_and_speeds(globalToLocal);
}
}
template <class T>
std::set<int> HaloDataOrganizer<T>::get_halo_nodes() const
{
std::set<int> haloSet;
std::set<int> tempSet;
for(const auto & haloIt : Halo)
{
tempSet = haloIt.second.get_halo_nodes();
for (const auto & tIt : tempSet)
{
haloSet.insert(tIt);
}
}
return haloSet;
}
template <class T>
void HaloDataOrganizer<T>::print_halo()
{
for(const auto &ngb_it : Halo)
{
printf("Neighbor Partition %d: \n",ngb_it.first);
ngb_it.second.print_halo();
}
}
template <class T>
int HaloDataOrganizer<T>::get_cut_size()
{
int numCuts = 0;
for (const auto & keyIter : Halo)
{
numCuts += keyIter.second.get_num_items();
}
return numCuts;
}
template <class T>
int HaloDataOrganizer<T>::get_num_halo_nodes()
{
int numHalo = 0;
for (const auto & keyIter : Halo)
{
numHalo += keyIter.second.get_num_nodes();
}
return numHalo;
}
template <class T>
HaloDataObject<T> & HaloDataOrganizer<T>::operator[](int k)
{
return Halo[k];
}
template <class T>
int HaloDataOrganizer<T>::get_num_neighbors()
{
return Halo.size();
}
template <class T>
void HaloDataOrganizer<T>::add_neighbor(int ngbNum)
{
Halo[ngbNum] = HaloDataObject<T>();
}
#endif /* INCLUDE_HALODATAORGANIZER_HPP_ */
| 3,192
| 1,379
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/clouddirectory/model/UpgradeAppliedSchemaRequest.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::CloudDirectory::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
UpgradeAppliedSchemaRequest::UpgradeAppliedSchemaRequest() :
m_publishedSchemaArnHasBeenSet(false),
m_directoryArnHasBeenSet(false),
m_dryRun(false),
m_dryRunHasBeenSet(false)
{
}
Aws::String UpgradeAppliedSchemaRequest::SerializePayload() const
{
JsonValue payload;
if(m_publishedSchemaArnHasBeenSet)
{
payload.WithString("PublishedSchemaArn", m_publishedSchemaArn);
}
if(m_directoryArnHasBeenSet)
{
payload.WithString("DirectoryArn", m_directoryArn);
}
if(m_dryRunHasBeenSet)
{
payload.WithBool("DryRun", m_dryRun);
}
return payload.View().WriteReadable();
}
| 983
| 366
|
#include "Interface/Core/ArchHelpers/Arm64Emitter.h"
#include <FEXCore/Utils/LogManager.h>
#include <FEXCore/Core/CoreState.h>
#include "aarch64/cpu-aarch64.h"
#include "cpu-features.h"
#include "aarch64/instructions-aarch64.h"
#include "utils-vixl.h"
#include <tuple>
namespace FEXCore::CPU {
#define STATE x28
// We want vixl to not allocate a default buffer. Jit and dispatcher will manually create one.
Arm64Emitter::Arm64Emitter(size_t size) : vixl::aarch64::Assembler(size, vixl::aarch64::PositionDependentCode) {
CPU.SetUp();
auto Features = vixl::CPUFeatures::InferFromOS();
SupportsAtomics = Features.Has(vixl::CPUFeatures::Feature::kAtomics);
// RCPC is bugged on Snapdragon 865
// Causes glibc cond16 test to immediately throw assert
// __pthread_mutex_cond_lock: Assertion `mutex->__data.__owner == 0'
SupportsRCPC = false; //Features.Has(vixl::CPUFeatures::Feature::kRCpc);
if (SupportsAtomics) {
// Hypervisor can hide this on the c630?
Features.Combine(vixl::CPUFeatures::Feature::kLORegions);
}
SetCPUFeatures(Features);
if (!SupportsAtomics) {
WARN_ONCE("Host CPU doesn't support atomics. Expect bad performance");
}
#ifdef _M_ARM_64
// We need to get the CPU's cache line size
// We expect sane targets that have correct cacheline sizes across clusters
uint64_t CTR;
__asm volatile ("mrs %[ctr], ctr_el0"
: [ctr] "=r"(CTR));
DCacheLineSize = 4 << ((CTR >> 16) & 0xF);
ICacheLineSize = 4 << (CTR & 0xF);
#endif
}
void Arm64Emitter::LoadConstant(vixl::aarch64::Register Reg, uint64_t Constant) {
bool Is64Bit = Reg.IsX();
int Segments = Is64Bit ? 4 : 2;
if (Is64Bit && ((~Constant)>> 16) == 0) {
movn(Reg, (~Constant) & 0xFFFF);
return;
}
movz(Reg, (Constant) & 0xFFFF, 0);
for (int i = 1; i < Segments; ++i) {
uint16_t Part = (Constant >> (i * 16)) & 0xFFFF;
if (Part) {
movk(Reg, Part, i * 16);
}
}
}
void Arm64Emitter::PushCalleeSavedRegisters() {
// We need to save pairs of registers
// We save r19-r30
MemOperand PairOffset(sp, -16, PreIndex);
const std::array<std::pair<vixl::aarch64::XRegister, vixl::aarch64::XRegister>, 6> CalleeSaved = {{
{x19, x20},
{x21, x22},
{x23, x24},
{x25, x26},
{x27, x28},
{x29, x30},
}};
for (auto &RegPair : CalleeSaved) {
stp(RegPair.first, RegPair.second, PairOffset);
}
// Additionally we need to store the lower 64bits of v8-v15
// Here's a fun thing, we can use two ST4 instructions to store everything
// We just need a single sub to sp before that
const std::array<
std::tuple<vixl::aarch64::VRegister,
vixl::aarch64::VRegister,
vixl::aarch64::VRegister,
vixl::aarch64::VRegister>, 2> FPRs = {{
{v8, v9, v10, v11},
{v12, v13, v14, v15},
}};
uint32_t VectorSaveSize = sizeof(uint64_t) * 8;
sub(sp, sp, VectorSaveSize);
// SP supporting move
// We just saved x19 so it is safe
add(x19, sp, 0);
MemOperand QuadOffset(x19, 32, PostIndex);
for (auto &RegQuad : FPRs) {
st4(std::get<0>(RegQuad).D(),
std::get<1>(RegQuad).D(),
std::get<2>(RegQuad).D(),
std::get<3>(RegQuad).D(),
0,
QuadOffset);
}
}
void Arm64Emitter::PopCalleeSavedRegisters() {
const std::array<
std::tuple<vixl::aarch64::VRegister,
vixl::aarch64::VRegister,
vixl::aarch64::VRegister,
vixl::aarch64::VRegister>, 2> FPRs = {{
{v12, v13, v14, v15},
{v8, v9, v10, v11},
}};
MemOperand QuadOffset(sp, 32, PostIndex);
for (auto &RegQuad : FPRs) {
ld4(std::get<0>(RegQuad).D(),
std::get<1>(RegQuad).D(),
std::get<2>(RegQuad).D(),
std::get<3>(RegQuad).D(),
0,
QuadOffset);
}
MemOperand PairOffset(sp, 16, PostIndex);
const std::array<std::pair<vixl::aarch64::XRegister, vixl::aarch64::XRegister>, 6> CalleeSaved = {{
{x29, x30},
{x27, x28},
{x25, x26},
{x23, x24},
{x21, x22},
{x19, x20},
}};
for (auto &RegPair : CalleeSaved) {
ldp(RegPair.first, RegPair.second, PairOffset);
}
}
void Arm64Emitter::SpillStaticRegs() {
if (StaticRegisterAllocation()) {
for (size_t i = 0; i < SRA64.size(); i+=2) {
stp(SRA64[i], SRA64[i+1], MemOperand(STATE, offsetof(FEXCore::Core::CpuStateFrame, State.gregs[i])));
}
for (size_t i = 0; i < SRAFPR.size(); i+=2) {
stp(SRAFPR[i].Q(), SRAFPR[i+1].Q(), MemOperand(STATE, offsetof(FEXCore::Core::CpuStateFrame, State.xmm[i][0])));
}
}
}
void Arm64Emitter::FillStaticRegs() {
if (StaticRegisterAllocation()) {
for (size_t i = 0; i < SRA64.size(); i+=2) {
ldp(SRA64[i], SRA64[i+1], MemOperand(STATE, offsetof(FEXCore::Core::CpuStateFrame, State.gregs[i])));
}
for (size_t i = 0; i < SRAFPR.size(); i+=2) {
ldp(SRAFPR[i].Q(), SRAFPR[i+1].Q(), MemOperand(STATE, offsetof(FEXCore::Core::CpuStateFrame, State.xmm[i][0])));
}
}
}
void Arm64Emitter::PushDynamicRegsAndLR() {
uint64_t SPOffset = AlignUp((RA64.size() + 1) * 8 + RAFPR.size() * 16, 16);
sub(sp, sp, SPOffset);
int i = 0;
for (auto RA : RAFPR)
{
str(RA.Q(), MemOperand(sp, i * 8));
i+=2;
}
#if 0 // All GPRs should be caller saved
for (auto RA : RA64)
{
str(RA, MemOperand(sp, i * 8));
i++;
}
#endif
str(lr, MemOperand(sp, i * 8));
}
void Arm64Emitter::PopDynamicRegsAndLR() {
uint64_t SPOffset = AlignUp((RA64.size() + 1) * 8 + RAFPR.size() * 16, 16);
int i = 0;
for (auto RA : RAFPR)
{
ldr(RA.Q(), MemOperand(sp, i * 8));
i+=2;
}
#if 0 // All GPRs should be caller saved
for (auto RA : RA64)
{
ldr(RA, MemOperand(sp, i * 8));
i++;
}
#endif
ldr(lr, MemOperand(sp, i * 8));
add(sp, sp, SPOffset);
}
void Arm64Emitter::ResetStack() {
if (SpillSlots == 0)
return;
if (IsImmAddSub(SpillSlots * 16)) {
add(sp, sp, SpillSlots * 16);
} else {
// Too big to fit in a 12bit immediate
LoadConstant(x0, SpillSlots * 16);
add(sp, sp, x0);
}
}
void Arm64Emitter::Align16B() {
uint64_t CurrentOffset = GetCursorAddress<uint64_t>();
for (uint64_t i = (16 - (CurrentOffset & 0xF)); i != 0; i -= 4) {
nop();
}
}
}
| 6,227
| 2,791
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "modules/fetch/BodyStreamBuffer.h"
#include "core/testing/DummyPageHolder.h"
#include "modules/fetch/DataConsumerHandleTestUtil.h"
#include "platform/testing/UnitTestHelpers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "wtf/OwnPtr.h"
namespace blink {
namespace {
using ::testing::InSequence;
using ::testing::_;
using ::testing::SaveArg;
using Checkpoint = ::testing::StrictMock<::testing::MockFunction<void(int)>>;
using Command = DataConsumerHandleTestUtil::Command;
using ReplayingHandle = DataConsumerHandleTestUtil::ReplayingHandle;
using MockFetchDataLoaderClient = DataConsumerHandleTestUtil::MockFetchDataLoaderClient;
class BodyStreamBufferTest : public ::testing::Test {
public:
BodyStreamBufferTest()
{
m_page = DummyPageHolder::create(IntSize(1, 1));
}
~BodyStreamBufferTest() override {}
protected:
ScriptState* scriptState() { return ScriptState::forMainWorld(m_page->document().frame()); }
ExecutionContext* executionContext() { return &m_page->document(); }
OwnPtr<DummyPageHolder> m_page;
};
TEST_F(BodyStreamBufferTest, ReleaseHandle)
{
OwnPtr<FetchDataConsumerHandle> handle = createFetchDataConsumerHandleFromWebHandle(createWaitingDataConsumerHandle());
FetchDataConsumerHandle* rawHandle = handle.get();
BodyStreamBuffer* buffer = new BodyStreamBuffer(handle.release());
EXPECT_FALSE(buffer->hasPendingActivity());
EXPECT_FALSE(buffer->stream()->isLocked());
EXPECT_FALSE(buffer->stream()->isDisturbed());
EXPECT_EQ(ReadableStream::Readable, buffer->stream()->stateInternal());
OwnPtr<FetchDataConsumerHandle> handle2 = buffer->releaseHandle(executionContext());
ASSERT_EQ(rawHandle, handle2.get());
EXPECT_TRUE(buffer->stream()->isLocked());
EXPECT_TRUE(buffer->stream()->isDisturbed());
EXPECT_EQ(ReadableStream::Closed, buffer->stream()->stateInternal());
}
TEST_F(BodyStreamBufferTest, LoadBodyStreamBufferAsArrayBuffer)
{
Checkpoint checkpoint;
MockFetchDataLoaderClient* client = MockFetchDataLoaderClient::create();
RefPtr<DOMArrayBuffer> arrayBuffer;
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
EXPECT_CALL(*client, didFetchDataLoadedArrayBufferMock(_)).WillOnce(SaveArg<0>(&arrayBuffer));
EXPECT_CALL(checkpoint, Call(2));
OwnPtr<ReplayingHandle> handle = ReplayingHandle::create();
handle->add(Command(Command::Data, "hello"));
handle->add(Command(Command::Done));
BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandleFromWebHandle(handle.release()));
buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsArrayBuffer(), client);
EXPECT_TRUE(buffer->stream()->isLocked());
EXPECT_TRUE(buffer->stream()->isDisturbed());
EXPECT_TRUE(buffer->hasPendingActivity());
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
EXPECT_TRUE(buffer->stream()->isLocked());
EXPECT_TRUE(buffer->stream()->isDisturbed());
EXPECT_FALSE(buffer->hasPendingActivity());
ASSERT_TRUE(arrayBuffer);
EXPECT_EQ("hello", String(static_cast<const char*>(arrayBuffer->data()), arrayBuffer->byteLength()));
}
TEST_F(BodyStreamBufferTest, LoadBodyStreamBufferAsBlob)
{
Checkpoint checkpoint;
MockFetchDataLoaderClient* client = MockFetchDataLoaderClient::create();
RefPtr<BlobDataHandle> blobDataHandle;
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
EXPECT_CALL(*client, didFetchDataLoadedBlobHandleMock(_)).WillOnce(SaveArg<0>(&blobDataHandle));
EXPECT_CALL(checkpoint, Call(2));
OwnPtr<ReplayingHandle> handle = ReplayingHandle::create();
handle->add(Command(Command::Data, "hello"));
handle->add(Command(Command::Done));
BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandleFromWebHandle(handle.release()));
buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsBlobHandle("text/plain"), client);
EXPECT_TRUE(buffer->stream()->isLocked());
EXPECT_TRUE(buffer->stream()->isDisturbed());
EXPECT_TRUE(buffer->hasPendingActivity());
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
EXPECT_TRUE(buffer->stream()->isLocked());
EXPECT_TRUE(buffer->stream()->isDisturbed());
EXPECT_FALSE(buffer->hasPendingActivity());
EXPECT_EQ(5u, blobDataHandle->size());
}
TEST_F(BodyStreamBufferTest, LoadBodyStreamBufferAsString)
{
Checkpoint checkpoint;
MockFetchDataLoaderClient* client = MockFetchDataLoaderClient::create();
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
EXPECT_CALL(*client, didFetchDataLoadedString(String("hello")));
EXPECT_CALL(checkpoint, Call(2));
OwnPtr<ReplayingHandle> handle = ReplayingHandle::create();
handle->add(Command(Command::Data, "hello"));
handle->add(Command(Command::Done));
BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandleFromWebHandle(handle.release()));
buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsString(), client);
EXPECT_TRUE(buffer->stream()->isLocked());
EXPECT_TRUE(buffer->stream()->isDisturbed());
EXPECT_TRUE(buffer->hasPendingActivity());
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
EXPECT_TRUE(buffer->stream()->isLocked());
EXPECT_TRUE(buffer->stream()->isDisturbed());
EXPECT_FALSE(buffer->hasPendingActivity());
}
TEST_F(BodyStreamBufferTest, ReleaseClosedHandle)
{
BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandleFromWebHandle(createDoneDataConsumerHandle()));
EXPECT_EQ(ReadableStream::Readable, buffer->stream()->stateInternal());
testing::runPendingTasks();
EXPECT_EQ(ReadableStream::Closed, buffer->stream()->stateInternal());
EXPECT_FALSE(buffer->stream()->isLocked());
EXPECT_FALSE(buffer->stream()->isDisturbed());
EXPECT_FALSE(buffer->hasPendingActivity());
OwnPtr<FetchDataConsumerHandle> handle = buffer->releaseHandle(executionContext());
EXPECT_TRUE(handle);
EXPECT_TRUE(buffer->stream()->isLocked());
EXPECT_TRUE(buffer->stream()->isDisturbed());
EXPECT_FALSE(buffer->hasPendingActivity());
}
TEST_F(BodyStreamBufferTest, LoadClosedHandle)
{
Checkpoint checkpoint;
MockFetchDataLoaderClient* client = MockFetchDataLoaderClient::create();
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
EXPECT_CALL(*client, didFetchDataLoadedString(String("")));
EXPECT_CALL(checkpoint, Call(2));
BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandleFromWebHandle(createDoneDataConsumerHandle()));
EXPECT_EQ(ReadableStream::Readable, buffer->stream()->stateInternal());
testing::runPendingTasks();
EXPECT_EQ(ReadableStream::Closed, buffer->stream()->stateInternal());
EXPECT_FALSE(buffer->stream()->isLocked());
EXPECT_FALSE(buffer->stream()->isDisturbed());
EXPECT_FALSE(buffer->hasPendingActivity());
buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsString(), client);
EXPECT_TRUE(buffer->stream()->isLocked());
EXPECT_TRUE(buffer->stream()->isDisturbed());
EXPECT_TRUE(buffer->hasPendingActivity());
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
EXPECT_TRUE(buffer->stream()->isLocked());
EXPECT_TRUE(buffer->stream()->isDisturbed());
EXPECT_FALSE(buffer->hasPendingActivity());
}
TEST_F(BodyStreamBufferTest, ReleaseErroredHandle)
{
BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandleFromWebHandle(createUnexpectedErrorDataConsumerHandle()));
EXPECT_EQ(ReadableStream::Readable, buffer->stream()->stateInternal());
testing::runPendingTasks();
EXPECT_EQ(ReadableStream::Errored, buffer->stream()->stateInternal());
EXPECT_FALSE(buffer->stream()->isLocked());
EXPECT_FALSE(buffer->stream()->isDisturbed());
EXPECT_FALSE(buffer->hasPendingActivity());
OwnPtr<FetchDataConsumerHandle> handle = buffer->releaseHandle(executionContext());
EXPECT_TRUE(handle);
EXPECT_TRUE(buffer->stream()->isLocked());
EXPECT_TRUE(buffer->stream()->isDisturbed());
EXPECT_FALSE(buffer->hasPendingActivity());
}
TEST_F(BodyStreamBufferTest, LoadErroredHandle)
{
Checkpoint checkpoint;
MockFetchDataLoaderClient* client = MockFetchDataLoaderClient::create();
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
EXPECT_CALL(*client, didFetchDataLoadFailed());
EXPECT_CALL(checkpoint, Call(2));
BodyStreamBuffer* buffer = new BodyStreamBuffer(createFetchDataConsumerHandleFromWebHandle(createUnexpectedErrorDataConsumerHandle()));
EXPECT_EQ(ReadableStream::Readable, buffer->stream()->stateInternal());
testing::runPendingTasks();
EXPECT_EQ(ReadableStream::Errored, buffer->stream()->stateInternal());
EXPECT_FALSE(buffer->stream()->isLocked());
EXPECT_FALSE(buffer->stream()->isDisturbed());
EXPECT_FALSE(buffer->hasPendingActivity());
buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsString(), client);
EXPECT_TRUE(buffer->stream()->isLocked());
EXPECT_TRUE(buffer->stream()->isDisturbed());
EXPECT_TRUE(buffer->hasPendingActivity());
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
EXPECT_TRUE(buffer->stream()->isLocked());
EXPECT_TRUE(buffer->stream()->isDisturbed());
EXPECT_FALSE(buffer->hasPendingActivity());
}
TEST_F(BodyStreamBufferTest, LoaderShouldBeKeptAliveByBodyStreamBuffer)
{
Checkpoint checkpoint;
MockFetchDataLoaderClient* client = MockFetchDataLoaderClient::create();
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
EXPECT_CALL(*client, didFetchDataLoadedString(String("hello")));
EXPECT_CALL(checkpoint, Call(2));
OwnPtr<ReplayingHandle> handle = ReplayingHandle::create();
handle->add(Command(Command::Data, "hello"));
handle->add(Command(Command::Done));
Persistent<BodyStreamBuffer> buffer = new BodyStreamBuffer(createFetchDataConsumerHandleFromWebHandle(handle.release()));
buffer->startLoading(executionContext(), FetchDataLoader::createLoaderAsString(), client);
Heap::collectAllGarbage();
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
}
// TODO(hiroshige): Merge this class into MockFetchDataConsumerHandle.
class MockFetchDataConsumerHandleWithMockDestructor : public DataConsumerHandleTestUtil::MockFetchDataConsumerHandle {
public:
static PassOwnPtr<::testing::StrictMock<MockFetchDataConsumerHandleWithMockDestructor>> create() { return adoptPtr(new ::testing::StrictMock<MockFetchDataConsumerHandleWithMockDestructor>); }
~MockFetchDataConsumerHandleWithMockDestructor() override
{
destruct();
}
MOCK_METHOD0(destruct, void());
};
TEST_F(BodyStreamBufferTest, SourceHandleAndReaderShouldBeDestructedWhenCanceled)
{
ScriptState::Scope scope(scriptState());
using MockHandle = MockFetchDataConsumerHandleWithMockDestructor;
using MockReader = DataConsumerHandleTestUtil::MockFetchDataConsumerReader;
OwnPtr<MockHandle> handle = MockHandle::create();
OwnPtr<MockReader> reader = MockReader::create();
Checkpoint checkpoint;
InSequence s;
EXPECT_CALL(*handle, obtainReaderInternal(_)).WillOnce(::testing::Return(reader.get()));
EXPECT_CALL(checkpoint, Call(1));
EXPECT_CALL(*reader, destruct());
EXPECT_CALL(*handle, destruct());
EXPECT_CALL(checkpoint, Call(2));
// |reader| is adopted by |obtainReader|.
ASSERT_TRUE(reader.leakPtr());
BodyStreamBuffer* buffer = new BodyStreamBuffer(handle.release());
checkpoint.Call(1);
ScriptValue reason(scriptState(), v8String(scriptState()->isolate(), "reason"));
buffer->cancelSource(scriptState(), reason);
checkpoint.Call(2);
}
} // namespace
} // namespace blink
| 12,139
| 3,718
|
#if !defined(DONT_DEFINE_TYPES)
#endif
#include "F:/Programming/CppLibs/imgui/imgui/examples/imgui_impl_glfw.h"
| 115
| 56
|
/*
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/video/video_receive_stream.h"
#include <stdlib.h>
#include <string>
#include "webrtc/base/checks.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/video/receive_statistics_proxy.h"
#include "webrtc/video_encoder.h"
#include "webrtc/video_receive_stream.h"
namespace webrtc {
std::string VideoReceiveStream::Decoder::ToString() const {
std::stringstream ss;
ss << "{decoder: " << (decoder != nullptr ? "(VideoDecoder)" : "nullptr");
ss << ", payload_type: " << payload_type;
ss << ", payload_name: " << payload_name;
ss << ", is_renderer: " << (is_renderer ? "yes" : "no");
ss << ", expected_delay_ms: " << expected_delay_ms;
ss << '}';
return ss.str();
}
std::string VideoReceiveStream::Config::ToString() const {
std::stringstream ss;
ss << "{decoders: [";
for (size_t i = 0; i < decoders.size(); ++i) {
ss << decoders[i].ToString();
if (i != decoders.size() - 1)
ss << ", ";
}
ss << ']';
ss << ", rtp: " << rtp.ToString();
ss << ", renderer: " << (renderer != nullptr ? "(renderer)" : "nullptr");
ss << ", render_delay_ms: " << render_delay_ms;
if (!sync_group.empty())
ss << ", sync_group: " << sync_group;
ss << ", pre_decode_callback: "
<< (pre_decode_callback != nullptr ? "(EncodedFrameObserver)" : "nullptr");
ss << ", pre_render_callback: "
<< (pre_render_callback != nullptr ? "(I420FrameCallback)" : "nullptr");
ss << ", target_delay_ms: " << target_delay_ms;
ss << '}';
return ss.str();
}
std::string VideoReceiveStream::Config::Rtp::ToString() const {
std::stringstream ss;
ss << "{remote_ssrc: " << remote_ssrc;
ss << ", local_ssrc: " << local_ssrc;
ss << ", rtcp_mode: "
<< (rtcp_mode == RtcpMode::kCompound ? "RtcpMode::kCompound"
: "RtcpMode::kReducedSize");
ss << ", rtcp_xr: ";
ss << "{receiver_reference_time_report: "
<< (rtcp_xr.receiver_reference_time_report ? "on" : "off");
ss << '}';
ss << ", remb: " << (remb ? "on" : "off");
ss << ", nack: {rtp_history_ms: " << nack.rtp_history_ms << '}';
ss << ", fec: " << fec.ToString();
ss << ", rtx: {";
for (auto& kv : rtx) {
ss << kv.first << " -> ";
ss << "{ssrc: " << kv.second.ssrc;
ss << ", payload_type: " << kv.second.payload_type;
ss << '}';
}
ss << '}';
ss << ", extensions: [";
for (size_t i = 0; i < extensions.size(); ++i) {
ss << extensions[i].ToString();
if (i != extensions.size() - 1)
ss << ", ";
}
ss << ']';
ss << '}';
return ss.str();
}
namespace internal {
namespace {
VideoCodec CreateDecoderVideoCodec(const VideoReceiveStream::Decoder& decoder) {
VideoCodec codec;
memset(&codec, 0, sizeof(codec));
codec.plType = decoder.payload_type;
strcpy(codec.plName, decoder.payload_name.c_str());
if (decoder.payload_name == "VP8") {
codec.codecType = kVideoCodecVP8;
} else if (decoder.payload_name == "VP9") {
codec.codecType = kVideoCodecVP9;
} else if (decoder.payload_name == "H264") {
codec.codecType = kVideoCodecH264;
} else {
codec.codecType = kVideoCodecGeneric;
}
if (codec.codecType == kVideoCodecVP8) {
codec.codecSpecific.VP8 = VideoEncoder::GetDefaultVp8Settings();
} else if (codec.codecType == kVideoCodecVP9) {
codec.codecSpecific.VP9 = VideoEncoder::GetDefaultVp9Settings();
} else if (codec.codecType == kVideoCodecH264) {
codec.codecSpecific.H264 = VideoEncoder::GetDefaultH264Settings();
}
codec.width = 320;
codec.height = 180;
codec.startBitrate = codec.minBitrate = codec.maxBitrate =
Call::Config::kDefaultStartBitrateBps / 1000;
return codec;
}
} // namespace
VideoReceiveStream::VideoReceiveStream(int num_cpu_cores,
ChannelGroup* channel_group,
int channel_id,
const VideoReceiveStream::Config& config,
webrtc::VoiceEngine* voice_engine)
: transport_adapter_(config.rtcp_send_transport),
encoded_frame_proxy_(config.pre_decode_callback),
config_(config),
clock_(Clock::GetRealTimeClock()),
channel_group_(channel_group),
channel_id_(channel_id) {
RTC_CHECK(channel_group_->CreateReceiveChannel(
channel_id_, &transport_adapter_, num_cpu_cores, config));
vie_channel_ = channel_group_->GetChannel(channel_id_);
// TODO(pbos): This is not fine grained enough...
vie_channel_->SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false,
-1, -1);
vie_channel_->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp);
RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff)
<< "A stream should not be configured with RTCP disabled. This value is "
"reserved for internal usage.";
vie_channel_->SetRTCPMode(config_.rtp.rtcp_mode);
RTC_DCHECK(config_.rtp.remote_ssrc != 0);
// TODO(pbos): What's an appropriate local_ssrc for receive-only streams?
RTC_DCHECK(config_.rtp.local_ssrc != 0);
RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc);
vie_channel_->SetSSRC(config_.rtp.local_ssrc, kViEStreamTypeNormal, 0);
// TODO(pbos): Support multiple RTX, per video payload.
Config::Rtp::RtxMap::const_iterator it = config_.rtp.rtx.begin();
for (; it != config_.rtp.rtx.end(); ++it) {
RTC_DCHECK(it->second.ssrc != 0);
RTC_DCHECK(it->second.payload_type != 0);
vie_channel_->SetRemoteSSRCType(kViEStreamTypeRtx, it->second.ssrc);
vie_channel_->SetRtxReceivePayloadType(it->second.payload_type, it->first);
}
// TODO(pbos): Remove channel_group_ usage from VideoReceiveStream. This
// should be configured in call.cc.
channel_group_->SetChannelRembStatus(false, config_.rtp.remb, vie_channel_);
for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) {
const std::string& extension = config_.rtp.extensions[i].name;
int id = config_.rtp.extensions[i].id;
// One-byte-extension local identifiers are in the range 1-14 inclusive.
RTC_DCHECK_GE(id, 1);
RTC_DCHECK_LE(id, 14);
if (extension == RtpExtension::kTOffset) {
RTC_CHECK_EQ(0, vie_channel_->SetReceiveTimestampOffsetStatus(true, id));
} else if (extension == RtpExtension::kAbsSendTime) {
RTC_CHECK_EQ(0, vie_channel_->SetReceiveAbsoluteSendTimeStatus(true, id));
} else if (extension == RtpExtension::kVideoRotation) {
RTC_CHECK_EQ(0, vie_channel_->SetReceiveVideoRotationStatus(true, id));
} else if (extension == RtpExtension::kTransportSequenceNumber) {
RTC_CHECK_EQ(0,
vie_channel_->SetReceiveTransportSequenceNumber(true, id));
} else {
RTC_NOTREACHED() << "Unsupported RTP extension.";
}
}
if (config_.rtp.fec.ulpfec_payload_type != -1) {
// ULPFEC without RED doesn't make sense.
RTC_DCHECK(config_.rtp.fec.red_payload_type != -1);
VideoCodec codec;
memset(&codec, 0, sizeof(codec));
codec.codecType = kVideoCodecULPFEC;
strcpy(codec.plName, "ulpfec");
codec.plType = config_.rtp.fec.ulpfec_payload_type;
RTC_CHECK_EQ(0, vie_channel_->SetReceiveCodec(codec));
}
if (config_.rtp.fec.red_payload_type != -1) {
VideoCodec codec;
memset(&codec, 0, sizeof(codec));
codec.codecType = kVideoCodecRED;
strcpy(codec.plName, "red");
codec.plType = config_.rtp.fec.red_payload_type;
RTC_CHECK_EQ(0, vie_channel_->SetReceiveCodec(codec));
if (config_.rtp.fec.red_rtx_payload_type != -1) {
vie_channel_->SetRtxReceivePayloadType(
config_.rtp.fec.red_rtx_payload_type,
config_.rtp.fec.red_payload_type);
}
}
if (config.rtp.rtcp_xr.receiver_reference_time_report)
vie_channel_->SetRtcpXrRrtrStatus(true);
stats_proxy_.reset(
new ReceiveStatisticsProxy(config_.rtp.remote_ssrc, clock_));
vie_channel_->RegisterReceiveStatisticsProxy(stats_proxy_.get());
vie_channel_->RegisterReceiveChannelRtcpStatisticsCallback(
stats_proxy_.get());
vie_channel_->RegisterReceiveChannelRtpStatisticsCallback(stats_proxy_.get());
vie_channel_->RegisterRtcpPacketTypeCounterObserver(stats_proxy_.get());
RTC_DCHECK(!config_.decoders.empty());
for (size_t i = 0; i < config_.decoders.size(); ++i) {
const Decoder& decoder = config_.decoders[i];
RTC_CHECK_EQ(0,
vie_channel_->RegisterExternalDecoder(
decoder.payload_type, decoder.decoder, decoder.is_renderer,
decoder.is_renderer ? decoder.expected_delay_ms
: config.render_delay_ms));
VideoCodec codec = CreateDecoderVideoCodec(decoder);
RTC_CHECK_EQ(0, vie_channel_->SetReceiveCodec(codec));
}
incoming_video_stream_.reset(new IncomingVideoStream(0));
incoming_video_stream_->SetExpectedRenderDelay(config.render_delay_ms);
incoming_video_stream_->SetExternalCallback(this);
vie_channel_->SetIncomingVideoStream(incoming_video_stream_.get());
if (config.pre_decode_callback)
vie_channel_->RegisterPreDecodeImageCallback(&encoded_frame_proxy_);
vie_channel_->RegisterPreRenderCallback(this);
}
VideoReceiveStream::~VideoReceiveStream() {
incoming_video_stream_->Stop();
vie_channel_->RegisterPreRenderCallback(nullptr);
vie_channel_->RegisterPreDecodeImageCallback(nullptr);
for (size_t i = 0; i < config_.decoders.size(); ++i)
vie_channel_->DeRegisterExternalDecoder(config_.decoders[i].payload_type);
channel_group_->DeleteChannel(channel_id_);
}
void VideoReceiveStream::Start() {
transport_adapter_.Enable();
incoming_video_stream_->Start();
vie_channel_->StartReceive();
}
void VideoReceiveStream::Stop() {
incoming_video_stream_->Stop();
vie_channel_->StopReceive();
transport_adapter_.Disable();
}
void VideoReceiveStream::SetSyncChannel(VoiceEngine* voice_engine,
int audio_channel_id) {
if (voice_engine != nullptr && audio_channel_id != -1) {
VoEVideoSync* voe_sync_interface = VoEVideoSync::GetInterface(voice_engine);
vie_channel_->SetVoiceChannel(audio_channel_id, voe_sync_interface);
voe_sync_interface->Release();
} else {
vie_channel_->SetVoiceChannel(-1, nullptr);
}
}
VideoReceiveStream::Stats VideoReceiveStream::GetStats() const {
return stats_proxy_->GetStats();
}
bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) {
return vie_channel_->ReceivedRTCPPacket(packet, length) == 0;
}
bool VideoReceiveStream::DeliverRtp(const uint8_t* packet,
size_t length,
const PacketTime& packet_time) {
return vie_channel_->ReceivedRTPPacket(packet, length, packet_time) == 0;
}
void VideoReceiveStream::FrameCallback(VideoFrame* video_frame) {
stats_proxy_->OnDecodedFrame();
// Post processing is not supported if the frame is backed by a texture.
if (video_frame->native_handle() == NULL) {
if (config_.pre_render_callback)
config_.pre_render_callback->FrameCallback(video_frame);
}
}
int VideoReceiveStream::RenderFrame(const uint32_t /*stream_id*/,
const VideoFrame& video_frame) {
// TODO(pbos): Wire up config_.render->IsTextureSupported() and convert if not
// supported. Or provide methods for converting a texture frame in
// VideoFrame.
if (config_.renderer != nullptr)
config_.renderer->RenderFrame(
video_frame,
video_frame.render_time_ms() - clock_->TimeInMilliseconds());
stats_proxy_->OnRenderedFrame(video_frame.width(), video_frame.height());
return 0;
}
void VideoReceiveStream::SignalNetworkState(NetworkState state) {
vie_channel_->SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode
: RtcpMode::kOff);
}
} // namespace internal
} // namespace webrtc
| 12,432
| 4,346
|
/**
##########################################################################
# If not stated otherwise in this file or this component's LICENSE
# file the following copyright and licenses apply:
#
# Copyright 2019 RDK Management
#
# 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.
##########################################################################
**/
#ifdef HAS_LICENSE
#include "licensetestssuite.h"
#include "utils/misc/license.h"
#define LICENSE_FILE "./License.lic"
LicenseTestsSuite::LicenseTestsSuite()
: BaseTestsSuite() {
}
LicenseTestsSuite::~LicenseTestsSuite() {
}
void LicenseTestsSuite::Run() {
License::SetLicenseFile(LICENSE_FILE);
License *pLicense = License::GetLicenseInstance();
LICENSE_VALIDATION retval = pLicense->ValidateLicense();
printf("ValidateLicense: %s\n", (pLicense->InterpretValidationCode(retval)).c_str());
TS_ASSERT((retval == VALID) || (retval == FOR_LM_VERIFICATION));
string licContents;
TS_ASSERT(pLicense->StringifyLicense(licContents) > 0);
License::ResetLicense();
}
#endif /* HAS_LICENSE */
| 1,601
| 536
|
/*
* Copyright (c) 2020 Andreas Pohl
* Licensed under MIT (https://github.com/apohl79/audiogridder/blob/master/COPYING)
*
* Author: Andreas Pohl
*/
#include "PluginProcessor.hpp"
#include <signal.h>
#include "PluginEditor.hpp"
#include "json.hpp"
using json = nlohmann::json;
AudioGridderAudioProcessor::AudioGridderAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor(BusesProperties()
#if !JucePlugin_IsMidiEffect
#if !JucePlugin_IsSynth
.withInput("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
m_client(this) {
signal(SIGPIPE, SIG_IGN);
File cfg(PLUGIN_CONFIG_FILE);
try {
if (cfg.exists()) {
FileInputStream fis(cfg);
json j = json::parse(fis.readEntireStreamAsString().toStdString());
if (j.find("Servers") != j.end()) {
for (auto& srv : j["Servers"]) {
m_servers.push_back(srv.get<std::string>());
}
}
if (j.find("Last") != j.end()) {
m_activeServer = j["Last"].get<int>();
}
if (j.find("NumberOfBuffers") != j.end()) {
m_client.NUM_OF_BUFFERS = j["NumberOfBuffers"].get<int>();
}
if (j.find("NumberOfAutomationSlots") != j.end()) {
m_numberOfAutomationSlots = j["NumberOfAutomationSlots"].get<int>();
}
}
} catch (json::parse_error& e) {
logln_clnt(&m_client, "parsing config failed: " << e.what());
}
m_unusedParam.name = "(unassigned)";
m_unusedDummyPlugin.name = "(unused)";
m_unusedDummyPlugin.bypassed = false;
m_unusedDummyPlugin.ok = true;
m_unusedDummyPlugin.params.add(m_unusedParam);
for (int i = 0; i < m_numberOfAutomationSlots; i++) {
addParameter(new Parameter(*this, i));
}
// load plugins on reconnect
m_client.setOnConnectCallback([this] {
int idx = 0;
for (auto& p : m_loadedPlugins) {
p.ok = m_client.addPlugin(p.id, p.presets, p.params, p.settings);
logln_clnt(&m_client, "loading " << p.name << " (" << p.id << ")... " << (p.ok ? "ok" : "failed"));
if (p.ok) {
logln_clnt(&m_client, "updating latency samples to " << m_client.getLatencySamples());
setLatencySamples(m_client.getLatencySamples());
if (p.bypassed) {
m_client.bypassPlugin(idx);
}
for (auto& p : p.params) {
if (p.automationSlot > -1) {
if (p.automationSlot < m_numberOfAutomationSlots) {
enableParamAutomation(idx, p.idx, p.automationSlot);
} else {
p.automationSlot = -1;
}
}
}
}
idx++;
}
MessageManager::callAsync([this] {
auto* editor = getActiveEditor();
if (editor != nullptr) {
dynamic_cast<AudioGridderAudioProcessorEditor*>(editor)->setConnected(true);
}
});
});
// handle connection close
m_client.setOnCloseCallback([this] {
MessageManager::callAsync([this] {
auto* editor = getActiveEditor();
if (editor != nullptr) {
dynamic_cast<AudioGridderAudioProcessorEditor*>(editor)->setConnected(false);
}
});
});
if (m_activeServer > -1 && m_activeServer < m_servers.size()) {
m_client.setServer(m_servers[m_activeServer]);
}
}
AudioGridderAudioProcessor::~AudioGridderAudioProcessor() {
m_client.signalThreadShouldExit();
m_client.close();
}
const String AudioGridderAudioProcessor::getName() const { return JucePlugin_Name; }
bool AudioGridderAudioProcessor::acceptsMidi() const {
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool AudioGridderAudioProcessor::producesMidi() const {
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool AudioGridderAudioProcessor::isMidiEffect() const {
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double AudioGridderAudioProcessor::getTailLengthSeconds() const { return 0.0; }
bool AudioGridderAudioProcessor::supportsDoublePrecisionProcessing() const { return true; }
int AudioGridderAudioProcessor::getNumPrograms() { return 1; }
int AudioGridderAudioProcessor::getCurrentProgram() { return 0; }
void AudioGridderAudioProcessor::setCurrentProgram(int index) {}
const String AudioGridderAudioProcessor::getProgramName(int index) { return {}; }
void AudioGridderAudioProcessor::changeProgramName(int index, const String& newName) {}
void AudioGridderAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock) {
m_client.init(getTotalNumInputChannels(), sampleRate, samplesPerBlock, isUsingDoublePrecision());
}
void AudioGridderAudioProcessor::releaseResources() {
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
#ifndef JucePlugin_PreferredChannelConfigurations
bool AudioGridderAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const {
#if JucePlugin_IsMidiEffect
ignoreUnused(layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() &&
layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) {
return false;
}
// This checks if the input layout matches the output layout
#if !JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) {
return false;
}
#endif
return true;
#endif
}
#endif
template <typename T>
void AudioGridderAudioProcessor::processBlockReal(AudioBuffer<T>& buffer, MidiBuffer& midiMessages) {
ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
auto* playHead = getPlayHead();
AudioPlayHead::CurrentPositionInfo posInfo;
playHead->getCurrentPosition(posInfo);
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) {
buffer.clear(i, 0, buffer.getNumSamples());
}
if (!m_client.isReadyLockFree()) {
for (auto i = 0; i < buffer.getNumChannels(); ++i) {
buffer.clear(i, 0, buffer.getNumSamples());
}
} else {
if (buffer.getNumChannels() > 0 && buffer.getNumSamples() > 0) {
m_client.send(buffer, midiMessages, posInfo);
m_client.read(buffer, midiMessages);
if (m_client.getLatencySamples() != getLatencySamples()) {
logln_clnt(&m_client, "updating latency samples to " << m_client.getLatencySamples());
setLatencySamples(m_client.getLatencySamples());
}
}
}
}
bool AudioGridderAudioProcessor::hasEditor() const { return true; }
AudioProcessorEditor* AudioGridderAudioProcessor::createEditor() { return new AudioGridderAudioProcessorEditor(*this); }
void AudioGridderAudioProcessor::getStateInformation(MemoryBlock& destData) {
json j;
auto jservers = json::array();
for (auto& srv : m_servers) {
jservers.push_back(srv.toStdString());
}
j["version"] = 2;
j["servers"] = jservers;
j["activeServer"] = m_activeServer;
auto jplugs = json::array();
for (int i = 0; i < m_loadedPlugins.size(); i++) {
auto& plug = m_loadedPlugins[i];
if (m_client.isReadyLockFree()) {
auto settings = m_client.getPluginSettings(static_cast<int>(i));
if (settings.getSize() > 0) {
plug.settings = settings.toBase64Encoding();
}
}
auto jpresets = json::array();
for (auto& p : plug.presets) {
jpresets.push_back(p.toStdString());
}
auto jparams = json::array();
for (auto& p : plug.params) {
jparams.push_back(p.toJson());
}
jplugs.push_back({plug.id.toStdString(), plug.name.toStdString(), plug.settings.toStdString(), jpresets,
jparams, plug.bypassed});
}
j["loadedPlugins"] = jplugs;
auto dump = j.dump();
destData.append(dump.data(), dump.length());
saveConfig();
}
void AudioGridderAudioProcessor::saveConfig(int numOfBuffers) {
auto jservers = json::array();
for (auto& srv : m_servers) {
jservers.push_back(srv.toStdString());
}
if (numOfBuffers < 0) {
numOfBuffers = m_client.NUM_OF_BUFFERS;
}
json jcfg;
jcfg["_comment_"] = "PLEASE DO NOT CHANGE THIS FILE WHILE YOUR DAW IS RUNNING AND HAS AUDIOGRIDDER PLUGINS LOADED";
jcfg["Servers"] = jservers;
jcfg["Last"] = m_activeServer;
jcfg["NumberOfBuffers"] = numOfBuffers;
jcfg["NumberOfAutomationSlots"] = m_numberOfAutomationSlots;
File cfg(PLUGIN_CONFIG_FILE);
cfg.deleteFile();
FileOutputStream fos(cfg);
fos.writeText(jcfg.dump(4), false, false, "\n");
}
void AudioGridderAudioProcessor::setStateInformation(const void* data, int sizeInBytes) {
std::string dump(static_cast<const char*>(data), sizeInBytes);
try {
json j = json::parse(dump);
int version = 0;
if (j.find("version") != j.end()) {
version = j["version"].get<int>();
}
m_servers.clear();
if (j.find("servers") != j.end()) {
for (auto& srv : j["servers"]) {
m_servers.push_back(srv.get<std::string>());
}
}
if (j.find("activeServer") != j.end()) {
m_activeServer = j["activeServer"].get<int>();
}
if (j.find("loadedPlugins") != j.end()) {
for (auto& plug : j["loadedPlugins"]) {
if (version < 1) {
StringArray dummy;
Array<e47::Client::Parameter> dummy2;
m_loadedPlugins.push_back({plug[0].get<std::string>(), plug[1].get<std::string>(),
plug[2].get<std::string>(), dummy, dummy2, false, false});
} else if (version == 1) {
StringArray dummy;
Array<e47::Client::Parameter> dummy2;
m_loadedPlugins.push_back({plug[0].get<std::string>(), plug[1].get<std::string>(),
plug[2].get<std::string>(), dummy, dummy2, plug[3].get<bool>(), false});
} else {
StringArray presets;
for (auto& p : plug[3]) {
presets.add(p.get<std::string>());
}
Array<e47::Client::Parameter> params;
for (auto& p : plug[4]) {
params.add(e47::Client::Parameter::fromJson(p));
}
m_loadedPlugins.push_back({plug[0].get<std::string>(), plug[1].get<std::string>(),
plug[2].get<std::string>(), presets, params, plug[5].get<bool>(),
false});
}
}
}
if (m_activeServer > -1 && m_activeServer < m_servers.size()) {
m_client.setServer(m_servers[m_activeServer]);
m_client.reconnect();
}
} catch (json::parse_error& e) {
logln_clnt(&m_client, "parsing state info failed: " << e.what());
}
}
std::vector<ServerPlugin> AudioGridderAudioProcessor::getPlugins(const String& type) const {
std::vector<ServerPlugin> ret;
for (auto& plugin : getPlugins()) {
if (!plugin.getType().compare(type)) {
ret.push_back(plugin);
}
}
return ret;
}
std::set<String> AudioGridderAudioProcessor::getPluginTypes() const {
std::set<String> ret;
for (auto& plugin : m_client.getPlugins()) {
ret.insert(plugin.getType());
}
return ret;
}
bool AudioGridderAudioProcessor::loadPlugin(const String& id, const String& name) {
StringArray presets;
Array<e47::Client::Parameter> params;
logln_clnt(&m_client, "loading " << name << " (" << id << ")... ");
suspendProcessing(true);
bool success = m_client.addPlugin(id, presets, params);
suspendProcessing(false);
logln_clnt(&m_client, "..." << (success ? "ok" : "error"));
if (success) {
logln_clnt(&m_client, "updating latency samples to " << m_client.getLatencySamples());
setLatencySamples(m_client.getLatencySamples());
m_loadedPlugins.push_back({id, name, "", presets, params, false, true});
}
return success;
}
void AudioGridderAudioProcessor::unloadPlugin(int idx) {
suspendProcessing(true);
m_client.delPlugin(idx);
suspendProcessing(false);
logln_clnt(&m_client, "updating latency samples to " << m_client.getLatencySamples());
setLatencySamples(m_client.getLatencySamples());
if (idx == m_activePlugin) {
hidePlugin();
} else if (idx < m_activePlugin) {
m_activePlugin--;
}
int i = 0;
for (auto it = m_loadedPlugins.begin(); it < m_loadedPlugins.end(); it++) {
if (i++ == idx) {
m_loadedPlugins.erase(it);
return;
}
}
}
void AudioGridderAudioProcessor::editPlugin(int idx) {
m_client.editPlugin(idx);
m_activePlugin = idx;
}
void AudioGridderAudioProcessor::hidePlugin(bool updateServer) {
if (updateServer) {
m_client.hidePlugin();
}
m_activePlugin = -1;
}
bool AudioGridderAudioProcessor::isBypassed(int idx) {
if (idx > -1 && idx < m_loadedPlugins.size()) {
return m_loadedPlugins[idx].bypassed;
}
return false;
}
void AudioGridderAudioProcessor::bypassPlugin(int idx) {
if (idx > -1 && idx < m_loadedPlugins.size()) {
m_client.bypassPlugin(idx);
m_loadedPlugins[idx].bypassed = true;
}
}
void AudioGridderAudioProcessor::unbypassPlugin(int idx) {
if (idx > -1 && idx < m_loadedPlugins.size()) {
m_client.unbypassPlugin(idx);
m_loadedPlugins[idx].bypassed = false;
}
}
void AudioGridderAudioProcessor::exchangePlugins(int idxA, int idxB) {
if (idxA > -1 && idxA < m_loadedPlugins.size() && idxB > -1 && idxB < m_loadedPlugins.size()) {
suspendProcessing(true);
m_client.exchangePlugins(idxA, idxB);
suspendProcessing(false);
std::swap(m_loadedPlugins[idxA], m_loadedPlugins[idxB]);
if (idxA == m_activePlugin) {
m_activePlugin = idxB;
} else if (idxB == m_activePlugin) {
m_activePlugin = idxA;
}
for (auto* p : getParameters()) {
auto* param = dynamic_cast<Parameter*>(p);
if (param->m_idx == idxA) {
param->m_idx = idxB;
} else if (param->m_idx == idxB) {
param->m_idx = idxA;
}
}
}
}
bool AudioGridderAudioProcessor::enableParamAutomation(int idx, int paramIdx, int slot) {
auto& param = m_loadedPlugins[idx].params.getReference(paramIdx);
Parameter* pparam = nullptr;
if (slot == -1) {
for (slot = 0; slot < m_numberOfAutomationSlots; slot++) {
pparam = dynamic_cast<Parameter*>(getParameters()[slot]);
if (pparam->m_idx == -1) {
break;
}
}
} else {
pparam = dynamic_cast<Parameter*>(getParameters()[slot]);
}
if (slot < m_numberOfAutomationSlots) {
pparam->m_idx = idx;
pparam->m_paramIdx = paramIdx;
param.automationSlot = slot;
updateHostDisplay();
return true;
}
return false;
}
void AudioGridderAudioProcessor::disableParamAutomation(int idx, int paramIdx) {
auto& param = m_loadedPlugins[idx].params.getReference(paramIdx);
auto* pparam = dynamic_cast<Parameter*>(getParameters()[param.automationSlot]);
pparam->reset();
updateHostDisplay();
param.automationSlot = -1;
}
void AudioGridderAudioProcessor::delServer(int idx) {
int i = 0;
for (auto it = m_servers.begin(); it < m_servers.end(); it++) {
if (i++ == idx) {
m_servers.erase(it);
return;
}
}
}
void AudioGridderAudioProcessor::setActiveServer(int i) {
if (i > -1 && i < m_servers.size()) {
m_activeServer = i;
m_client.setServer(m_servers[i]);
}
}
float AudioGridderAudioProcessor::Parameter::getValue() const {
if (m_idx > -1 && m_paramIdx > -1) {
return m_processor.getClient().getParameterValue(m_idx, m_paramIdx);
}
return 0;
}
void AudioGridderAudioProcessor::Parameter::setValue(float newValue) {
if (m_idx > -1 && m_paramIdx > -1) {
MessageManager::callAsync(
[this, newValue] { m_processor.getClient().setParameterValue(m_idx, m_paramIdx, newValue); });
}
}
String AudioGridderAudioProcessor::Parameter::getName(int maximumStringLength) const {
String name;
name << m_slotId << ":" << getPlugin().name << ":" << getParam().name;
if (name.length() <= maximumStringLength) {
return name;
} else {
return name.dropLastCharacters(name.length() - maximumStringLength);
}
}
//==============================================================================
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new AudioGridderAudioProcessor(); }
| 17,818
| 5,615
|
/////////////////////////////////////////////////////////////////////
// = NMatrix
//
// A linear algebra library for scientific computation in Ruby.
// NMatrix is part of SciRuby.
//
// NMatrix was originally inspired by and derived from NArray, by
// Masahiro Tanaka: http://narray.rubyforge.org
//
// == Copyright Information
//
// SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation
// NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation
//
// Please see LICENSE.txt for additional copyright notices.
//
// == Contributing
//
// By contributing source code to SciRuby, you agree to be bound by
// our Contributor Agreement:
//
// * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
//
// == dense.c
//
// Dense n-dimensional matrix storage.
/*
* Standard Includes
*/
#include <ruby.h>
/*
* Project Includes
*/
#include "../../data/data.h"
#include "../../math/long_dtype.h"
#include "../../math/gemm.h"
#include "../../math/gemv.h"
#include "../../math/math.h"
#include "../common.h"
#include "dense.h"
/*
* Macros
*/
/*
* Global Variables
*/
/*
* Forward Declarations
*/
namespace nm { namespace dense_storage {
template<typename LDType, typename RDType>
void ref_slice_copy_transposed(const DENSE_STORAGE* rhs, DENSE_STORAGE* lhs);
template <typename LDType, typename RDType>
DENSE_STORAGE* cast_copy(const DENSE_STORAGE* rhs, nm::dtype_t new_dtype);
template <typename LDType, typename RDType>
bool eqeq(const DENSE_STORAGE* left, const DENSE_STORAGE* right);
template <typename DType>
static DENSE_STORAGE* matrix_multiply(const STORAGE_PAIR& casted_storage, size_t* resulting_shape, bool vector);
template <typename DType>
bool is_hermitian(const DENSE_STORAGE* mat, int lda);
template <typename DType>
bool is_symmetric(const DENSE_STORAGE* mat, int lda);
/*
* Recursive slicing for N-dimensional matrix.
*/
template <typename LDType, typename RDType>
static void slice_copy(DENSE_STORAGE *dest, const DENSE_STORAGE *src, size_t* lengths, size_t pdest, size_t psrc, size_t n) {
if (src->dim - n > 1) {
for (size_t i = 0; i < lengths[n]; ++i) {
slice_copy<LDType,RDType>(dest, src, lengths,
pdest + dest->stride[n]*i,
psrc + src->stride[n]*i,
n + 1);
}
} else {
for (size_t p = 0; p < dest->shape[n]; ++p) {
reinterpret_cast<LDType*>(dest->elements)[p+pdest] = reinterpret_cast<RDType*>(src->elements)[p+psrc];
}
/*memcpy((char*)dest->elements + pdest*DTYPE_SIZES[dest->dtype],
(char*)src->elements + psrc*DTYPE_SIZES[src->dtype],
dest->shape[n]*DTYPE_SIZES[dest->dtype]); */
}
}
/*
* Recursive function, sets multiple values in a matrix from a single source value. Same basic pattern as slice_copy.
*/
template <typename D>
static void slice_set(DENSE_STORAGE* dest, size_t* lengths, size_t pdest, size_t rank, D* const v, size_t v_size, size_t& v_offset) {
if (dest->dim - rank > 1) {
for (size_t i = 0; i < lengths[rank]; ++i) {
slice_set<D>(dest, lengths, pdest + dest->stride[rank] * i, rank + 1, v, v_size, v_offset);
}
} else {
for (size_t p = 0; p < lengths[rank]; ++p, ++v_offset) {
if (v_offset >= v_size) v_offset %= v_size;
D* elem = reinterpret_cast<D*>(dest->elements);
elem[p + pdest] = v[v_offset];
}
}
}
/*
* Dense storage set/slice-set function, templated version.
*/
template <typename D>
void set(VALUE left, SLICE* slice, VALUE right) {
NM_CONSERVATIVE(nm_register_value(&left));
NM_CONSERVATIVE(nm_register_value(&right));
DENSE_STORAGE* s = NM_STORAGE_DENSE(left);
std::pair<NMATRIX*,bool> nm_and_free =
interpret_arg_as_dense_nmatrix(right, s->dtype);
// Map the data onto D* v.
D* v;
size_t v_size = 1;
if (nm_and_free.first) {
DENSE_STORAGE* t = reinterpret_cast<DENSE_STORAGE*>(nm_and_free.first->storage);
v = reinterpret_cast<D*>(t->elements);
v_size = nm_storage_count_max_elements(t);
} else if (TYPE(right) == T_ARRAY) {
v_size = RARRAY_LEN(right);
v = NM_ALLOC_N(D, v_size);
if (s->dtype == nm::RUBYOBJ)
nm_register_values(reinterpret_cast<VALUE*>(v), v_size);
for (size_t m = 0; m < v_size; ++m) {
rubyval_to_cval(rb_ary_entry(right, m), s->dtype, &(v[m]));
}
} else {
v = reinterpret_cast<D*>(rubyobj_to_cval(right, NM_DTYPE(left)));
if (s->dtype == nm::RUBYOBJ)
nm_register_values(reinterpret_cast<VALUE*>(v), v_size);
}
if (slice->single) {
reinterpret_cast<D*>(s->elements)[nm_dense_storage_pos(s, slice->coords)] = *v;
} else {
size_t v_offset = 0;
slice_set(s, slice->lengths, nm_dense_storage_pos(s, slice->coords), 0, v, v_size, v_offset);
}
// Only free v if it was allocated in this function.
if (nm_and_free.first) {
if (nm_and_free.second) {
nm_delete(nm_and_free.first);
}
} else {
if (s->dtype == nm::RUBYOBJ)
nm_unregister_values(reinterpret_cast<VALUE*>(v), v_size);
NM_FREE(v);
}
NM_CONSERVATIVE(nm_unregister_value(&left));
NM_CONSERVATIVE(nm_unregister_value(&right));
}
}} // end of namespace nm::dense_storage
extern "C" {
static size_t* stride(size_t* shape, size_t dim);
static void slice_copy(DENSE_STORAGE *dest, const DENSE_STORAGE *src, size_t* lengths, size_t pdest, size_t psrc, size_t n);
/*
* Functions
*/
///////////////
// Lifecycle //
///////////////
/*
* This creates a dummy with all the properties of dense storage, but no actual elements allocation.
*
* elements will be NULL when this function finishes. You can clean up with nm_dense_storage_delete, which will
* check for that NULL pointer before freeing elements.
*/
static DENSE_STORAGE* nm_dense_storage_create_dummy(nm::dtype_t dtype, size_t* shape, size_t dim) {
DENSE_STORAGE* s = NM_ALLOC( DENSE_STORAGE );
s->dim = dim;
s->shape = shape;
s->dtype = dtype;
s->offset = NM_ALLOC_N(size_t, dim);
memset(s->offset, 0, sizeof(size_t)*dim);
s->stride = stride(shape, dim);
s->count = 0;
s->src = s;
s->elements = NULL;
return s;
}
/*
* Note that elements and elements_length are for initial value(s) passed in.
* If they are the correct length, they will be used directly. If not, they
* will be concatenated over and over again into a new elements array. If
* elements is NULL, the new elements array will not be initialized.
*/
DENSE_STORAGE* nm_dense_storage_create(nm::dtype_t dtype, size_t* shape, size_t dim, void* elements, size_t elements_length) {
if (dtype == nm::RUBYOBJ)
nm_register_values(reinterpret_cast<VALUE*>(elements), elements_length);
DENSE_STORAGE* s = nm_dense_storage_create_dummy(dtype, shape, dim);
size_t count = nm_storage_count_max_elements(s);
if (elements_length == count) {
s->elements = elements;
s->count = count;
if (dtype == nm::RUBYOBJ)
nm_unregister_values(reinterpret_cast<VALUE*>(elements), elements_length);
} else {
s->elements = NM_ALLOC_N(char, DTYPE_SIZES[dtype]*count);
s->count = count;
if (dtype == nm::RUBYOBJ)
nm_unregister_values(reinterpret_cast<VALUE*>(elements), elements_length);
size_t copy_length = elements_length;
if (elements_length > 0) {
// Repeat elements over and over again until the end of the matrix.
for (size_t i = 0; i < count; i += elements_length) {
if (i + elements_length > count) {
copy_length = count - i;
}
memcpy((char*)(s->elements)+i*DTYPE_SIZES[dtype], (char*)(elements)+(i % elements_length)*DTYPE_SIZES[dtype], copy_length*DTYPE_SIZES[dtype]);
}
// Get rid of the init_val.
NM_FREE(elements);
}
}
return s;
}
/*
* Destructor for dense storage. Make sure when you update this you also update nm_dense_storage_delete_dummy.
*/
void nm_dense_storage_delete(STORAGE* s) {
// Sometimes Ruby passes in NULL storage for some reason (probably on copy construction failure).
if (s) {
DENSE_STORAGE* storage = (DENSE_STORAGE*)s;
if(storage->count-- == 1) {
NM_FREE(storage->shape);
NM_FREE(storage->offset);
NM_FREE(storage->stride);
if (storage->elements != NULL) {// happens with dummy objects
NM_FREE(storage->elements);
}
NM_FREE(storage);
}
}
}
/*
* Destructor for dense storage references (slicing).
*/
void nm_dense_storage_delete_ref(STORAGE* s) {
// Sometimes Ruby passes in NULL storage for some reason (probably on copy construction failure).
if (s) {
DENSE_STORAGE* storage = (DENSE_STORAGE*)s;
nm_dense_storage_delete( reinterpret_cast<STORAGE*>(storage->src) );
NM_FREE(storage->shape);
NM_FREE(storage->offset);
NM_FREE(storage);
}
}
/*
* Mark values in a dense matrix for garbage collection. This may not be necessary -- further testing required.
*/
void nm_dense_storage_mark(STORAGE* storage_base) {
DENSE_STORAGE* storage = (DENSE_STORAGE*)storage_base;
if (storage && storage->dtype == nm::RUBYOBJ) {
VALUE* els = reinterpret_cast<VALUE*>(storage->elements);
if (els) {
rb_gc_mark_locations(els, &(els[nm_storage_count_max_elements(storage)-1]));
}
//for (size_t index = nm_storage_count_max_elements(storage); index-- > 0;) {
// rb_gc_mark(els[index]);
//}
}
}
/**
* Register a dense storage struct as in-use to avoid garbage collection of the
* elements stored.
*
* This function will check dtype and ignore non-object dtype, so its safe to pass any dense storage in.
*
*/
void nm_dense_storage_register(const STORAGE* s) {
const DENSE_STORAGE* storage = reinterpret_cast<const DENSE_STORAGE*>(s);
if (storage->dtype == nm::RUBYOBJ && storage->elements) {
nm_register_values(reinterpret_cast<VALUE*>(storage->elements), nm_storage_count_max_elements(storage));
}
}
/**
* Unregister a dense storage struct to allow normal garbage collection of the
* elements stored.
*
* This function will check dtype and ignore non-object dtype, so its safe to pass any dense storage in.
*
*/
void nm_dense_storage_unregister(const STORAGE* s) {
const DENSE_STORAGE* storage = reinterpret_cast<const DENSE_STORAGE*>(s);
if (storage->dtype == nm::RUBYOBJ && storage->elements) {
nm_unregister_values(reinterpret_cast<VALUE*>(storage->elements), nm_storage_count_max_elements(storage));
}
}
///////////////
// Accessors //
///////////////
/*
* map_pair iterator for dense matrices (for element-wise operations)
*/
VALUE nm_dense_map_pair(VALUE self, VALUE right) {
NM_CONSERVATIVE(nm_register_value(&self));
NM_CONSERVATIVE(nm_register_value(&right));
RETURN_SIZED_ENUMERATOR_PRE
NM_CONSERVATIVE(nm_unregister_value(&right));
NM_CONSERVATIVE(nm_unregister_value(&self));
RETURN_SIZED_ENUMERATOR(self, 0, 0, nm_enumerator_length);
DENSE_STORAGE *s = NM_STORAGE_DENSE(self),
*t = NM_STORAGE_DENSE(right);
size_t* coords = NM_ALLOCA_N(size_t, s->dim);
memset(coords, 0, sizeof(size_t) * s->dim);
size_t *shape_copy = NM_ALLOC_N(size_t, s->dim);
memcpy(shape_copy, s->shape, sizeof(size_t) * s->dim);
size_t count = nm_storage_count_max_elements(s);
DENSE_STORAGE* result = nm_dense_storage_create(nm::RUBYOBJ, shape_copy, s->dim, NULL, 0);
VALUE* result_elem = reinterpret_cast<VALUE*>(result->elements);
nm_dense_storage_register(result);
for (size_t k = 0; k < count; ++k) {
nm_dense_storage_coords(result, k, coords);
size_t s_index = nm_dense_storage_pos(s, coords),
t_index = nm_dense_storage_pos(t, coords);
VALUE sval = NM_DTYPE(self) == nm::RUBYOBJ ? reinterpret_cast<VALUE*>(s->elements)[s_index] : rubyobj_from_cval((char*)(s->elements) + s_index*DTYPE_SIZES[NM_DTYPE(self)], NM_DTYPE(self)).rval;
nm_register_value(&sval);
VALUE tval = NM_DTYPE(right) == nm::RUBYOBJ ? reinterpret_cast<VALUE*>(t->elements)[t_index] : rubyobj_from_cval((char*)(t->elements) + t_index*DTYPE_SIZES[NM_DTYPE(right)], NM_DTYPE(right)).rval;
result_elem[k] = rb_yield_values(2, sval, tval);
nm_unregister_value(&sval);
}
VALUE klass = CLASS_OF(self);
NMATRIX* m = nm_create(nm::DENSE_STORE, reinterpret_cast<STORAGE*>(result));
nm_register_nmatrix(m);
VALUE to_return = Data_Wrap_Struct(klass, nm_mark, nm_delete, m);
nm_unregister_nmatrix(m);
nm_dense_storage_unregister(result);
NM_CONSERVATIVE(nm_unregister_value(&self));
NM_CONSERVATIVE(nm_unregister_value(&right));
return to_return;
}
/*
* map enumerator for dense matrices.
*/
VALUE nm_dense_map(VALUE self) {
NM_CONSERVATIVE(nm_register_value(&self));
RETURN_SIZED_ENUMERATOR_PRE
NM_CONSERVATIVE(nm_unregister_value(&self));
RETURN_SIZED_ENUMERATOR(self, 0, 0, nm_enumerator_length);
DENSE_STORAGE *s = NM_STORAGE_DENSE(self);
size_t* coords = NM_ALLOCA_N(size_t, s->dim);
memset(coords, 0, sizeof(size_t) * s->dim);
size_t *shape_copy = NM_ALLOC_N(size_t, s->dim);
memcpy(shape_copy, s->shape, sizeof(size_t) * s->dim);
size_t count = nm_storage_count_max_elements(s);
DENSE_STORAGE* result = nm_dense_storage_create(nm::RUBYOBJ, shape_copy, s->dim, NULL, 0);
VALUE* result_elem = reinterpret_cast<VALUE*>(result->elements);
nm_dense_storage_register(result);
for (size_t k = 0; k < count; ++k) {
nm_dense_storage_coords(result, k, coords);
size_t s_index = nm_dense_storage_pos(s, coords);
result_elem[k] = rb_yield(NM_DTYPE(self) == nm::RUBYOBJ ? reinterpret_cast<VALUE*>(s->elements)[s_index] : rubyobj_from_cval((char*)(s->elements) + s_index*DTYPE_SIZES[NM_DTYPE(self)], NM_DTYPE(self)).rval);
}
VALUE klass = CLASS_OF(self);
NMATRIX* m = nm_create(nm::DENSE_STORE, reinterpret_cast<STORAGE*>(result));
nm_register_nmatrix(m);
VALUE to_return = Data_Wrap_Struct(klass, nm_mark, nm_delete, m);
nm_unregister_nmatrix(m);
nm_dense_storage_unregister(result);
NM_CONSERVATIVE(nm_unregister_value(&self));
return to_return;
}
/*
* each_with_indices iterator for dense matrices.
*/
VALUE nm_dense_each_with_indices(VALUE nmatrix) {
NM_CONSERVATIVE(nm_register_value(&nmatrix));
RETURN_SIZED_ENUMERATOR_PRE
NM_CONSERVATIVE(nm_unregister_value(&nmatrix));
RETURN_SIZED_ENUMERATOR(nmatrix, 0, 0, nm_enumerator_length); // fourth argument only used by Ruby2+
DENSE_STORAGE* s = NM_STORAGE_DENSE(nmatrix);
// Create indices and initialize them to zero
size_t* coords = NM_ALLOCA_N(size_t, s->dim);
memset(coords, 0, sizeof(size_t) * s->dim);
size_t slice_index;
size_t* shape_copy = NM_ALLOC_N(size_t, s->dim);
memcpy(shape_copy, s->shape, sizeof(size_t) * s->dim);
DENSE_STORAGE* sliced_dummy = nm_dense_storage_create_dummy(s->dtype, shape_copy, s->dim);
for (size_t k = 0; k < nm_storage_count_max_elements(s); ++k) {
nm_dense_storage_coords(sliced_dummy, k, coords);
slice_index = nm_dense_storage_pos(s, coords);
VALUE ary = rb_ary_new();
nm_register_value(&ary);
if (NM_DTYPE(nmatrix) == nm::RUBYOBJ) rb_ary_push(ary, reinterpret_cast<VALUE*>(s->elements)[slice_index]);
else rb_ary_push(ary, rubyobj_from_cval((char*)(s->elements) + slice_index*DTYPE_SIZES[NM_DTYPE(nmatrix)], NM_DTYPE(nmatrix)).rval);
for (size_t p = 0; p < s->dim; ++p) {
rb_ary_push(ary, INT2FIX(coords[p]));
}
// yield the array which now consists of the value and the indices
rb_yield(ary);
nm_unregister_value(&ary);
}
nm_dense_storage_delete(sliced_dummy);
NM_CONSERVATIVE(nm_unregister_value(&nmatrix));
return nmatrix;
}
/*
* Borrowed this function from NArray. Handles 'each' iteration on a dense
* matrix.
*
* Additionally, handles separately matrices containing VALUEs and matrices
* containing other types of data.
*/
VALUE nm_dense_each(VALUE nmatrix) {
NM_CONSERVATIVE(nm_register_value(&nmatrix));
RETURN_SIZED_ENUMERATOR_PRE
NM_CONSERVATIVE(nm_unregister_value(&nmatrix));
RETURN_SIZED_ENUMERATOR(nmatrix, 0, 0, nm_enumerator_length);
DENSE_STORAGE* s = NM_STORAGE_DENSE(nmatrix);
size_t* temp_coords = NM_ALLOCA_N(size_t, s->dim);
size_t sliced_index;
size_t* shape_copy = NM_ALLOC_N(size_t, s->dim);
memcpy(shape_copy, s->shape, sizeof(size_t) * s->dim);
DENSE_STORAGE* sliced_dummy = nm_dense_storage_create_dummy(s->dtype, shape_copy, s->dim);
if (NM_DTYPE(nmatrix) == nm::RUBYOBJ) {
// matrix of Ruby objects -- yield those objects directly
for (size_t i = 0; i < nm_storage_count_max_elements(s); ++i) {
nm_dense_storage_coords(sliced_dummy, i, temp_coords);
sliced_index = nm_dense_storage_pos(s, temp_coords);
rb_yield( reinterpret_cast<VALUE*>(s->elements)[sliced_index] );
}
} else {
// We're going to copy the matrix element into a Ruby VALUE and then operate on it. This way user can't accidentally
// modify it and cause a seg fault.
for (size_t i = 0; i < nm_storage_count_max_elements(s); ++i) {
nm_dense_storage_coords(sliced_dummy, i, temp_coords);
sliced_index = nm_dense_storage_pos(s, temp_coords);
VALUE v = rubyobj_from_cval((char*)(s->elements) + sliced_index*DTYPE_SIZES[NM_DTYPE(nmatrix)], NM_DTYPE(nmatrix)).rval;
rb_yield( v ); // yield to the copy we made
}
}
nm_dense_storage_delete(sliced_dummy);
NM_CONSERVATIVE(nm_unregister_value(&nmatrix));
return nmatrix;
}
/*
* Non-templated version of nm::dense_storage::slice_copy
*/
static void slice_copy(DENSE_STORAGE *dest, const DENSE_STORAGE *src, size_t* lengths, size_t pdest, size_t psrc, size_t n) {
NAMED_LR_DTYPE_TEMPLATE_TABLE(slice_copy_table, nm::dense_storage::slice_copy, void, DENSE_STORAGE*, const DENSE_STORAGE*, size_t*, size_t, size_t, size_t)
slice_copy_table[dest->dtype][src->dtype](dest, src, lengths, pdest, psrc, n);
}
/*
* Get a slice or one element, using copying.
*
* FIXME: Template the first condition.
*/
void* nm_dense_storage_get(const STORAGE* storage, SLICE* slice) {
DENSE_STORAGE* s = (DENSE_STORAGE*)storage;
if (slice->single)
return (char*)(s->elements) + nm_dense_storage_pos(s, slice->coords) * DTYPE_SIZES[s->dtype];
else {
nm_dense_storage_register(s);
size_t *shape = NM_ALLOC_N(size_t, s->dim);
for (size_t i = 0; i < s->dim; ++i) {
shape[i] = slice->lengths[i];
}
DENSE_STORAGE* ns = nm_dense_storage_create(s->dtype, shape, s->dim, NULL, 0);
slice_copy(ns,
reinterpret_cast<const DENSE_STORAGE*>(s->src),
slice->lengths,
0,
nm_dense_storage_pos(s, slice->coords),
0);
nm_dense_storage_unregister(s);
return ns;
}
}
/*
* Get a slice or one element by reference (no copy).
*
* FIXME: Template the first condition.
*/
void* nm_dense_storage_ref(const STORAGE* storage, SLICE* slice) {
DENSE_STORAGE* s = (DENSE_STORAGE*)storage;
if (slice->single)
return (char*)(s->elements) + nm_dense_storage_pos(s, slice->coords) * DTYPE_SIZES[s->dtype];
else {
nm_dense_storage_register(s);
DENSE_STORAGE* ns = NM_ALLOC( DENSE_STORAGE );
ns->dim = s->dim;
ns->dtype = s->dtype;
ns->offset = NM_ALLOC_N(size_t, ns->dim);
ns->shape = NM_ALLOC_N(size_t, ns->dim);
for (size_t i = 0; i < ns->dim; ++i) {
ns->offset[i] = slice->coords[i] + s->offset[i];
ns->shape[i] = slice->lengths[i];
}
ns->stride = s->stride;
ns->elements = s->elements;
s->src->count++;
ns->src = s->src;
nm_dense_storage_unregister(s);
return ns;
}
}
/*
* Set a value or values in a dense matrix. Requires that right be either a single value or an NMatrix (ref or real).
*/
void nm_dense_storage_set(VALUE left, SLICE* slice, VALUE right) {
NAMED_DTYPE_TEMPLATE_TABLE(ttable, nm::dense_storage::set, void, VALUE, SLICE*, VALUE)
nm::dtype_t dtype = NM_DTYPE(left);
ttable[dtype](left, slice, right);
}
///////////
// Tests //
///////////
/*
* Do these two dense matrices have the same contents?
*
* TODO: Test the shape of the two matrices.
* TODO: See if using memcmp is faster when the left- and right-hand matrices
* have the same dtype.
*/
bool nm_dense_storage_eqeq(const STORAGE* left, const STORAGE* right) {
LR_DTYPE_TEMPLATE_TABLE(nm::dense_storage::eqeq, bool, const DENSE_STORAGE*, const DENSE_STORAGE*)
if (!ttable[left->dtype][right->dtype]) {
rb_raise(nm_eDataTypeError, "comparison between these dtypes is undefined");
return false;
}
return ttable[left->dtype][right->dtype]((const DENSE_STORAGE*)left, (const DENSE_STORAGE*)right);
}
/*
* Test to see if the matrix is Hermitian. If the matrix does not have a
* dtype of Complex64 or Complex128 this is the same as testing for symmetry.
*/
bool nm_dense_storage_is_hermitian(const DENSE_STORAGE* mat, int lda) {
if (mat->dtype == nm::COMPLEX64) {
return nm::dense_storage::is_hermitian<nm::Complex64>(mat, lda);
} else if (mat->dtype == nm::COMPLEX128) {
return nm::dense_storage::is_hermitian<nm::Complex128>(mat, lda);
} else {
return nm_dense_storage_is_symmetric(mat, lda);
}
}
/*
* Is this dense matrix symmetric about the diagonal?
*/
bool nm_dense_storage_is_symmetric(const DENSE_STORAGE* mat, int lda) {
DTYPE_TEMPLATE_TABLE(nm::dense_storage::is_symmetric, bool, const DENSE_STORAGE*, int);
return ttable[mat->dtype](mat, lda);
}
//////////
// Math //
//////////
/*
* Dense matrix-matrix multiplication.
*/
STORAGE* nm_dense_storage_matrix_multiply(const STORAGE_PAIR& casted_storage, size_t* resulting_shape, bool vector) {
DTYPE_TEMPLATE_TABLE(nm::dense_storage::matrix_multiply, DENSE_STORAGE*, const STORAGE_PAIR& casted_storage, size_t* resulting_shape, bool vector);
return ttable[casted_storage.left->dtype](casted_storage, resulting_shape, vector);
}
/////////////
// Utility //
/////////////
/*
* Determine the linear array position (in elements of s) of some set of coordinates
* (given by slice).
*/
size_t nm_dense_storage_pos(const DENSE_STORAGE* s, const size_t* coords) {
size_t pos = 0;
for (size_t i = 0; i < s->dim; ++i)
pos += (coords[i] + s->offset[i]) * s->stride[i];
return pos;
}
/*
* Determine the a set of slice coordinates from linear array position (in elements
* of s) of some set of coordinates (given by slice). (Inverse of
* nm_dense_storage_pos).
*
* The parameter coords_out should be a pre-allocated array of size equal to s->dim.
*/
void nm_dense_storage_coords(const DENSE_STORAGE* s, const size_t slice_pos, size_t* coords_out) {
size_t temp_pos = slice_pos;
for (size_t i = 0; i < s->dim; ++i) {
coords_out[i] = (temp_pos - temp_pos % s->stride[i])/s->stride[i] - s->offset[i];
temp_pos = temp_pos % s->stride[i];
}
}
/*
* Calculate the stride length.
*/
static size_t* stride(size_t* shape, size_t dim) {
size_t i, j;
size_t* stride = NM_ALLOC_N(size_t, dim);
for (i = 0; i < dim; ++i) {
stride[i] = 1;
for (j = i+1; j < dim; ++j) {
stride[i] *= shape[j];
}
}
return stride;
}
/////////////////////////
// Copying and Casting //
/////////////////////////
/*
* Copy dense storage, changing dtype if necessary.
*/
STORAGE* nm_dense_storage_cast_copy(const STORAGE* rhs, nm::dtype_t new_dtype, void* dummy) {
NAMED_LR_DTYPE_TEMPLATE_TABLE(ttable, nm::dense_storage::cast_copy, DENSE_STORAGE*, const DENSE_STORAGE* rhs, nm::dtype_t new_dtype);
if (!ttable[new_dtype][rhs->dtype]) {
rb_raise(nm_eDataTypeError, "cast between these dtypes is undefined");
return NULL;
}
return (STORAGE*)ttable[new_dtype][rhs->dtype]((DENSE_STORAGE*)rhs, new_dtype);
}
/*
* Copy dense storage without a change in dtype.
*/
DENSE_STORAGE* nm_dense_storage_copy(const DENSE_STORAGE* rhs) {
nm_dense_storage_register(rhs);
size_t count = 0;
size_t *shape = NM_ALLOC_N(size_t, rhs->dim);
// copy shape and offset
for (size_t i = 0; i < rhs->dim; ++i) {
shape[i] = rhs->shape[i];
}
DENSE_STORAGE* lhs = nm_dense_storage_create(rhs->dtype, shape, rhs->dim, NULL, 0);
count = nm_storage_count_max_elements(lhs);
// Ensure that allocation worked before copying.
if (lhs && count) {
if (rhs == rhs->src) // not a reference
memcpy(lhs->elements, rhs->elements, DTYPE_SIZES[rhs->dtype] * count);
else { // slice whole matrix
nm_dense_storage_register(lhs);
size_t *offset = NM_ALLOC_N(size_t, rhs->dim);
memset(offset, 0, sizeof(size_t) * rhs->dim);
slice_copy(lhs,
reinterpret_cast<const DENSE_STORAGE*>(rhs->src),
rhs->shape,
0,
nm_dense_storage_pos(rhs, offset),
0);
nm_dense_storage_unregister(lhs);
}
}
nm_dense_storage_unregister(rhs);
return lhs;
}
/*
* Transpose dense storage into a new dense storage object. Basically a copy constructor.
*
* Not much point in templating this as it's pretty straight-forward.
*/
STORAGE* nm_dense_storage_copy_transposed(const STORAGE* rhs_base) {
DENSE_STORAGE* rhs = (DENSE_STORAGE*)rhs_base;
nm_dense_storage_register(rhs);
size_t *shape = NM_ALLOC_N(size_t, rhs->dim);
// swap shape
shape[0] = rhs->shape[1];
shape[1] = rhs->shape[0];
DENSE_STORAGE *lhs = nm_dense_storage_create(rhs->dtype, shape, rhs->dim, NULL, 0);
nm_dense_storage_register(lhs);
if (rhs_base->src == rhs_base) {
nm_math_transpose_generic(rhs->shape[0], rhs->shape[1], rhs->elements, rhs->shape[1], lhs->elements, lhs->shape[1], DTYPE_SIZES[rhs->dtype]);
} else {
NAMED_LR_DTYPE_TEMPLATE_TABLE(ttable, nm::dense_storage::ref_slice_copy_transposed, void, const DENSE_STORAGE* rhs, DENSE_STORAGE* lhs);
if (!ttable[lhs->dtype][rhs->dtype]) {
nm_dense_storage_unregister(rhs);
nm_dense_storage_unregister(lhs);
rb_raise(nm_eDataTypeError, "transposition between these dtypes is undefined");
}
ttable[lhs->dtype][rhs->dtype](rhs, lhs);
}
nm_dense_storage_unregister(rhs);
nm_dense_storage_unregister(lhs);
return (STORAGE*)lhs;
}
} // end of extern "C" block
namespace nm {
/*
* Used for slice setting. Takes the right-hand of the equal sign, a single VALUE, and massages
* it into the correct form if it's not already there (dtype, non-ref, dense). Returns a pair of the NMATRIX* and a
* boolean. If the boolean is true, the calling function is responsible for calling nm_delete on the NMATRIX*.
* Otherwise, the NMATRIX* still belongs to Ruby and Ruby will free it.
*/
std::pair<NMATRIX*,bool> interpret_arg_as_dense_nmatrix(VALUE right, nm::dtype_t dtype) {
NM_CONSERVATIVE(nm_register_value(&right));
if (TYPE(right) == T_DATA && (RDATA(right)->dfree == (RUBY_DATA_FUNC)nm_delete || RDATA(right)->dfree == (RUBY_DATA_FUNC)nm_delete_ref)) {
NMATRIX *r;
if (NM_STYPE(right) != DENSE_STORE || NM_DTYPE(right) != dtype || NM_SRC(right) != NM_STORAGE(right)) {
UnwrapNMatrix( right, r );
NMATRIX* ldtype_r = nm_cast_with_ctype_args(r, nm::DENSE_STORE, dtype, NULL);
NM_CONSERVATIVE(nm_unregister_value(&right));
return std::make_pair(ldtype_r,true);
} else { // simple case -- right-hand matrix is dense and is not a reference and has same dtype
UnwrapNMatrix( right, r );
NM_CONSERVATIVE(nm_unregister_value(&right));
return std::make_pair(r, false);
}
// Do not set v_alloc = true for either of these. It is the responsibility of r/ldtype_r
} else if (TYPE(right) == T_DATA) {
NM_CONSERVATIVE(nm_unregister_value(&right));
rb_raise(rb_eTypeError, "unrecognized type for slice assignment");
}
NM_CONSERVATIVE(nm_unregister_value(&right));
return std::make_pair<NMATRIX*,bool>(NULL, false);
}
namespace dense_storage {
/////////////////////////
// Templated Functions //
/////////////////////////
template<typename LDType, typename RDType>
void ref_slice_copy_transposed(const DENSE_STORAGE* rhs, DENSE_STORAGE* lhs) {
nm_dense_storage_register(rhs);
nm_dense_storage_register(lhs);
LDType* lhs_els = reinterpret_cast<LDType*>(lhs->elements);
RDType* rhs_els = reinterpret_cast<RDType*>(rhs->elements);
size_t count = nm_storage_count_max_elements(lhs);;
size_t* temp_coords = NM_ALLOCA_N(size_t, lhs->dim);
size_t coord_swap_temp;
while (count-- > 0) {
nm_dense_storage_coords(lhs, count, temp_coords);
NM_SWAP(temp_coords[0], temp_coords[1], coord_swap_temp);
size_t r_coord = nm_dense_storage_pos(rhs, temp_coords);
lhs_els[count] = rhs_els[r_coord];
}
nm_dense_storage_unregister(rhs);
nm_dense_storage_unregister(lhs);
}
template <typename LDType, typename RDType>
DENSE_STORAGE* cast_copy(const DENSE_STORAGE* rhs, dtype_t new_dtype) {
nm_dense_storage_register(rhs);
size_t count = nm_storage_count_max_elements(rhs);
size_t *shape = NM_ALLOC_N(size_t, rhs->dim);
memcpy(shape, rhs->shape, sizeof(size_t) * rhs->dim);
DENSE_STORAGE* lhs = nm_dense_storage_create(new_dtype, shape, rhs->dim, NULL, 0);
nm_dense_storage_register(lhs);
// Ensure that allocation worked before copying.
if (lhs && count) {
if (rhs->src != rhs) { // Make a copy of a ref to a matrix.
size_t* offset = NM_ALLOCA_N(size_t, rhs->dim);
memset(offset, 0, sizeof(size_t) * rhs->dim);
slice_copy(lhs, reinterpret_cast<const DENSE_STORAGE*>(rhs->src),
rhs->shape, 0,
nm_dense_storage_pos(rhs, offset), 0);
} else { // Make a regular copy.
RDType* rhs_els = reinterpret_cast<RDType*>(rhs->elements);
LDType* lhs_els = reinterpret_cast<LDType*>(lhs->elements);
for (size_t i = 0; i < count; ++i)
lhs_els[i] = rhs_els[i];
}
}
nm_dense_storage_unregister(rhs);
nm_dense_storage_unregister(lhs);
return lhs;
}
template <typename LDType, typename RDType>
bool eqeq(const DENSE_STORAGE* left, const DENSE_STORAGE* right) {
nm_dense_storage_register(left);
nm_dense_storage_register(right);
size_t index;
DENSE_STORAGE *tmp1, *tmp2;
tmp1 = NULL; tmp2 = NULL;
bool result = true;
/* FIXME: Very strange behavior! The GC calls the method directly with non-initialized data. */
if (left->dim != right->dim) {
nm_dense_storage_unregister(right);
nm_dense_storage_unregister(left);
return false;
}
LDType* left_elements = (LDType*)left->elements;
RDType* right_elements = (RDType*)right->elements;
// Copy elements in temp matrix if you have reference to the right.
if (left->src != left) {
tmp1 = nm_dense_storage_copy(left);
nm_dense_storage_register(tmp1);
left_elements = (LDType*)tmp1->elements;
}
if (right->src != right) {
tmp2 = nm_dense_storage_copy(right);
nm_dense_storage_register(tmp2);
right_elements = (RDType*)tmp2->elements;
}
for (index = nm_storage_count_max_elements(left); index-- > 0;) {
if (left_elements[index] != right_elements[index]) {
result = false;
break;
}
}
if (tmp1) {
nm_dense_storage_unregister(tmp1);
NM_FREE(tmp1);
}
if (tmp2) {
nm_dense_storage_unregister(tmp2);
NM_FREE(tmp2);
}
nm_dense_storage_unregister(left);
nm_dense_storage_unregister(right);
return result;
}
template <typename DType>
bool is_hermitian(const DENSE_STORAGE* mat, int lda) {
unsigned int i, j;
register DType complex_conj;
const DType* els = (DType*) mat->elements;
for (i = mat->shape[0]; i-- > 0;) {
for (j = i + 1; j < mat->shape[1]; ++j) {
complex_conj = els[j*lda + i];
complex_conj.i = -complex_conj.i;
if (els[i*lda+j] != complex_conj) {
return false;
}
}
}
return true;
}
template <typename DType>
bool is_symmetric(const DENSE_STORAGE* mat, int lda) {
unsigned int i, j;
const DType* els = (DType*) mat->elements;
for (i = mat->shape[0]; i-- > 0;) {
for (j = i + 1; j < mat->shape[1]; ++j) {
if (els[i*lda+j] != els[j*lda+i]) {
return false;
}
}
}
return true;
}
/*
* DType-templated matrix-matrix multiplication for dense storage.
*/
template <typename DType>
static DENSE_STORAGE* matrix_multiply(const STORAGE_PAIR& casted_storage, size_t* resulting_shape, bool vector) {
DENSE_STORAGE *left = (DENSE_STORAGE*)(casted_storage.left),
*right = (DENSE_STORAGE*)(casted_storage.right);
nm_dense_storage_register(left);
nm_dense_storage_register(right);
// Create result storage.
DENSE_STORAGE* result = nm_dense_storage_create(left->dtype, resulting_shape, 2, NULL, 0);
nm_dense_storage_register(result);
DType *pAlpha = NM_ALLOCA_N(DType, 1),
*pBeta = NM_ALLOCA_N(DType, 1);
*pAlpha = 1;
*pBeta = 0;
// Do the multiplication
if (vector) nm::math::gemv<DType>(CblasNoTrans, left->shape[0], left->shape[1], pAlpha,
reinterpret_cast<DType*>(left->elements), left->shape[1],
reinterpret_cast<DType*>(right->elements), 1, pBeta,
reinterpret_cast<DType*>(result->elements), 1);
else nm::math::gemm<DType>(CblasRowMajor, CblasNoTrans, CblasNoTrans, left->shape[0], right->shape[1], left->shape[1],
pAlpha, reinterpret_cast<DType*>(left->elements), left->shape[1],
reinterpret_cast<DType*>(right->elements), right->shape[1], pBeta,
reinterpret_cast<DType*>(result->elements), result->shape[1]);
nm_dense_storage_unregister(left);
nm_dense_storage_unregister(right);
nm_dense_storage_unregister(result);
return result;
}
}} // end of namespace nm::dense_storage
| 33,837
| 13,396
|
#include "stdafx.h"
void Camera::UpdateProjectionMatrix() {
m_projectionMatrix = Matrix4::Perspective(m_FOV, GetApplication()->GetAspect(), m_nearPlane, m_farPlane);
}
| 169
| 61
|
#include <ros/ros.h>
#include <nodelet/loader.h>
#include <image_topic_to_image/advertisement_checker.h>
int main(int argc, char **argv)
{
ros::init(argc, argv, "image_topic_to_image");
// Check for common user errors
if (ros::names::remap("camera") != "camera")
{
ROS_WARN("Remapping 'camera' has no effect! Start image_topic_to_image in the "
"camera namespace instead.\nExample command-line usage:\n"
"\t$ ROS_NAMESPACE=%s rosrun image_topic_to_image image_topic_to_image",
ros::names::remap("camera").c_str());
}
if (ros::this_node::getNamespace() == "/")
{
ROS_WARN("Started in the global namespace! This is probably wrong. Start image_topic_to_image "
"in the camera namespace.\nExample command-line usage:\n"
"\t$ ROS_NAMESPACE=my_camera rosrun image_topic_to_image image_topic_to_image");
}
// Shared parameters to be propagated to nodelet private namespaces
ros::NodeHandle private_nh("~");
XmlRpc::XmlRpcValue shared_params;
int queue_size;
if (private_nh.getParam("queue_size", queue_size))
shared_params["queue_size"] = queue_size;
nodelet::Loader manager(false); // Don't bring up the manager ROS API
nodelet::M_string remappings(ros::names::getRemappings());
nodelet::V_string my_argv;
std::string create_file_name = ros::this_node::getName() + "_create_file";
remappings["camera/image_raw"] = ros::names::resolve("image_raw");
remappings["camera/camera_info"] = ros::names::resolve("camera_info");
if (shared_params.valid())
ros::param::set(create_file_name, shared_params);
manager.load(create_file_name, "image_topic_to_image/create_file", remappings, my_argv);
// Check for only the original camera topics
ros::V_string topics;
topics.push_back(ros::names::resolve("image_raw"));
topics.push_back(ros::names::resolve("camera_info"));
image_topic_to_image::AdvertisementChecker check_inputs(ros::NodeHandle(), ros::this_node::getName());
check_inputs.start(topics, 60.0);
ros::spin();
return 0;
}
| 2,060
| 698
|
// Copyright (c) 2007-2017 Hartmut Kaiser
// Copyright (c) 2011 Bryce Lelbach
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if !defined(HPX_APPLIER_APPLY_HELPER_JUN_25_2008_0917PM)
#define HPX_APPLIER_APPLY_HELPER_JUN_25_2008_0917PM
#include <hpx/config.hpp>
#include <hpx/compat/thread.hpp>
#include <hpx/state.hpp>
#include <hpx/runtime_fwd.hpp>
#include <hpx/runtime/actions/action_support.hpp>
#include <hpx/runtime/naming/address.hpp>
#include <hpx/runtime/threads/thread_enums.hpp>
#include <hpx/runtime/threads/thread_helpers.hpp>
#include <hpx/traits/action_decorate_continuation.hpp>
#include <hpx/traits/action_continuation.hpp>
#include <hpx/traits/action_priority.hpp>
#include <hpx/traits/action_schedule_thread.hpp>
#include <hpx/traits/action_stacksize.hpp>
#include <hpx/util/decay.hpp>
#include <chrono>
#include <exception>
#include <memory>
#include <utility>
namespace hpx
{
bool HPX_EXPORT is_pre_startup();
}
namespace hpx { namespace applier { namespace detail
{
///////////////////////////////////////////////////////////////////////
template <typename Action>
inline threads::thread_priority
fix_priority(threads::thread_priority priority)
{
return hpx::actions::detail::thread_priority<
static_cast<threads::thread_priority>(
traits::action_priority<Action>::value)
>::call(priority);
}
///////////////////////////////////////////////////////////////////////
template <typename Action,
bool DirectExecute = Action::direct_execution::value>
struct apply_helper;
template <typename Action>
struct apply_helper<Action, /*DirectExecute=*/false>
{
template <typename ...Ts>
static void
call (threads::thread_init_data&& data, naming::id_type const& target,
naming::address::address_type lva,
naming::address::component_type comptype,
threads::thread_priority priority, Ts&&... vs)
{
typedef typename traits::action_continuation<Action>::type
continuation_type;
continuation_type cont;
if (traits::action_decorate_continuation<Action>::call(cont)) //-V614
{
data.func = Action::construct_thread_function(target,
std::move(cont), lva, comptype, std::forward<Ts>(vs)...);
}
else
{
data.func = Action::construct_thread_function(target, lva,
comptype, std::forward<Ts>(vs)...);
}
#if defined(HPX_HAVE_THREAD_TARGET_ADDRESS)
data.lva = lva;
#endif
#if defined(HPX_HAVE_THREAD_DESCRIPTION)
#if HPX_HAVE_ITTNOTIFY != 0 && !defined(HPX_HAVE_APEX)
data.description = util::thread_description(
actions::detail::get_action_name<Action>(),
actions::detail::get_action_name_itt<Action>());
#else
data.description = actions::detail::get_action_name<Action>();
#endif
#endif
data.priority = fix_priority<Action>(priority);
data.stacksize = threads::get_stack_size(
static_cast<threads::thread_stacksize>(
traits::action_stacksize<Action>::value));
while (!threads::threadmanager_is_at_least(state_running))
{
compat::this_thread::sleep_for(
std::chrono::milliseconds(HPX_NETWORK_RETRIES_SLEEP));
}
traits::action_schedule_thread<Action>::call(
lva, comptype, data, threads::pending);
}
template <typename Continuation, typename ...Ts>
static void
call (threads::thread_init_data&& data, Continuation && cont,
naming::id_type const& target, naming::address::address_type lva,
naming::address::component_type comptype,
threads::thread_priority priority, Ts&&... vs)
{
// first decorate the continuation
traits::action_decorate_continuation<Action>::call(cont);
// now, schedule the thread
data.func = Action::construct_thread_function(target,
std::forward<Continuation>(cont), lva, comptype,
std::forward<Ts>(vs)...);
#if defined(HPX_HAVE_THREAD_TARGET_ADDRESS)
data.lva = lva;
#endif
#if defined(HPX_HAVE_THREAD_DESCRIPTION)
#if HPX_HAVE_ITTNOTIFY != 0 && !defined(HPX_HAVE_APEX)
data.description = util::thread_description(
actions::detail::get_action_name<Action>(),
actions::detail::get_action_name_itt<Action>());
#else
data.description = actions::detail::get_action_name<Action>();
#endif
#endif
data.priority = fix_priority<Action>(priority);
data.stacksize = threads::get_stack_size(
static_cast<threads::thread_stacksize>(
traits::action_stacksize<Action>::value));
while (!threads::threadmanager_is_at_least(state_running))
{
compat::this_thread::sleep_for(
std::chrono::milliseconds(HPX_NETWORK_RETRIES_SLEEP));
}
traits::action_schedule_thread<Action>::call(
lva, comptype, data, threads::pending);
}
};
///////////////////////////////////////////////////////////////////////////
template <typename Action>
struct apply_helper<Action, /*DirectExecute=*/true>
{
// If local and to be directly executed, just call the function
template <typename ...Ts>
HPX_FORCEINLINE static void
call (threads::thread_init_data&& data, naming::id_type const& target,
naming::address::address_type lva,
naming::address::component_type comptype,
threads::thread_priority priority, Ts &&... vs)
{
// Direct actions should be able to be executed from a non-HPX thread
// as well
if (this_thread::has_sufficient_stack_space() ||
!threads::threadmanager_is_at_least(state_running))
{
Action::execute_function(lva, comptype, std::forward<Ts>(vs)...);
}
else
{
apply_helper<Action, false>::call(std::move(data), target, lva,
comptype, priority, std::forward<Ts>(vs)...);
}
}
template <typename Continuation, typename ...Ts>
HPX_FORCEINLINE static void
call (threads::thread_init_data&& data, Continuation && cont,
naming::id_type const& target, naming::address::address_type lva,
naming::address::component_type comptype,
threads::thread_priority priority, Ts &&... vs)
{
// Direct actions should be able to be executed from a non-HPX thread
// as well
if (this_thread::has_sufficient_stack_space() ||
!threads::threadmanager_is_at_least(state_running))
{
try {
cont.trigger_value(Action::execute_function(lva, comptype,
std::forward<Ts>(vs)...));
}
catch (...) {
// make sure hpx::exceptions are propagated back to the
// client
cont.trigger_error(std::current_exception());
}
}
else
{
apply_helper<Action, false>::call(std::move(data),
std::forward<Continuation>(cont),
target, lva, comptype, priority, std::forward<Ts>(vs)...);
}
}
};
}}}
#endif
| 7,842
| 2,286
|
/**********************************************************************
* Copyright (c) 2008-2015, Alliance for Sustainable Energy.
* All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********************************************************************/
#ifndef MODEL_BLIND_HPP
#define MODEL_BLIND_HPP
#include "ModelAPI.hpp"
#include "ShadingMaterial.hpp"
namespace openstudio {
class Quantity;
class OSOptionalQuantity;
namespace model {
namespace detail {
class Blind_Impl;
} // detail
/** Blind is a ShadingMaterial that wraps the OpenStudio IDD object 'OS:WindowMaterial:Blind'. */
class MODEL_API Blind : public ShadingMaterial {
public:
/** @name Constructors and Destructors */
//@{
explicit Blind(const Model& model,
double slatWidth = 0.025,
double slatSeparation = 0.01875,
double frontSideSlatBeamSolarReflectance = 0.5,
double backSideSlatBeamSolarReflectance = 0.5,
double frontSideSlatDiffuseSolarReflectance = 0.5,
double backSideSlatDiffuseSolarReflectance = 0.5,
double slatBeamVisibleTransmittance = 0.0);
virtual ~Blind() {}
//@}
static IddObjectType iddObjectType();
static std::vector<std::string> slatOrientationValues();
/** @name Getters */
//@{
std::string slatOrientation() const;
bool isSlatOrientationDefaulted() const;
double slatWidth() const;
Quantity getSlatWidth(bool returnIP=false) const;
double slatSeparation() const;
Quantity getSlatSeparation(bool returnIP=false) const;
double slatThickness() const;
Quantity getSlatThickness(bool returnIP=false) const;
bool isSlatThicknessDefaulted() const;
double slatAngle() const;
Quantity getSlatAngle(bool returnIP=false) const;
bool isSlatAngleDefaulted() const;
double slatConductivity() const;
Quantity getSlatConductivity(bool returnIP=false) const;
bool isSlatConductivityDefaulted() const;
double slatBeamSolarTransmittance() const;
Quantity getSlatBeamSolarTransmittance(bool returnIP=false) const;
bool isSlatBeamSolarTransmittanceDefaulted() const;
double frontSideSlatBeamSolarReflectance() const;
Quantity getFrontSideSlatBeamSolarReflectance(bool returnIP=false) const;
double backSideSlatBeamSolarReflectance() const;
Quantity getBackSideSlatBeamSolarReflectance(bool returnIP=false) const;
double slatDiffuseSolarTransmittance() const;
Quantity getSlatDiffuseSolarTransmittance(bool returnIP=false) const;
bool isSlatDiffuseSolarTransmittanceDefaulted() const;
double frontSideSlatDiffuseSolarReflectance() const;
Quantity getFrontSideSlatDiffuseSolarReflectance(bool returnIP=false) const;
double backSideSlatDiffuseSolarReflectance() const;
Quantity getBackSideSlatDiffuseSolarReflectance(bool returnIP=false) const;
double slatBeamVisibleTransmittance() const;
Quantity getSlatBeamVisibleTransmittance(bool returnIP=false) const;
boost::optional<double> frontSideSlatBeamVisibleReflectance() const;
OSOptionalQuantity getFrontSideSlatBeamVisibleReflectance(bool returnIP=false) const;
boost::optional<double> backSideSlatBeamVisibleReflectance() const;
OSOptionalQuantity getBackSideSlatBeamVisibleReflectance(bool returnIP=false) const;
double slatDiffuseVisibleTransmittance() const;
Quantity getSlatDiffuseVisibleTransmittance(bool returnIP=false) const;
bool isSlatDiffuseVisibleTransmittanceDefaulted() const;
boost::optional<double> frontSideSlatDiffuseVisibleReflectance() const;
OSOptionalQuantity getFrontSideSlatDiffuseVisibleReflectance(bool returnIP=false) const;
boost::optional<double> backSideSlatDiffuseVisibleReflectance() const;
OSOptionalQuantity getBackSideSlatDiffuseVisibleReflectance(bool returnIP=false) const;
double slatInfraredHemisphericalTransmittance() const;
Quantity getSlatInfraredHemisphericalTransmittance(bool returnIP=false) const;
bool isSlatInfraredHemisphericalTransmittanceDefaulted() const;
double frontSideSlatInfraredHemisphericalEmissivity() const;
Quantity getFrontSideSlatInfraredHemisphericalEmissivity(bool returnIP=false) const;
bool isFrontSideSlatInfraredHemisphericalEmissivityDefaulted() const;
double backSideSlatInfraredHemisphericalEmissivity() const;
Quantity getBackSideSlatInfraredHemisphericalEmissivity(bool returnIP=false) const;
bool isBackSideSlatInfraredHemisphericalEmissivityDefaulted() const;
double blindtoGlassDistance() const;
Quantity getBlindtoGlassDistance(bool returnIP=false) const;
bool isBlindtoGlassDistanceDefaulted() const;
double blindTopOpeningMultiplier() const;
Quantity getBlindTopOpeningMultiplier(bool returnIP=false) const;
bool isBlindTopOpeningMultiplierDefaulted() const;
double blindBottomOpeningMultiplier() const;
Quantity getBlindBottomOpeningMultiplier(bool returnIP=false) const;
bool isBlindBottomOpeningMultiplierDefaulted() const;
double blindLeftSideOpeningMultiplier() const;
Quantity getBlindLeftSideOpeningMultiplier(bool returnIP=false) const;
bool isBlindLeftSideOpeningMultiplierDefaulted() const;
double blindRightSideOpeningMultiplier() const;
Quantity getBlindRightSideOpeningMultiplier(bool returnIP=false) const;
bool isBlindRightSideOpeningMultiplierDefaulted() const;
double minimumSlatAngle() const;
Quantity getMinimumSlatAngle(bool returnIP=false) const;
bool isMinimumSlatAngleDefaulted() const;
double maximumSlatAngle() const;
Quantity getMaximumSlatAngle(bool returnIP=false) const;
bool isMaximumSlatAngleDefaulted() const;
//@}
/** @name Setters */
//@{
bool setSlatOrientation(std::string slatOrientation);
void resetSlatOrientation();
bool setSlatWidth(double slatWidth);
bool setSlatWidth(const Quantity& slatWidth);
bool setSlatSeparation(double slatSeparation);
bool setSlatSeparation(const Quantity& slatSeparation);
bool setSlatThickness(double slatThickness);
bool setSlatThickness(const Quantity& slatThickness);
void resetSlatThickness();
bool setSlatAngle(double slatAngle);
bool setSlatAngle(const Quantity& slatAngle);
void resetSlatAngle();
bool setSlatConductivity(double slatConductivity);
bool setSlatConductivity(const Quantity& slatConductivity);
void resetSlatConductivity();
bool setSlatBeamSolarTransmittance(double slatBeamSolarTransmittance);
bool setSlatBeamSolarTransmittance(const Quantity& slatBeamSolarTransmittance);
void resetSlatBeamSolarTransmittance();
bool setFrontSideSlatBeamSolarReflectance(double frontSideSlatBeamSolarReflectance);
bool setFrontSideSlatBeamSolarReflectance(const Quantity& frontSideSlatBeamSolarReflectance);
bool setBackSideSlatBeamSolarReflectance(double backSideSlatBeamSolarReflectance);
bool setBackSideSlatBeamSolarReflectance(const Quantity& backSideSlatBeamSolarReflectance);
bool setSlatDiffuseSolarTransmittance(double slatDiffuseSolarTransmittance);
bool setSlatDiffuseSolarTransmittance(const Quantity& slatDiffuseSolarTransmittance);
void resetSlatDiffuseSolarTransmittance();
bool setFrontSideSlatDiffuseSolarReflectance(double frontSideSlatDiffuseSolarReflectance);
bool setFrontSideSlatDiffuseSolarReflectance(const Quantity& frontSideSlatDiffuseSolarReflectance);
bool setBackSideSlatDiffuseSolarReflectance(double backSideSlatDiffuseSolarReflectance);
bool setBackSideSlatDiffuseSolarReflectance(const Quantity& backSideSlatDiffuseSolarReflectance);
bool setSlatBeamVisibleTransmittance(double slatBeamVisibleTransmittance);
bool setSlatBeamVisibleTransmittance(const Quantity& slatBeamVisibleTransmittance);
bool setFrontSideSlatBeamVisibleReflectance(double frontSideSlatBeamVisibleReflectance);
bool setFrontSideSlatBeamVisibleReflectance(const Quantity& frontSideSlatBeamVisibleReflectance);
void resetFrontSideSlatBeamVisibleReflectance();
bool setBackSideSlatBeamVisibleReflectance(double backSideSlatBeamVisibleReflectance);
bool setBackSideSlatBeamVisibleReflectance(const Quantity& backSideSlatBeamVisibleReflectance);
void resetBackSideSlatBeamVisibleReflectance();
bool setSlatDiffuseVisibleTransmittance(double slatDiffuseVisibleTransmittance);
bool setSlatDiffuseVisibleTransmittance(const Quantity& slatDiffuseVisibleTransmittance);
void resetSlatDiffuseVisibleTransmittance();
bool setFrontSideSlatDiffuseVisibleReflectance(double frontSideSlatDiffuseVisibleReflectance);
bool setFrontSideSlatDiffuseVisibleReflectance(const Quantity& frontSideSlatDiffuseVisibleReflectance);
void resetFrontSideSlatDiffuseVisibleReflectance();
bool setBackSideSlatDiffuseVisibleReflectance(double backSideSlatDiffuseVisibleReflectance);
bool setBackSideSlatDiffuseVisibleReflectance(const Quantity& backSideSlatDiffuseVisibleReflectance);
void resetBackSideSlatDiffuseVisibleReflectance();
bool setSlatInfraredHemisphericalTransmittance(double slatInfraredHemisphericalTransmittance);
bool setSlatInfraredHemisphericalTransmittance(const Quantity& slatInfraredHemisphericalTransmittance);
void resetSlatInfraredHemisphericalTransmittance();
bool setFrontSideSlatInfraredHemisphericalEmissivity(double frontSideSlatInfraredHemisphericalEmissivity);
bool setFrontSideSlatInfraredHemisphericalEmissivity(const Quantity& frontSideSlatInfraredHemisphericalEmissivity);
void resetFrontSideSlatInfraredHemisphericalEmissivity();
bool setBackSideSlatInfraredHemisphericalEmissivity(double backSideSlatInfraredHemisphericalEmissivity);
bool setBackSideSlatInfraredHemisphericalEmissivity(const Quantity& backSideSlatInfraredHemisphericalEmissivity);
void resetBackSideSlatInfraredHemisphericalEmissivity();
bool setBlindtoGlassDistance(double blindtoGlassDistance);
bool setBlindtoGlassDistance(const Quantity& blindtoGlassDistance);
void resetBlindtoGlassDistance();
bool setBlindTopOpeningMultiplier(double blindTopOpeningMultiplier);
bool setBlindTopOpeningMultiplier(const Quantity& blindTopOpeningMultiplier);
void resetBlindTopOpeningMultiplier();
bool setBlindBottomOpeningMultiplier(double blindBottomOpeningMultiplier);
bool setBlindBottomOpeningMultiplier(const Quantity& blindBottomOpeningMultiplier);
void resetBlindBottomOpeningMultiplier();
bool setBlindLeftSideOpeningMultiplier(double blindLeftSideOpeningMultiplier);
bool setBlindLeftSideOpeningMultiplier(const Quantity& blindLeftSideOpeningMultiplier);
void resetBlindLeftSideOpeningMultiplier();
bool setBlindRightSideOpeningMultiplier(double blindRightSideOpeningMultiplier);
bool setBlindRightSideOpeningMultiplier(const Quantity& blindRightSideOpeningMultiplier);
void resetBlindRightSideOpeningMultiplier();
bool setMinimumSlatAngle(double minimumSlatAngle);
bool setMinimumSlatAngle(const Quantity& minimumSlatAngle);
void resetMinimumSlatAngle();
bool setMaximumSlatAngle(double maximumSlatAngle);
bool setMaximumSlatAngle(const Quantity& maximumSlatAngle);
void resetMaximumSlatAngle();
//@}
/** @name Other */
//@{
//@}
protected:
/// @cond
typedef detail::Blind_Impl ImplType;
explicit Blind(std::shared_ptr<detail::Blind_Impl> impl);
friend class detail::Blind_Impl;
friend class Model;
friend class IdfObject;
friend class openstudio::detail::IdfObject_Impl;
/// @endcond
private:
REGISTER_LOGGER("openstudio.model.Blind");
};
/** \relates Blind*/
typedef boost::optional<Blind> OptionalBlind;
/** \relates Blind*/
typedef std::vector<Blind> BlindVector;
} // model
} // openstudio
#endif // MODEL_BLIND_HPP
| 12,353
| 4,006
|
#include <algorithm>
#include <iterator>
#define CATCH_CONFIG_PREFIX_ALL
#include "perceive/calibration/aruco-cube.hpp"
#include "perceive/contrib/catch.hpp"
#include "perceive/geometry.hpp"
#include "perceive/geometry/projective/binocular-camera.hpp"
namespace perceive
{
static const string c1001_v6 = R"V0G0N(
{
"camera-id": "C0001001_v6",
"rotation-axis": [-5.289019071995259002605e-01, -8.037447439841696184004e-01, 2.725016680295973547921e-01],
"rotation-angle": 4.403040718534967368214e-02,
"t": [-9.999691706199903551422e-01, 4.682000672898050178117e-03, -6.303703615144396268932e-03],
"baseline": 1.677118998537401595161e-01,
"sensor0":
{
"model": "polynomial<8>",
"sensor-id": "STR00017",
"format": [2592, 1944],
"center": [1.259908344467880397133e+03, 9.543476067019000765868e+02],
"scale": 1.733503229994983732207e-03,
"calib-region": [82.4137, 125.912, 2499.89, 1843.35],
"A":
[[4.081363182094257385790e-04, 7.846591271087714758448e-05, 1.117749802370410043550e-03, 2.050148110624722824769e-04, 8.499430114145657211636e-04, 1.202137033918700137480e-04, 2.657899442004324659650e-04, 2.557591866361383359241e-05, 1.478675890686819479475e-04, 3.551415648586637562739e-03, -4.607412044975141632297e-05, 1.061446051619520727916e-02, -4.051013608679160577820e-05, 9.430254182018919795194e-03, -7.433659454589812420888e-05, 2.520923581562218521862e-03, -8.578724808384115968485e-05, -2.794302257206254802568e-03, -1.184080115168654676050e-03, -4.807017326956552344397e-03, -1.889330041735894083477e-03, -1.854248730084105331595e-03, -5.923062148343941069051e-04, -6.226051325912054096312e-04, -7.918204510909552379383e-03, 2.807659980136358035541e-04, -1.386692371503723923698e-02, 3.144186716624482180737e-04, -3.137869973570229370496e-03, 3.464792809319654220968e-04, 7.406920122703386510921e-03, 1.918694069271629750253e-03, 6.451037704162667155150e-03, 8.917384701673108926556e-04, 9.915152431928843379527e-04, 6.928405896704332989078e-02, -1.756316883927931671305e-04, 6.449975726755774463328e-02, -4.511063214778510133129e-04, -2.036354542474170387090e-03, -5.293037764114348620037e-03, -1.087122720821221549814e-03, 5.137947864186872548586e-01, 5.065063338827674541825e-04, 4.882256460082610299844e-02],
[2.415619570788307658108e-05, 3.020746602274122869641e-04, 1.374092341015142274691e-04, 6.174744303661985336470e-04, 1.455262958724064248361e-04, 2.937011790217409525072e-04, -3.602390364017271640051e-05, -2.319655276377142745330e-05, -6.724065902904974301180e-05, -1.045114328824338400040e-05, 3.487486800742341502141e-03, -4.192946074774118667139e-05, 9.147459014495772783304e-03, -6.302296973057191879775e-05, 7.339344583677403534294e-03, -3.002658437739483612838e-05, 1.818669534496500199416e-03, -2.348697602473663256784e-04, -1.735129306810551108597e-03, -1.336041998393913817975e-03, -1.639638486985247386313e-03, -1.056904463852648135003e-03, 9.235646859584206898319e-05, -1.235380936145946684235e-05, 6.549325746959058780483e-05, -6.470080080674704345323e-03, 2.144445755465525238481e-04, -4.865152943111726926984e-03, 9.600404768035815383787e-05, 1.985069646551262945167e-03, 7.123550072457365822665e-04, 3.971930067778821002444e-03, 1.223496889110331498074e-03, 1.469815532720685456736e-03, -5.141728148921054231124e-04, -2.007789192047726087309e-04, 6.315384976319464438443e-02, 1.232334347574595700969e-05, 5.335636347570283516406e-02, -7.757682209504875373018e-04, 1.701908258753077364533e-03, -4.529528852638423086496e-03, -4.330224473192770262564e-04, 5.188048489012443420521e-01, -1.066161721393027624061e-02]],
"calib-hull": [[82.4137, 994.589], [82.7395, 912.795], [85.3685, 871.576], [92.3784, 775.055], [111.127, 642.099], [138.231, 516.635], [171.755, 400.84], [216.257, 372.164], [271.933, 343.728], [286.076, 336.848], [368.694, 298.754], [446.104, 267.531], [463.093, 261.22], [486.837, 252.871], [557.389, 229.269], [576.681, 223.354], [605.074, 215.252], [687.066, 192.667], [709.383, 187.521], [741.772, 180.559], [805.271, 167.766], [835.322, 161.766], [860.417, 157.08], [896.734, 151.781], [999.599, 138.492], [1026.97, 135.686], [1065.98, 132.822], [1175.51, 126.613], [1203.93, 126.197], [1244.34, 125.912], [1354.78, 128.147], [1383.09, 129.904], [1422.63, 132.578], [1496.12, 139.68], [1529.49, 143.017], [1556.09, 146.504], [1593.15, 152.095], [1661.32, 163.546], [1691.41, 168.604], [1716.05, 173.134], [1749.25, 180.858], [1836.85, 201.752], [1858.53, 207.677], [1887.77, 216.351], [1915.64, 224.752], [1963.5, 239.446], [1982.11, 245.471], [2007.04, 254.468], [2052.54, 271.451], [2072.39, 278.928], [2087.93, 285], [2109.35, 293.832], [2147.74, 310.319], [2177.11, 323.306], [2212.51, 340.414], [2266.29, 367.373], [2282.88, 376.233], [2336.32, 405.799], [2342.31, 409.657], [2426.92, 466.272], [2454.03, 570.463], [2476.27, 680.971], [2491.85, 796.413], [2499.89, 915.432], [2499.46, 1035.58], [2491.39, 1154.54], [2475.95, 1269.77], [2453.58, 1379.92], [2426.41, 1482.96], [2383.01, 1512.72], [2348.33, 1535.02], [2326.94, 1547.95], [2285.49, 1572.44], [2147.68, 1649.75], [2059.28, 1687.99], [2036.64, 1696.75], [1956.44, 1726.57], [1913.45, 1741], [1838.17, 1763.23], [1788.82, 1776.6], [1704.06, 1796.15], [1648.84, 1806.85], [1555.2, 1822.09], [1495.53, 1829.43], [1395.3, 1838.39], [1332.84, 1841.68], [1229.52, 1843.35], [1191.18, 1842.53], [1166.66, 1842], [1064.71, 1836.18], [1027.51, 1832.73], [1003.98, 1830.47], [907.22, 1817.6], [872.222, 1811.98], [850.59, 1808.28], [761.806, 1790.37], [730.341, 1782.97], [710.577, 1778.24], [631.272, 1756.58], [603.563, 1748.4], [586.526, 1743.08], [517.243, 1719.7], [492.838, 1710.75], [478.08, 1705.22], [418.06, 1681.11], [384.471, 1666.8], [332.937, 1643.06], [315.234, 1634.4], [304.34, 1628.77], [245.08, 1598], [235.749, 1592.75], [177.24, 1558.86], [146.527, 1459], [120.765, 1351.49], [100.792, 1237.1], [95.3592, 1189.32], [87.6047, 1117.45], [83.8578, 1052.18], [82.4137, 994.589]]
}
,
"sensor1":
{
"model": "polynomial<8>",
"sensor-id": "STR00018",
"format": [2592, 1944],
"center": [1.365996599067576426023e+03, 9.619834715588560811739e+02],
"scale": 1.736291840401992837839e-03,
"calib-region": [78.7126, 124.979, 2550.85, 1835],
"A":
[[-5.315756199690442607153e-04, 8.046465077178252545131e-05, -1.522758043595403253112e-03, 1.346582592538676792504e-04, -1.498953500720120665668e-03, -6.184453678833223486122e-05, -6.962423581377014808469e-04, -1.119249465862583864384e-04, -1.757216516818263345179e-04, 3.669268064188274322546e-03, 1.766078796994431307499e-04, 1.084797525230436418542e-02, 3.153399946020565142168e-04, 9.496429630240233940586e-03, 1.092412281521589964561e-04, 2.439028130512555393034e-03, 7.932339148422444530251e-06, 5.173378866164785039317e-03, -1.050818808285107486267e-03, 1.001481104868468668956e-02, -1.178458695038332726401e-03, 5.313466479842779421894e-03, -2.664260414071695226568e-06, 8.827648883154804934636e-04, -8.440530738109436326155e-03, -9.967795995024439359433e-04, -1.417627701385058489048e-02, -8.585297867090037338134e-04, -2.727156356488617816591e-03, -4.331716336005569933931e-05, -1.249821847767965121712e-02, 1.441495676987598895114e-03, -1.268309194468521944321e-02, 1.173228543019655401025e-04, -2.004245713858156599518e-03, 7.111781150188134503765e-02, 1.119815287340029941188e-03, 6.509604266012522510998e-02, -1.582743336962632446641e-04, 1.671795931208419627723e-02, -4.906944105397343519614e-03, 2.868963539565123899155e-03, 5.172421081249921614997e-01, -2.643700981644531849968e-03, 4.824947005114835207884e-02],
[3.578825528978738738234e-05, -3.932581736850303960606e-04, 1.884504816094725171416e-04, -8.019180890467313485570e-04, 4.201937561761591444220e-04, -1.459995350831010466064e-04, 4.827778197111758790028e-04, 4.487328898503959231925e-04, 1.637110298065916347277e-04, 3.988925765715015635260e-05, 3.533145510380931650363e-03, 2.008976838215881244309e-04, 9.168158870775627855565e-03, 8.693744979788257248865e-05, 6.942543139443178162873e-03, -2.407835536954059871273e-04, 1.457883788077445844783e-03, -3.201801397215240513328e-04, 3.570788063624465158430e-03, -1.674870996303291781349e-03, 4.171110785729122832910e-03, -2.426937210629385999194e-03, -5.498491718434490166389e-04, -9.597464068950289917126e-04, -2.055548056429101766440e-04, -6.403146838894081122051e-03, -5.676372262405880719793e-04, -3.853991144828171344638e-03, 4.452330757886771572807e-04, 3.387757367917261681900e-03, 9.799256737675569178814e-04, -6.438375170346698206369e-03, 2.286510576990127829866e-03, -1.055892257477417106593e-03, 8.581349086410200444064e-04, 6.479658737773563714768e-04, 6.348403960312912208686e-02, 5.361297573553552853198e-04, 5.271980626052616414334e-02, -8.809615456876473960079e-04, 8.757857304262026132413e-03, -4.984164990529466737756e-03, 2.046508215556562884641e-03, 5.230369314085653309476e-01, -1.336270119324906371916e-02]],
"calib-hull": [[78.7126, 952.206], [83.8904, 844.077], [95.0449, 738.086], [112.615, 635.416], [135.392, 537.371], [162.807, 483.393], [188.535, 444.362], [237.205, 413.567], [252.003, 404.348], [312.761, 369.838], [313.887, 369.244], [363.366, 343.786], [385.316, 332.68], [386.505, 332.104], [471.656, 293.466], [576.639, 252.499], [659.697, 225.38], [699.404, 212.759], [796.943, 187.599], [843.354, 176.447], [927.762, 160.777], [955.203, 155.725], [1005.17, 147.377], [1131.6, 133.681], [1185.78, 129.132], [1319.61, 125.309], [1375.64, 124.979], [1378.18, 125.104], [1509.81, 131.899], [1566.71, 136.438], [1692.12, 152.882], [1742.75, 161.106], [1744.76, 161.437], [1858.47, 185.055], [1903.32, 195.688], [1905.22, 196.176], [2004.54, 224.377], [2044.8, 236.747], [2163.27, 279.414], [2262.98, 322.01], [2345.37, 362.694], [2384.42, 383.952], [2422.21, 405.414], [2443.01, 417.768], [2456.45, 426.214], [2477.64, 478.807], [2507.54, 589.064], [2526.71, 688.715], [2540.66, 793.045], [2549.13, 899.659], [2550.85, 1007.61], [2546.54, 1114.82], [2536.17, 1219.73], [2520.19, 1320.95], [2499.35, 1417.38], [2475.19, 1507.31], [2440.16, 1546.05], [2405.36, 1566.8], [2360.57, 1591.58], [2335.4, 1604.71], [2301.76, 1621.42], [2282.35, 1630.83], [2252.32, 1645.11], [2212.22, 1662.58], [2189.27, 1672.35], [2153.23, 1687.03], [2106.01, 1704.78], [2078.78, 1714.48], [2036.09, 1729.05], [1981.68, 1746.26], [1948.45, 1755.2], [1898.84, 1768.16], [1835.64, 1783.4], [1797.89, 1790.78], [1741.66, 1801.38], [1670.68, 1812.55], [1629.05, 1817.68], [1567.22, 1824.6], [1489.89, 1830.55], [1446.66, 1832.46], [1373.18, 1835], [1238.91, 1833.7], [1215.23, 1832.66], [1085.14, 1822.4], [1062.44, 1820.04], [940.302, 1802.12], [919.235, 1798.5], [808.059, 1774.77], [670.717, 1736.19], [586.083, 1706.27], [548.654, 1692.41], [496.151, 1670.69], [479.206, 1663.42], [463.843, 1656.66], [461.859, 1655.76], [419.036, 1636.25], [403.82, 1629.17], [388.657, 1621.52], [351.652, 1602.49], [326.098, 1588.83], [294.196, 1570.64], [273.319, 1558.46], [244.333, 1541.17], [200.765, 1513.25], [185.281, 1502.17], [148.646, 1469.08], [123.563, 1373.42], [103.197, 1272.74], [88.8354, 1168.51], [80.5573, 1060.87], [78.7126, 952.206]]
}
}
)V0G0N";
CATCH_TEST_CASE("EuclideanTransform", "[euclidean_transform]")
{
CATCH_SECTION("TestEuclideanTransform")
{
const auto aa1 = Vector4{0.1, 1.0, 1.0, to_radians(35.0)};
const auto aa2 = Vector4{0.2, 0.4, 1.0, to_radians(15.0)};
const auto e1 = EuclideanTransform(
Vector3(0.1, 0.2, 1.0), axis_angle_to_quaternion(aa1), 6.0);
const auto e2 = EuclideanTransform(
Vector3{1.0, 1.1, 1.2}, axis_angle_to_quaternion(aa2), 2.0);
auto test_it = [](const auto& et, const Vector3& X) {
auto Y1 = et.apply(X);
Matrix4r M = make_transform_matrix(et);
Vector4r Z = M * Vector4r(X(0), X(1), X(2), 1.0);
auto Y2 = Vector3(Z(0), Z(1), Z(2)) / Z(3);
auto err = (Y2 - Y1).norm();
if(false) {
cout << "--------------------" << endl;
cout << format("et = {:s}, X = {:s}", str(et), str(X)) << endl;
cout << format("|{:s} - {:s}| = {}", str(Y1), str(Y2), err) << endl;
cout << endl;
}
CATCH_REQUIRE(fabs(err) < 1e-9);
};
test_it(e1, Vector3{1.0, 0.0, 0.0});
test_it(e1, Vector3{1.0, 1.0, 0.0});
test_it(e1, Vector3{1.0, 1.0, 1.0});
test_it(e2, Vector3{1.0, 0.0, 0.0});
test_it(e2, Vector3{1.0, 1.0, 0.0});
test_it(e2, Vector3{1.0, 1.0, 1.0});
auto test_e12 = [&](const auto& e1, const auto& e2, const Vector3& X) {
const auto et = compose(e1, e2);
auto Y = e1.apply(X);
auto Z = e2.apply(Y);
auto W = et.apply(X);
Matrix4r M1 = make_transform_matrix(e1);
Matrix4r M2 = make_transform_matrix(e2);
Matrix4r M = M2 * M1;
Vector4r U = M * Vector4r(X(0), X(1), X(2), 1.0);
auto V = Vector3(U(0), U(1), U(2)) / U(3);
auto err = (W - Z).norm();
auto err1 = (W - V).norm();
auto err2 = (V - Z).norm();
if(false) {
cout << "--------------------" << endl;
cout << format("X = {:s}", str(X)) << endl;
cout << format("e1 = {:s}, Y = {:s}", str(e1), str(Y)) << endl;
cout << format("e2 = {:s}, Z = {:s}", str(e2), str(Z)) << endl;
cout << format("et = {:s}, W = {:s}", str(et), str(W)) << endl;
cout << format("|{:s} - {:s}| = {}", str(W), str(Z), err) << endl;
cout << format("|{:s} - {:s}| = {}", str(W), str(V), err1) << endl;
cout << format("|{:s} - {:s}| = {}", str(V), str(Z), err2) << endl;
cout << endl;
}
CATCH_REQUIRE(fabs(err) < 1e-9);
CATCH_REQUIRE(fabs(err1) < 1e-9);
CATCH_REQUIRE(fabs(err2) < 1e-9);
};
test_e12(e1, e2, Vector3{1.0, 0.0, 0.0});
test_e12(e1, e2, Vector3{1.0, 1.0, 0.0});
test_e12(e1, e2, Vector3{1.0, 1.0, 1.0});
test_e12(e1, e2, Vector3{1.0, 0.0, 1.0});
auto test_i12 = [&](const auto& e1, const auto& e2, const Vector3& X) {
const auto et = compose(e1, e2);
const auto ez = et / e2; // ez should be the same as e1
auto Y = e1.apply(X);
auto Z = e2.apply(Y);
auto V = e2.inverse_apply(Z); // Should be Y
auto W = ez.apply(X); // Should be Y
auto err1 = (Y - V).norm();
auto err2 = (Y - W).norm();
if(false) {
cout << "--------------------" << endl;
cout << format("X = {:s}", str(X)) << endl;
cout << format("e1 = {:s}, Y = {:s}", str(e1), str(Y)) << endl;
cout << format("e2 = {:s}, Z = {:s}", str(e2), str(Z)) << endl;
cout << format("et = {:s}, W = {:s}", str(et), str(W)) << endl;
cout << format("ez = {:s}, W = {:s}", str(et), str(W)) << endl;
cout << format("|{:s} - {:s}| = {}", str(Y), str(V), err1) << endl;
cout << format("|{:s} - {:s}| = {}", str(Y), str(W), err2) << endl;
cout << endl;
}
CATCH_REQUIRE(fabs(err1) < 1e-9);
CATCH_REQUIRE(fabs(err2) < 1e-9);
};
test_i12(e1, e2, Vector3{1.0, 0.0, 0.0});
test_i12(e1, e2, Vector3{1.0, 1.0, 0.0});
test_i12(e1, e2, Vector3{1.0, 1.0, 1.0});
test_i12(e1, e2, Vector3{1.0, 0.0, 1.0});
auto test_inverse = [&](const auto& e1, const Vector3& X) {
const auto e_inv = EuclideanTransform{} / e1;
auto A = e1.apply(X);
auto B = e_inv.inverse_apply(X);
auto err = (A - B).norm();
if(false) {
cout << "--------------------" << endl;
cout << format("X = {:s}", str(X)) << endl;
cout << format("e1 = {:s}, Y = {:s}", str(e1), str(A)) << endl;
cout << format("ei = {:s}, Z = {:s}", str(e_inv), str(B)) << endl;
cout << format("|{:s} - {:s}| = {}", str(A), str(B), err) << endl;
cout << endl;
}
CATCH_REQUIRE(fabs(err) < 1e-9);
};
test_inverse(e1, Vector3{1.0, 0.0, 0.0});
test_inverse(e1, Vector3{1.0, 1.0, 0.0});
test_inverse(e1, Vector3{1.0, 1.0, 1.0});
test_inverse(e1, Vector3{1.0, 0.0, 1.0});
test_inverse(e2, Vector3{1.0, 0.0, 0.0});
test_inverse(e2, Vector3{1.0, 1.0, 0.0});
test_inverse(e2, Vector3{1.0, 1.0, 1.0});
test_inverse(e2, Vector3{1.0, 0.0, 1.0});
}
CATCH_SECTION("TestKabschAlgorithm")
{
const vector<Vector3> A{{{1.520167, 2.2585, 0.0641333},
{2.95617, 0.3275, 0.224667},
{1.13917, 0.1735, 0.0391333},
{1.13617, 0.6435, 0.0391333},
{3.11083, 0.5545, 0.0411333},
{2.64083, 0.5595, 0.0411333}}};
const auto N = A.size();
const Quaternion q
= Quaternion::between_vectors(Vector3(0, 0, 1), Vector3(0.2, 1.8, 0));
const Vector3 C0
= std::accumulate(cbegin(A), cend(A), Vector3(0, 0, 0)) / real(N);
const Vector3 C1 = Vector3(9.1, -2.0, -2.5);
vector<Vector3> B(A.size());
std::transform(cbegin(A), cend(A), begin(B), [&](const auto& X) {
return q.rotate(X - C0) + C1;
});
const auto et = transform_between(A, B);
for(auto i = 0u; i < N; ++i)
CATCH_REQUIRE((et.apply(A[i]) - B[i]).norm() < 1e-9);
}
CATCH_SECTION("et-pack-unpack-6df")
{
std::mt19937 gen;
std::uniform_real_distribution<double> distribution{0.0, 1.0};
gen.seed(123456);
auto rand = [&](real a, real b) -> real {
return (b - a) * distribution(gen) + a;
};
auto rand_X = [&]() {
return Vector3(
rand(-100.0, 100.0), rand(-100.0, 100.0), rand(-100.0, 100.0));
};
auto rand_et = [&]() {
EuclideanTransform et;
et.scale = rand(0.5, 1.5);
et.translation
= Vector3(rand(-1.0, 1.0), rand(-1.0, 1.0), rand(-1.0, 1.0));
et.rotation = saa_to_quaternion(
Vector3(rand(-M_PI, M_PI), rand(-M_PI, M_PI), rand(-M_PI, M_PI)));
return et;
};
auto test_it
= [&](const EuclideanTransform& et0, const EuclideanTransform& et1) {
const auto X = rand_X();
const auto Y = et0.apply(X);
const auto Z = et1.apply(X);
const auto err = (Y - Z).norm();
// INFO(format("|{} - {}| = {}", str(Y), str(Z), err));
// if(std::fabs(err) > 1e-3) FATAL("kAABM!");
CATCH_REQUIRE(true);
};
auto test_et = [&](const EuclideanTransform& et0) {
array<real, 6> Xs;
pack_et_6df(et0, Xs.data());
const auto et1 = unpack_et_6df(Xs.data());
test_it(et0, et1); // should produce the same transformations
};
for(auto i = 0; i < 100; ++i) test_et(rand_et());
}
CATCH_SECTION("et_with_bcam")
{
vector<Vector3> Ws{{{3.0920, 3.4870, 0.7400},
{3.0920, 1.1370, 0.7400},
{2.0870, 1.1370, 0.7400},
{2.0870, 3.4870, 0.7400}}};
// C1001_v6
vector<Vector2> Ps{{{1167, 601}, {1907, 1063}, {1603, 1428}, {859, 738}}};
vector<Vector2> Qs{{{1176, 642}, {1893, 1102}, {1555, 1469}, {868, 774}}};
const auto N = Ws.size();
Expects(N == Ps.size());
Expects(N == Qs.size());
// Load bcam_info
BinocularCameraInfo bcam;
read(bcam, c1001_v6);
// Transform for Cam0
EuclideanTransform et0, et1;
et0.scale = 1.0;
et0.translation
= Vector3(1.376556240246096, 1.0544132990288464, 2.2821151846153271);
et0.rotation = Quaternion(0.87261013236307849,
-0.31804190363459633,
0.1041066722243857,
-0.3557565252080937);
et1 = bcam.make_et1(et0);
const auto C0 = bcam.C0();
const auto C1 = bcam.C1();
// Check the sanity of inputs
for(auto i = 0u; i < N; ++i) {
const auto& W = Ws[i];
const auto& p = Ps[i];
const auto& q = Qs[i];
const auto E0 = et0.inverse_apply(W); // eye co-ordinate
const auto E1 = bcam.q.apply(E0 - C1);
const auto E_ = et0.rotation.inverse_rotate(W - et0.translation);
const auto Q_ = et1.inverse_apply(W);
const auto D0 = bcam.M[0].distort(homgen_P2_to_R2(E0));
const auto D1 = bcam.M[1].distort(homgen_P2_to_R2(E1));
const auto e0 = (D0 - Ps[i]).norm();
const auto e1 = (D1 - Qs[i]).norm();
CATCH_REQUIRE((E0 - E_).norm() < 1e-9);
CATCH_REQUIRE((E1 - Q_).norm() < 1e-9);
if(false) {
cout << string(80, '-') << endl;
cout << format("W = {:s}", str(W)) << endl;
cout << format("E_ = {:s}", str(E_)) << endl;
cout << format("E0 = {:s}", str(E0)) << endl;
cout << format("E1 = {:s}", str(E1)) << endl;
cout << format("Q_ = {:s}", str(Q_)) << endl;
cout << format("D0 = {:s}", str(D0)) << endl;
cout << format("D1 = {:s}", str(D1)) << endl;
cout << format("e0 = {}", e0) << endl;
cout << format("e1 = {}", e1) << endl;
cout << endl;
}
}
// CATCH_REQUIRE(true);
}
CATCH_SECTION("euclidean-transform-plane")
{
std::mt19937 gen;
std::uniform_real_distribution<double> distribution{0.0, 1.0};
gen.seed(123456);
auto rand = [&](real a, real b) -> real {
return (b - a) * distribution(gen) + a;
};
auto test_it = [&]() {
// A random transform
EuclideanTransform et;
et.scale = rand(0.5, 1.5);
et.translation
= Vector3(rand(-1.0, 1.0), rand(-1.0, 1.0), rand(-1.0, 1.0));
et.rotation = saa_to_quaternion(
Vector3(rand(-M_PI, M_PI), rand(-M_PI, M_PI), rand(-M_PI, M_PI)));
// A random plane
Plane p3 = Plane(
spherical_to_cartesian(rand(-M_PI, M_PI), rand(-M_PI, M_PI), 1.0),
rand(-10.0, 10.0));
// Some points on the plane
array<Vector3, 10> Xs;
for(auto& X : Xs)
X = p3.image(Vector3(
rand(-100.0, 100.0), rand(-100.0, 100.0), rand(-100.0, 100.0)));
Plane t3 = et.apply_to_plane(p3); // transformed plane
// Test plane equation transformation here
for(auto i = 0; i < 100; ++i) {
// Generate a random point
const Vector3 X = p3.image(Vector3(
rand(-100.0, 100.0), rand(-100.0, 100.0), rand(-100.0, 100.0)));
// The transformed point
const Vector3 Y = et.apply(X);
// X must be on the random plane
CATCH_REQUIRE(std::fabs(p3.side(X)) < 1e-9);
// The transformed point (Y) must be on the transformed plane
CATCH_REQUIRE(std::fabs(t3.side(Y)) < 1e-9);
}
};
for(auto i = 0; i < 100; ++i) test_it();
}
CATCH_SECTION("euclidean-math-health")
{
const ArucoCube ac = make_kyle_aruco_cube();
Matrix3r K = Matrix3r::Identity();
const unsigned uh = 1944;
const unsigned uw = 2592;
const real vfov = 70.0; // vertical field of view
K(0, 0) = K(1, 1) = 0.5 * real(uh) / tan(0.5 * to_radians(vfov));
K(0, 2) = uw * 0.5;
K(1, 2) = uh * 0.5;
const Matrix3r K_inv = K.inverse();
array<real, 7> ets_p0 = {
1.796946, 0.519288, 2.404663, 0.505111, 0.328718, 3.442211, 1.000000};
array<real, 7> ets_p1 = {
1.805852, 0.527716, 2.401060, 0.453412, 0.374650, 3.472033, 1.000000};
array<EuclideanTransform, 2> ets;
ets[0].unpack(&ets_p0[0]);
ets[1].unpack(&ets_p1[0]);
const EuclideanTransform e01 = ets[0].inverse() * ets[1];
BinocularCameraInfo bcam_info;
bcam_info.set_from_et(e01.inverse());
const auto C0 = bcam_info.C0();
const auto C1 = bcam_info.C1();
const auto q = bcam_info.q;
const auto bt1 = bcam_info.make_et1(ets[0].inverse()).inverse();
CachingUndistortInverse cu0, cu1;
cu0.init(K);
cu1.init(K);
{
const auto i = 4; // TOP face
const Plane p3 = ac.measures[i].p3;
const Plane p3_ = ets[0].apply_to_plane(ac.measures[i].p3);
const Plane p31 = ets[1].apply_to_plane(ac.measures[i].p3);
for(auto j = 0; j < 4; ++j) {
EuclideanTransform et;
const auto M = ac.measures[i].Xs[size_t(j)];
const auto X = ets[0].apply(M);
const auto Y = ets[1].apply(M);
const auto Y_ = bt1.apply(M);
const auto Z = e01.apply(X);
const auto a = bcam_info.to_ray(0, X);
const auto b = bcam_info.to_ray(1, X);
const auto A = plane_ray_intersection(p3_, C0, C0 + a);
const auto B
= plane_ray_intersection(p3_, C1, C1 + q.inverse_apply(b));
const auto x0
= homgen_P2_to_R2(to_vec3(K * Vector3r(a.x, a.y, a.z)));
const auto x1 = homgen_P2_to_R2(to_vec3(K * to_vec3r(X)));
const auto y0
= homgen_P2_to_R2(to_vec3(K * Vector3r(b.x, b.y, b.z)));
const auto y1
= homgen_P2_to_R2(to_vec3(K * to_vec3r(Y))); // Correct
const auto zx = transfer_point_between_images(
y1, p31, ets[1], ets[0], cu1, cu0);
const auto zy = transfer_point_between_images(
x1, p3_, ets[0], ets[1], cu0, cu1);
auto make_M0 = [&]() { // Take x, and convert to M
auto ray
= to_vec3(K_inv * Vector3r(x0.x, x0.y, 1.0)).normalised();
return ets[0].inverse_apply(
plane_ray_intersection(p3_, C0, C0 + ray));
};
const auto M0 = make_M0();
auto make_M1 = [&]() { // Take x, and convert to M
auto ray
= to_vec3(K_inv * Vector3r(y1.x, y1.y, 1.0)).normalised();
ray = q.inverse_apply(ray);
return ets[0].inverse_apply(
plane_ray_intersection(p3_, C1, C1 + ray));
};
const auto M1 = make_M1();
if(false) {
cout << format("M = {:s}", str(M)) << endl;
cout << format("M0 = {:s}", str(M0)) << endl;
cout << format("M1 = {:s}", str(M1)) << endl;
cout << format("X = {:s}", str(X)) << endl;
cout << format("A = {:s}", str(A)) << endl;
cout << format("B = {:s}", str(B)) << endl;
cout << format("Y = {:s}", str(Y)) << endl;
cout << format("Z = {:s}", str(Z)) << endl;
cout << format("x0 = {:s}", str(x0)) << endl;
cout << format("x1 = {:s}", str(x0)) << endl;
cout << format("zx = {:s}", str(zx)) << endl;
cout << format("y0 = {:s}", str(y0)) << endl;
cout << format("y1 = {:s}", str(y1)) << endl;
cout << format("zy = {:s}", str(zy)) << endl;
cout << endl;
}
CATCH_REQUIRE((M - M0).norm() < 1e-9);
CATCH_REQUIRE((M - M1).norm() < 1e-9);
CATCH_REQUIRE((Y - Z).norm() < 1e-9);
CATCH_REQUIRE((Y - Y_).norm() < 1e-9);
CATCH_REQUIRE((A - X).norm() < 1e-9);
CATCH_REQUIRE((B - X).norm() < 1e-9);
CATCH_REQUIRE((x1 - x0).norm() < 1e-9);
CATCH_REQUIRE((y1 - y0).norm() < 1e-9);
CATCH_REQUIRE((zx - x0).norm() < 1e-9);
CATCH_REQUIRE((zy - y0).norm() < 1e-9);
}
}
}
}
} // namespace perceive
| 28,395
| 17,147
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu/ipc/service/gpu_memory_buffer_factory_dxgi.h"
#include <vector>
#include "base/memory/unsafe_shared_memory_region.h"
#include "base/trace_event/trace_event.h"
#include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
#include "gpu/ipc/common/dxgi_helpers.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gl/gl_angle_util_win.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_image_dxgi.h"
namespace gpu {
GpuMemoryBufferFactoryDXGI::GpuMemoryBufferFactoryDXGI() {
DETACH_FROM_THREAD(thread_checker_);
}
GpuMemoryBufferFactoryDXGI::~GpuMemoryBufferFactoryDXGI() = default;
// TODO(crbug.com/1223490): Avoid the need for a separate D3D device here by
// sharing keyed mutex state between DXGI GMBs and D3D shared image backings.
Microsoft::WRL::ComPtr<ID3D11Device>
GpuMemoryBufferFactoryDXGI::GetOrCreateD3D11Device() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!d3d11_device_) {
// Use same adapter as ANGLE device.
auto angle_d3d11_device = gl::QueryD3D11DeviceObjectFromANGLE();
if (!angle_d3d11_device) {
DLOG(ERROR) << "Failed to get ANGLE D3D11 device";
return nullptr;
}
Microsoft::WRL::ComPtr<IDXGIDevice> angle_dxgi_device;
HRESULT hr = angle_d3d11_device.As(&angle_dxgi_device);
CHECK(SUCCEEDED(hr));
Microsoft::WRL::ComPtr<IDXGIAdapter> dxgi_adapter = nullptr;
hr = FAILED(angle_dxgi_device->GetAdapter(&dxgi_adapter));
if (FAILED(hr)) {
DLOG(ERROR) << "GetAdapter failed with error 0x" << std::hex << hr;
return nullptr;
}
// If adapter is not null, driver type must be D3D_DRIVER_TYPE_UNKNOWN
// otherwise D3D11CreateDevice will return E_INVALIDARG.
// See
// https://docs.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-d3d11createdevice#return-value
const D3D_DRIVER_TYPE driver_type =
dxgi_adapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE;
// It's ok to use D3D11_CREATE_DEVICE_SINGLETHREADED because this device is
// only ever used on the IO thread (verified by |thread_checker_|).
const UINT flags = D3D11_CREATE_DEVICE_SINGLETHREADED;
// Using D3D_FEATURE_LEVEL_11_1 is ok since we only support D3D11 when the
// platform update containing DXGI 1.2 is present on Win7.
const D3D_FEATURE_LEVEL feature_levels[] = {
D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_9_2,
D3D_FEATURE_LEVEL_9_1};
hr = D3D11CreateDevice(dxgi_adapter.Get(), driver_type,
/*Software=*/nullptr, flags, feature_levels,
base::size(feature_levels), D3D11_SDK_VERSION,
&d3d11_device_, /*pFeatureLevel=*/nullptr,
/*ppImmediateContext=*/nullptr);
if (FAILED(hr)) {
DLOG(ERROR) << "D3D11CreateDevice failed with error 0x" << std::hex << hr;
return nullptr;
}
const char* kDebugName = "GPUIPC_GpuMemoryBufferFactoryDXGI";
d3d11_device_->SetPrivateData(WKPDID_D3DDebugObjectName, strlen(kDebugName),
kDebugName);
}
DCHECK(d3d11_device_);
return d3d11_device_;
}
gfx::GpuMemoryBufferHandle GpuMemoryBufferFactoryDXGI::CreateGpuMemoryBuffer(
gfx::GpuMemoryBufferId id,
const gfx::Size& size,
const gfx::Size& framebuffer_size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
int client_id,
SurfaceHandle surface_handle) {
TRACE_EVENT0("gpu", "GpuMemoryBufferFactoryDXGI::CreateGpuMemoryBuffer");
DCHECK_EQ(framebuffer_size, size);
gfx::GpuMemoryBufferHandle handle;
auto d3d11_device = GetOrCreateD3D11Device();
if (!d3d11_device)
return handle;
DXGI_FORMAT dxgi_format;
switch (format) {
case gfx::BufferFormat::RGBA_8888:
case gfx::BufferFormat::RGBX_8888:
dxgi_format = DXGI_FORMAT_R8G8B8A8_UNORM;
break;
default:
NOTREACHED();
return handle;
}
size_t buffer_size;
if (!BufferSizeForBufferFormatChecked(size, format, &buffer_size))
return handle;
// We are binding as a shader resource and render target regardless of usage,
// so make sure that the usage is one that we support.
DCHECK(usage == gfx::BufferUsage::GPU_READ ||
usage == gfx::BufferUsage::SCANOUT);
D3D11_TEXTURE2D_DESC desc = {
static_cast<UINT>(size.width()),
static_cast<UINT>(size.height()),
1,
1,
dxgi_format,
{1, 0},
D3D11_USAGE_DEFAULT,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET,
0,
D3D11_RESOURCE_MISC_SHARED_NTHANDLE |
D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX};
Microsoft::WRL::ComPtr<ID3D11Texture2D> d3d11_texture;
if (FAILED(d3d11_device->CreateTexture2D(&desc, nullptr, &d3d11_texture)))
return handle;
Microsoft::WRL::ComPtr<IDXGIResource1> dxgi_resource;
if (FAILED(d3d11_texture.As(&dxgi_resource)))
return handle;
HANDLE texture_handle;
if (FAILED(dxgi_resource->CreateSharedHandle(
nullptr, DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE,
nullptr, &texture_handle)))
return handle;
handle.dxgi_handle.Set(texture_handle);
handle.type = gfx::DXGI_SHARED_HANDLE;
handle.id = id;
return handle;
}
void GpuMemoryBufferFactoryDXGI::DestroyGpuMemoryBuffer(
gfx::GpuMemoryBufferId id,
int client_id) {}
bool GpuMemoryBufferFactoryDXGI::FillSharedMemoryRegionWithBufferContents(
gfx::GpuMemoryBufferHandle buffer_handle,
base::UnsafeSharedMemoryRegion shared_memory) {
DCHECK_EQ(buffer_handle.type, gfx::GpuMemoryBufferType::DXGI_SHARED_HANDLE);
auto d3d11_device = GetOrCreateD3D11Device();
if (!d3d11_device)
return false;
return CopyDXGIBufferToShMem(buffer_handle.dxgi_handle.Get(),
std::move(shared_memory), d3d11_device.Get(),
&staging_texture_);
}
ImageFactory* GpuMemoryBufferFactoryDXGI::AsImageFactory() {
return this;
}
scoped_refptr<gl::GLImage>
GpuMemoryBufferFactoryDXGI::CreateImageForGpuMemoryBuffer(
gfx::GpuMemoryBufferHandle handle,
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferPlane plane,
int client_id,
SurfaceHandle surface_handle) {
if (handle.type != gfx::DXGI_SHARED_HANDLE)
return nullptr;
if (plane != gfx::BufferPlane::DEFAULT)
return nullptr;
// Transfer ownership of handle to GLImageDXGI.
auto image = base::MakeRefCounted<gl::GLImageDXGI>(size, nullptr);
if (!image->InitializeHandle(std::move(handle.dxgi_handle), 0, format))
return nullptr;
return image;
}
unsigned GpuMemoryBufferFactoryDXGI::RequiredTextureType() {
return GL_TEXTURE_2D;
}
bool GpuMemoryBufferFactoryDXGI::SupportsFormatRGB() {
return true;
}
} // namespace gpu
| 7,011
| 2,720
|
/*
** ClanLib SDK
** Copyright (c) 1997-2020 The ClanLib Team
**
** 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.
**
** Note: Some of the libraries ClanLib may link to may have additional
** requirements or restrictions.
**
** File Author(s):
**
** Magnus Norddahl
** Mark Page
** Artem Khomenko
*/
#include "precomp.h"
#include "app.h"
#include "../../../ThemeAero/Sources/theme.h"
#include <ClanLib/UI/SystemDialogs/folder_browse_dialog.h>
#include <ClanLib/UI/SystemDialogs/open_file_dialog.h>
#include <ClanLib/UI/SystemDialogs/save_file_dialog.h>
using namespace clan;
clan::ApplicationInstance<App> clanapp;
App::App()
{
#if defined(WIN32) && !defined(__MINGW32__)
clan::D3DTarget::set_current();
#else
clan::OpenGLTarget::set_current();
#endif
// Create a window:
DisplayWindowDescription desc;
desc.set_title("UICore: Hello World");
desc.set_allow_resize(true);
window = std::make_shared<TopLevelWindow>(desc);
auto pRootView = window->root_view();
pRootView->slots.connect(window->root_view()->sig_close(), [&](CloseEvent &e) { RunLoop::exit(); });
pRootView->slots.connect(pRootView->sig_key_press(), [&](clan::KeyEvent &e)
{ if (e.key() == clan::Key::escape) RunLoop::exit(); }
);
// Need for receive a keyboard events.
pRootView->set_focus();
// Create a source for our resources
FileResourceDocument doc(FileSystem("../../ThemeAero"));
ResourceManager resources = FileResourceManager::create(doc);
// Mark this thread as the UI thread
ui_thread = UIThread(resources);
// Style the root view to use rounded corners and a bit of drop shadow
pRootView->style()->set("padding: 11px");
pRootView->style()->set("background: #efefef");
pRootView->style()->set("flex-direction: column");
// First (top) panel with button and text
//
auto panel1 = std::make_shared<View>();
panel1->style()->set("background: white");
panel1->style()->set("padding: 11px");
panel1->style()->set("flex-direction: row");
panel1->style()->set("flex: auto");
pRootView->add_child(panel1);
auto button1 = Theme::create_button();
button1->style()->set("height: 40px");
button1->style()->set("width: 120px");
button1->label()->set_text("Folder browse");
button1->style()->set("flex: none");
button1->image_view()->set_image(clan::Image(pRootView->canvas(), "./document_open.png"));
button1->func_clicked() = clan::bind_member(this, &App::on_button1_down);
panel1->add_child(button1);
label1 = std::make_shared<LabelView>();
label1->style()->set("font: 20px/40px 'Ravie'");
label1->style()->set("padding: 0px 10px");
label1->set_text("Press the button for select a folder");
panel1->add_child(label1);
// Second panel with button and text
//
auto panel2 = std::make_shared<View>();
panel2->style()->set("background: white");
panel2->style()->set("padding: 11px");
panel2->style()->set("flex-direction: row");
panel2->style()->set("flex: auto");
pRootView->add_child(panel2);
auto button2 = Theme::create_button();
button2->style()->set("height: 40px");
button2->style()->set("width: 120px");
button2->label()->set_text("Open file");
button2->style()->set("flex: none");
button2->func_clicked() = clan::bind_member(this, &App::on_button2_down);
panel2->add_child(button2);
label2 = std::make_shared<LabelView>();
label2->style()->set("font: 20px/40px 'Ravie'");
label2->style()->set("padding: 0px 10px");
label2->set_text("Press the button for select only existing file");
panel2->add_child(label2);
// Third panel with button and text
//
auto panel3 = std::make_shared<View>();
panel3->style()->set("background: white");
panel3->style()->set("padding: 11px");
panel3->style()->set("flex-direction: row");
panel3->style()->set("flex: auto");
pRootView->add_child(panel3);
auto button3 = Theme::create_button();
button3->style()->set("height: 40px");
button3->style()->set("width: 120px");
button3->label()->set_text("Save file");
button3->style()->set("flex: none");
button3->func_clicked() = clan::bind_member(this, &App::on_button3_down);
panel3->add_child(button3);
label3 = std::make_shared<LabelView>();
label3->style()->set("font: 20px/40px 'Ravie'");
label3->style()->set("padding: 0px 10px");
label3->set_text("Press the button for select existing or new file");
panel3->add_child(label3);
// Fourth panel with button and text
//
auto panel4 = std::make_shared<View>();
panel4->style()->set("background: white");
panel4->style()->set("padding: 11px");
panel4->style()->set("flex-direction: row");
panel4->style()->set("flex: auto");
pRootView->add_child(panel4);
button4 = Theme::create_button();
button4->style()->set("height: 40px");
button4->style()->set("width: 120px");
button4->label()->set_text("Sticky button");
button4->style()->set("flex: none");
button4->func_clicked() = clan::bind_member(this, &App::on_button4_down);
button4->set_sticky(true);
button4->set_pressed(true);
panel4->add_child(button4);
label4 = std::make_shared<LabelView>();
label4->style()->set("font: 20px/40px 'Ravie'");
label4->style()->set("padding: 0px 10px");
panel4->add_child(label4);
on_button4_down(); // Manual setting button's "pressed" property doesn't call user event handler automatically.
}
void App::on_button1_down()
{
auto dlg = std::make_shared<BrowseFolderDialog>(window->root_view().get());
label1->set_text(dlg->show() ? dlg->selected_path() : "Canceled");
}
void App::on_button2_down()
{
auto dlg = std::make_shared<OpenFileDialog>(window->root_view().get());
label2->set_text(dlg->show() ? dlg->filename() : "Canceled");
}
void App::on_button3_down()
{
auto dlg = std::make_shared<SaveFileDialog>(window->root_view().get());
label3->set_text(dlg->show() ? dlg->filename() : "Canceled");
}
void App::on_button4_down()
{
label4->set_text(button4->pressed() ? "Sticky button is pressed" : "Sticky button is unpressed");
}
bool App::update()
{
// This needs only if nothing is drawn. Otherwise, use display_window().flip().
window->display_window().request_repaint();
//window->display_window().flip();
return true;
}
| 6,890
| 2,408
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string solve(string s) {
if(s == "AAA" || s == "BBB")
return "No";
return "Yes";
}
/*
int main() {
string s;
cin >> s;
cout << solve(s);
}
*/
| 238
| 95
|
#include <iostream>
#include <vector>
#include <queue>
#define INF 10000000
using namespace std;
vector<vector<pair<int, int> > > graph;
void dijkstra(int start) {
vector<int>dist((int)graph.size(), INF);
vector<int>path((int)graph.size(), -1);
priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > pq;
dist[start] = 0;
pq.push({dist[start], start});
while(!pq.empty()) {
int v = pq.top().second;
pq.pop();
for (int i = 0; i < (int)graph[v].size(); i++) {
int u = graph[v][i].first;
int w = graph[v][i].second;
if(dist[u] > dist[v] + w) {
dist[u] = dist[v] + w;
path[u] = v;
pq.push({dist[u], u});
}
}
}
int aux = 0;
vector<int>trace;
while(aux != -1) {
trace.push_back(aux);
aux = path[aux];
}
if(dist[0] > 120) {
cout << "It will be " << dist[0] - 120 << " minutes late. ";
} else {
cout << "Will not be late. ";
}
cout << "Travel time - " << dist[0] << " - best way - ";
for (int i = (int)trace.size() - 1; i >= 0 ; i--) {
if(i != (int)trace.size() - 1)
cout << " ";
cout << trace[i] + 1;
}
cout << endl;
}
int main()
{
int cidades, estradas, v1, v2, time, start;
while(cin >> cidades >> estradas && cidades && estradas) {
graph.assign(cidades, vector<pair<int,int> >());
while(estradas--) {
cin >> v1 >> v2 >> time;
v1--; v2--;
graph[v1].push_back({v2, time});
graph[v2].push_back({v1, time});
}
cin >> start;
dijkstra(--start);
}
return 0;
}
| 1,748
| 667
|
/**
* File : F.cpp
* Author : Kazune Takahashi
* Created : 2018-4-14 21:58:25
* Powered by Visual Studio Code
*/
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define DEBUG 0 // change 0 -> 1 if we need debug.
typedef long long ll;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};
// const int C = 1e6+10;
// const ll M = 1000000007;
int N;
vector<int> V[100010];
int visited[100010];
vector<int> path;
vector<int> ans;
vector<int> ans2;
int longest(int v)
{
fill(visited, visited+100010, -1);
queue<int> Q;
Q.push(v);
visited[v] = 0;
while (!Q.empty())
{
int now = Q.front();
Q.pop();
for (auto x : V[now])
{
if (visited[x] == -1)
{
visited[x] = visited[now] + 1;
Q.push(x);
}
}
}
int maxi = 0;
int max_t = v;
for (auto i = 0; i < N; i++)
{
assert(visited[i] >= 0);
if (visited[i] > maxi)
{
maxi = visited[i];
max_t = i;
}
}
return max_t;
}
int main()
{
cin >> N;
for (auto i = 0; i < N-1; i++)
{
int v, w;
cin >> v >> w;
v--;
w--;
V[v].push_back(w);
V[w].push_back(v);
}
int start = longest(0);
int goal = longest(start);
assert(V[start].size() == 1 && V[goal].size() == 1);
longest(start);
int dist = visited[goal];
int now = goal;
path.push_back(goal);
while (dist > 0)
{
// cerr << "dist = " << dist << ", now = " << now << endl;
for (auto x : V[now])
{
// cerr << "visited[" << x << "] = " << visited[x] << endl;
if (visited[x] == dist - 1)
{
now = x;
path.push_back(now);
dist--;
break;
}
}
}
reverse(path.begin(), path.end());
int S = path.size();
int cnt = 2;
for (auto i = 1; i < S - 1; i++)
{
assert(V[path[i]].size() >= 2);
// cerr << "V[" << path[i] << "].size() = " << V[path[i]].size() << endl;
cnt += V[path[i]].size() - 1;
}
if (cnt != N)
{
// cerr << "N = " << N << ", cnt = " << cnt << endl;
assert(cnt < N);
cout << -1 << endl;
return 0;
}
ans.push_back(1);
int num = 1;
for (auto i = 1; i < S - 1; i++)
{
int subtree = V[path[i]].size() - 1;
vector<int> X;
for (auto j = 1; j < subtree; j++)
{
X.push_back(j);
}
X.push_back(0);
for (auto i = 0; i < subtree; i++)
{
ans.push_back(X[i] + num + 1);
}
num += subtree;
}
assert(num + 1 == N);
ans.push_back(num + 1);
assert((int)ans.size() == N);
//
reverse(path.begin(), path.end());
ans2.push_back(1);
num = 1;
for (auto i = 1; i < S - 1; i++)
{
int subtree = V[path[i]].size() - 1;
vector<int> X;
for (auto j = 1; j < subtree; j++)
{
X.push_back(j);
}
X.push_back(0);
for (auto i = 0; i < subtree; i++)
{
ans2.push_back(X[i] + num + 1);
}
num += subtree;
}
ans2.push_back(num + 1);
for (auto i = 0; i < N; i++)
{
if (ans[i] > ans2[i]) {
swap(ans, ans2);
break;
} else if (ans[i] < ans2[i]) {
break;
}
}
for (auto i = 0; i < N; i++)
{
cout << ans[i];
if (i < N-1)
{
cout << " ";
}
else
{
cout << endl;
}
}
}
| 3,696
| 1,658
|
/*
* Copyright © 2011 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 "main/core.h"
#include "ir.h"
#include "linker.h"
#include "ir_uniform.h"
#include "glsl_symbol_table.h"
#include "program/hash_table.h"
/**
* \file link_uniforms.cpp
* Assign locations for GLSL uniforms.
*
* \author Ian Romanick <ian.d.romanick@intel.com>
*/
/**
* Count the backing storage requirements for a type
*/
static unsigned
values_for_type(const glsl_type *type)
{
if (type->is_sampler()) {
return 1;
} else if (type->is_array() && type->fields.array->is_sampler()) {
return type->array_size();
} else {
return type->component_slots();
}
}
void
uniform_field_visitor::process(ir_variable *var)
{
const glsl_type *t = var->type;
/* Only strdup the name if we actually will need to modify it. */
if (t->is_record() || (t->is_array() && t->fields.array->is_record())) {
char *name = ralloc_strdup(NULL, var->name);
recursion(var->type, &name, strlen(name));
ralloc_free(name);
} else {
this->visit_field(t, var->name);
}
}
void
uniform_field_visitor::recursion(const glsl_type *t, char **name,
unsigned name_length)
{
/* Records need to have each field processed individually.
*
* Arrays of records need to have each array element processed
* individually, then each field of the resulting array elements processed
* individually.
*/
if (t->is_record()) {
for (unsigned i = 0; i < t->length; i++) {
const char *field = t->fields.structure[i].name;
/* Append '.field' to the current uniform name. */
ralloc_asprintf_rewrite_tail(name, name_length, ".%s", field);
recursion(t->fields.structure[i].type, name,
name_length + 1 + strlen(field));
}
} else if (t->is_array() && t->fields.array->is_record()) {
for (unsigned i = 0; i < t->length; i++) {
char subscript[13];
/* Append the subscript to the current uniform name */
const unsigned subscript_length = snprintf(subscript, 13, "[%u]", i);
ralloc_asprintf_rewrite_tail(name, name_length, "%s", subscript);
recursion(t->fields.array, name, name_length + subscript_length);
}
} else {
this->visit_field(t, *name);
}
}
/**
* Class to help calculate the storage requirements for a set of uniforms
*
* As uniforms are added to the active set the number of active uniforms and
* the storage requirements for those uniforms are accumulated. The active
* uniforms are added the the hash table supplied to the constructor.
*
* If the same uniform is added multiple times (i.e., once for each shader
* target), it will only be accounted once.
*/
class count_uniform_size : public uniform_field_visitor {
public:
count_uniform_size(struct string_to_uint_map *map)
: num_active_uniforms(0), num_values(0), num_shader_samplers(0),
num_shader_uniform_components(0), map(map)
{
/* empty */
}
void start_shader()
{
this->num_shader_samplers = 0;
this->num_shader_uniform_components = 0;
}
/**
* Total number of active uniforms counted
*/
unsigned num_active_uniforms;
/**
* Number of data values required to back the storage for the active uniforms
*/
unsigned num_values;
/**
* Number of samplers used
*/
unsigned num_shader_samplers;
/**
* Number of uniforms used in the current shader
*/
unsigned num_shader_uniform_components;
private:
virtual void visit_field(const glsl_type *type, const char *name)
{
assert(!type->is_record());
assert(!(type->is_array() && type->fields.array->is_record()));
/* Count the number of samplers regardless of whether the uniform is
* already in the hash table. The hash table prevents adding the same
* uniform for multiple shader targets, but in this case we want to
* count it for each shader target.
*/
const unsigned values = values_for_type(type);
if (type->contains_sampler()) {
this->num_shader_samplers +=
type->is_array() ? type->array_size() : 1;
} else {
/* Accumulate the total number of uniform slots used by this shader.
* Note that samplers do not count against this limit because they
* don't use any storage on current hardware.
*/
this->num_shader_uniform_components += values;
}
/* If the uniform is already in the map, there's nothing more to do.
*/
unsigned id;
if (this->map->get(id, name))
return;
char *key = strdup(name);
this->map->put(this->num_active_uniforms, key);
/* Each leaf uniform occupies one entry in the list of active
* uniforms.
*/
this->num_active_uniforms++;
this->num_values += values;
}
struct string_to_uint_map *map;
};
/**
* Class to help parcel out pieces of backing storage to uniforms
*
* Each uniform processed has some range of the \c gl_constant_value
* structures associated with it. The association is done by finding
* the uniform in the \c string_to_uint_map and using the value from
* the map to connect that slot in the \c gl_uniform_storage table
* with the next available slot in the \c gl_constant_value array.
*
* \warning
* This class assumes that every uniform that will be processed is
* already in the \c string_to_uint_map. In addition, it assumes that
* the \c gl_uniform_storage and \c gl_constant_value arrays are "big
* enough."
*/
class parcel_out_uniform_storage : public uniform_field_visitor {
public:
parcel_out_uniform_storage(struct string_to_uint_map *map,
struct gl_uniform_storage *uniforms,
union gl_constant_value *values)
: map(map), uniforms(uniforms), next_sampler(0), values(values)
{
memset(this->targets, 0, sizeof(this->targets));
}
void start_shader()
{
this->shader_samplers_used = 0;
this->shader_shadow_samplers = 0;
}
private:
virtual void visit_field(const glsl_type *type, const char *name)
{
assert(!type->is_record());
assert(!(type->is_array() && type->fields.array->is_record()));
unsigned id;
bool found = this->map->get(id, name);
assert(found);
if (!found)
return;
/* If there is already storage associated with this uniform, it means
* that it was set while processing an earlier shader stage. For
* example, we may be processing the uniform in the fragment shader, but
* the uniform was already processed in the vertex shader.
*/
if (this->uniforms[id].storage != NULL) {
/* If the uniform already has storage set from another shader stage,
* mark the samplers used for this shader stage.
*/
if (type->contains_sampler()) {
const unsigned count = MAX2(1, this->uniforms[id].array_elements);
const unsigned shadow = (type->is_array())
? type->fields.array->sampler_shadow : type->sampler_shadow;
for (unsigned i = 0; i < count; i++) {
const unsigned s = this->uniforms[id].sampler + i;
this->shader_samplers_used |= 1U << s;
this->shader_shadow_samplers |= shadow << s;
}
}
return;
}
const glsl_type *base_type;
if (type->is_array()) {
this->uniforms[id].array_elements = type->length;
base_type = type->fields.array;
} else {
this->uniforms[id].array_elements = 0;
base_type = type;
}
if (base_type->is_sampler()) {
this->uniforms[id].sampler = this->next_sampler;
/* Increment the sampler by 1 for non-arrays and by the number of
* array elements for arrays.
*/
this->next_sampler += MAX2(1, this->uniforms[id].array_elements);
const gl_texture_index target = base_type->sampler_index();
const unsigned shadow = base_type->sampler_shadow;
for (unsigned i = this->uniforms[id].sampler
; i < this->next_sampler
; i++) {
this->targets[i] = target;
this->shader_samplers_used |= 1U << i;
this->shader_shadow_samplers |= shadow << i;
}
} else {
this->uniforms[id].sampler = ~0;
}
this->uniforms[id].name = ralloc_strdup(this->uniforms, name);
this->uniforms[id].type = base_type;
this->uniforms[id].initialized = 0;
this->uniforms[id].num_driver_storage = 0;
this->uniforms[id].driver_storage = NULL;
this->uniforms[id].storage = this->values;
this->values += values_for_type(type);
}
struct string_to_uint_map *map;
struct gl_uniform_storage *uniforms;
unsigned next_sampler;
public:
union gl_constant_value *values;
gl_texture_index targets[MAX_SAMPLERS];
/**
* Mask of samplers used by the current shader stage.
*/
unsigned shader_samplers_used;
/**
* Mask of samplers used by the current shader stage for shadows.
*/
unsigned shader_shadow_samplers;
};
void
link_assign_uniform_locations(struct gl_shader_program *prog)
{
ralloc_free(prog->UniformStorage);
prog->UniformStorage = NULL;
prog->NumUserUniformStorage = 0;
if (prog->UniformHash != NULL) {
prog->UniformHash->clear();
} else {
prog->UniformHash = new string_to_uint_map;
}
for (unsigned i = 0; i < Elements(prog->SamplerUnits); i++) {
prog->SamplerUnits[i] = i;
}
/* First pass: Count the uniform resources used by the user-defined
* uniforms. While this happens, each active uniform will have an index
* assigned to it.
*
* Note: this is *NOT* the index that is returned to the application by
* glGetUniformLocation.
*/
count_uniform_size uniform_size(prog->UniformHash);
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
if (prog->_LinkedShaders[i] == NULL)
continue;
/* Reset various per-shader target counts.
*/
uniform_size.start_shader();
foreach_list(node, prog->_LinkedShaders[i]->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
if ((var == NULL) || (var->mode != ir_var_uniform))
continue;
/* FINISHME: Update code to process built-in uniforms!
*/
if (strncmp("gl_", var->name, 3) == 0)
continue;
uniform_size.process(var);
}
prog->_LinkedShaders[i]->num_samplers = uniform_size.num_shader_samplers;
prog->_LinkedShaders[i]->num_uniform_components =
uniform_size.num_shader_uniform_components;
}
const unsigned num_user_uniforms = uniform_size.num_active_uniforms;
const unsigned num_data_slots = uniform_size.num_values;
/* On the outside chance that there were no uniforms, bail out.
*/
if (num_user_uniforms == 0)
return;
struct gl_uniform_storage *uniforms =
rzalloc_array(prog, struct gl_uniform_storage, num_user_uniforms);
union gl_constant_value *data =
rzalloc_array(uniforms, union gl_constant_value, num_data_slots);
#ifndef NDEBUG
union gl_constant_value *data_end = &data[num_data_slots];
#endif
parcel_out_uniform_storage parcel(prog->UniformHash, uniforms, data);
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
if (prog->_LinkedShaders[i] == NULL)
continue;
/* Reset various per-shader target counts.
*/
parcel.start_shader();
foreach_list(node, prog->_LinkedShaders[i]->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
if ((var == NULL) || (var->mode != ir_var_uniform))
continue;
/* FINISHME: Update code to process built-in uniforms!
*/
if (strncmp("gl_", var->name, 3) == 0)
continue;
parcel.process(var);
}
prog->_LinkedShaders[i]->active_samplers = parcel.shader_samplers_used;
prog->_LinkedShaders[i]->shadow_samplers = parcel.shader_shadow_samplers;
}
assert(sizeof(prog->SamplerTargets) == sizeof(parcel.targets));
memcpy(prog->SamplerTargets, parcel.targets, sizeof(prog->SamplerTargets));
#ifndef NDEBUG
for (unsigned i = 0; i < num_user_uniforms; i++) {
assert(uniforms[i].storage != NULL);
}
assert(parcel.values == data_end);
#endif
prog->NumUserUniformStorage = num_user_uniforms;
prog->UniformStorage = uniforms;
return;
}
| 13,177
| 4,374
|
#include <iostream>
using namespace std;
class strings_recursion
{
public:
int length(char s[]);
void removeX(char s[]);
};
int strings_recursion::length(char s[])
{
if (s[0] == '\0')
{
return 0;
}
int smallStringLength = length(s + 1);
return 1 + smallStringLength;
}
void strings_recursion::removeX(char s[])
{
if (s[0] == '\0')
{
return;
}
if (s[0] != 'x')
{
removeX(s + 1);
}
else
{
int i = 1;
for (; s[i] != '\0'; i++)
{
s[i - 1] = s[i];
}
s[i - 1] = s[i];
removeX(s);
}
}
int main()
{
strings_recursion l;
char str[100];
cin >> str;
cout << l.length(str) << endl;
l.removeX(str);
cout << str << endl;
cout << l.length(str) << endl;
}
| 822
| 332
|
//----------------------------------------------------------------------------------------------------------------------
// CCoreGraphics.cpp ©2020 Stevo Brock All rights reserved.
//----------------------------------------------------------------------------------------------------------------------
#include "CCoreGraphics.h"
//----------------------------------------------------------------------------------------------------------------------
// MARK: CCoreGraphics
// MARK: Class methods
//----------------------------------------------------------------------------------------------------------------------
CGImageRef CCoreGraphics::newImageRef(const CBitmap& bitmap)
//----------------------------------------------------------------------------------------------------------------------
{
// Setup
const S2DSizeS32& size = bitmap.getSize();
const CData& data = bitmap.getPixelData();
CGBitmapInfo bitmapInfo;
switch (bitmap.getFormat()) {
case CBitmap::kFormatRGB888: bitmapInfo = kCGImageAlphaNone; break;
case CBitmap::kFormatRGBA8888: bitmapInfo = kCGImageAlphaPremultipliedLast; break;
case CBitmap::kFormatARGB8888: bitmapInfo = kCGImageAlphaPremultipliedFirst; break;
default: bitmapInfo = 0; break;
}
CGColorSpaceRef colorSpaceRef = ::CGColorSpaceCreateDeviceRGB();
CGDataProviderRef dataProviderRef =
::CGDataProviderCreateWithData(nil, data.getBytePtr(),
bitmap.getBytesPerRow() * size.mHeight, nil);
CGImageRef imageRef =
::CGImageCreate(size.mWidth, size.mHeight, 8, bitmap.getBytesPerPixel() * 8,
bitmap.getBytesPerRow(), colorSpaceRef, bitmapInfo, dataProviderRef, nil, 1,
kCGRenderingIntentDefault);
::CGDataProviderRelease(dataProviderRef);
::CGColorSpaceRelease(colorSpaceRef);
return imageRef;
}
| 1,814
| 537
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/prefs/writeable_pref_store.h"
void WriteablePrefStore::ReportSubValuesChanged(
const std::string& key,
std::set<std::vector<std::string>> path_components,
uint32_t flags) {
// Default implementation. Subclasses may use |path_components| to improve
// performance.
ReportValueChanged(key, flags);
}
| 504
| 157
|
//===------- LegalizeVectorTypes.cpp - Legalization of vector types -------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file performs vector type splitting and scalarization for LegalizeTypes.
// Scalarization is the act of changing a computation in an illegal one-element
// vector type to be a computation in its scalar element type. For example,
// implementing <1 x f32> arithmetic in a scalar f32 register. This is needed
// as a base case when scalarizing vector arithmetic like <4 x f32>, which
// eventually decomposes to scalars if the target doesn't support v4f32 or v2f32
// types.
// Splitting is the act of changing a computation in an invalid vector type to
// be a computation in two vectors of half the size. For example, implementing
// <128 x f32> operations in terms of two <64 x f32> operations.
//
//===----------------------------------------------------------------------===//
#include "LegalizeTypes.h"
#include "llvm/DataLayout.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
// Result Vector Scalarization: <1 x ty> -> ty.
//===----------------------------------------------------------------------===//
void DAGTypeLegalizer::ScalarizeVectorResult(SDNode *N, unsigned ResNo) {
DEBUG(dbgs() << "Scalarize node result " << ResNo << ": ";
N->dump(&DAG);
dbgs() << "\n");
SDValue R = SDValue();
switch (N->getOpcode()) {
default:
#ifndef NDEBUG
dbgs() << "ScalarizeVectorResult #" << ResNo << ": ";
N->dump(&DAG);
dbgs() << "\n";
#endif
report_fatal_error("Do not know how to scalarize the result of this "
"operator!\n");
case ISD::MERGE_VALUES: R = ScalarizeVecRes_MERGE_VALUES(N, ResNo);break;
case ISD::BITCAST: R = ScalarizeVecRes_BITCAST(N); break;
case ISD::BUILD_VECTOR: R = ScalarizeVecRes_BUILD_VECTOR(N); break;
case ISD::CONVERT_RNDSAT: R = ScalarizeVecRes_CONVERT_RNDSAT(N); break;
case ISD::EXTRACT_SUBVECTOR: R = ScalarizeVecRes_EXTRACT_SUBVECTOR(N); break;
case ISD::FP_ROUND: R = ScalarizeVecRes_FP_ROUND(N); break;
case ISD::FP_ROUND_INREG: R = ScalarizeVecRes_InregOp(N); break;
case ISD::FPOWI: R = ScalarizeVecRes_FPOWI(N); break;
case ISD::INSERT_VECTOR_ELT: R = ScalarizeVecRes_INSERT_VECTOR_ELT(N); break;
case ISD::LOAD: R = ScalarizeVecRes_LOAD(cast<LoadSDNode>(N));break;
case ISD::SCALAR_TO_VECTOR: R = ScalarizeVecRes_SCALAR_TO_VECTOR(N); break;
case ISD::SIGN_EXTEND_INREG: R = ScalarizeVecRes_InregOp(N); break;
case ISD::VSELECT: R = ScalarizeVecRes_VSELECT(N); break;
case ISD::SELECT: R = ScalarizeVecRes_SELECT(N); break;
case ISD::SELECT_CC: R = ScalarizeVecRes_SELECT_CC(N); break;
case ISD::SETCC: R = ScalarizeVecRes_SETCC(N); break;
case ISD::UNDEF: R = ScalarizeVecRes_UNDEF(N); break;
case ISD::VECTOR_SHUFFLE: R = ScalarizeVecRes_VECTOR_SHUFFLE(N); break;
case ISD::ANY_EXTEND:
case ISD::CTLZ:
case ISD::CTPOP:
case ISD::CTTZ:
case ISD::FABS:
case ISD::FCEIL:
case ISD::FCOS:
case ISD::FEXP:
case ISD::FEXP2:
case ISD::FFLOOR:
case ISD::FLOG:
case ISD::FLOG10:
case ISD::FLOG2:
case ISD::FNEARBYINT:
case ISD::FNEG:
case ISD::FP_EXTEND:
case ISD::FP_TO_SINT:
case ISD::FP_TO_UINT:
case ISD::FRINT:
case ISD::FSIN:
case ISD::FSQRT:
case ISD::FTRUNC:
case ISD::SIGN_EXTEND:
case ISD::SINT_TO_FP:
case ISD::TRUNCATE:
case ISD::UINT_TO_FP:
case ISD::ZERO_EXTEND:
R = ScalarizeVecRes_UnaryOp(N);
break;
case ISD::ADD:
case ISD::AND:
case ISD::FADD:
case ISD::FDIV:
case ISD::FMUL:
case ISD::FPOW:
case ISD::FREM:
case ISD::FSUB:
case ISD::MUL:
case ISD::OR:
case ISD::SDIV:
case ISD::SREM:
case ISD::SUB:
case ISD::UDIV:
case ISD::UREM:
case ISD::XOR:
case ISD::SHL:
case ISD::SRA:
case ISD::SRL:
R = ScalarizeVecRes_BinOp(N);
break;
case ISD::FMA:
R = ScalarizeVecRes_TernaryOp(N);
break;
}
// If R is null, the sub-method took care of registering the result.
if (R.getNode())
SetScalarizedVector(SDValue(N, ResNo), R);
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_BinOp(SDNode *N) {
SDValue LHS = GetScalarizedVector(N->getOperand(0));
SDValue RHS = GetScalarizedVector(N->getOperand(1));
return DAG.getNode(N->getOpcode(), N->getDebugLoc(),
LHS.getValueType(), LHS, RHS);
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_TernaryOp(SDNode *N) {
SDValue Op0 = GetScalarizedVector(N->getOperand(0));
SDValue Op1 = GetScalarizedVector(N->getOperand(1));
SDValue Op2 = GetScalarizedVector(N->getOperand(2));
return DAG.getNode(N->getOpcode(), N->getDebugLoc(),
Op0.getValueType(), Op0, Op1, Op2);
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_MERGE_VALUES(SDNode *N,
unsigned ResNo) {
SDValue Op = DisintegrateMERGE_VALUES(N, ResNo);
return GetScalarizedVector(Op);
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_BITCAST(SDNode *N) {
EVT NewVT = N->getValueType(0).getVectorElementType();
return DAG.getNode(ISD::BITCAST, N->getDebugLoc(),
NewVT, N->getOperand(0));
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_BUILD_VECTOR(SDNode *N) {
EVT EltVT = N->getValueType(0).getVectorElementType();
SDValue InOp = N->getOperand(0);
// The BUILD_VECTOR operands may be of wider element types and
// we may need to truncate them back to the requested return type.
if (EltVT.isInteger())
return DAG.getNode(ISD::TRUNCATE, N->getDebugLoc(), EltVT, InOp);
return InOp;
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_CONVERT_RNDSAT(SDNode *N) {
EVT NewVT = N->getValueType(0).getVectorElementType();
SDValue Op0 = GetScalarizedVector(N->getOperand(0));
return DAG.getConvertRndSat(NewVT, N->getDebugLoc(),
Op0, DAG.getValueType(NewVT),
DAG.getValueType(Op0.getValueType()),
N->getOperand(3),
N->getOperand(4),
cast<CvtRndSatSDNode>(N)->getCvtCode());
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_EXTRACT_SUBVECTOR(SDNode *N) {
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, N->getDebugLoc(),
N->getValueType(0).getVectorElementType(),
N->getOperand(0), N->getOperand(1));
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_FP_ROUND(SDNode *N) {
EVT NewVT = N->getValueType(0).getVectorElementType();
SDValue Op = GetScalarizedVector(N->getOperand(0));
return DAG.getNode(ISD::FP_ROUND, N->getDebugLoc(),
NewVT, Op, N->getOperand(1));
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_FPOWI(SDNode *N) {
SDValue Op = GetScalarizedVector(N->getOperand(0));
return DAG.getNode(ISD::FPOWI, N->getDebugLoc(),
Op.getValueType(), Op, N->getOperand(1));
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_INSERT_VECTOR_ELT(SDNode *N) {
// The value to insert may have a wider type than the vector element type,
// so be sure to truncate it to the element type if necessary.
SDValue Op = N->getOperand(1);
EVT EltVT = N->getValueType(0).getVectorElementType();
if (Op.getValueType() != EltVT)
// FIXME: Can this happen for floating point types?
Op = DAG.getNode(ISD::TRUNCATE, N->getDebugLoc(), EltVT, Op);
return Op;
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_LOAD(LoadSDNode *N) {
assert(N->isUnindexed() && "Indexed vector load?");
SDValue Result = DAG.getLoad(ISD::UNINDEXED,
N->getExtensionType(),
N->getValueType(0).getVectorElementType(),
N->getDebugLoc(),
N->getChain(), N->getBasePtr(),
DAG.getUNDEF(N->getBasePtr().getValueType()),
N->getPointerInfo(),
N->getMemoryVT().getVectorElementType(),
N->isVolatile(), N->isNonTemporal(),
N->isInvariant(), N->getOriginalAlignment());
// Legalized the chain result - switch anything that used the old chain to
// use the new one.
ReplaceValueWith(SDValue(N, 1), Result.getValue(1));
return Result;
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_UnaryOp(SDNode *N) {
// Get the dest type - it doesn't always match the input type, e.g. int_to_fp.
EVT DestVT = N->getValueType(0).getVectorElementType();
SDValue Op = GetScalarizedVector(N->getOperand(0));
return DAG.getNode(N->getOpcode(), N->getDebugLoc(), DestVT, Op);
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_InregOp(SDNode *N) {
EVT EltVT = N->getValueType(0).getVectorElementType();
EVT ExtVT = cast<VTSDNode>(N->getOperand(1))->getVT().getVectorElementType();
SDValue LHS = GetScalarizedVector(N->getOperand(0));
return DAG.getNode(N->getOpcode(), N->getDebugLoc(), EltVT,
LHS, DAG.getValueType(ExtVT));
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_SCALAR_TO_VECTOR(SDNode *N) {
// If the operand is wider than the vector element type then it is implicitly
// truncated. Make that explicit here.
EVT EltVT = N->getValueType(0).getVectorElementType();
SDValue InOp = N->getOperand(0);
if (InOp.getValueType() != EltVT)
return DAG.getNode(ISD::TRUNCATE, N->getDebugLoc(), EltVT, InOp);
return InOp;
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_VSELECT(SDNode *N) {
SDValue Cond = GetScalarizedVector(N->getOperand(0));
SDValue LHS = GetScalarizedVector(N->getOperand(1));
TargetLowering::BooleanContent ScalarBool = TLI.getBooleanContents(false);
TargetLowering::BooleanContent VecBool = TLI.getBooleanContents(true);
if (ScalarBool != VecBool) {
EVT CondVT = Cond.getValueType();
switch (ScalarBool) {
case TargetLowering::UndefinedBooleanContent:
break;
case TargetLowering::ZeroOrOneBooleanContent:
assert(VecBool == TargetLowering::UndefinedBooleanContent ||
VecBool == TargetLowering::ZeroOrNegativeOneBooleanContent);
// Vector read from all ones, scalar expects a single 1 so mask.
Cond = DAG.getNode(ISD::AND, N->getDebugLoc(), CondVT,
Cond, DAG.getConstant(1, CondVT));
break;
case TargetLowering::ZeroOrNegativeOneBooleanContent:
assert(VecBool == TargetLowering::UndefinedBooleanContent ||
VecBool == TargetLowering::ZeroOrOneBooleanContent);
// Vector reads from a one, scalar from all ones so sign extend.
Cond = DAG.getNode(ISD::SIGN_EXTEND_INREG, N->getDebugLoc(), CondVT,
Cond, DAG.getValueType(MVT::i1));
break;
}
}
return DAG.getNode(ISD::SELECT, N->getDebugLoc(),
LHS.getValueType(), Cond, LHS,
GetScalarizedVector(N->getOperand(2)));
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_SELECT(SDNode *N) {
SDValue LHS = GetScalarizedVector(N->getOperand(1));
return DAG.getNode(ISD::SELECT, N->getDebugLoc(),
LHS.getValueType(), N->getOperand(0), LHS,
GetScalarizedVector(N->getOperand(2)));
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_SELECT_CC(SDNode *N) {
SDValue LHS = GetScalarizedVector(N->getOperand(2));
return DAG.getNode(ISD::SELECT_CC, N->getDebugLoc(), LHS.getValueType(),
N->getOperand(0), N->getOperand(1),
LHS, GetScalarizedVector(N->getOperand(3)),
N->getOperand(4));
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_SETCC(SDNode *N) {
assert(N->getValueType(0).isVector() ==
N->getOperand(0).getValueType().isVector() &&
"Scalar/Vector type mismatch");
if (N->getValueType(0).isVector()) return ScalarizeVecRes_VSETCC(N);
SDValue LHS = GetScalarizedVector(N->getOperand(0));
SDValue RHS = GetScalarizedVector(N->getOperand(1));
DebugLoc DL = N->getDebugLoc();
// Turn it into a scalar SETCC.
return DAG.getNode(ISD::SETCC, DL, MVT::i1, LHS, RHS, N->getOperand(2));
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_UNDEF(SDNode *N) {
return DAG.getUNDEF(N->getValueType(0).getVectorElementType());
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_VECTOR_SHUFFLE(SDNode *N) {
// Figure out if the scalar is the LHS or RHS and return it.
SDValue Arg = N->getOperand(2).getOperand(0);
if (Arg.getOpcode() == ISD::UNDEF)
return DAG.getUNDEF(N->getValueType(0).getVectorElementType());
unsigned Op = !cast<ConstantSDNode>(Arg)->isNullValue();
return GetScalarizedVector(N->getOperand(Op));
}
SDValue DAGTypeLegalizer::ScalarizeVecRes_VSETCC(SDNode *N) {
assert(N->getValueType(0).isVector() &&
N->getOperand(0).getValueType().isVector() &&
"Operand types must be vectors");
SDValue LHS = GetScalarizedVector(N->getOperand(0));
SDValue RHS = GetScalarizedVector(N->getOperand(1));
EVT NVT = N->getValueType(0).getVectorElementType();
DebugLoc DL = N->getDebugLoc();
// Turn it into a scalar SETCC.
SDValue Res = DAG.getNode(ISD::SETCC, DL, MVT::i1, LHS, RHS,
N->getOperand(2));
// Vectors may have a different boolean contents to scalars. Promote the
// value appropriately.
ISD::NodeType ExtendCode =
TargetLowering::getExtendForContent(TLI.getBooleanContents(true));
return DAG.getNode(ExtendCode, DL, NVT, Res);
}
//===----------------------------------------------------------------------===//
// Operand Vector Scalarization <1 x ty> -> ty.
//===----------------------------------------------------------------------===//
bool DAGTypeLegalizer::ScalarizeVectorOperand(SDNode *N, unsigned OpNo) {
DEBUG(dbgs() << "Scalarize node operand " << OpNo << ": ";
N->dump(&DAG);
dbgs() << "\n");
SDValue Res = SDValue();
if (Res.getNode() == 0) {
switch (N->getOpcode()) {
default:
#ifndef NDEBUG
dbgs() << "ScalarizeVectorOperand Op #" << OpNo << ": ";
N->dump(&DAG);
dbgs() << "\n";
#endif
llvm_unreachable("Do not know how to scalarize this operator's operand!");
case ISD::BITCAST:
Res = ScalarizeVecOp_BITCAST(N);
break;
case ISD::CONCAT_VECTORS:
Res = ScalarizeVecOp_CONCAT_VECTORS(N);
break;
case ISD::EXTRACT_VECTOR_ELT:
Res = ScalarizeVecOp_EXTRACT_VECTOR_ELT(N);
break;
case ISD::STORE:
Res = ScalarizeVecOp_STORE(cast<StoreSDNode>(N), OpNo);
break;
}
}
// If the result is null, the sub-method took care of registering results etc.
if (!Res.getNode()) return false;
// If the result is N, the sub-method updated N in place. Tell the legalizer
// core about this.
if (Res.getNode() == N)
return true;
assert(Res.getValueType() == N->getValueType(0) && N->getNumValues() == 1 &&
"Invalid operand expansion");
ReplaceValueWith(SDValue(N, 0), Res);
return false;
}
/// ScalarizeVecOp_BITCAST - If the value to convert is a vector that needs
/// to be scalarized, it must be <1 x ty>. Convert the element instead.
SDValue DAGTypeLegalizer::ScalarizeVecOp_BITCAST(SDNode *N) {
SDValue Elt = GetScalarizedVector(N->getOperand(0));
return DAG.getNode(ISD::BITCAST, N->getDebugLoc(),
N->getValueType(0), Elt);
}
/// ScalarizeVecOp_CONCAT_VECTORS - The vectors to concatenate have length one -
/// use a BUILD_VECTOR instead.
SDValue DAGTypeLegalizer::ScalarizeVecOp_CONCAT_VECTORS(SDNode *N) {
SmallVector<SDValue, 8> Ops(N->getNumOperands());
for (unsigned i = 0, e = N->getNumOperands(); i < e; ++i)
Ops[i] = GetScalarizedVector(N->getOperand(i));
return DAG.getNode(ISD::BUILD_VECTOR, N->getDebugLoc(), N->getValueType(0),
&Ops[0], Ops.size());
}
/// ScalarizeVecOp_EXTRACT_VECTOR_ELT - If the input is a vector that needs to
/// be scalarized, it must be <1 x ty>, so just return the element, ignoring the
/// index.
SDValue DAGTypeLegalizer::ScalarizeVecOp_EXTRACT_VECTOR_ELT(SDNode *N) {
SDValue Res = GetScalarizedVector(N->getOperand(0));
if (Res.getValueType() != N->getValueType(0))
Res = DAG.getNode(ISD::ANY_EXTEND, N->getDebugLoc(), N->getValueType(0),
Res);
return Res;
}
/// ScalarizeVecOp_STORE - If the value to store is a vector that needs to be
/// scalarized, it must be <1 x ty>. Just store the element.
SDValue DAGTypeLegalizer::ScalarizeVecOp_STORE(StoreSDNode *N, unsigned OpNo){
assert(N->isUnindexed() && "Indexed store of one-element vector?");
assert(OpNo == 1 && "Do not know how to scalarize this operand!");
DebugLoc dl = N->getDebugLoc();
if (N->isTruncatingStore())
return DAG.getTruncStore(N->getChain(), dl,
GetScalarizedVector(N->getOperand(1)),
N->getBasePtr(), N->getPointerInfo(),
N->getMemoryVT().getVectorElementType(),
N->isVolatile(), N->isNonTemporal(),
N->getAlignment());
return DAG.getStore(N->getChain(), dl, GetScalarizedVector(N->getOperand(1)),
N->getBasePtr(), N->getPointerInfo(),
N->isVolatile(), N->isNonTemporal(),
N->getOriginalAlignment());
}
//===----------------------------------------------------------------------===//
// Result Vector Splitting
//===----------------------------------------------------------------------===//
/// SplitVectorResult - This method is called when the specified result of the
/// specified node is found to need vector splitting. At this point, the node
/// may also have invalid operands or may have other results that need
/// legalization, we just know that (at least) one result needs vector
/// splitting.
void DAGTypeLegalizer::SplitVectorResult(SDNode *N, unsigned ResNo) {
DEBUG(dbgs() << "Split node result: ";
N->dump(&DAG);
dbgs() << "\n");
SDValue Lo, Hi;
// See if the target wants to custom expand this node.
if (CustomLowerNode(N, N->getValueType(ResNo), true))
return;
switch (N->getOpcode()) {
default:
#ifndef NDEBUG
dbgs() << "SplitVectorResult #" << ResNo << ": ";
N->dump(&DAG);
dbgs() << "\n";
#endif
report_fatal_error("Do not know how to split the result of this "
"operator!\n");
case ISD::MERGE_VALUES: SplitRes_MERGE_VALUES(N, ResNo, Lo, Hi); break;
case ISD::VSELECT:
case ISD::SELECT: SplitRes_SELECT(N, Lo, Hi); break;
case ISD::SELECT_CC: SplitRes_SELECT_CC(N, Lo, Hi); break;
case ISD::UNDEF: SplitRes_UNDEF(N, Lo, Hi); break;
case ISD::BITCAST: SplitVecRes_BITCAST(N, Lo, Hi); break;
case ISD::BUILD_VECTOR: SplitVecRes_BUILD_VECTOR(N, Lo, Hi); break;
case ISD::CONCAT_VECTORS: SplitVecRes_CONCAT_VECTORS(N, Lo, Hi); break;
case ISD::EXTRACT_SUBVECTOR: SplitVecRes_EXTRACT_SUBVECTOR(N, Lo, Hi); break;
case ISD::FP_ROUND_INREG: SplitVecRes_InregOp(N, Lo, Hi); break;
case ISD::FPOWI: SplitVecRes_FPOWI(N, Lo, Hi); break;
case ISD::INSERT_VECTOR_ELT: SplitVecRes_INSERT_VECTOR_ELT(N, Lo, Hi); break;
case ISD::SCALAR_TO_VECTOR: SplitVecRes_SCALAR_TO_VECTOR(N, Lo, Hi); break;
case ISD::SIGN_EXTEND_INREG: SplitVecRes_InregOp(N, Lo, Hi); break;
case ISD::LOAD:
SplitVecRes_LOAD(cast<LoadSDNode>(N), Lo, Hi);
break;
case ISD::SETCC:
SplitVecRes_SETCC(N, Lo, Hi);
break;
case ISD::VECTOR_SHUFFLE:
SplitVecRes_VECTOR_SHUFFLE(cast<ShuffleVectorSDNode>(N), Lo, Hi);
break;
case ISD::ANY_EXTEND:
case ISD::CONVERT_RNDSAT:
case ISD::CTLZ:
case ISD::CTTZ:
case ISD::CTLZ_ZERO_UNDEF:
case ISD::CTTZ_ZERO_UNDEF:
case ISD::CTPOP:
case ISD::FABS:
case ISD::FCEIL:
case ISD::FCOS:
case ISD::FEXP:
case ISD::FEXP2:
case ISD::FFLOOR:
case ISD::FLOG:
case ISD::FLOG10:
case ISD::FLOG2:
case ISD::FNEARBYINT:
case ISD::FNEG:
case ISD::FP_EXTEND:
case ISD::FP_ROUND:
case ISD::FP_TO_SINT:
case ISD::FP_TO_UINT:
case ISD::FRINT:
case ISD::FSIN:
case ISD::FSQRT:
case ISD::FTRUNC:
case ISD::SIGN_EXTEND:
case ISD::SINT_TO_FP:
case ISD::TRUNCATE:
case ISD::UINT_TO_FP:
case ISD::ZERO_EXTEND:
SplitVecRes_UnaryOp(N, Lo, Hi);
break;
case ISD::ADD:
case ISD::SUB:
case ISD::MUL:
case ISD::FADD:
case ISD::FSUB:
case ISD::FMUL:
case ISD::SDIV:
case ISD::UDIV:
case ISD::FDIV:
case ISD::FPOW:
case ISD::AND:
case ISD::OR:
case ISD::XOR:
case ISD::SHL:
case ISD::SRA:
case ISD::SRL:
case ISD::UREM:
case ISD::SREM:
case ISD::FREM:
SplitVecRes_BinOp(N, Lo, Hi);
break;
case ISD::FMA:
SplitVecRes_TernaryOp(N, Lo, Hi);
break;
}
// If Lo/Hi is null, the sub-method took care of registering results etc.
if (Lo.getNode())
SetSplitVector(SDValue(N, ResNo), Lo, Hi);
}
void DAGTypeLegalizer::SplitVecRes_BinOp(SDNode *N, SDValue &Lo,
SDValue &Hi) {
SDValue LHSLo, LHSHi;
GetSplitVector(N->getOperand(0), LHSLo, LHSHi);
SDValue RHSLo, RHSHi;
GetSplitVector(N->getOperand(1), RHSLo, RHSHi);
DebugLoc dl = N->getDebugLoc();
Lo = DAG.getNode(N->getOpcode(), dl, LHSLo.getValueType(), LHSLo, RHSLo);
Hi = DAG.getNode(N->getOpcode(), dl, LHSHi.getValueType(), LHSHi, RHSHi);
}
void DAGTypeLegalizer::SplitVecRes_TernaryOp(SDNode *N, SDValue &Lo,
SDValue &Hi) {
SDValue Op0Lo, Op0Hi;
GetSplitVector(N->getOperand(0), Op0Lo, Op0Hi);
SDValue Op1Lo, Op1Hi;
GetSplitVector(N->getOperand(1), Op1Lo, Op1Hi);
SDValue Op2Lo, Op2Hi;
GetSplitVector(N->getOperand(2), Op2Lo, Op2Hi);
DebugLoc dl = N->getDebugLoc();
Lo = DAG.getNode(N->getOpcode(), dl, Op0Lo.getValueType(),
Op0Lo, Op1Lo, Op2Lo);
Hi = DAG.getNode(N->getOpcode(), dl, Op0Hi.getValueType(),
Op0Hi, Op1Hi, Op2Hi);
}
void DAGTypeLegalizer::SplitVecRes_BITCAST(SDNode *N, SDValue &Lo,
SDValue &Hi) {
// We know the result is a vector. The input may be either a vector or a
// scalar value.
EVT LoVT, HiVT;
GetSplitDestVTs(N->getValueType(0), LoVT, HiVT);
DebugLoc dl = N->getDebugLoc();
SDValue InOp = N->getOperand(0);
EVT InVT = InOp.getValueType();
// Handle some special cases efficiently.
switch (getTypeAction(InVT)) {
case TargetLowering::TypeLegal:
case TargetLowering::TypePromoteInteger:
case TargetLowering::TypeSoftenFloat:
case TargetLowering::TypeScalarizeVector:
case TargetLowering::TypeWidenVector:
break;
case TargetLowering::TypeExpandInteger:
case TargetLowering::TypeExpandFloat:
// A scalar to vector conversion, where the scalar needs expansion.
// If the vector is being split in two then we can just convert the
// expanded pieces.
if (LoVT == HiVT) {
GetExpandedOp(InOp, Lo, Hi);
if (TLI.isBigEndian())
std::swap(Lo, Hi);
Lo = DAG.getNode(ISD::BITCAST, dl, LoVT, Lo);
Hi = DAG.getNode(ISD::BITCAST, dl, HiVT, Hi);
return;
}
break;
case TargetLowering::TypeSplitVector:
// If the input is a vector that needs to be split, convert each split
// piece of the input now.
GetSplitVector(InOp, Lo, Hi);
Lo = DAG.getNode(ISD::BITCAST, dl, LoVT, Lo);
Hi = DAG.getNode(ISD::BITCAST, dl, HiVT, Hi);
return;
}
// In the general case, convert the input to an integer and split it by hand.
EVT LoIntVT = EVT::getIntegerVT(*DAG.getContext(), LoVT.getSizeInBits());
EVT HiIntVT = EVT::getIntegerVT(*DAG.getContext(), HiVT.getSizeInBits());
if (TLI.isBigEndian())
std::swap(LoIntVT, HiIntVT);
SplitInteger(BitConvertToInteger(InOp), LoIntVT, HiIntVT, Lo, Hi);
if (TLI.isBigEndian())
std::swap(Lo, Hi);
Lo = DAG.getNode(ISD::BITCAST, dl, LoVT, Lo);
Hi = DAG.getNode(ISD::BITCAST, dl, HiVT, Hi);
}
void DAGTypeLegalizer::SplitVecRes_BUILD_VECTOR(SDNode *N, SDValue &Lo,
SDValue &Hi) {
EVT LoVT, HiVT;
DebugLoc dl = N->getDebugLoc();
GetSplitDestVTs(N->getValueType(0), LoVT, HiVT);
unsigned LoNumElts = LoVT.getVectorNumElements();
SmallVector<SDValue, 8> LoOps(N->op_begin(), N->op_begin()+LoNumElts);
Lo = DAG.getNode(ISD::BUILD_VECTOR, dl, LoVT, &LoOps[0], LoOps.size());
SmallVector<SDValue, 8> HiOps(N->op_begin()+LoNumElts, N->op_end());
Hi = DAG.getNode(ISD::BUILD_VECTOR, dl, HiVT, &HiOps[0], HiOps.size());
}
void DAGTypeLegalizer::SplitVecRes_CONCAT_VECTORS(SDNode *N, SDValue &Lo,
SDValue &Hi) {
assert(!(N->getNumOperands() & 1) && "Unsupported CONCAT_VECTORS");
DebugLoc dl = N->getDebugLoc();
unsigned NumSubvectors = N->getNumOperands() / 2;
if (NumSubvectors == 1) {
Lo = N->getOperand(0);
Hi = N->getOperand(1);
return;
}
EVT LoVT, HiVT;
GetSplitDestVTs(N->getValueType(0), LoVT, HiVT);
SmallVector<SDValue, 8> LoOps(N->op_begin(), N->op_begin()+NumSubvectors);
Lo = DAG.getNode(ISD::CONCAT_VECTORS, dl, LoVT, &LoOps[0], LoOps.size());
SmallVector<SDValue, 8> HiOps(N->op_begin()+NumSubvectors, N->op_end());
Hi = DAG.getNode(ISD::CONCAT_VECTORS, dl, HiVT, &HiOps[0], HiOps.size());
}
void DAGTypeLegalizer::SplitVecRes_EXTRACT_SUBVECTOR(SDNode *N, SDValue &Lo,
SDValue &Hi) {
SDValue Vec = N->getOperand(0);
SDValue Idx = N->getOperand(1);
DebugLoc dl = N->getDebugLoc();
EVT LoVT, HiVT;
GetSplitDestVTs(N->getValueType(0), LoVT, HiVT);
Lo = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, LoVT, Vec, Idx);
uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
Hi = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, HiVT, Vec,
DAG.getIntPtrConstant(IdxVal + LoVT.getVectorNumElements()));
}
void DAGTypeLegalizer::SplitVecRes_FPOWI(SDNode *N, SDValue &Lo,
SDValue &Hi) {
DebugLoc dl = N->getDebugLoc();
GetSplitVector(N->getOperand(0), Lo, Hi);
Lo = DAG.getNode(ISD::FPOWI, dl, Lo.getValueType(), Lo, N->getOperand(1));
Hi = DAG.getNode(ISD::FPOWI, dl, Hi.getValueType(), Hi, N->getOperand(1));
}
void DAGTypeLegalizer::SplitVecRes_InregOp(SDNode *N, SDValue &Lo,
SDValue &Hi) {
SDValue LHSLo, LHSHi;
GetSplitVector(N->getOperand(0), LHSLo, LHSHi);
DebugLoc dl = N->getDebugLoc();
EVT LoVT, HiVT;
GetSplitDestVTs(cast<VTSDNode>(N->getOperand(1))->getVT(), LoVT, HiVT);
Lo = DAG.getNode(N->getOpcode(), dl, LHSLo.getValueType(), LHSLo,
DAG.getValueType(LoVT));
Hi = DAG.getNode(N->getOpcode(), dl, LHSHi.getValueType(), LHSHi,
DAG.getValueType(HiVT));
}
void DAGTypeLegalizer::SplitVecRes_INSERT_VECTOR_ELT(SDNode *N, SDValue &Lo,
SDValue &Hi) {
SDValue Vec = N->getOperand(0);
SDValue Elt = N->getOperand(1);
SDValue Idx = N->getOperand(2);
DebugLoc dl = N->getDebugLoc();
GetSplitVector(Vec, Lo, Hi);
if (ConstantSDNode *CIdx = dyn_cast<ConstantSDNode>(Idx)) {
unsigned IdxVal = CIdx->getZExtValue();
unsigned LoNumElts = Lo.getValueType().getVectorNumElements();
if (IdxVal < LoNumElts)
Lo = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl,
Lo.getValueType(), Lo, Elt, Idx);
else
Hi = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, Hi.getValueType(), Hi, Elt,
DAG.getIntPtrConstant(IdxVal - LoNumElts));
return;
}
// Spill the vector to the stack.
EVT VecVT = Vec.getValueType();
EVT EltVT = VecVT.getVectorElementType();
SDValue StackPtr = DAG.CreateStackTemporary(VecVT);
SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr,
MachinePointerInfo(), false, false, 0);
// Store the new element. This may be larger than the vector element type,
// so use a truncating store.
SDValue EltPtr = GetVectorElementPointer(StackPtr, EltVT, Idx);
Type *VecType = VecVT.getTypeForEVT(*DAG.getContext());
unsigned Alignment =
TLI.getDataLayout()->getPrefTypeAlignment(VecType);
Store = DAG.getTruncStore(Store, dl, Elt, EltPtr, MachinePointerInfo(), EltVT,
false, false, 0);
// Load the Lo part from the stack slot.
Lo = DAG.getLoad(Lo.getValueType(), dl, Store, StackPtr, MachinePointerInfo(),
false, false, false, 0);
// Increment the pointer to the other part.
unsigned IncrementSize = Lo.getValueType().getSizeInBits() / 8;
StackPtr = DAG.getNode(ISD::ADD, dl, StackPtr.getValueType(), StackPtr,
DAG.getIntPtrConstant(IncrementSize));
// Load the Hi part from the stack slot.
Hi = DAG.getLoad(Hi.getValueType(), dl, Store, StackPtr, MachinePointerInfo(),
false, false, false, MinAlign(Alignment, IncrementSize));
}
void DAGTypeLegalizer::SplitVecRes_SCALAR_TO_VECTOR(SDNode *N, SDValue &Lo,
SDValue &Hi) {
EVT LoVT, HiVT;
DebugLoc dl = N->getDebugLoc();
GetSplitDestVTs(N->getValueType(0), LoVT, HiVT);
Lo = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, LoVT, N->getOperand(0));
Hi = DAG.getUNDEF(HiVT);
}
void DAGTypeLegalizer::SplitVecRes_LOAD(LoadSDNode *LD, SDValue &Lo,
SDValue &Hi) {
assert(ISD::isUNINDEXEDLoad(LD) && "Indexed load during type legalization!");
EVT LoVT, HiVT;
DebugLoc dl = LD->getDebugLoc();
GetSplitDestVTs(LD->getValueType(0), LoVT, HiVT);
ISD::LoadExtType ExtType = LD->getExtensionType();
SDValue Ch = LD->getChain();
SDValue Ptr = LD->getBasePtr();
SDValue Offset = DAG.getUNDEF(Ptr.getValueType());
EVT MemoryVT = LD->getMemoryVT();
unsigned Alignment = LD->getOriginalAlignment();
bool isVolatile = LD->isVolatile();
bool isNonTemporal = LD->isNonTemporal();
bool isInvariant = LD->isInvariant();
EVT LoMemVT, HiMemVT;
GetSplitDestVTs(MemoryVT, LoMemVT, HiMemVT);
Lo = DAG.getLoad(ISD::UNINDEXED, ExtType, LoVT, dl, Ch, Ptr, Offset,
LD->getPointerInfo(), LoMemVT, isVolatile, isNonTemporal,
isInvariant, Alignment);
unsigned IncrementSize = LoMemVT.getSizeInBits()/8;
Ptr = DAG.getNode(ISD::ADD, dl, Ptr.getValueType(), Ptr,
DAG.getIntPtrConstant(IncrementSize));
Hi = DAG.getLoad(ISD::UNINDEXED, ExtType, HiVT, dl, Ch, Ptr, Offset,
LD->getPointerInfo().getWithOffset(IncrementSize),
HiMemVT, isVolatile, isNonTemporal, isInvariant, Alignment);
// Build a factor node to remember that this load is independent of the
// other one.
Ch = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Lo.getValue(1),
Hi.getValue(1));
// Legalized the chain result - switch anything that used the old chain to
// use the new one.
ReplaceValueWith(SDValue(LD, 1), Ch);
}
void DAGTypeLegalizer::SplitVecRes_SETCC(SDNode *N, SDValue &Lo, SDValue &Hi) {
assert(N->getValueType(0).isVector() &&
N->getOperand(0).getValueType().isVector() &&
"Operand types must be vectors");
EVT LoVT, HiVT;
DebugLoc DL = N->getDebugLoc();
GetSplitDestVTs(N->getValueType(0), LoVT, HiVT);
// Split the input.
EVT InVT = N->getOperand(0).getValueType();
SDValue LL, LH, RL, RH;
EVT InNVT = EVT::getVectorVT(*DAG.getContext(), InVT.getVectorElementType(),
LoVT.getVectorNumElements());
LL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0),
DAG.getIntPtrConstant(0));
LH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(0),
DAG.getIntPtrConstant(InNVT.getVectorNumElements()));
RL = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1),
DAG.getIntPtrConstant(0));
RH = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InNVT, N->getOperand(1),
DAG.getIntPtrConstant(InNVT.getVectorNumElements()));
Lo = DAG.getNode(N->getOpcode(), DL, LoVT, LL, RL, N->getOperand(2));
Hi = DAG.getNode(N->getOpcode(), DL, HiVT, LH, RH, N->getOperand(2));
}
void DAGTypeLegalizer::SplitVecRes_UnaryOp(SDNode *N, SDValue &Lo,
SDValue &Hi) {
// Get the dest types - they may not match the input types, e.g. int_to_fp.
EVT LoVT, HiVT;
DebugLoc dl = N->getDebugLoc();
GetSplitDestVTs(N->getValueType(0), LoVT, HiVT);
// If the input also splits, handle it directly for a compile time speedup.
// Otherwise split it by hand.
EVT InVT = N->getOperand(0).getValueType();
if (getTypeAction(InVT) == TargetLowering::TypeSplitVector) {
GetSplitVector(N->getOperand(0), Lo, Hi);
} else {
EVT InNVT = EVT::getVectorVT(*DAG.getContext(), InVT.getVectorElementType(),
LoVT.getVectorNumElements());
Lo = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InNVT, N->getOperand(0),
DAG.getIntPtrConstant(0));
Hi = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InNVT, N->getOperand(0),
DAG.getIntPtrConstant(InNVT.getVectorNumElements()));
}
if (N->getOpcode() == ISD::FP_ROUND) {
Lo = DAG.getNode(N->getOpcode(), dl, LoVT, Lo, N->getOperand(1));
Hi = DAG.getNode(N->getOpcode(), dl, HiVT, Hi, N->getOperand(1));
} else if (N->getOpcode() == ISD::CONVERT_RNDSAT) {
SDValue DTyOpLo = DAG.getValueType(LoVT);
SDValue DTyOpHi = DAG.getValueType(HiVT);
SDValue STyOpLo = DAG.getValueType(Lo.getValueType());
SDValue STyOpHi = DAG.getValueType(Hi.getValueType());
SDValue RndOp = N->getOperand(3);
SDValue SatOp = N->getOperand(4);
ISD::CvtCode CvtCode = cast<CvtRndSatSDNode>(N)->getCvtCode();
Lo = DAG.getConvertRndSat(LoVT, dl, Lo, DTyOpLo, STyOpLo, RndOp, SatOp,
CvtCode);
Hi = DAG.getConvertRndSat(HiVT, dl, Hi, DTyOpHi, STyOpHi, RndOp, SatOp,
CvtCode);
} else {
Lo = DAG.getNode(N->getOpcode(), dl, LoVT, Lo);
Hi = DAG.getNode(N->getOpcode(), dl, HiVT, Hi);
}
}
void DAGTypeLegalizer::SplitVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N,
SDValue &Lo, SDValue &Hi) {
// The low and high parts of the original input give four input vectors.
SDValue Inputs[4];
DebugLoc dl = N->getDebugLoc();
GetSplitVector(N->getOperand(0), Inputs[0], Inputs[1]);
GetSplitVector(N->getOperand(1), Inputs[2], Inputs[3]);
EVT NewVT = Inputs[0].getValueType();
unsigned NewElts = NewVT.getVectorNumElements();
// If Lo or Hi uses elements from at most two of the four input vectors, then
// express it as a vector shuffle of those two inputs. Otherwise extract the
// input elements by hand and construct the Lo/Hi output using a BUILD_VECTOR.
SmallVector<int, 16> Ops;
for (unsigned High = 0; High < 2; ++High) {
SDValue &Output = High ? Hi : Lo;
// Build a shuffle mask for the output, discovering on the fly which
// input vectors to use as shuffle operands (recorded in InputUsed).
// If building a suitable shuffle vector proves too hard, then bail
// out with useBuildVector set.
unsigned InputUsed[2] = { -1U, -1U }; // Not yet discovered.
unsigned FirstMaskIdx = High * NewElts;
bool useBuildVector = false;
for (unsigned MaskOffset = 0; MaskOffset < NewElts; ++MaskOffset) {
// The mask element. This indexes into the input.
int Idx = N->getMaskElt(FirstMaskIdx + MaskOffset);
// The input vector this mask element indexes into.
unsigned Input = (unsigned)Idx / NewElts;
if (Input >= array_lengthof(Inputs)) {
// The mask element does not index into any input vector.
Ops.push_back(-1);
continue;
}
// Turn the index into an offset from the start of the input vector.
Idx -= Input * NewElts;
// Find or create a shuffle vector operand to hold this input.
unsigned OpNo;
for (OpNo = 0; OpNo < array_lengthof(InputUsed); ++OpNo) {
if (InputUsed[OpNo] == Input) {
// This input vector is already an operand.
break;
} else if (InputUsed[OpNo] == -1U) {
// Create a new operand for this input vector.
InputUsed[OpNo] = Input;
break;
}
}
if (OpNo >= array_lengthof(InputUsed)) {
// More than two input vectors used! Give up on trying to create a
// shuffle vector. Insert all elements into a BUILD_VECTOR instead.
useBuildVector = true;
break;
}
// Add the mask index for the new shuffle vector.
Ops.push_back(Idx + OpNo * NewElts);
}
if (useBuildVector) {
EVT EltVT = NewVT.getVectorElementType();
SmallVector<SDValue, 16> SVOps;
// Extract the input elements by hand.
for (unsigned MaskOffset = 0; MaskOffset < NewElts; ++MaskOffset) {
// The mask element. This indexes into the input.
int Idx = N->getMaskElt(FirstMaskIdx + MaskOffset);
// The input vector this mask element indexes into.
unsigned Input = (unsigned)Idx / NewElts;
if (Input >= array_lengthof(Inputs)) {
// The mask element is "undef" or indexes off the end of the input.
SVOps.push_back(DAG.getUNDEF(EltVT));
continue;
}
// Turn the index into an offset from the start of the input vector.
Idx -= Input * NewElts;
// Extract the vector element by hand.
SVOps.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT,
Inputs[Input], DAG.getIntPtrConstant(Idx)));
}
// Construct the Lo/Hi output using a BUILD_VECTOR.
Output = DAG.getNode(ISD::BUILD_VECTOR,dl,NewVT, &SVOps[0], SVOps.size());
} else if (InputUsed[0] == -1U) {
// No input vectors were used! The result is undefined.
Output = DAG.getUNDEF(NewVT);
} else {
SDValue Op0 = Inputs[InputUsed[0]];
// If only one input was used, use an undefined vector for the other.
SDValue Op1 = InputUsed[1] == -1U ?
DAG.getUNDEF(NewVT) : Inputs[InputUsed[1]];
// At least one input vector was used. Create a new shuffle vector.
Output = DAG.getVectorShuffle(NewVT, dl, Op0, Op1, &Ops[0]);
}
Ops.clear();
}
}
//===----------------------------------------------------------------------===//
// Operand Vector Splitting
//===----------------------------------------------------------------------===//
/// SplitVectorOperand - This method is called when the specified operand of the
/// specified node is found to need vector splitting. At this point, all of the
/// result types of the node are known to be legal, but other operands of the
/// node may need legalization as well as the specified one.
bool DAGTypeLegalizer::SplitVectorOperand(SDNode *N, unsigned OpNo) {
DEBUG(dbgs() << "Split node operand: ";
N->dump(&DAG);
dbgs() << "\n");
SDValue Res = SDValue();
if (Res.getNode() == 0) {
switch (N->getOpcode()) {
default:
#ifndef NDEBUG
dbgs() << "SplitVectorOperand Op #" << OpNo << ": ";
N->dump(&DAG);
dbgs() << "\n";
#endif
report_fatal_error("Do not know how to split this operator's "
"operand!\n");
case ISD::SETCC: Res = SplitVecOp_VSETCC(N); break;
case ISD::BITCAST: Res = SplitVecOp_BITCAST(N); break;
case ISD::EXTRACT_SUBVECTOR: Res = SplitVecOp_EXTRACT_SUBVECTOR(N); break;
case ISD::EXTRACT_VECTOR_ELT:Res = SplitVecOp_EXTRACT_VECTOR_ELT(N); break;
case ISD::CONCAT_VECTORS: Res = SplitVecOp_CONCAT_VECTORS(N); break;
case ISD::FP_ROUND: Res = SplitVecOp_FP_ROUND(N); break;
case ISD::STORE:
Res = SplitVecOp_STORE(cast<StoreSDNode>(N), OpNo);
break;
case ISD::CTTZ:
case ISD::CTLZ:
case ISD::CTPOP:
case ISD::FP_EXTEND:
case ISD::FP_TO_SINT:
case ISD::FP_TO_UINT:
case ISD::SINT_TO_FP:
case ISD::UINT_TO_FP:
case ISD::FTRUNC:
case ISD::TRUNCATE:
case ISD::SIGN_EXTEND:
case ISD::ZERO_EXTEND:
case ISD::ANY_EXTEND:
Res = SplitVecOp_UnaryOp(N);
break;
}
}
// If the result is null, the sub-method took care of registering results etc.
if (!Res.getNode()) return false;
// If the result is N, the sub-method updated N in place. Tell the legalizer
// core about this.
if (Res.getNode() == N)
return true;
assert(Res.getValueType() == N->getValueType(0) && N->getNumValues() == 1 &&
"Invalid operand expansion");
ReplaceValueWith(SDValue(N, 0), Res);
return false;
}
SDValue DAGTypeLegalizer::SplitVecOp_UnaryOp(SDNode *N) {
// The result has a legal vector type, but the input needs splitting.
EVT ResVT = N->getValueType(0);
SDValue Lo, Hi;
DebugLoc dl = N->getDebugLoc();
GetSplitVector(N->getOperand(0), Lo, Hi);
EVT InVT = Lo.getValueType();
EVT OutVT = EVT::getVectorVT(*DAG.getContext(), ResVT.getVectorElementType(),
InVT.getVectorNumElements());
Lo = DAG.getNode(N->getOpcode(), dl, OutVT, Lo);
Hi = DAG.getNode(N->getOpcode(), dl, OutVT, Hi);
return DAG.getNode(ISD::CONCAT_VECTORS, dl, ResVT, Lo, Hi);
}
SDValue DAGTypeLegalizer::SplitVecOp_BITCAST(SDNode *N) {
// For example, i64 = BITCAST v4i16 on alpha. Typically the vector will
// end up being split all the way down to individual components. Convert the
// split pieces into integers and reassemble.
SDValue Lo, Hi;
GetSplitVector(N->getOperand(0), Lo, Hi);
Lo = BitConvertToInteger(Lo);
Hi = BitConvertToInteger(Hi);
if (TLI.isBigEndian())
std::swap(Lo, Hi);
return DAG.getNode(ISD::BITCAST, N->getDebugLoc(), N->getValueType(0),
JoinIntegers(Lo, Hi));
}
SDValue DAGTypeLegalizer::SplitVecOp_EXTRACT_SUBVECTOR(SDNode *N) {
// We know that the extracted result type is legal.
EVT SubVT = N->getValueType(0);
SDValue Idx = N->getOperand(1);
DebugLoc dl = N->getDebugLoc();
SDValue Lo, Hi;
GetSplitVector(N->getOperand(0), Lo, Hi);
uint64_t LoElts = Lo.getValueType().getVectorNumElements();
uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
if (IdxVal < LoElts) {
assert(IdxVal + SubVT.getVectorNumElements() <= LoElts &&
"Extracted subvector crosses vector split!");
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, SubVT, Lo, Idx);
} else {
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, SubVT, Hi,
DAG.getConstant(IdxVal - LoElts, Idx.getValueType()));
}
}
SDValue DAGTypeLegalizer::SplitVecOp_EXTRACT_VECTOR_ELT(SDNode *N) {
SDValue Vec = N->getOperand(0);
SDValue Idx = N->getOperand(1);
EVT VecVT = Vec.getValueType();
if (isa<ConstantSDNode>(Idx)) {
uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
assert(IdxVal < VecVT.getVectorNumElements() && "Invalid vector index!");
SDValue Lo, Hi;
GetSplitVector(Vec, Lo, Hi);
uint64_t LoElts = Lo.getValueType().getVectorNumElements();
if (IdxVal < LoElts)
return SDValue(DAG.UpdateNodeOperands(N, Lo, Idx), 0);
return SDValue(DAG.UpdateNodeOperands(N, Hi,
DAG.getConstant(IdxVal - LoElts,
Idx.getValueType())), 0);
}
// Store the vector to the stack.
EVT EltVT = VecVT.getVectorElementType();
DebugLoc dl = N->getDebugLoc();
SDValue StackPtr = DAG.CreateStackTemporary(VecVT);
SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr,
MachinePointerInfo(), false, false, 0);
// Load back the required element.
StackPtr = GetVectorElementPointer(StackPtr, EltVT, Idx);
return DAG.getExtLoad(ISD::EXTLOAD, dl, N->getValueType(0), Store, StackPtr,
MachinePointerInfo(), EltVT, false, false, 0);
}
SDValue DAGTypeLegalizer::SplitVecOp_STORE(StoreSDNode *N, unsigned OpNo) {
assert(N->isUnindexed() && "Indexed store of vector?");
assert(OpNo == 1 && "Can only split the stored value");
DebugLoc DL = N->getDebugLoc();
bool isTruncating = N->isTruncatingStore();
SDValue Ch = N->getChain();
SDValue Ptr = N->getBasePtr();
EVT MemoryVT = N->getMemoryVT();
unsigned Alignment = N->getOriginalAlignment();
bool isVol = N->isVolatile();
bool isNT = N->isNonTemporal();
SDValue Lo, Hi;
GetSplitVector(N->getOperand(1), Lo, Hi);
EVT LoMemVT, HiMemVT;
GetSplitDestVTs(MemoryVT, LoMemVT, HiMemVT);
unsigned IncrementSize = LoMemVT.getSizeInBits()/8;
if (isTruncating)
Lo = DAG.getTruncStore(Ch, DL, Lo, Ptr, N->getPointerInfo(),
LoMemVT, isVol, isNT, Alignment);
else
Lo = DAG.getStore(Ch, DL, Lo, Ptr, N->getPointerInfo(),
isVol, isNT, Alignment);
// Increment the pointer to the other half.
Ptr = DAG.getNode(ISD::ADD, DL, Ptr.getValueType(), Ptr,
DAG.getIntPtrConstant(IncrementSize));
if (isTruncating)
Hi = DAG.getTruncStore(Ch, DL, Hi, Ptr,
N->getPointerInfo().getWithOffset(IncrementSize),
HiMemVT, isVol, isNT, Alignment);
else
Hi = DAG.getStore(Ch, DL, Hi, Ptr,
N->getPointerInfo().getWithOffset(IncrementSize),
isVol, isNT, Alignment);
return DAG.getNode(ISD::TokenFactor, DL, MVT::Other, Lo, Hi);
}
SDValue DAGTypeLegalizer::SplitVecOp_CONCAT_VECTORS(SDNode *N) {
DebugLoc DL = N->getDebugLoc();
// The input operands all must have the same type, and we know the result the
// result type is valid. Convert this to a buildvector which extracts all the
// input elements.
// TODO: If the input elements are power-two vectors, we could convert this to
// a new CONCAT_VECTORS node with elements that are half-wide.
SmallVector<SDValue, 32> Elts;
EVT EltVT = N->getValueType(0).getVectorElementType();
for (unsigned op = 0, e = N->getNumOperands(); op != e; ++op) {
SDValue Op = N->getOperand(op);
for (unsigned i = 0, e = Op.getValueType().getVectorNumElements();
i != e; ++i) {
Elts.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, EltVT,
Op, DAG.getIntPtrConstant(i)));
}
}
return DAG.getNode(ISD::BUILD_VECTOR, DL, N->getValueType(0),
&Elts[0], Elts.size());
}
SDValue DAGTypeLegalizer::SplitVecOp_VSETCC(SDNode *N) {
assert(N->getValueType(0).isVector() &&
N->getOperand(0).getValueType().isVector() &&
"Operand types must be vectors");
// The result has a legal vector type, but the input needs splitting.
SDValue Lo0, Hi0, Lo1, Hi1, LoRes, HiRes;
DebugLoc DL = N->getDebugLoc();
GetSplitVector(N->getOperand(0), Lo0, Hi0);
GetSplitVector(N->getOperand(1), Lo1, Hi1);
unsigned PartElements = Lo0.getValueType().getVectorNumElements();
EVT PartResVT = EVT::getVectorVT(*DAG.getContext(), MVT::i1, PartElements);
EVT WideResVT = EVT::getVectorVT(*DAG.getContext(), MVT::i1, 2*PartElements);
LoRes = DAG.getNode(ISD::SETCC, DL, PartResVT, Lo0, Lo1, N->getOperand(2));
HiRes = DAG.getNode(ISD::SETCC, DL, PartResVT, Hi0, Hi1, N->getOperand(2));
SDValue Con = DAG.getNode(ISD::CONCAT_VECTORS, DL, WideResVT, LoRes, HiRes);
return PromoteTargetBoolean(Con, N->getValueType(0));
}
SDValue DAGTypeLegalizer::SplitVecOp_FP_ROUND(SDNode *N) {
// The result has a legal vector type, but the input needs splitting.
EVT ResVT = N->getValueType(0);
SDValue Lo, Hi;
DebugLoc DL = N->getDebugLoc();
GetSplitVector(N->getOperand(0), Lo, Hi);
EVT InVT = Lo.getValueType();
EVT OutVT = EVT::getVectorVT(*DAG.getContext(), ResVT.getVectorElementType(),
InVT.getVectorNumElements());
Lo = DAG.getNode(ISD::FP_ROUND, DL, OutVT, Lo, N->getOperand(1));
Hi = DAG.getNode(ISD::FP_ROUND, DL, OutVT, Hi, N->getOperand(1));
return DAG.getNode(ISD::CONCAT_VECTORS, DL, ResVT, Lo, Hi);
}
//===----------------------------------------------------------------------===//
// Result Vector Widening
//===----------------------------------------------------------------------===//
void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) {
DEBUG(dbgs() << "Widen node result " << ResNo << ": ";
N->dump(&DAG);
dbgs() << "\n");
// See if the target wants to custom widen this node.
if (CustomWidenLowerNode(N, N->getValueType(ResNo)))
return;
SDValue Res = SDValue();
switch (N->getOpcode()) {
default:
#ifndef NDEBUG
dbgs() << "WidenVectorResult #" << ResNo << ": ";
N->dump(&DAG);
dbgs() << "\n";
#endif
llvm_unreachable("Do not know how to widen the result of this operator!");
case ISD::MERGE_VALUES: Res = WidenVecRes_MERGE_VALUES(N, ResNo); break;
case ISD::BITCAST: Res = WidenVecRes_BITCAST(N); break;
case ISD::BUILD_VECTOR: Res = WidenVecRes_BUILD_VECTOR(N); break;
case ISD::CONCAT_VECTORS: Res = WidenVecRes_CONCAT_VECTORS(N); break;
case ISD::CONVERT_RNDSAT: Res = WidenVecRes_CONVERT_RNDSAT(N); break;
case ISD::EXTRACT_SUBVECTOR: Res = WidenVecRes_EXTRACT_SUBVECTOR(N); break;
case ISD::FP_ROUND_INREG: Res = WidenVecRes_InregOp(N); break;
case ISD::INSERT_VECTOR_ELT: Res = WidenVecRes_INSERT_VECTOR_ELT(N); break;
case ISD::LOAD: Res = WidenVecRes_LOAD(N); break;
case ISD::SCALAR_TO_VECTOR: Res = WidenVecRes_SCALAR_TO_VECTOR(N); break;
case ISD::SIGN_EXTEND_INREG: Res = WidenVecRes_InregOp(N); break;
case ISD::VSELECT:
case ISD::SELECT: Res = WidenVecRes_SELECT(N); break;
case ISD::SELECT_CC: Res = WidenVecRes_SELECT_CC(N); break;
case ISD::SETCC: Res = WidenVecRes_SETCC(N); break;
case ISD::UNDEF: Res = WidenVecRes_UNDEF(N); break;
case ISD::VECTOR_SHUFFLE:
Res = WidenVecRes_VECTOR_SHUFFLE(cast<ShuffleVectorSDNode>(N));
break;
case ISD::ADD:
case ISD::AND:
case ISD::BSWAP:
case ISD::FADD:
case ISD::FCOPYSIGN:
case ISD::FDIV:
case ISD::FMUL:
case ISD::FPOW:
case ISD::FREM:
case ISD::FSUB:
case ISD::MUL:
case ISD::MULHS:
case ISD::MULHU:
case ISD::OR:
case ISD::SDIV:
case ISD::SREM:
case ISD::UDIV:
case ISD::UREM:
case ISD::SUB:
case ISD::XOR:
Res = WidenVecRes_Binary(N);
break;
case ISD::FPOWI:
Res = WidenVecRes_POWI(N);
break;
case ISD::SHL:
case ISD::SRA:
case ISD::SRL:
Res = WidenVecRes_Shift(N);
break;
case ISD::ANY_EXTEND:
case ISD::FP_EXTEND:
case ISD::FP_ROUND:
case ISD::FP_TO_SINT:
case ISD::FP_TO_UINT:
case ISD::SIGN_EXTEND:
case ISD::SINT_TO_FP:
case ISD::TRUNCATE:
case ISD::UINT_TO_FP:
case ISD::ZERO_EXTEND:
Res = WidenVecRes_Convert(N);
break;
case ISD::CTLZ:
case ISD::CTPOP:
case ISD::CTTZ:
case ISD::FABS:
case ISD::FCEIL:
case ISD::FCOS:
case ISD::FEXP:
case ISD::FEXP2:
case ISD::FFLOOR:
case ISD::FLOG:
case ISD::FLOG10:
case ISD::FLOG2:
case ISD::FNEARBYINT:
case ISD::FNEG:
case ISD::FRINT:
case ISD::FSIN:
case ISD::FSQRT:
case ISD::FTRUNC:
Res = WidenVecRes_Unary(N);
break;
case ISD::FMA:
Res = WidenVecRes_Ternary(N);
break;
}
// If Res is null, the sub-method took care of registering the result.
if (Res.getNode())
SetWidenedVector(SDValue(N, ResNo), Res);
}
SDValue DAGTypeLegalizer::WidenVecRes_Ternary(SDNode *N) {
// Ternary op widening.
DebugLoc dl = N->getDebugLoc();
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
SDValue InOp1 = GetWidenedVector(N->getOperand(0));
SDValue InOp2 = GetWidenedVector(N->getOperand(1));
SDValue InOp3 = GetWidenedVector(N->getOperand(2));
return DAG.getNode(N->getOpcode(), dl, WidenVT, InOp1, InOp2, InOp3);
}
SDValue DAGTypeLegalizer::WidenVecRes_Binary(SDNode *N) {
// Binary op widening.
unsigned Opcode = N->getOpcode();
DebugLoc dl = N->getDebugLoc();
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
EVT WidenEltVT = WidenVT.getVectorElementType();
EVT VT = WidenVT;
unsigned NumElts = VT.getVectorNumElements();
while (!TLI.isTypeLegal(VT) && NumElts != 1) {
NumElts = NumElts / 2;
VT = EVT::getVectorVT(*DAG.getContext(), WidenEltVT, NumElts);
}
if (NumElts != 1 && !TLI.canOpTrap(N->getOpcode(), VT)) {
// Operation doesn't trap so just widen as normal.
SDValue InOp1 = GetWidenedVector(N->getOperand(0));
SDValue InOp2 = GetWidenedVector(N->getOperand(1));
return DAG.getNode(N->getOpcode(), dl, WidenVT, InOp1, InOp2);
}
// No legal vector version so unroll the vector operation and then widen.
if (NumElts == 1)
return DAG.UnrollVectorOp(N, WidenVT.getVectorNumElements());
// Since the operation can trap, apply operation on the original vector.
EVT MaxVT = VT;
SDValue InOp1 = GetWidenedVector(N->getOperand(0));
SDValue InOp2 = GetWidenedVector(N->getOperand(1));
unsigned CurNumElts = N->getValueType(0).getVectorNumElements();
SmallVector<SDValue, 16> ConcatOps(CurNumElts);
unsigned ConcatEnd = 0; // Current ConcatOps index.
int Idx = 0; // Current Idx into input vectors.
// NumElts := greatest legal vector size (at most WidenVT)
// while (orig. vector has unhandled elements) {
// take munches of size NumElts from the beginning and add to ConcatOps
// NumElts := next smaller supported vector size or 1
// }
while (CurNumElts != 0) {
while (CurNumElts >= NumElts) {
SDValue EOp1 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VT, InOp1,
DAG.getIntPtrConstant(Idx));
SDValue EOp2 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VT, InOp2,
DAG.getIntPtrConstant(Idx));
ConcatOps[ConcatEnd++] = DAG.getNode(Opcode, dl, VT, EOp1, EOp2);
Idx += NumElts;
CurNumElts -= NumElts;
}
do {
NumElts = NumElts / 2;
VT = EVT::getVectorVT(*DAG.getContext(), WidenEltVT, NumElts);
} while (!TLI.isTypeLegal(VT) && NumElts != 1);
if (NumElts == 1) {
for (unsigned i = 0; i != CurNumElts; ++i, ++Idx) {
SDValue EOp1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, WidenEltVT,
InOp1, DAG.getIntPtrConstant(Idx));
SDValue EOp2 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, WidenEltVT,
InOp2, DAG.getIntPtrConstant(Idx));
ConcatOps[ConcatEnd++] = DAG.getNode(Opcode, dl, WidenEltVT,
EOp1, EOp2);
}
CurNumElts = 0;
}
}
// Check to see if we have a single operation with the widen type.
if (ConcatEnd == 1) {
VT = ConcatOps[0].getValueType();
if (VT == WidenVT)
return ConcatOps[0];
}
// while (Some element of ConcatOps is not of type MaxVT) {
// From the end of ConcatOps, collect elements of the same type and put
// them into an op of the next larger supported type
// }
while (ConcatOps[ConcatEnd-1].getValueType() != MaxVT) {
Idx = ConcatEnd - 1;
VT = ConcatOps[Idx--].getValueType();
while (Idx >= 0 && ConcatOps[Idx].getValueType() == VT)
Idx--;
int NextSize = VT.isVector() ? VT.getVectorNumElements() : 1;
EVT NextVT;
do {
NextSize *= 2;
NextVT = EVT::getVectorVT(*DAG.getContext(), WidenEltVT, NextSize);
} while (!TLI.isTypeLegal(NextVT));
if (!VT.isVector()) {
// Scalar type, create an INSERT_VECTOR_ELEMENT of type NextVT
SDValue VecOp = DAG.getUNDEF(NextVT);
unsigned NumToInsert = ConcatEnd - Idx - 1;
for (unsigned i = 0, OpIdx = Idx+1; i < NumToInsert; i++, OpIdx++) {
VecOp = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, NextVT, VecOp,
ConcatOps[OpIdx], DAG.getIntPtrConstant(i));
}
ConcatOps[Idx+1] = VecOp;
ConcatEnd = Idx + 2;
} else {
// Vector type, create a CONCAT_VECTORS of type NextVT
SDValue undefVec = DAG.getUNDEF(VT);
unsigned OpsToConcat = NextSize/VT.getVectorNumElements();
SmallVector<SDValue, 16> SubConcatOps(OpsToConcat);
unsigned RealVals = ConcatEnd - Idx - 1;
unsigned SubConcatEnd = 0;
unsigned SubConcatIdx = Idx + 1;
while (SubConcatEnd < RealVals)
SubConcatOps[SubConcatEnd++] = ConcatOps[++Idx];
while (SubConcatEnd < OpsToConcat)
SubConcatOps[SubConcatEnd++] = undefVec;
ConcatOps[SubConcatIdx] = DAG.getNode(ISD::CONCAT_VECTORS, dl,
NextVT, &SubConcatOps[0],
OpsToConcat);
ConcatEnd = SubConcatIdx + 1;
}
}
// Check to see if we have a single operation with the widen type.
if (ConcatEnd == 1) {
VT = ConcatOps[0].getValueType();
if (VT == WidenVT)
return ConcatOps[0];
}
// add undefs of size MaxVT until ConcatOps grows to length of WidenVT
unsigned NumOps = WidenVT.getVectorNumElements()/MaxVT.getVectorNumElements();
if (NumOps != ConcatEnd ) {
SDValue UndefVal = DAG.getUNDEF(MaxVT);
for (unsigned j = ConcatEnd; j < NumOps; ++j)
ConcatOps[j] = UndefVal;
}
return DAG.getNode(ISD::CONCAT_VECTORS, dl, WidenVT, &ConcatOps[0], NumOps);
}
SDValue DAGTypeLegalizer::WidenVecRes_Convert(SDNode *N) {
SDValue InOp = N->getOperand(0);
DebugLoc DL = N->getDebugLoc();
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
unsigned WidenNumElts = WidenVT.getVectorNumElements();
EVT InVT = InOp.getValueType();
EVT InEltVT = InVT.getVectorElementType();
EVT InWidenVT = EVT::getVectorVT(*DAG.getContext(), InEltVT, WidenNumElts);
unsigned Opcode = N->getOpcode();
unsigned InVTNumElts = InVT.getVectorNumElements();
if (getTypeAction(InVT) == TargetLowering::TypeWidenVector) {
InOp = GetWidenedVector(N->getOperand(0));
InVT = InOp.getValueType();
InVTNumElts = InVT.getVectorNumElements();
if (InVTNumElts == WidenNumElts) {
if (N->getNumOperands() == 1)
return DAG.getNode(Opcode, DL, WidenVT, InOp);
return DAG.getNode(Opcode, DL, WidenVT, InOp, N->getOperand(1));
}
}
if (TLI.isTypeLegal(InWidenVT)) {
// Because the result and the input are different vector types, widening
// the result could create a legal type but widening the input might make
// it an illegal type that might lead to repeatedly splitting the input
// and then widening it. To avoid this, we widen the input only if
// it results in a legal type.
if (WidenNumElts % InVTNumElts == 0) {
// Widen the input and call convert on the widened input vector.
unsigned NumConcat = WidenNumElts/InVTNumElts;
SmallVector<SDValue, 16> Ops(NumConcat);
Ops[0] = InOp;
SDValue UndefVal = DAG.getUNDEF(InVT);
for (unsigned i = 1; i != NumConcat; ++i)
Ops[i] = UndefVal;
SDValue InVec = DAG.getNode(ISD::CONCAT_VECTORS, DL, InWidenVT,
&Ops[0], NumConcat);
if (N->getNumOperands() == 1)
return DAG.getNode(Opcode, DL, WidenVT, InVec);
return DAG.getNode(Opcode, DL, WidenVT, InVec, N->getOperand(1));
}
if (InVTNumElts % WidenNumElts == 0) {
SDValue InVal = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, InWidenVT,
InOp, DAG.getIntPtrConstant(0));
// Extract the input and convert the shorten input vector.
if (N->getNumOperands() == 1)
return DAG.getNode(Opcode, DL, WidenVT, InVal);
return DAG.getNode(Opcode, DL, WidenVT, InVal, N->getOperand(1));
}
}
// Otherwise unroll into some nasty scalar code and rebuild the vector.
SmallVector<SDValue, 16> Ops(WidenNumElts);
EVT EltVT = WidenVT.getVectorElementType();
unsigned MinElts = std::min(InVTNumElts, WidenNumElts);
unsigned i;
for (i=0; i < MinElts; ++i) {
SDValue Val = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, InEltVT, InOp,
DAG.getIntPtrConstant(i));
if (N->getNumOperands() == 1)
Ops[i] = DAG.getNode(Opcode, DL, EltVT, Val);
else
Ops[i] = DAG.getNode(Opcode, DL, EltVT, Val, N->getOperand(1));
}
SDValue UndefVal = DAG.getUNDEF(EltVT);
for (; i < WidenNumElts; ++i)
Ops[i] = UndefVal;
return DAG.getNode(ISD::BUILD_VECTOR, DL, WidenVT, &Ops[0], WidenNumElts);
}
SDValue DAGTypeLegalizer::WidenVecRes_POWI(SDNode *N) {
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
SDValue InOp = GetWidenedVector(N->getOperand(0));
SDValue ShOp = N->getOperand(1);
return DAG.getNode(N->getOpcode(), N->getDebugLoc(), WidenVT, InOp, ShOp);
}
SDValue DAGTypeLegalizer::WidenVecRes_Shift(SDNode *N) {
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
SDValue InOp = GetWidenedVector(N->getOperand(0));
SDValue ShOp = N->getOperand(1);
EVT ShVT = ShOp.getValueType();
if (getTypeAction(ShVT) == TargetLowering::TypeWidenVector) {
ShOp = GetWidenedVector(ShOp);
ShVT = ShOp.getValueType();
}
EVT ShWidenVT = EVT::getVectorVT(*DAG.getContext(),
ShVT.getVectorElementType(),
WidenVT.getVectorNumElements());
if (ShVT != ShWidenVT)
ShOp = ModifyToType(ShOp, ShWidenVT);
return DAG.getNode(N->getOpcode(), N->getDebugLoc(), WidenVT, InOp, ShOp);
}
SDValue DAGTypeLegalizer::WidenVecRes_Unary(SDNode *N) {
// Unary op widening.
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
SDValue InOp = GetWidenedVector(N->getOperand(0));
return DAG.getNode(N->getOpcode(), N->getDebugLoc(), WidenVT, InOp);
}
SDValue DAGTypeLegalizer::WidenVecRes_InregOp(SDNode *N) {
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
EVT ExtVT = EVT::getVectorVT(*DAG.getContext(),
cast<VTSDNode>(N->getOperand(1))->getVT()
.getVectorElementType(),
WidenVT.getVectorNumElements());
SDValue WidenLHS = GetWidenedVector(N->getOperand(0));
return DAG.getNode(N->getOpcode(), N->getDebugLoc(),
WidenVT, WidenLHS, DAG.getValueType(ExtVT));
}
SDValue DAGTypeLegalizer::WidenVecRes_MERGE_VALUES(SDNode *N, unsigned ResNo) {
SDValue WidenVec = DisintegrateMERGE_VALUES(N, ResNo);
return GetWidenedVector(WidenVec);
}
SDValue DAGTypeLegalizer::WidenVecRes_BITCAST(SDNode *N) {
SDValue InOp = N->getOperand(0);
EVT InVT = InOp.getValueType();
EVT VT = N->getValueType(0);
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
DebugLoc dl = N->getDebugLoc();
switch (getTypeAction(InVT)) {
case TargetLowering::TypeLegal:
break;
case TargetLowering::TypePromoteInteger:
// If the incoming type is a vector that is being promoted, then
// we know that the elements are arranged differently and that we
// must perform the conversion using a stack slot.
if (InVT.isVector())
break;
// If the InOp is promoted to the same size, convert it. Otherwise,
// fall out of the switch and widen the promoted input.
InOp = GetPromotedInteger(InOp);
InVT = InOp.getValueType();
if (WidenVT.bitsEq(InVT))
return DAG.getNode(ISD::BITCAST, dl, WidenVT, InOp);
break;
case TargetLowering::TypeSoftenFloat:
case TargetLowering::TypeExpandInteger:
case TargetLowering::TypeExpandFloat:
case TargetLowering::TypeScalarizeVector:
case TargetLowering::TypeSplitVector:
break;
case TargetLowering::TypeWidenVector:
// If the InOp is widened to the same size, convert it. Otherwise, fall
// out of the switch and widen the widened input.
InOp = GetWidenedVector(InOp);
InVT = InOp.getValueType();
if (WidenVT.bitsEq(InVT))
// The input widens to the same size. Convert to the widen value.
return DAG.getNode(ISD::BITCAST, dl, WidenVT, InOp);
break;
}
unsigned WidenSize = WidenVT.getSizeInBits();
unsigned InSize = InVT.getSizeInBits();
// x86mmx is not an acceptable vector element type, so don't try.
if (WidenSize % InSize == 0 && InVT != MVT::x86mmx) {
// Determine new input vector type. The new input vector type will use
// the same element type (if its a vector) or use the input type as a
// vector. It is the same size as the type to widen to.
EVT NewInVT;
unsigned NewNumElts = WidenSize / InSize;
if (InVT.isVector()) {
EVT InEltVT = InVT.getVectorElementType();
NewInVT = EVT::getVectorVT(*DAG.getContext(), InEltVT,
WidenSize / InEltVT.getSizeInBits());
} else {
NewInVT = EVT::getVectorVT(*DAG.getContext(), InVT, NewNumElts);
}
if (TLI.isTypeLegal(NewInVT)) {
// Because the result and the input are different vector types, widening
// the result could create a legal type but widening the input might make
// it an illegal type that might lead to repeatedly splitting the input
// and then widening it. To avoid this, we widen the input only if
// it results in a legal type.
SmallVector<SDValue, 16> Ops(NewNumElts);
SDValue UndefVal = DAG.getUNDEF(InVT);
Ops[0] = InOp;
for (unsigned i = 1; i < NewNumElts; ++i)
Ops[i] = UndefVal;
SDValue NewVec;
if (InVT.isVector())
NewVec = DAG.getNode(ISD::CONCAT_VECTORS, dl,
NewInVT, &Ops[0], NewNumElts);
else
NewVec = DAG.getNode(ISD::BUILD_VECTOR, dl,
NewInVT, &Ops[0], NewNumElts);
return DAG.getNode(ISD::BITCAST, dl, WidenVT, NewVec);
}
}
return CreateStackStoreLoad(InOp, WidenVT);
}
SDValue DAGTypeLegalizer::WidenVecRes_BUILD_VECTOR(SDNode *N) {
DebugLoc dl = N->getDebugLoc();
// Build a vector with undefined for the new nodes.
EVT VT = N->getValueType(0);
EVT EltVT = VT.getVectorElementType();
unsigned NumElts = VT.getVectorNumElements();
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
unsigned WidenNumElts = WidenVT.getVectorNumElements();
SmallVector<SDValue, 16> NewOps(N->op_begin(), N->op_end());
NewOps.reserve(WidenNumElts);
for (unsigned i = NumElts; i < WidenNumElts; ++i)
NewOps.push_back(DAG.getUNDEF(EltVT));
return DAG.getNode(ISD::BUILD_VECTOR, dl, WidenVT, &NewOps[0], NewOps.size());
}
SDValue DAGTypeLegalizer::WidenVecRes_CONCAT_VECTORS(SDNode *N) {
EVT InVT = N->getOperand(0).getValueType();
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
DebugLoc dl = N->getDebugLoc();
unsigned WidenNumElts = WidenVT.getVectorNumElements();
unsigned NumInElts = InVT.getVectorNumElements();
unsigned NumOperands = N->getNumOperands();
bool InputWidened = false; // Indicates we need to widen the input.
if (getTypeAction(InVT) != TargetLowering::TypeWidenVector) {
if (WidenVT.getVectorNumElements() % InVT.getVectorNumElements() == 0) {
// Add undef vectors to widen to correct length.
unsigned NumConcat = WidenVT.getVectorNumElements() /
InVT.getVectorNumElements();
SDValue UndefVal = DAG.getUNDEF(InVT);
SmallVector<SDValue, 16> Ops(NumConcat);
for (unsigned i=0; i < NumOperands; ++i)
Ops[i] = N->getOperand(i);
for (unsigned i = NumOperands; i != NumConcat; ++i)
Ops[i] = UndefVal;
return DAG.getNode(ISD::CONCAT_VECTORS, dl, WidenVT, &Ops[0], NumConcat);
}
} else {
InputWidened = true;
if (WidenVT == TLI.getTypeToTransformTo(*DAG.getContext(), InVT)) {
// The inputs and the result are widen to the same value.
unsigned i;
for (i=1; i < NumOperands; ++i)
if (N->getOperand(i).getOpcode() != ISD::UNDEF)
break;
if (i == NumOperands)
// Everything but the first operand is an UNDEF so just return the
// widened first operand.
return GetWidenedVector(N->getOperand(0));
if (NumOperands == 2) {
// Replace concat of two operands with a shuffle.
SmallVector<int, 16> MaskOps(WidenNumElts, -1);
for (unsigned i = 0; i < NumInElts; ++i) {
MaskOps[i] = i;
MaskOps[i + NumInElts] = i + WidenNumElts;
}
return DAG.getVectorShuffle(WidenVT, dl,
GetWidenedVector(N->getOperand(0)),
GetWidenedVector(N->getOperand(1)),
&MaskOps[0]);
}
}
}
// Fall back to use extracts and build vector.
EVT EltVT = WidenVT.getVectorElementType();
SmallVector<SDValue, 16> Ops(WidenNumElts);
unsigned Idx = 0;
for (unsigned i=0; i < NumOperands; ++i) {
SDValue InOp = N->getOperand(i);
if (InputWidened)
InOp = GetWidenedVector(InOp);
for (unsigned j=0; j < NumInElts; ++j)
Ops[Idx++] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, InOp,
DAG.getIntPtrConstant(j));
}
SDValue UndefVal = DAG.getUNDEF(EltVT);
for (; Idx < WidenNumElts; ++Idx)
Ops[Idx] = UndefVal;
return DAG.getNode(ISD::BUILD_VECTOR, dl, WidenVT, &Ops[0], WidenNumElts);
}
SDValue DAGTypeLegalizer::WidenVecRes_CONVERT_RNDSAT(SDNode *N) {
DebugLoc dl = N->getDebugLoc();
SDValue InOp = N->getOperand(0);
SDValue RndOp = N->getOperand(3);
SDValue SatOp = N->getOperand(4);
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
unsigned WidenNumElts = WidenVT.getVectorNumElements();
EVT InVT = InOp.getValueType();
EVT InEltVT = InVT.getVectorElementType();
EVT InWidenVT = EVT::getVectorVT(*DAG.getContext(), InEltVT, WidenNumElts);
SDValue DTyOp = DAG.getValueType(WidenVT);
SDValue STyOp = DAG.getValueType(InWidenVT);
ISD::CvtCode CvtCode = cast<CvtRndSatSDNode>(N)->getCvtCode();
unsigned InVTNumElts = InVT.getVectorNumElements();
if (getTypeAction(InVT) == TargetLowering::TypeWidenVector) {
InOp = GetWidenedVector(InOp);
InVT = InOp.getValueType();
InVTNumElts = InVT.getVectorNumElements();
if (InVTNumElts == WidenNumElts)
return DAG.getConvertRndSat(WidenVT, dl, InOp, DTyOp, STyOp, RndOp,
SatOp, CvtCode);
}
if (TLI.isTypeLegal(InWidenVT)) {
// Because the result and the input are different vector types, widening
// the result could create a legal type but widening the input might make
// it an illegal type that might lead to repeatedly splitting the input
// and then widening it. To avoid this, we widen the input only if
// it results in a legal type.
if (WidenNumElts % InVTNumElts == 0) {
// Widen the input and call convert on the widened input vector.
unsigned NumConcat = WidenNumElts/InVTNumElts;
SmallVector<SDValue, 16> Ops(NumConcat);
Ops[0] = InOp;
SDValue UndefVal = DAG.getUNDEF(InVT);
for (unsigned i = 1; i != NumConcat; ++i)
Ops[i] = UndefVal;
InOp = DAG.getNode(ISD::CONCAT_VECTORS, dl, InWidenVT, &Ops[0],NumConcat);
return DAG.getConvertRndSat(WidenVT, dl, InOp, DTyOp, STyOp, RndOp,
SatOp, CvtCode);
}
if (InVTNumElts % WidenNumElts == 0) {
// Extract the input and convert the shorten input vector.
InOp = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InWidenVT, InOp,
DAG.getIntPtrConstant(0));
return DAG.getConvertRndSat(WidenVT, dl, InOp, DTyOp, STyOp, RndOp,
SatOp, CvtCode);
}
}
// Otherwise unroll into some nasty scalar code and rebuild the vector.
SmallVector<SDValue, 16> Ops(WidenNumElts);
EVT EltVT = WidenVT.getVectorElementType();
DTyOp = DAG.getValueType(EltVT);
STyOp = DAG.getValueType(InEltVT);
unsigned MinElts = std::min(InVTNumElts, WidenNumElts);
unsigned i;
for (i=0; i < MinElts; ++i) {
SDValue ExtVal = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, InEltVT, InOp,
DAG.getIntPtrConstant(i));
Ops[i] = DAG.getConvertRndSat(WidenVT, dl, ExtVal, DTyOp, STyOp, RndOp,
SatOp, CvtCode);
}
SDValue UndefVal = DAG.getUNDEF(EltVT);
for (; i < WidenNumElts; ++i)
Ops[i] = UndefVal;
return DAG.getNode(ISD::BUILD_VECTOR, dl, WidenVT, &Ops[0], WidenNumElts);
}
SDValue DAGTypeLegalizer::WidenVecRes_EXTRACT_SUBVECTOR(SDNode *N) {
EVT VT = N->getValueType(0);
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
unsigned WidenNumElts = WidenVT.getVectorNumElements();
SDValue InOp = N->getOperand(0);
SDValue Idx = N->getOperand(1);
DebugLoc dl = N->getDebugLoc();
if (getTypeAction(InOp.getValueType()) == TargetLowering::TypeWidenVector)
InOp = GetWidenedVector(InOp);
EVT InVT = InOp.getValueType();
// Check if we can just return the input vector after widening.
uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
if (IdxVal == 0 && InVT == WidenVT)
return InOp;
// Check if we can extract from the vector.
unsigned InNumElts = InVT.getVectorNumElements();
if (IdxVal % WidenNumElts == 0 && IdxVal + WidenNumElts < InNumElts)
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, WidenVT, InOp, Idx);
// We could try widening the input to the right length but for now, extract
// the original elements, fill the rest with undefs and build a vector.
SmallVector<SDValue, 16> Ops(WidenNumElts);
EVT EltVT = VT.getVectorElementType();
unsigned NumElts = VT.getVectorNumElements();
unsigned i;
for (i=0; i < NumElts; ++i)
Ops[i] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, InOp,
DAG.getIntPtrConstant(IdxVal+i));
SDValue UndefVal = DAG.getUNDEF(EltVT);
for (; i < WidenNumElts; ++i)
Ops[i] = UndefVal;
return DAG.getNode(ISD::BUILD_VECTOR, dl, WidenVT, &Ops[0], WidenNumElts);
}
SDValue DAGTypeLegalizer::WidenVecRes_INSERT_VECTOR_ELT(SDNode *N) {
SDValue InOp = GetWidenedVector(N->getOperand(0));
return DAG.getNode(ISD::INSERT_VECTOR_ELT, N->getDebugLoc(),
InOp.getValueType(), InOp,
N->getOperand(1), N->getOperand(2));
}
SDValue DAGTypeLegalizer::WidenVecRes_LOAD(SDNode *N) {
LoadSDNode *LD = cast<LoadSDNode>(N);
ISD::LoadExtType ExtType = LD->getExtensionType();
SDValue Result;
SmallVector<SDValue, 16> LdChain; // Chain for the series of load
if (ExtType != ISD::NON_EXTLOAD)
Result = GenWidenVectorExtLoads(LdChain, LD, ExtType);
else
Result = GenWidenVectorLoads(LdChain, LD);
// If we generate a single load, we can use that for the chain. Otherwise,
// build a factor node to remember the multiple loads are independent and
// chain to that.
SDValue NewChain;
if (LdChain.size() == 1)
NewChain = LdChain[0];
else
NewChain = DAG.getNode(ISD::TokenFactor, LD->getDebugLoc(), MVT::Other,
&LdChain[0], LdChain.size());
// Modified the chain - switch anything that used the old chain to use
// the new one.
ReplaceValueWith(SDValue(N, 1), NewChain);
return Result;
}
SDValue DAGTypeLegalizer::WidenVecRes_SCALAR_TO_VECTOR(SDNode *N) {
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
return DAG.getNode(ISD::SCALAR_TO_VECTOR, N->getDebugLoc(),
WidenVT, N->getOperand(0));
}
SDValue DAGTypeLegalizer::WidenVecRes_SELECT(SDNode *N) {
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
unsigned WidenNumElts = WidenVT.getVectorNumElements();
SDValue Cond1 = N->getOperand(0);
EVT CondVT = Cond1.getValueType();
if (CondVT.isVector()) {
EVT CondEltVT = CondVT.getVectorElementType();
EVT CondWidenVT = EVT::getVectorVT(*DAG.getContext(),
CondEltVT, WidenNumElts);
if (getTypeAction(CondVT) == TargetLowering::TypeWidenVector)
Cond1 = GetWidenedVector(Cond1);
if (Cond1.getValueType() != CondWidenVT)
Cond1 = ModifyToType(Cond1, CondWidenVT);
}
SDValue InOp1 = GetWidenedVector(N->getOperand(1));
SDValue InOp2 = GetWidenedVector(N->getOperand(2));
assert(InOp1.getValueType() == WidenVT && InOp2.getValueType() == WidenVT);
return DAG.getNode(N->getOpcode(), N->getDebugLoc(),
WidenVT, Cond1, InOp1, InOp2);
}
SDValue DAGTypeLegalizer::WidenVecRes_SELECT_CC(SDNode *N) {
SDValue InOp1 = GetWidenedVector(N->getOperand(2));
SDValue InOp2 = GetWidenedVector(N->getOperand(3));
return DAG.getNode(ISD::SELECT_CC, N->getDebugLoc(),
InOp1.getValueType(), N->getOperand(0),
N->getOperand(1), InOp1, InOp2, N->getOperand(4));
}
SDValue DAGTypeLegalizer::WidenVecRes_SETCC(SDNode *N) {
assert(N->getValueType(0).isVector() ==
N->getOperand(0).getValueType().isVector() &&
"Scalar/Vector type mismatch");
if (N->getValueType(0).isVector()) return WidenVecRes_VSETCC(N);
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
SDValue InOp1 = GetWidenedVector(N->getOperand(0));
SDValue InOp2 = GetWidenedVector(N->getOperand(1));
return DAG.getNode(ISD::SETCC, N->getDebugLoc(), WidenVT,
InOp1, InOp2, N->getOperand(2));
}
SDValue DAGTypeLegalizer::WidenVecRes_UNDEF(SDNode *N) {
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
return DAG.getUNDEF(WidenVT);
}
SDValue DAGTypeLegalizer::WidenVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N) {
EVT VT = N->getValueType(0);
DebugLoc dl = N->getDebugLoc();
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
unsigned NumElts = VT.getVectorNumElements();
unsigned WidenNumElts = WidenVT.getVectorNumElements();
SDValue InOp1 = GetWidenedVector(N->getOperand(0));
SDValue InOp2 = GetWidenedVector(N->getOperand(1));
// Adjust mask based on new input vector length.
SmallVector<int, 16> NewMask;
for (unsigned i = 0; i != NumElts; ++i) {
int Idx = N->getMaskElt(i);
if (Idx < (int)NumElts)
NewMask.push_back(Idx);
else
NewMask.push_back(Idx - NumElts + WidenNumElts);
}
for (unsigned i = NumElts; i != WidenNumElts; ++i)
NewMask.push_back(-1);
return DAG.getVectorShuffle(WidenVT, dl, InOp1, InOp2, &NewMask[0]);
}
SDValue DAGTypeLegalizer::WidenVecRes_VSETCC(SDNode *N) {
assert(N->getValueType(0).isVector() &&
N->getOperand(0).getValueType().isVector() &&
"Operands must be vectors");
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
unsigned WidenNumElts = WidenVT.getVectorNumElements();
SDValue InOp1 = N->getOperand(0);
EVT InVT = InOp1.getValueType();
assert(InVT.isVector() && "can not widen non vector type");
EVT WidenInVT = EVT::getVectorVT(*DAG.getContext(),
InVT.getVectorElementType(), WidenNumElts);
InOp1 = GetWidenedVector(InOp1);
SDValue InOp2 = GetWidenedVector(N->getOperand(1));
// Assume that the input and output will be widen appropriately. If not,
// we will have to unroll it at some point.
assert(InOp1.getValueType() == WidenInVT &&
InOp2.getValueType() == WidenInVT &&
"Input not widened to expected type!");
(void)WidenInVT;
return DAG.getNode(ISD::SETCC, N->getDebugLoc(),
WidenVT, InOp1, InOp2, N->getOperand(2));
}
//===----------------------------------------------------------------------===//
// Widen Vector Operand
//===----------------------------------------------------------------------===//
bool DAGTypeLegalizer::WidenVectorOperand(SDNode *N, unsigned OpNo) {
DEBUG(dbgs() << "Widen node operand " << OpNo << ": ";
N->dump(&DAG);
dbgs() << "\n");
SDValue Res = SDValue();
// See if the target wants to custom widen this node.
if (CustomLowerNode(N, N->getOperand(OpNo).getValueType(), false))
return false;
switch (N->getOpcode()) {
default:
#ifndef NDEBUG
dbgs() << "WidenVectorOperand op #" << OpNo << ": ";
N->dump(&DAG);
dbgs() << "\n";
#endif
llvm_unreachable("Do not know how to widen this operator's operand!");
case ISD::BITCAST: Res = WidenVecOp_BITCAST(N); break;
case ISD::CONCAT_VECTORS: Res = WidenVecOp_CONCAT_VECTORS(N); break;
case ISD::EXTRACT_SUBVECTOR: Res = WidenVecOp_EXTRACT_SUBVECTOR(N); break;
case ISD::EXTRACT_VECTOR_ELT: Res = WidenVecOp_EXTRACT_VECTOR_ELT(N); break;
case ISD::STORE: Res = WidenVecOp_STORE(N); break;
case ISD::SETCC: Res = WidenVecOp_SETCC(N); break;
case ISD::FP_EXTEND:
case ISD::FP_TO_SINT:
case ISD::FP_TO_UINT:
case ISD::SINT_TO_FP:
case ISD::UINT_TO_FP:
case ISD::TRUNCATE:
case ISD::SIGN_EXTEND:
case ISD::ZERO_EXTEND:
case ISD::ANY_EXTEND:
Res = WidenVecOp_Convert(N);
break;
}
// If Res is null, the sub-method took care of registering the result.
if (!Res.getNode()) return false;
// If the result is N, the sub-method updated N in place. Tell the legalizer
// core about this.
if (Res.getNode() == N)
return true;
assert(Res.getValueType() == N->getValueType(0) && N->getNumValues() == 1 &&
"Invalid operand expansion");
ReplaceValueWith(SDValue(N, 0), Res);
return false;
}
SDValue DAGTypeLegalizer::WidenVecOp_Convert(SDNode *N) {
// Since the result is legal and the input is illegal, it is unlikely
// that we can fix the input to a legal type so unroll the convert
// into some scalar code and create a nasty build vector.
EVT VT = N->getValueType(0);
EVT EltVT = VT.getVectorElementType();
DebugLoc dl = N->getDebugLoc();
unsigned NumElts = VT.getVectorNumElements();
SDValue InOp = N->getOperand(0);
if (getTypeAction(InOp.getValueType()) == TargetLowering::TypeWidenVector)
InOp = GetWidenedVector(InOp);
EVT InVT = InOp.getValueType();
EVT InEltVT = InVT.getVectorElementType();
unsigned Opcode = N->getOpcode();
SmallVector<SDValue, 16> Ops(NumElts);
for (unsigned i=0; i < NumElts; ++i)
Ops[i] = DAG.getNode(Opcode, dl, EltVT,
DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, InEltVT, InOp,
DAG.getIntPtrConstant(i)));
return DAG.getNode(ISD::BUILD_VECTOR, dl, VT, &Ops[0], NumElts);
}
SDValue DAGTypeLegalizer::WidenVecOp_BITCAST(SDNode *N) {
EVT VT = N->getValueType(0);
SDValue InOp = GetWidenedVector(N->getOperand(0));
EVT InWidenVT = InOp.getValueType();
DebugLoc dl = N->getDebugLoc();
// Check if we can convert between two legal vector types and extract.
unsigned InWidenSize = InWidenVT.getSizeInBits();
unsigned Size = VT.getSizeInBits();
// x86mmx is not an acceptable vector element type, so don't try.
if (InWidenSize % Size == 0 && !VT.isVector() && VT != MVT::x86mmx) {
unsigned NewNumElts = InWidenSize / Size;
EVT NewVT = EVT::getVectorVT(*DAG.getContext(), VT, NewNumElts);
if (TLI.isTypeLegal(NewVT)) {
SDValue BitOp = DAG.getNode(ISD::BITCAST, dl, NewVT, InOp);
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, VT, BitOp,
DAG.getIntPtrConstant(0));
}
}
return CreateStackStoreLoad(InOp, VT);
}
SDValue DAGTypeLegalizer::WidenVecOp_CONCAT_VECTORS(SDNode *N) {
// If the input vector is not legal, it is likely that we will not find a
// legal vector of the same size. Replace the concatenate vector with a
// nasty build vector.
EVT VT = N->getValueType(0);
EVT EltVT = VT.getVectorElementType();
DebugLoc dl = N->getDebugLoc();
unsigned NumElts = VT.getVectorNumElements();
SmallVector<SDValue, 16> Ops(NumElts);
EVT InVT = N->getOperand(0).getValueType();
unsigned NumInElts = InVT.getVectorNumElements();
unsigned Idx = 0;
unsigned NumOperands = N->getNumOperands();
for (unsigned i=0; i < NumOperands; ++i) {
SDValue InOp = N->getOperand(i);
if (getTypeAction(InOp.getValueType()) == TargetLowering::TypeWidenVector)
InOp = GetWidenedVector(InOp);
for (unsigned j=0; j < NumInElts; ++j)
Ops[Idx++] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, InOp,
DAG.getIntPtrConstant(j));
}
return DAG.getNode(ISD::BUILD_VECTOR, dl, VT, &Ops[0], NumElts);
}
SDValue DAGTypeLegalizer::WidenVecOp_EXTRACT_SUBVECTOR(SDNode *N) {
SDValue InOp = GetWidenedVector(N->getOperand(0));
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, N->getDebugLoc(),
N->getValueType(0), InOp, N->getOperand(1));
}
SDValue DAGTypeLegalizer::WidenVecOp_EXTRACT_VECTOR_ELT(SDNode *N) {
SDValue InOp = GetWidenedVector(N->getOperand(0));
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, N->getDebugLoc(),
N->getValueType(0), InOp, N->getOperand(1));
}
SDValue DAGTypeLegalizer::WidenVecOp_STORE(SDNode *N) {
// We have to widen the value but we want only to store the original
// vector type.
StoreSDNode *ST = cast<StoreSDNode>(N);
SmallVector<SDValue, 16> StChain;
if (ST->isTruncatingStore())
GenWidenVectorTruncStores(StChain, ST);
else
GenWidenVectorStores(StChain, ST);
if (StChain.size() == 1)
return StChain[0];
else
return DAG.getNode(ISD::TokenFactor, ST->getDebugLoc(),
MVT::Other,&StChain[0],StChain.size());
}
SDValue DAGTypeLegalizer::WidenVecOp_SETCC(SDNode *N) {
SDValue InOp0 = GetWidenedVector(N->getOperand(0));
SDValue InOp1 = GetWidenedVector(N->getOperand(1));
DebugLoc dl = N->getDebugLoc();
// WARNING: In this code we widen the compare instruction with garbage.
// This garbage may contain denormal floats which may be slow. Is this a real
// concern ? Should we zero the unused lanes if this is a float compare ?
// Get a new SETCC node to compare the newly widened operands.
// Only some of the compared elements are legal.
EVT SVT = TLI.getSetCCResultType(InOp0.getValueType());
SDValue WideSETCC = DAG.getNode(ISD::SETCC, N->getDebugLoc(),
SVT, InOp0, InOp1, N->getOperand(2));
// Extract the needed results from the result vector.
EVT ResVT = EVT::getVectorVT(*DAG.getContext(),
SVT.getVectorElementType(),
N->getValueType(0).getVectorNumElements());
SDValue CC = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl,
ResVT, WideSETCC, DAG.getIntPtrConstant(0));
return PromoteTargetBoolean(CC, N->getValueType(0));
}
//===----------------------------------------------------------------------===//
// Vector Widening Utilities
//===----------------------------------------------------------------------===//
// Utility function to find the type to chop up a widen vector for load/store
// TLI: Target lowering used to determine legal types.
// Width: Width left need to load/store.
// WidenVT: The widen vector type to load to/store from
// Align: If 0, don't allow use of a wider type
// WidenEx: If Align is not 0, the amount additional we can load/store from.
static EVT FindMemType(SelectionDAG& DAG, const TargetLowering &TLI,
unsigned Width, EVT WidenVT,
unsigned Align = 0, unsigned WidenEx = 0) {
EVT WidenEltVT = WidenVT.getVectorElementType();
unsigned WidenWidth = WidenVT.getSizeInBits();
unsigned WidenEltWidth = WidenEltVT.getSizeInBits();
unsigned AlignInBits = Align*8;
// If we have one element to load/store, return it.
EVT RetVT = WidenEltVT;
if (Width == WidenEltWidth)
return RetVT;
// See if there is larger legal integer than the element type to load/store
unsigned VT;
for (VT = (unsigned)MVT::LAST_INTEGER_VALUETYPE;
VT >= (unsigned)MVT::FIRST_INTEGER_VALUETYPE; --VT) {
EVT MemVT((MVT::SimpleValueType) VT);
unsigned MemVTWidth = MemVT.getSizeInBits();
if (MemVT.getSizeInBits() <= WidenEltWidth)
break;
if (TLI.isTypeLegal(MemVT) && (WidenWidth % MemVTWidth) == 0 &&
isPowerOf2_32(WidenWidth / MemVTWidth) &&
(MemVTWidth <= Width ||
(Align!=0 && MemVTWidth<=AlignInBits && MemVTWidth<=Width+WidenEx))) {
RetVT = MemVT;
break;
}
}
// See if there is a larger vector type to load/store that has the same vector
// element type and is evenly divisible with the WidenVT.
for (VT = (unsigned)MVT::LAST_VECTOR_VALUETYPE;
VT >= (unsigned)MVT::FIRST_VECTOR_VALUETYPE; --VT) {
EVT MemVT = (MVT::SimpleValueType) VT;
unsigned MemVTWidth = MemVT.getSizeInBits();
if (TLI.isTypeLegal(MemVT) && WidenEltVT == MemVT.getVectorElementType() &&
(WidenWidth % MemVTWidth) == 0 &&
isPowerOf2_32(WidenWidth / MemVTWidth) &&
(MemVTWidth <= Width ||
(Align!=0 && MemVTWidth<=AlignInBits && MemVTWidth<=Width+WidenEx))) {
if (RetVT.getSizeInBits() < MemVTWidth || MemVT == WidenVT)
return MemVT;
}
}
return RetVT;
}
// Builds a vector type from scalar loads
// VecTy: Resulting Vector type
// LDOps: Load operators to build a vector type
// [Start,End) the list of loads to use.
static SDValue BuildVectorFromScalar(SelectionDAG& DAG, EVT VecTy,
SmallVector<SDValue, 16>& LdOps,
unsigned Start, unsigned End) {
DebugLoc dl = LdOps[Start].getDebugLoc();
EVT LdTy = LdOps[Start].getValueType();
unsigned Width = VecTy.getSizeInBits();
unsigned NumElts = Width / LdTy.getSizeInBits();
EVT NewVecVT = EVT::getVectorVT(*DAG.getContext(), LdTy, NumElts);
unsigned Idx = 1;
SDValue VecOp = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, NewVecVT,LdOps[Start]);
for (unsigned i = Start + 1; i != End; ++i) {
EVT NewLdTy = LdOps[i].getValueType();
if (NewLdTy != LdTy) {
NumElts = Width / NewLdTy.getSizeInBits();
NewVecVT = EVT::getVectorVT(*DAG.getContext(), NewLdTy, NumElts);
VecOp = DAG.getNode(ISD::BITCAST, dl, NewVecVT, VecOp);
// Readjust position and vector position based on new load type
Idx = Idx * LdTy.getSizeInBits() / NewLdTy.getSizeInBits();
LdTy = NewLdTy;
}
VecOp = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, NewVecVT, VecOp, LdOps[i],
DAG.getIntPtrConstant(Idx++));
}
return DAG.getNode(ISD::BITCAST, dl, VecTy, VecOp);
}
SDValue DAGTypeLegalizer::GenWidenVectorLoads(SmallVector<SDValue, 16> &LdChain,
LoadSDNode *LD) {
// The strategy assumes that we can efficiently load powers of two widths.
// The routines chops the vector into the largest vector loads with the same
// element type or scalar loads and then recombines it to the widen vector
// type.
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(),LD->getValueType(0));
unsigned WidenWidth = WidenVT.getSizeInBits();
EVT LdVT = LD->getMemoryVT();
DebugLoc dl = LD->getDebugLoc();
assert(LdVT.isVector() && WidenVT.isVector());
assert(LdVT.getVectorElementType() == WidenVT.getVectorElementType());
// Load information
SDValue Chain = LD->getChain();
SDValue BasePtr = LD->getBasePtr();
unsigned Align = LD->getAlignment();
bool isVolatile = LD->isVolatile();
bool isNonTemporal = LD->isNonTemporal();
bool isInvariant = LD->isInvariant();
int LdWidth = LdVT.getSizeInBits();
int WidthDiff = WidenWidth - LdWidth; // Difference
unsigned LdAlign = (isVolatile) ? 0 : Align; // Allow wider loads
// Find the vector type that can load from.
EVT NewVT = FindMemType(DAG, TLI, LdWidth, WidenVT, LdAlign, WidthDiff);
int NewVTWidth = NewVT.getSizeInBits();
SDValue LdOp = DAG.getLoad(NewVT, dl, Chain, BasePtr, LD->getPointerInfo(),
isVolatile, isNonTemporal, isInvariant, Align);
LdChain.push_back(LdOp.getValue(1));
// Check if we can load the element with one instruction
if (LdWidth <= NewVTWidth) {
if (!NewVT.isVector()) {
unsigned NumElts = WidenWidth / NewVTWidth;
EVT NewVecVT = EVT::getVectorVT(*DAG.getContext(), NewVT, NumElts);
SDValue VecOp = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, NewVecVT, LdOp);
return DAG.getNode(ISD::BITCAST, dl, WidenVT, VecOp);
}
if (NewVT == WidenVT)
return LdOp;
assert(WidenWidth % NewVTWidth == 0);
unsigned NumConcat = WidenWidth / NewVTWidth;
SmallVector<SDValue, 16> ConcatOps(NumConcat);
SDValue UndefVal = DAG.getUNDEF(NewVT);
ConcatOps[0] = LdOp;
for (unsigned i = 1; i != NumConcat; ++i)
ConcatOps[i] = UndefVal;
return DAG.getNode(ISD::CONCAT_VECTORS, dl, WidenVT, &ConcatOps[0],
NumConcat);
}
// Load vector by using multiple loads from largest vector to scalar
SmallVector<SDValue, 16> LdOps;
LdOps.push_back(LdOp);
LdWidth -= NewVTWidth;
unsigned Offset = 0;
while (LdWidth > 0) {
unsigned Increment = NewVTWidth / 8;
Offset += Increment;
BasePtr = DAG.getNode(ISD::ADD, dl, BasePtr.getValueType(), BasePtr,
DAG.getIntPtrConstant(Increment));
SDValue L;
if (LdWidth < NewVTWidth) {
// Our current type we are using is too large, find a better size
NewVT = FindMemType(DAG, TLI, LdWidth, WidenVT, LdAlign, WidthDiff);
NewVTWidth = NewVT.getSizeInBits();
L = DAG.getLoad(NewVT, dl, Chain, BasePtr,
LD->getPointerInfo().getWithOffset(Offset), isVolatile,
isNonTemporal, isInvariant, MinAlign(Align, Increment));
LdChain.push_back(L.getValue(1));
if (L->getValueType(0).isVector()) {
SmallVector<SDValue, 16> Loads;
Loads.push_back(L);
unsigned size = L->getValueSizeInBits(0);
while (size < LdOp->getValueSizeInBits(0)) {
Loads.push_back(DAG.getUNDEF(L->getValueType(0)));
size += L->getValueSizeInBits(0);
}
L = DAG.getNode(ISD::CONCAT_VECTORS, dl, LdOp->getValueType(0),
&Loads[0], Loads.size());
}
} else {
L = DAG.getLoad(NewVT, dl, Chain, BasePtr,
LD->getPointerInfo().getWithOffset(Offset), isVolatile,
isNonTemporal, isInvariant, MinAlign(Align, Increment));
LdChain.push_back(L.getValue(1));
}
LdOps.push_back(L);
LdWidth -= NewVTWidth;
}
// Build the vector from the loads operations
unsigned End = LdOps.size();
if (!LdOps[0].getValueType().isVector())
// All the loads are scalar loads.
return BuildVectorFromScalar(DAG, WidenVT, LdOps, 0, End);
// If the load contains vectors, build the vector using concat vector.
// All of the vectors used to loads are power of 2 and the scalars load
// can be combined to make a power of 2 vector.
SmallVector<SDValue, 16> ConcatOps(End);
int i = End - 1;
int Idx = End;
EVT LdTy = LdOps[i].getValueType();
// First combine the scalar loads to a vector
if (!LdTy.isVector()) {
for (--i; i >= 0; --i) {
LdTy = LdOps[i].getValueType();
if (LdTy.isVector())
break;
}
ConcatOps[--Idx] = BuildVectorFromScalar(DAG, LdTy, LdOps, i+1, End);
}
ConcatOps[--Idx] = LdOps[i];
for (--i; i >= 0; --i) {
EVT NewLdTy = LdOps[i].getValueType();
if (NewLdTy != LdTy) {
// Create a larger vector
ConcatOps[End-1] = DAG.getNode(ISD::CONCAT_VECTORS, dl, NewLdTy,
&ConcatOps[Idx], End - Idx);
Idx = End - 1;
LdTy = NewLdTy;
}
ConcatOps[--Idx] = LdOps[i];
}
if (WidenWidth == LdTy.getSizeInBits()*(End - Idx))
return DAG.getNode(ISD::CONCAT_VECTORS, dl, WidenVT,
&ConcatOps[Idx], End - Idx);
// We need to fill the rest with undefs to build the vector
unsigned NumOps = WidenWidth / LdTy.getSizeInBits();
SmallVector<SDValue, 16> WidenOps(NumOps);
SDValue UndefVal = DAG.getUNDEF(LdTy);
{
unsigned i = 0;
for (; i != End-Idx; ++i)
WidenOps[i] = ConcatOps[Idx+i];
for (; i != NumOps; ++i)
WidenOps[i] = UndefVal;
}
return DAG.getNode(ISD::CONCAT_VECTORS, dl, WidenVT, &WidenOps[0],NumOps);
}
SDValue
DAGTypeLegalizer::GenWidenVectorExtLoads(SmallVector<SDValue, 16>& LdChain,
LoadSDNode * LD,
ISD::LoadExtType ExtType) {
// For extension loads, it may not be more efficient to chop up the vector
// and then extended it. Instead, we unroll the load and build a new vector.
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(),LD->getValueType(0));
EVT LdVT = LD->getMemoryVT();
DebugLoc dl = LD->getDebugLoc();
assert(LdVT.isVector() && WidenVT.isVector());
// Load information
SDValue Chain = LD->getChain();
SDValue BasePtr = LD->getBasePtr();
unsigned Align = LD->getAlignment();
bool isVolatile = LD->isVolatile();
bool isNonTemporal = LD->isNonTemporal();
EVT EltVT = WidenVT.getVectorElementType();
EVT LdEltVT = LdVT.getVectorElementType();
unsigned NumElts = LdVT.getVectorNumElements();
// Load each element and widen
unsigned WidenNumElts = WidenVT.getVectorNumElements();
SmallVector<SDValue, 16> Ops(WidenNumElts);
unsigned Increment = LdEltVT.getSizeInBits() / 8;
Ops[0] = DAG.getExtLoad(ExtType, dl, EltVT, Chain, BasePtr,
LD->getPointerInfo(),
LdEltVT, isVolatile, isNonTemporal, Align);
LdChain.push_back(Ops[0].getValue(1));
unsigned i = 0, Offset = Increment;
for (i=1; i < NumElts; ++i, Offset += Increment) {
SDValue NewBasePtr = DAG.getNode(ISD::ADD, dl, BasePtr.getValueType(),
BasePtr, DAG.getIntPtrConstant(Offset));
Ops[i] = DAG.getExtLoad(ExtType, dl, EltVT, Chain, NewBasePtr,
LD->getPointerInfo().getWithOffset(Offset), LdEltVT,
isVolatile, isNonTemporal, Align);
LdChain.push_back(Ops[i].getValue(1));
}
// Fill the rest with undefs
SDValue UndefVal = DAG.getUNDEF(EltVT);
for (; i != WidenNumElts; ++i)
Ops[i] = UndefVal;
return DAG.getNode(ISD::BUILD_VECTOR, dl, WidenVT, &Ops[0], Ops.size());
}
void DAGTypeLegalizer::GenWidenVectorStores(SmallVector<SDValue, 16>& StChain,
StoreSDNode *ST) {
// The strategy assumes that we can efficiently store powers of two widths.
// The routines chops the vector into the largest vector stores with the same
// element type or scalar stores.
SDValue Chain = ST->getChain();
SDValue BasePtr = ST->getBasePtr();
unsigned Align = ST->getAlignment();
bool isVolatile = ST->isVolatile();
bool isNonTemporal = ST->isNonTemporal();
SDValue ValOp = GetWidenedVector(ST->getValue());
DebugLoc dl = ST->getDebugLoc();
EVT StVT = ST->getMemoryVT();
unsigned StWidth = StVT.getSizeInBits();
EVT ValVT = ValOp.getValueType();
unsigned ValWidth = ValVT.getSizeInBits();
EVT ValEltVT = ValVT.getVectorElementType();
unsigned ValEltWidth = ValEltVT.getSizeInBits();
assert(StVT.getVectorElementType() == ValEltVT);
int Idx = 0; // current index to store
unsigned Offset = 0; // offset from base to store
while (StWidth != 0) {
// Find the largest vector type we can store with
EVT NewVT = FindMemType(DAG, TLI, StWidth, ValVT);
unsigned NewVTWidth = NewVT.getSizeInBits();
unsigned Increment = NewVTWidth / 8;
if (NewVT.isVector()) {
unsigned NumVTElts = NewVT.getVectorNumElements();
do {
SDValue EOp = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, NewVT, ValOp,
DAG.getIntPtrConstant(Idx));
StChain.push_back(DAG.getStore(Chain, dl, EOp, BasePtr,
ST->getPointerInfo().getWithOffset(Offset),
isVolatile, isNonTemporal,
MinAlign(Align, Offset)));
StWidth -= NewVTWidth;
Offset += Increment;
Idx += NumVTElts;
BasePtr = DAG.getNode(ISD::ADD, dl, BasePtr.getValueType(), BasePtr,
DAG.getIntPtrConstant(Increment));
} while (StWidth != 0 && StWidth >= NewVTWidth);
} else {
// Cast the vector to the scalar type we can store
unsigned NumElts = ValWidth / NewVTWidth;
EVT NewVecVT = EVT::getVectorVT(*DAG.getContext(), NewVT, NumElts);
SDValue VecOp = DAG.getNode(ISD::BITCAST, dl, NewVecVT, ValOp);
// Readjust index position based on new vector type
Idx = Idx * ValEltWidth / NewVTWidth;
do {
SDValue EOp = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, NewVT, VecOp,
DAG.getIntPtrConstant(Idx++));
StChain.push_back(DAG.getStore(Chain, dl, EOp, BasePtr,
ST->getPointerInfo().getWithOffset(Offset),
isVolatile, isNonTemporal,
MinAlign(Align, Offset)));
StWidth -= NewVTWidth;
Offset += Increment;
BasePtr = DAG.getNode(ISD::ADD, dl, BasePtr.getValueType(), BasePtr,
DAG.getIntPtrConstant(Increment));
} while (StWidth != 0 && StWidth >= NewVTWidth);
// Restore index back to be relative to the original widen element type
Idx = Idx * NewVTWidth / ValEltWidth;
}
}
}
void
DAGTypeLegalizer::GenWidenVectorTruncStores(SmallVector<SDValue, 16>& StChain,
StoreSDNode *ST) {
// For extension loads, it may not be more efficient to truncate the vector
// and then store it. Instead, we extract each element and then store it.
SDValue Chain = ST->getChain();
SDValue BasePtr = ST->getBasePtr();
unsigned Align = ST->getAlignment();
bool isVolatile = ST->isVolatile();
bool isNonTemporal = ST->isNonTemporal();
SDValue ValOp = GetWidenedVector(ST->getValue());
DebugLoc dl = ST->getDebugLoc();
EVT StVT = ST->getMemoryVT();
EVT ValVT = ValOp.getValueType();
// It must be true that we the widen vector type is bigger than where
// we need to store.
assert(StVT.isVector() && ValOp.getValueType().isVector());
assert(StVT.bitsLT(ValOp.getValueType()));
// For truncating stores, we can not play the tricks of chopping legal
// vector types and bit cast it to the right type. Instead, we unroll
// the store.
EVT StEltVT = StVT.getVectorElementType();
EVT ValEltVT = ValVT.getVectorElementType();
unsigned Increment = ValEltVT.getSizeInBits() / 8;
unsigned NumElts = StVT.getVectorNumElements();
SDValue EOp = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, ValEltVT, ValOp,
DAG.getIntPtrConstant(0));
StChain.push_back(DAG.getTruncStore(Chain, dl, EOp, BasePtr,
ST->getPointerInfo(), StEltVT,
isVolatile, isNonTemporal, Align));
unsigned Offset = Increment;
for (unsigned i=1; i < NumElts; ++i, Offset += Increment) {
SDValue NewBasePtr = DAG.getNode(ISD::ADD, dl, BasePtr.getValueType(),
BasePtr, DAG.getIntPtrConstant(Offset));
SDValue EOp = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, ValEltVT, ValOp,
DAG.getIntPtrConstant(0));
StChain.push_back(DAG.getTruncStore(Chain, dl, EOp, NewBasePtr,
ST->getPointerInfo().getWithOffset(Offset),
StEltVT, isVolatile, isNonTemporal,
MinAlign(Align, Offset)));
}
}
/// Modifies a vector input (widen or narrows) to a vector of NVT. The
/// input vector must have the same element type as NVT.
SDValue DAGTypeLegalizer::ModifyToType(SDValue InOp, EVT NVT) {
// Note that InOp might have been widened so it might already have
// the right width or it might need be narrowed.
EVT InVT = InOp.getValueType();
assert(InVT.getVectorElementType() == NVT.getVectorElementType() &&
"input and widen element type must match");
DebugLoc dl = InOp.getDebugLoc();
// Check if InOp already has the right width.
if (InVT == NVT)
return InOp;
unsigned InNumElts = InVT.getVectorNumElements();
unsigned WidenNumElts = NVT.getVectorNumElements();
if (WidenNumElts > InNumElts && WidenNumElts % InNumElts == 0) {
unsigned NumConcat = WidenNumElts / InNumElts;
SmallVector<SDValue, 16> Ops(NumConcat);
SDValue UndefVal = DAG.getUNDEF(InVT);
Ops[0] = InOp;
for (unsigned i = 1; i != NumConcat; ++i)
Ops[i] = UndefVal;
return DAG.getNode(ISD::CONCAT_VECTORS, dl, NVT, &Ops[0], NumConcat);
}
if (WidenNumElts < InNumElts && InNumElts % WidenNumElts)
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, NVT, InOp,
DAG.getIntPtrConstant(0));
// Fall back to extract and build.
SmallVector<SDValue, 16> Ops(WidenNumElts);
EVT EltVT = NVT.getVectorElementType();
unsigned MinNumElts = std::min(WidenNumElts, InNumElts);
unsigned Idx;
for (Idx = 0; Idx < MinNumElts; ++Idx)
Ops[Idx] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, InOp,
DAG.getIntPtrConstant(Idx));
SDValue UndefVal = DAG.getUNDEF(EltVT);
for ( ; Idx < WidenNumElts; ++Idx)
Ops[Idx] = UndefVal;
return DAG.getNode(ISD::BUILD_VECTOR, dl, NVT, &Ops[0], WidenNumElts);
}
| 106,081
| 39,614
|
// This file is part of CROWN, which is distributed under the revised
// BSD license. A copy of this license can be found in the file LICENSE.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE
// for details.
/***
* Author: Sudeep juvekar (sjuvekar@eecs.berkeley.edu)
* 4/17/09
*/
#include <assert.h>
#include <cstdlib>
#include <cstring>
#include <z3.h>
#include <iostream>
#include "base/basic_functions.h"
#include "run_crown/deref_expression.h"
#include "run_crown/symbolic_object.h"
#include "run_crown/object_tracker.h"
#include "run_crown/symbolic_expression_factory.h"
namespace crown {
DerefExpr::DerefExpr(SymbolicExpr *c, size_t managerIdx, size_t snapshotIdx,
size_t s, Value_t v)
: SymbolicExpr(s,v), managerIdx_(managerIdx), snapshotIdx_(snapshotIdx), addr_(c) { }
DerefExpr::DerefExpr(const DerefExpr& de)
: SymbolicExpr(de.size(), de.value()),
managerIdx_(de.managerIdx_), snapshotIdx_(de.snapshotIdx_),
object_(de.object_), addr_(de.addr_->Clone())
{ }
DerefExpr::~DerefExpr() {
delete addr_;
}
DerefExpr* DerefExpr::Clone() const {
return new DerefExpr(*this);
}
void DerefExpr::AppendVars(set<var_t>* vars) const {
ObjectTracker* tracker = global_tracker_;
assert(tracker->snapshotManager().size() > managerIdx_);
assert(tracker->snapshotManager()[managerIdx_]->size() > snapshotIdx_);
SymbolicObject* object = tracker->snapshotManager()[managerIdx_]->at(snapshotIdx_);
addr_->AppendVars(vars);
for(size_t i = 0; i < object->writes().size(); i++){
SymbolicExpr *index = object->writes()[i].first;
SymbolicExpr *exp = object->writes()[i].second;
index->AppendVars(vars);
exp->AppendVars(vars);
}
}
bool DerefExpr::DependsOn(const map<var_t,type_t>& vars) const {
ObjectTracker* tracker = global_tracker_;
assert(tracker->snapshotManager().size() > managerIdx_);
assert(tracker->snapshotManager()[managerIdx_]->size() > snapshotIdx_);
SymbolicObject* object = tracker->snapshotManager()[managerIdx_]->at(snapshotIdx_);
for(size_t i = 0; i < object->writes().size(); i++){
SymbolicExpr *index = object->writes()[i].first;
SymbolicExpr *exp = object->writes()[i].second;
bool res = index->DependsOn(vars) || exp->DependsOn(vars);
if(res == true){
return true;
}
}
return addr_->DependsOn(vars);
}
void DerefExpr::AppendToString(string *s) const {
char buff[92];
s->append("(a!");
sprintf(buff, "%d%d[ ", managerIdx_,snapshotIdx_);
s->append(buff);
// s->append(", ");
addr_->AppendToString(s);
s->append(" ])");
}
Z3_ast DerefExpr::ConvertToSMT(Z3_context ctx, Z3_solver sol) const {
#ifdef DEBUG
printf("ConvertToSMT Deref %d %d\n",managerIdx_, snapshotIdx_);
#endif
global_numOfOperator_++;
size_t size_ = size();
Value_t value_ = value();
ObjectTracker* tracker = global_tracker_;
assert(tracker->snapshotManager().size() > managerIdx_);
assert(tracker->snapshotManager()[managerIdx_]->size() > snapshotIdx_);
SymbolicObject* object = tracker->snapshotManager()[managerIdx_]->at(snapshotIdx_);
//If the snapshots are not created as a SMT, then create dummy SMT
if(tracker->isASTInit == false){
char name[24] = "t0";
Z3_sort ty = Z3_mk_bv_sort(ctx, 32);
Z3_ast con = Z3_mk_const(ctx, Z3_mk_string_symbol(ctx, name), ty);
for(size_t iter = 0; iter < tracker->snapshotManager().size(); iter++){
size_t objSize = tracker->snapshotManager()[iter]->size();
for(size_t iter2 = 0; iter2 < objSize; iter2++){
tracker->astManager()[iter]->push_back(con);
tracker->isCreateAST()[iter]->push_back(false);
}
}
tracker->isASTInit = true;
}
//size_t mem_length = object->writes().size();
//Naming the uninterpreted function
char c[32];
sprintf(c, "a%ld",(unsigned long)this);
//Bit-blast the address
Z3_ast args_z3_f[1] = {addr_->ConvertToSMT(ctx, sol)};
Z3_sort input_type = Z3_mk_bv_sort(ctx, addr_->size() * 8);
Z3_sort output_type;
//Output values of a[x] needs to be registered. (e.g. double a[4])
if(value_.type == types::FLOAT){
output_type = Z3_mk_fpa_sort_single(ctx);
}else if(value_.type == types::DOUBLE){
output_type = Z3_mk_fpa_sort_double(ctx);
}else{
output_type = Z3_mk_bv_sort(ctx, size_*8);
}
Z3_symbol array_symbol = Z3_mk_string_symbol(ctx, c);
Z3_sort array_sort = Z3_mk_array_sort(ctx, input_type, output_type);
Z3_ast array = Z3_mk_const(ctx, array_symbol, array_sort);
//If the object isn't already created as SMT, then create it.
if(tracker->isCreateAST()[managerIdx_]->at(snapshotIdx_) == false){
array = object->ConvertToSMT(ctx, sol, array, output_type);
tracker->astManager()[managerIdx_]->at(snapshotIdx_) = array;
tracker->isCreateAST()[managerIdx_]->at(snapshotIdx_) = true;
}else{
array = tracker->astManager()[managerIdx_]->at(snapshotIdx_);
}
//Dereference has to be in array (e.g. a[4] -> index can be 0,1,2,3)
int sortSizeOfArray = Z3_get_bv_sort_size(ctx, Z3_get_sort(ctx, args_z3_f[0]));
Z3_ast startAST = Z3_mk_int64(ctx, object->start(), Z3_mk_bv_sort(ctx, sortSizeOfArray));
Z3_ast endAST = Z3_mk_int64(ctx, object->start()+object->size(), Z3_mk_bv_sort(ctx, sortSizeOfArray));
Z3_ast startAST2 = Z3_mk_bvuge(ctx, args_z3_f[0], startAST);
Z3_ast endAST2 = Z3_mk_bvult(ctx, args_z3_f[0], endAST);
global_numOfExpr_+=2;
//Assert that symbolic address is equal to at one of the values in domain
Z3_solver_assert(ctx, sol,startAST2);
Z3_solver_assert(ctx, sol,endAST2);
//Return the application of the function to addr_
Z3_ast tmp = Z3_mk_select(ctx, array, args_z3_f[0]);
return tmp;
}
bool DerefExpr::Equals(const SymbolicExpr& e) const {
const DerefExpr* d = e.CastDerefExpr();
return ((d != NULL)
&& addr_->Equals(*d->addr_)
&& object_->Equals(*d->object_));
}
} // namespace crown
| 5,873
| 2,402
|
#include "Assembler.hpp"
#include "MinHash.hpp"
using namespace ChanZuckerberg;
using namespace shasta;
// Use the minHash algorithm to find alignment candidates.
// Use as features sequences of m consecutive special k-mers.
void Assembler::findAlignmentCandidatesMinHash(
size_t m, // Number of consecutive k-mers that define a feature.
size_t minHashIterationCount, // Number of minHash iterations.
size_t log2MinHashBucketCount, // Base 2 log of number of buckets for minHash.
size_t maxBucketSize, // The maximum size for a bucket to be used.
size_t minFrequency, // Minimum number of minHash hits for a pair to become a candidate.
size_t threadCount
)
{
checkKmersAreOpen();
checkMarkersAreOpen();
const ReadId readCount = ReadId(markers.size() / 2);
CZI_ASSERT(readCount > 0);
// If log2MinHashBucketCount is 0, choose a reasonable value
// for the current number of reads.
if(log2MinHashBucketCount == 0) {
// Compute an approximate base 2 log of the number of reads.
static_assert(sizeof(readCount) == 4, "Unexpected readCount size.");
const int leadingZeroBitCount = __builtin_clz(readCount);
const int log2ReadCount = 32 - leadingZeroBitCount;
// Make log2MinHashBucketCount reasonably larger
// than the approximate base 2 log of the number of reads.
log2MinHashBucketCount = 5 + log2ReadCount;
cout << "Set log2MinHashBucketCount to " << log2MinHashBucketCount << endl;
}
// Check that log2MinHashBucketCount is not unreasonably small.
if((1ULL << (log2MinHashBucketCount-3ULL)) < readCount) {
throw runtime_error("log2MinHashBucketCount is unreasonably small.\n"
"Must at least equal base 2 log of number of reads plus 3.");
}
// Create the alignment candidates.
alignmentCandidates.createNew(largeDataName("AlignmentCandidates"), largeDataPageSize);
// Run the MinHash computation to find candidate alignments.
MinHash minHash(
m,
minHashIterationCount,
log2MinHashBucketCount,
maxBucketSize,
minFrequency,
threadCount,
kmerTable,
markers,
alignmentCandidates,
largeDataFileNamePrefix,
largeDataPageSize);
}
void Assembler::accessAlignmentCandidates()
{
alignmentCandidates.accessExistingReadOnly(largeDataName("AlignmentCandidates"));
}
void Assembler::checkAlignmentCandidatesAreOpen() const
{
if(!alignmentCandidates.isOpen) {
throw runtime_error("Alignment candidates are not accessible.");
}
}
// Write the reads that overlap a given read.
void Assembler::writeOverlappingReads(
ReadId readId0,
Strand strand0,
const string& fileName)
{
// Check that we have what we need.
checkReadsAreOpen();
checkAlignmentCandidatesAreOpen();
// Open the output file and write the oriented read we were given.
ofstream file(fileName);
const OrientedReadId orientedReadId0(readId0, strand0);
writeOrientedRead(orientedReadId0, file);
const uint64_t length0 = reads[orientedReadId0.getReadId()].baseCount;
cout << "Reads overlapping " << orientedReadId0 << " length " << length0 << endl;
// Loop over all overlaps involving this oriented read.
for(const uint64_t i: alignmentTable[orientedReadId0.getValue()]) {
const AlignmentData& ad = alignmentData[i];
// Get the other oriented read involved in this overlap.
const OrientedReadId orientedReadId1 = ad.getOther(orientedReadId0);
// Write it out.
const uint64_t length1 = reads[orientedReadId1.getReadId()].baseCount;
cout << orientedReadId1 << " length " << length1 << endl;
writeOrientedRead(orientedReadId1, file);
}
cout << "Found " << alignmentTable[orientedReadId0.getValue()].size();
cout << " overlapping oriented reads." << endl;
}
| 3,975
| 1,192
|
#ifdef _WIN32
#include <windows.h>
#include <windowsx.h>
#else
#include "../swell/swell.h"
#endif
#include <stdlib.h>
#include <string.h>
#ifndef CURSES_INSTANCE
#define CURSES_INSTANCE ((win32CursesCtx *)m_cursesCtx)
#endif
#include "curses.h"
#include "eel_edit.h"
#include "../wdlutf8.h"
#include "../win32_utf8.h"
#include "../wdlcstring.h"
#include "../eel2/ns-eel-int.h"
int g_eel_editor_max_vis_suggestions = 50;
EEL_Editor::EEL_Editor(void *cursesCtx) : WDL_CursesEditor(cursesCtx)
{
m_suggestion_curline_comment_state=0;
m_suggestion_x=m_suggestion_y=-1;
m_case_sensitive=false;
m_comment_str="//"; // todo IsWithinComment() or something?
m_function_prefix = "function ";
m_suggestion_hwnd=NULL;
m_code_func_cache_lines=0;
m_code_func_cache_time=0;
}
EEL_Editor::~EEL_Editor()
{
if (m_suggestion_hwnd) DestroyWindow(m_suggestion_hwnd);
m_code_func_cache.Empty(true,free);
}
#define sh_func_ontoken(x,y)
int EEL_Editor::namedTokenHighlight(const char *tokStart, int len, int state)
{
if (len == 4 && !strnicmp(tokStart,"this",4)) return SYNTAX_KEYWORD;
if (len == 7 && !strnicmp(tokStart,"_global",7)) return SYNTAX_KEYWORD;
if (len == 5 && !strnicmp(tokStart,"local",5)) return SYNTAX_KEYWORD;
if (len == 8 && !strnicmp(tokStart,"function",8)) return SYNTAX_KEYWORD;
if (len == 6 && !strnicmp(tokStart,"static",6)) return SYNTAX_KEYWORD;
if (len == 8 && !strnicmp(tokStart,"instance",8)) return SYNTAX_KEYWORD;
if (len == 6 && !strnicmp(tokStart,"global",6)) return SYNTAX_KEYWORD;
if (len == 7 && !strnicmp(tokStart,"globals",7)) return SYNTAX_KEYWORD;
if (len == 5 && !strnicmp(tokStart,"while",5)) return SYNTAX_KEYWORD;
if (len == 4 && !strnicmp(tokStart,"loop",4)) return SYNTAX_KEYWORD;
if (len == 17 && !strnicmp(tokStart,"__denormal_likely",17)) return SYNTAX_FUNC;
if (len == 19 && !strnicmp(tokStart,"__denormal_unlikely",19)) return SYNTAX_FUNC;
char buf[512];
lstrcpyn_safe(buf,tokStart,wdl_min(sizeof(buf),len+1));
NSEEL_VMCTX vm = peek_want_VM_funcs() ? peek_get_VM() : NULL;
if (nseel_getFunctionByName((compileContext*)vm,buf,NULL)) return SYNTAX_FUNC;
return A_NORMAL;
}
int EEL_Editor::parse_format_specifier(const char *fmt_in, int *var_offs, int *var_len)
{
const char *fmt = fmt_in+1;
*var_offs = 0;
*var_len = 0;
if (fmt_in[0] != '%') return 0; // passed a non-specifier
while (*fmt)
{
const char c = *fmt++;
if (c>0 && isalpha(c))
{
return (int) (fmt - fmt_in);
}
if (c == '.' || c == '+' || c == '-' || c == ' ' || (c>='0' && c<='9'))
{
}
else if (c == '{')
{
if (*var_offs!=0) return 0; // already specified
*var_offs = (int)(fmt-fmt_in);
if (*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) return 0; // symbol name can't start with 0-9 or .
while (*fmt != '}')
{
if ((*fmt >= 'a' && *fmt <= 'z') ||
(*fmt >= 'A' && *fmt <= 'Z') ||
(*fmt >= '0' && *fmt <= '9') ||
*fmt == '_' || *fmt == '.' || *fmt == '#')
{
fmt++;
}
else
{
return 0; // bad character in variable name
}
}
*var_len = (int)((fmt-fmt_in) - *var_offs);
fmt++;
}
else
{
break;
}
}
return 0;
}
void EEL_Editor::draw_string(int *skipcnt, const char *str, int amt, int *attr, int newAttr, int comment_string_state)
{
if (amt > 0 && comment_string_state=='"')
{
while (amt > 0 && *str)
{
const char *str_scan = str;
int varpos,varlen,l=0;
while (!l && *str_scan)
{
while (*str_scan && *str_scan != '%' && str_scan < str+amt) str_scan++;
if (str_scan >= str+amt) break;
l = parse_format_specifier(str_scan,&varpos,&varlen);
if (!l && *str_scan) if (*++str_scan == '%') str_scan++;
}
if (!*str_scan || str_scan >= str+amt) break; // allow default processing to happen if we reached the end of the string
if (l > amt) l=amt;
if (str_scan > str)
{
const int sz=wdl_min((int)(str_scan-str),amt);
draw_string_urlchk(skipcnt,str,sz,attr,newAttr);
str += sz;
amt -= sz;
}
{
const int sz=(varlen>0) ? wdl_min(varpos,amt) : wdl_min(l,amt);
if (sz>0)
{
draw_string_internal(skipcnt,str,sz,attr,SYNTAX_HIGHLIGHT2);
str += sz;
amt -= sz;
}
}
if (varlen>0)
{
int sz = wdl_min(varlen,amt);
if (sz>0)
{
draw_string_internal(skipcnt,str,sz,attr,*str == '#' ? SYNTAX_STRINGVAR : SYNTAX_HIGHLIGHT1);
amt -= sz;
str += sz;
}
sz = wdl_min(l - varpos - varlen, amt);
if (sz>0)
{
draw_string_internal(skipcnt,str,sz,attr,SYNTAX_HIGHLIGHT2);
amt-=sz;
str+=sz;
}
}
}
}
draw_string_urlchk(skipcnt,str,amt,attr,newAttr);
}
void EEL_Editor::draw_string_urlchk(int *skipcnt, const char *str, int amt, int *attr, int newAttr)
{
if (amt > 0 && (newAttr == SYNTAX_COMMENT || newAttr == SYNTAX_STRING))
{
const char *sstr=str;
while (amt > 0 && *str)
{
const char *str_scan = str;
int l=0;
while (l < 10 && *str_scan)
{
str_scan += l;
l=0;
while (*str_scan &&
(strncmp(str_scan,"http://",7) || (sstr != str_scan && str_scan[-1] > 0 && isalnum(str_scan[-1]))) &&
str_scan < str+amt) str_scan++;
if (!*str_scan || str_scan >= str+amt) break;
while (str_scan[l] && str_scan[l] != ')' && str_scan[l] != '\"' && str_scan[l] != ')' && str_scan[l] != ' ' && str_scan[l] != '\t') l++;
}
if (!*str_scan || str_scan >= str+amt) break; // allow default processing to happen if we reached the end of the string
if (l > amt) l=amt;
if (str_scan > str)
{
const int sz=wdl_min((int)(str_scan-str),amt);
draw_string_internal(skipcnt,str,sz,attr,newAttr);
str += sz;
amt -= sz;
}
const int sz=wdl_min(l,amt);
if (sz>0)
{
draw_string_internal(skipcnt,str,sz,attr,SYNTAX_HIGHLIGHT1);
str += sz;
amt -= sz;
}
}
}
draw_string_internal(skipcnt,str,amt,attr,newAttr);
}
void EEL_Editor::draw_string_internal(int *skipcnt, const char *str, int amt, int *attr, int newAttr)
{
// *skipcnt is in characters, amt is in bytes
while (*skipcnt > 0 && amt > 0)
{
const int clen = wdl_utf8_parsechar(str,NULL);
str += clen;
amt -= clen;
*skipcnt -= 1;
}
if (amt>0)
{
if (*attr != newAttr)
{
attrset(newAttr);
*attr = newAttr;
}
addnstr(str,amt);
}
}
WDL_TypedBuf<char> EEL_Editor::s_draw_parentokenstack;
bool EEL_Editor::sh_draw_parenttokenstack_pop(char c)
{
int sz = s_draw_parentokenstack.GetSize();
while (--sz >= 0)
{
char tc = s_draw_parentokenstack.Get()[sz];
if (tc == c)
{
s_draw_parentokenstack.Resize(sz,false);
return false;
}
switch (c)
{
case '?':
// any open paren or semicolon is enough to cause error for ?:
return true;
case '(':
if (tc == '[') return true;
break;
case '[':
if (tc == '(') return true;
break;
}
}
return true;
}
bool EEL_Editor::sh_draw_parentokenstack_update(const char *tok, int toklen)
{
if (toklen == 1)
{
switch (*tok)
{
case '(':
case '[':
case ';':
case '?':
s_draw_parentokenstack.Add(*tok);
break;
case ':': return sh_draw_parenttokenstack_pop('?');
case ')': return sh_draw_parenttokenstack_pop('(');
case ']': return sh_draw_parenttokenstack_pop('[');
}
}
return false;
}
void EEL_Editor::draw_line_highlight(int y, const char *p, int *c_comment_state, int line_n)
{
if (line_n == m_curs_y)
m_suggestion_curline_comment_state = *c_comment_state;
int last_attr = A_NORMAL;
attrset(last_attr);
move(y, 0);
int rv = do_draw_line(p, c_comment_state, last_attr);
attrset(rv< 0 ? SYNTAX_ERROR : A_NORMAL);
clrtoeol();
if (rv < 0) attrset(A_NORMAL);
}
int EEL_Editor::do_draw_line(const char *p, int *c_comment_state, int last_attr)
{
//skipcnt = m_offs_x
if (is_code_start_line(p))
{
*c_comment_state=0;
s_draw_parentokenstack.Resize(0,false);
}
int skipcnt = m_offs_x;
int ignoreSyntaxState = overrideSyntaxDrawingForLine(&skipcnt, &p, c_comment_state, &last_attr);
if (ignoreSyntaxState>0)
{
int len = (int)strlen(p);
draw_string(&skipcnt,p,len,&last_attr,ignoreSyntaxState==100 ? SYNTAX_ERROR :
ignoreSyntaxState==2 ? SYNTAX_COMMENT : A_NORMAL);
return len-m_offs_x < COLS;
}
// syntax highlighting
const char *endptr = p+strlen(p);
const char *tok;
const char *lp = p;
int toklen=0;
int last_comment_state=*c_comment_state;
while (NULL != (tok = sh_tokenize(&p,endptr,&toklen,c_comment_state)) || lp < endptr)
{
if (tok && *tok < 0 && toklen == 1)
{
while (tok[toklen] < 0) {p++; toklen++; } // utf-8 skip
}
if (last_comment_state>0) // if in a multi-line string or comment
{
// draw empty space between lp and p as a string. in this case, tok/toklen includes our string, so we quickly finish after
draw_string(&skipcnt,lp,(int)(p-lp),&last_attr, last_comment_state==1 ? SYNTAX_COMMENT:SYNTAX_STRING, last_comment_state);
last_comment_state=0;
lp = p;
continue;
}
sh_func_ontoken(tok,toklen);
// draw empty space between lp and tok/endptr as normal
const char *adv_to = tok ? tok : endptr;
if (adv_to > lp) draw_string(&skipcnt,lp,(int)(adv_to-lp),&last_attr, A_NORMAL);
if (adv_to >= endptr) break;
last_comment_state=0;
lp = p;
if (adv_to == p) continue;
// draw token
int attr = A_NORMAL;
int err_left=0;
int err_right=0;
int start_of_tok = 0;
if (tok[0] == '/' && toklen > 1 && (tok[1] == '*' || tok[1] == '/'))
{
attr = SYNTAX_COMMENT;
}
else if (tok[0] > 0 && (isalpha(tok[0]) || tok[0] == '_' || tok[0] == '#'))
{
int def_attr = A_NORMAL;
bool isf=true;
if (tok[0] == '#')
{
def_attr = SYNTAX_STRINGVAR;
draw_string(&skipcnt,tok,1,&last_attr,def_attr);
tok++;
toklen--;
}
while (toklen > 0)
{
// divide up by .s, if any
int this_len=0;
while (this_len < toklen && tok[this_len] != '.') this_len++;
if (this_len > 0)
{
int attr=isf?namedTokenHighlight(tok,this_len,*c_comment_state):def_attr;
if (isf && attr == A_NORMAL)
{
int ntok_len=0, cc = *c_comment_state;
const char *pp=lp,*ntok = sh_tokenize(&pp,endptr,&ntok_len,&cc);
if (ntok && ntok_len>0 && *ntok == '(') def_attr = attr = SYNTAX_FUNC2;
}
draw_string(&skipcnt,tok,this_len,&last_attr,attr==A_NORMAL?def_attr:attr);
tok += this_len;
toklen -= this_len;
}
if (toklen > 0)
{
draw_string(&skipcnt,tok,1,&last_attr,SYNTAX_HIGHLIGHT1);
tok++;
toklen--;
}
isf=false;
}
continue;
}
else if (tok[0] == '.' ||
(tok[0] >= '0' && tok[0] <= '9') ||
(toklen > 1 && tok[0] == '$' && (tok[1] == 'x' || tok[1]=='X')))
{
attr = SYNTAX_HIGHLIGHT2;
int x=1,mode=0;
if (tok[0] == '.') mode=1;
else if (toklen > 1 && (tok[0] == '$' || tok[0] == '0') && (tok[1] == 'x' || tok[1] == 'X')) { mode=2; x++; }
for(;x<toklen;x++)
{
if (tok[x] == '.' && !mode) mode=1;
else if (tok[x] < '0' || tok[x] > '9')
{
if (mode != 2 || ((tok[x] < 'a' || tok[x] > 'f') && (tok[x] < 'A' || tok[x] > 'F')))
break;
}
}
if (x<toklen) err_right=toklen-x;
}
else if (tok[0] == '\'' || tok[0] == '\"')
{
start_of_tok = tok[0];
attr = SYNTAX_STRING;
}
else if (tok[0] == '$')
{
attr = SYNTAX_HIGHLIGHT2;
if (toklen >= 3 && !strnicmp(tok,"$pi",3)) err_right = toklen - 3;
else if (toklen >= 2 && !strnicmp(tok,"$e",2)) err_right = toklen - 2;
else if (toklen >= 4 && !strnicmp(tok,"$phi",4)) err_right = toklen - 4;
else if (toklen == 4 && tok[1] == '\'' && tok[3] == '\'') { }
else if (toklen > 1 && tok[1] == '~')
{
int x;
for(x=2;x<toklen;x++) if (tok[x] < '0' || tok[x] > '9') break;
if (x<toklen) err_right=toklen-x;
}
else err_right = toklen;
}
else if (ignoreSyntaxState==-1 && (tok[0] == '{' || tok[0] == '}'))
{
attr = SYNTAX_HIGHLIGHT1;
}
else
{
const char *h="()+*-=/,|&%;!<>?:^!~[]";
while (*h && *h != tok[0]) h++;
if (*h)
{
if (*c_comment_state != STATE_BEFORE_CODE && sh_draw_parentokenstack_update(tok,toklen))
attr = SYNTAX_ERROR;
else
attr = SYNTAX_HIGHLIGHT1;
}
else
{
err_left=1;
if (tok[0] < 0) while (err_left < toklen && tok[err_left]<0) err_left++; // utf-8 skip
}
}
if (ignoreSyntaxState) err_left = err_right = 0;
if (err_left > 0)
{
if (err_left > toklen) err_left=toklen;
draw_string(&skipcnt,tok,err_left,&last_attr,SYNTAX_ERROR);
tok+=err_left;
toklen -= err_left;
}
if (err_right > toklen) err_right=toklen;
draw_string(&skipcnt, tok, toklen - err_right, &last_attr, attr, start_of_tok);
if (err_right > 0)
draw_string(&skipcnt,tok+toklen-err_right,err_right,&last_attr,SYNTAX_ERROR);
if (ignoreSyntaxState == -1 && tok[0] == '>')
{
draw_string(&skipcnt,p,strlen(p),&last_attr,ignoreSyntaxState==2 ? SYNTAX_COMMENT : A_NORMAL);
break;
}
}
return 1;
}
int EEL_Editor::GetCommentStateForLineStart(int line)
{
if (m_write_leading_tabs<=0) m_indent_size=2;
const bool uses_code_start_lines = !!is_code_start_line(NULL);
int state=0;
int x=0;
if (uses_code_start_lines)
{
state=STATE_BEFORE_CODE;
for (;;x++)
{
WDL_FastString *t = m_text.Get(x);
if (!t || is_code_start_line(t->Get())) break;
const char *p=t->Get();
if (!strnicmp(p,"tabsize:",8))
{
int a = atoi(p+8);
if (a>0 && a < 32) m_indent_size = a;
}
}
// scan backwards to find line starting with @
for (x=line;x>=0;x--)
{
WDL_FastString *t = m_text.Get(x);
if (!t) break;
if (is_code_start_line(t->Get()))
{
state=0;
break;
}
}
x++;
}
s_draw_parentokenstack.Resize(0,false);
for (;x<line;x++)
{
WDL_FastString *t = m_text.Get(x);
const char *p = t?t->Get():"";
if (is_code_start_line(p))
{
s_draw_parentokenstack.Resize(0,false);
state=0;
}
else if (state != STATE_BEFORE_CODE)
{
const int ll=t?t->GetLength():0;
const char *endp = p+ll;
int toklen;
const char *tok;
while (NULL != (tok=sh_tokenize(&p,endp,&toklen,&state))) // eat all tokens, updating state
{
sh_func_ontoken(tok,toklen);
sh_draw_parentokenstack_update(tok,toklen);
}
}
}
return state;
}
const char *EEL_Editor::sh_tokenize(const char **ptr, const char *endptr, int *lenOut, int *state)
{
return nseel_simple_tokenizer(ptr, endptr, lenOut, state);
}
bool EEL_Editor::LineCanAffectOtherLines(const char *txt, int spos, int slen) // if multiline comment etc
{
const char *special_start = txt + spos;
const char *special_end = txt + spos + slen;
while (*txt)
{
if (txt >= special_start-1 && txt < special_end)
{
const char c = txt[0];
if (c == '*' && txt[1] == '/') return true;
if (c == '/' && (txt[1] == '/' || txt[1] == '*')) return true;
if (c == '\\' && (txt[1] == '\"' || txt[1] == '\'')) return true;
if (txt >= special_start)
{
if (c == '\"' || c == '\'') return true;
if (c == '(' || c == '[' || c == ')' || c == ']' || c == ':' || c == ';' || c == '?') return true;
}
}
txt++;
}
return false;
}
struct eel_sh_token
{
int line, col, end_col;
unsigned int data; // packed char for token type, plus 24 bits for linecnt (0=single line, 1=extra line, etc)
eel_sh_token(int _line, int _col, int toklen, unsigned char c)
{
line = _line;
col = _col;
end_col = col + toklen;
data = c;
}
~eel_sh_token() { }
void add_linecnt(int endcol) { data += 256; end_col = endcol; }
int get_linecnt() const { return (data >> 8); }
char get_c() const { return (char) (data & 255); }
bool is_comment() const {
return get_c() == '/' && (get_linecnt() || end_col>col+1);
};
};
static int eel_sh_get_token_for_pos(const WDL_TypedBuf<eel_sh_token> *toklist, int line, int col, bool *is_after)
{
const int sz = toklist->GetSize();
int x;
for (x=0; x < sz; x ++)
{
const eel_sh_token *tok = toklist->Get()+x;
const int first_line = tok->line;
const int last_line = first_line+tok->get_linecnt(); // last affected line (usually same as first)
if (last_line >= line) // if this token doesn't end before the line we care about
{
// check to see if the token starts after our position
if (first_line > line || (first_line == line && tok->col > col)) break;
// token started before line/col, see if it ends after line/col
if (last_line > line || tok->end_col > col)
{
// direct hit
*is_after = false;
return x;
}
}
}
*is_after = true;
return x-1;
}
static void eel_sh_generate_token_list(const WDL_PtrList<WDL_FastString> *lines, WDL_TypedBuf<eel_sh_token> *toklist, int start_line, EEL_Editor *editor)
{
toklist->Resize(0,false);
int state=0;
int l;
int end_line = lines->GetSize();
if (editor->is_code_start_line(NULL))
{
for (l = start_line; l < end_line; l ++)
{
WDL_FastString *s = lines->Get(l);
if (s && editor->is_code_start_line(s->Get()))
{
end_line = l;
break;
}
}
for (; start_line >= 0; start_line--)
{
WDL_FastString *s = lines->Get(start_line);
if (s && editor->is_code_start_line(s->Get())) break;
}
if (start_line < 0) return; // before any code
start_line++;
}
else
{
start_line = 0;
}
for (l=start_line;l<end_line;l++)
{
WDL_FastString *t = lines->Get(l);
const int ll = t?t->GetLength():0;
const char *start_p = t?t->Get():"";
const char *p = start_p;
const char *endp = start_p+ll;
const char *tok;
int last_state=state;
int toklen;
while (NULL != (tok=editor->sh_tokenize(&p,endp,&toklen,&state))||last_state)
{
if (last_state == '\'' || last_state == '"' || last_state==1)
{
const int sz=toklist->GetSize();
// update last token to include this data
if (sz) toklist->Get()[sz-1].add_linecnt((int) ((tok ? p:endp) - start_p));
}
else
{
if (tok) switch (tok[0])
{
case '{':
case '}':
case '?':
case ':':
case ';':
case '(':
case '[':
case ')':
case ']':
case '\'':
case '"':
case '/': // comment
{
eel_sh_token t(l,(int)(tok-start_p),toklen,tok[0]);
toklist->Add(t);
}
break;
}
}
last_state=0;
}
}
}
static bool eel_sh_get_matching_pos_for_pos(WDL_PtrList<WDL_FastString> *text, int curx, int cury, int *newx, int *newy, const char **errmsg, EEL_Editor *editor)
{
static WDL_TypedBuf<eel_sh_token> toklist;
eel_sh_generate_token_list(text,&toklist, cury,editor);
bool is_after;
const int hit_tokidx = eel_sh_get_token_for_pos(&toklist, cury, curx, &is_after);
const eel_sh_token *hit_tok = hit_tokidx >= 0 ? toklist.Get() + hit_tokidx : NULL;
if (!is_after && hit_tok && (hit_tok->get_c() == '"' || hit_tok->get_c() == '\'' || hit_tok->is_comment()))
{
eel_sh_token tok = *hit_tok; // save a copy, toklist might get destroyed recursively here
hit_tok = &tok;
//if (tok.get_c() == '"')
{
// the user could be editing code in code, tokenize it and see if we can make sense of it
WDL_FastString start, end;
WDL_PtrList<WDL_FastString> tmplist;
WDL_FastString *s = text->Get(tok.line);
if (s && s->GetLength() > tok.col+1)
{
int maxl = tok.get_linecnt()>0 ? 0 : tok.end_col - tok.col - 2;
start.Set(s->Get() + tok.col+1, maxl);
}
tmplist.Add(&start);
const int linecnt = tok.get_linecnt();
if (linecnt>0)
{
for (int a=1; a < linecnt; a ++)
{
s = text->Get(tok.line + a);
if (s) tmplist.Add(s);
}
s = text->Get(tok.line + linecnt);
if (s)
{
if (tok.end_col>1) end.Set(s->Get(), tok.end_col-1);
tmplist.Add(&end);
}
}
int lx = curx, ly = cury - tok.line;
if (cury == tok.line) lx -= (tok.col+1);
// this will destroy the token
if (eel_sh_get_matching_pos_for_pos(&tmplist, lx, ly, newx, newy, errmsg, editor))
{
*newy += tok.line;
if (cury == tok.line) *newx += tok.col + 1;
return true;
}
}
// if within a string or comment, move to start, unless already at start, move to end
if (cury == hit_tok->line && curx == hit_tok->col)
{
*newx=hit_tok->end_col-1;
*newy=hit_tok->line + hit_tok->get_linecnt();
}
else
{
*newx=hit_tok->col;
*newy=hit_tok->line;
}
return true;
}
if (!hit_tok) return false;
const int toksz=toklist.GetSize();
int tokpos = hit_tokidx;
int pc1=0,pc2=0; // (, [ count
int pc3=0; // : or ? count depending on mode
int dir=-1, mode=0; // default to scan to previous [(
if (!is_after)
{
switch (hit_tok->get_c())
{
case '(': mode=1; dir=1; break;
case '[': mode=2; dir=1; break;
case ')': mode=3; dir=-1; break;
case ']': mode=4; dir=-1; break;
case '?': mode=5; dir=1; break;
case ':': mode=6; break;
case ';': mode=7; break;
}
// if hit a token, exclude this token from scanning
tokpos += dir;
}
while (tokpos>=0 && tokpos<toksz)
{
const eel_sh_token *tok = toklist.Get() + tokpos;
const char this_c = tok->get_c();
if (!pc1 && !pc2)
{
bool match=false, want_abort=false;
switch (mode)
{
case 0: match = this_c == '(' || this_c == '['; break;
case 1: match = this_c == ')'; break;
case 2: match = this_c == ']'; break;
case 3: match = this_c == '('; break;
case 4: match = this_c == '['; break;
case 5:
// scan forward to nearest : or ;
if (this_c == '?') pc3++;
else if (this_c == ':')
{
if (pc3>0) pc3--;
else match=true;
}
else if (this_c == ';') match=true;
else if (this_c == ')' || this_c == ']')
{
want_abort=true; // if you have "(x<y?z)", don't match for the ?
}
break;
case 6: // scanning back from : to ?, if any
case 7: // semicolon searches same as colon, effectively
if (this_c == ':') pc3++;
else if (this_c == '?')
{
if (pc3>0) pc3--;
else match = true;
}
else if (this_c == ';' || this_c == '(' || this_c == '[')
{
want_abort=true;
}
break;
}
if (want_abort) break;
if (match)
{
*newx=tok->col;
*newy=tok->line;
return true;
}
}
switch (this_c)
{
case '[': pc2++; break;
case ']': pc2--; break;
case '(': pc1++; break;
case ')': pc1--; break;
}
tokpos+=dir;
}
if (errmsg)
{
if (!mode) *errmsg = "Could not find previous [ or (";
else if (mode == 1) *errmsg = "Could not find matching )";
else if (mode == 2) *errmsg = "Could not find matching ]";
else if (mode == 3) *errmsg = "Could not find matching (";
else if (mode == 4) *errmsg = "Could not find matching [";
else if (mode == 5) *errmsg = "Could not find matching : or ; for ?";
else if (mode == 6) *errmsg = "Could not find matching ? for :";
else if (mode == 7) *errmsg = "Could not find matching ? for ;";
}
return false;
}
void EEL_Editor::doParenMatching()
{
WDL_FastString *curstr;
const char *errmsg = "";
if (NULL != (curstr=m_text.Get(m_curs_y)))
{
int bytex = WDL_utf8_charpos_to_bytepos(curstr->Get(),m_curs_x);
if (bytex >= curstr->GetLength()) bytex=curstr->GetLength()-1;
if (bytex<0) bytex = 0;
int new_x,new_y;
if (eel_sh_get_matching_pos_for_pos(&m_text, bytex,m_curs_y,&new_x,&new_y,&errmsg,this))
{
curstr = m_text.Get(new_y);
if (curstr) new_x = WDL_utf8_bytepos_to_charpos(curstr->Get(),new_x);
m_curs_x=new_x;
m_curs_y=new_y;
m_want_x=-1;
draw();
setCursor(1);
}
else if (errmsg[0])
{
draw_message(errmsg);
setCursor(0);
}
}
}
static int word_len(const char *p)
{
int l = 0;
if (*p >= 'a' && *p <='z')
{
l++;
// lowercase word
while (p[l] && p[l] != '_' && p[l] != '.' && !(p[l] >= 'A' && p[l] <='Z')) l++;
}
else if (*p >= 'A' && *p <= 'Z')
{
if (!strcmp(p,"MIDI")) return 4;
l++;
if (p[l] >= 'A' && p[l] <='Z') // UPPERCASE word
while (p[l] && p[l] != '_' && p[l] != '.' && !(p[l] >= 'a' && p[l] <='z')) l++;
else // Titlecase word
while (p[l] && p[l] != '_' && p[l] != '.' && !(p[l] >= 'A' && p[l] <='Z')) l++;
}
return l;
}
static int search_str_partial(const char *str, int reflen, const char *word, int wordlen)
{
// find the longest leading segment of word in str
int best_len = 0;
for (int y = 0; y < reflen; y ++)
{
while (y < reflen && !strnicmp(str+y,word,best_len+1))
{
if (++best_len >= wordlen) return best_len;
reflen--;
}
}
return best_len;
}
static int fuzzy_match2(const char *codestr, int codelen, const char *refstr, int reflen)
{
// codestr is user-typed, refstr is the reference function name
// our APIs are gfx_blah_blah or TrackBlahBlah so breaking the API up by words
// and searching the user-entered code should be effective
int lendiff = reflen - codelen;
if (lendiff < 0) lendiff = -lendiff;
const char *word = refstr;
int score = 0;
for (;;)
{
while (*word == '_' || *word == '.') word++;
const int wordlen = word_len(word);
if (!wordlen) break;
char word_buf[128];
lstrcpyn_safe(word_buf,word,wordlen+1);
if (WDL_stristr(refstr,word_buf)==word)
{
int max_match_len = search_str_partial(codestr,codelen,word,wordlen);
if (max_match_len < 2 && wordlen == 5 && !strnicmp(word,"Count",5))
{
max_match_len = search_str_partial(codestr,codelen,"Num",3);
}
if (max_match_len > (wordlen <= 2 ? 1 : 2))
score += max_match_len;
}
word += wordlen;
}
if (!score) return 0;
return score * 1000 + 1000 - wdl_clamp(lendiff*2,0,200);
}
int EEL_Editor::fuzzy_match(const char *codestr, const char *refstr)
{
const int codestr_len = (int)strlen(codestr), refstr_len = (int)strlen(refstr);
if (refstr_len >= codestr_len && !strnicmp(codestr,refstr,codestr_len)) return 1000000000;
int score1 = fuzzy_match2(refstr,refstr_len,codestr,codestr_len);
int score2 = fuzzy_match2(codestr,codestr_len,refstr,refstr_len);
if (score2 > score1) return score2 | 1;
return score1&~1;
}
static int eeledit_varenumfunc(const char *name, EEL_F *val, void *ctx)
{
void **parms = (void **)ctx;
int score = ((EEL_Editor*)parms[2])->fuzzy_match((const char *)parms[1], name);
if (score > 0) ((suggested_matchlist*)parms[0])->add(name,score,suggested_matchlist::MODE_VAR);
return 1;
}
void EEL_Editor::get_suggested_token_names(const char *fname, int chkmask, suggested_matchlist *list)
{
int x;
if (chkmask & (KEYWORD_MASK_BUILTIN_FUNC|KEYWORD_MASK_USER_VAR))
{
peek_lock();
NSEEL_VMCTX vm = peek_get_VM();
compileContext *fvm = vm && peek_want_VM_funcs() ? (compileContext*)vm : NULL;
if (chkmask&KEYWORD_MASK_BUILTIN_FUNC) for (x=0;;x++)
{
functionType *p = nseel_enumFunctions(fvm,x);
if (!p) break;
int score = fuzzy_match(fname,p->name);
if (score>0) list->add(p->name,score);
}
if (vm && (chkmask&KEYWORD_MASK_USER_VAR))
{
const void *parms[3] = { list, fname, this };
NSEEL_VM_enumallvars(vm, eeledit_varenumfunc, parms);
}
peek_unlock();
}
if (chkmask & KEYWORD_MASK_USER_FUNC)
{
ensure_code_func_cache_valid();
for (int x=0;x< m_code_func_cache.GetSize();x++)
{
const char *k = m_code_func_cache.Get(x) + 4;
if (WDL_NORMALLY(k))
{
int score = fuzzy_match(fname,k);
if (score > 0) list->add(k,score,suggested_matchlist::MODE_USERFUNC);
}
}
}
}
int EEL_Editor::peek_get_token_info(const char *name, char *sstr, size_t sstr_sz, int chkmask, int ignoreline)
{
if (chkmask&KEYWORD_MASK_USER_FUNC)
{
ensure_code_func_cache_valid();
for (int i = 0; i < m_code_func_cache.GetSize(); i ++)
{
const char *cacheptr = m_code_func_cache.Get(i);
const char *nameptr = cacheptr + sizeof(int);
if (!(m_case_sensitive ? strcmp(nameptr, name):stricmp(nameptr,name)) &&
*(int *)cacheptr != ignoreline)
{
const char *parms = nameptr+strlen(nameptr)+1;
const char *trail = parms+strlen(parms)+1;
snprintf(sstr,sstr_sz,"%s%s%s%s",nameptr,parms,*trail?" " :"",trail);
return 4;
}
}
}
if (chkmask & (KEYWORD_MASK_BUILTIN_FUNC|KEYWORD_MASK_USER_VAR))
{
int rv = 0;
peek_lock();
NSEEL_VMCTX vm = peek_want_VM_funcs() ? peek_get_VM() : NULL;
functionType *f = (chkmask&KEYWORD_MASK_BUILTIN_FUNC) ? nseel_getFunctionByName((compileContext*)vm,name,NULL) : NULL;
double v;
if (f)
{
snprintf(sstr,sstr_sz,"'%s' is a function that requires %d parameters", f->name,f->nParams&0xff);
rv = KEYWORD_MASK_BUILTIN_FUNC;
}
else if (chkmask & KEYWORD_MASK_USER_VAR)
{
if (!vm) vm = peek_get_VM();
EEL_F *vptr=NSEEL_VM_getvar(vm,name);
if (vptr)
{
v = *vptr;
rv = KEYWORD_MASK_USER_VAR;
}
}
peek_unlock();
if (rv == KEYWORD_MASK_USER_VAR)
{
int good_len=-1;
snprintf(sstr,sstr_sz,"%s=%.14f",name,v);
if (v > -1.0 && v < NSEEL_RAM_ITEMSPERBLOCK*NSEEL_RAM_BLOCKS)
{
const unsigned int w = (unsigned int) (v+NSEEL_CLOSEFACTOR);
EEL_F *dv = NSEEL_VM_getramptr_noalloc(vm,w,NULL);
if (dv)
{
snprintf_append(sstr,sstr_sz," [0x%06x]=%.14f",w,*dv);
good_len=-2;
}
else
{
good_len = strlen(sstr);
snprintf_append(sstr,sstr_sz," [0x%06x]=<uninit>",w);
}
}
char buf[512];
buf[0]=0;
if (peek_get_numbered_string_value(v,buf,sizeof(buf)))
{
if (good_len==-2)
snprintf_append(sstr,sstr_sz," %.0f(str)=%s",v,buf);
else
{
if (good_len>=0) sstr[good_len]=0; // remove [addr]=<uninit> if a string and no ram
snprintf_append(sstr,sstr_sz," (str)=%s",buf);
}
}
}
if (rv) return rv;
}
return 0;
}
void EEL_Editor::doWatchInfo(int c)
{
// determine the word we are on, check its value in the effect
char sstr[512], buf[512];
lstrcpyn_safe(sstr,"Use this on a valid symbol name", sizeof(sstr));
WDL_FastString *t=m_text.Get(m_curs_y);
char curChar=0;
if (t)
{
const char *p=t->Get();
const int bytex = WDL_utf8_charpos_to_bytepos(p,m_curs_x);
if (bytex >= 0 && bytex < t->GetLength()) curChar = p[bytex];
if (c != KEY_F1 && (m_selecting ||
curChar == '(' ||
curChar == '[' ||
curChar == ')' ||
curChar == ']'
))
{
WDL_FastString code;
int miny,maxy,minx,maxx;
bool ok = false;
if (!m_selecting)
{
if (eel_sh_get_matching_pos_for_pos(&m_text,minx=m_curs_x,miny=m_curs_y,&maxx, &maxy,NULL,this))
{
if (maxy==miny)
{
if (maxx < minx)
{
int tmp = minx;
minx=maxx;
maxx=tmp;
}
}
else if (maxy < miny)
{
int tmp=maxy;
maxy=miny;
miny=tmp;
tmp = minx;
minx=maxx;
maxx=tmp;
}
ok = true;
minx++; // skip leading (
}
}
else
{
ok=true;
getselectregion(minx,miny,maxx,maxy);
WDL_FastString *s;
s = m_text.Get(miny);
if (s) minx = WDL_utf8_charpos_to_bytepos(s->Get(),minx);
s = m_text.Get(maxy);
if (s) maxx = WDL_utf8_charpos_to_bytepos(s->Get(),maxx);
}
if (ok)
{
int x;
for (x = miny; x <= maxy; x ++)
{
WDL_FastString *s=m_text.Get(x);
if (s)
{
const char *str=s->Get();
int sx,ex;
if (x == miny) sx=wdl_max(minx,0);
else sx=0;
int tmp=s->GetLength();
if (sx > tmp) sx=tmp;
if (x == maxy) ex=wdl_min(maxx,tmp);
else ex=tmp;
if (code.GetLength()) code.Append("\r\n");
code.Append(ex-sx?str+sx:"",ex-sx);
}
}
}
if (code.Get()[0])
{
if (m_selecting && (GetAsyncKeyState(VK_SHIFT)&0x8000))
{
peek_lock();
NSEEL_CODEHANDLE ch;
NSEEL_VMCTX vm = peek_get_VM();
if (vm && (ch = NSEEL_code_compile_ex(vm,code.Get(),1,0)))
{
codeHandleType *p = (codeHandleType*)ch;
code.Ellipsize(3,20);
const char *errstr = "failed writing to";
if (p->code)
{
buf[0]=0;
GetTempPath(sizeof(buf)-64,buf);
lstrcatn(buf,"jsfx-out",sizeof(buf));
FILE *fp = fopen(buf,"wb");
if (fp)
{
errstr="wrote to";
fwrite(p->code,1,p->code_size,fp);
fclose(fp);
}
}
snprintf(sstr,sizeof(sstr),"Expression '%s' compiled to %d bytes, %s temp/jsfx-out",code.Get(),p->code_size, errstr);
NSEEL_code_free(ch);
}
else
{
code.Ellipsize(3,20);
snprintf(sstr,sizeof(sstr),"Expression '%s' could not compile",code.Get());
}
peek_unlock();
}
else
{
WDL_FastString code2;
code2.Set("__debug_watch_value = (((((");
code2.Append(code.Get());
code2.Append(")))));");
peek_lock();
NSEEL_VMCTX vm = peek_get_VM();
EEL_F *vptr=NULL;
double v=0.0;
const char *err="Invalid context";
if (vm)
{
NSEEL_CODEHANDLE ch = NSEEL_code_compile_ex(vm,code2.Get(),1,0);
if (!ch) err = "Error parsing";
else
{
NSEEL_code_execute(ch);
NSEEL_code_free(ch);
vptr = NSEEL_VM_getvar(vm,"__debug_watch_value");
if (vptr) v = *vptr;
}
}
peek_unlock();
{
// remove whitespace from code for display
int x;
bool lb=true;
for (x=0;x<code.GetLength();x++)
{
if (isspace(code.Get()[x]))
{
if (lb) code.DeleteSub(x--,1);
lb=true;
}
else
{
lb=false;
}
}
if (lb && code.GetLength()>0) code.SetLen(code.GetLength()-1);
}
code.Ellipsize(3,20);
if (vptr)
{
snprintf(sstr,sizeof(sstr),"Expression '%s' evaluates to %.14f",code.Get(),v);
}
else
{
snprintf(sstr,sizeof(sstr),"Error evaluating '%s': %s",code.Get(),err?err:"Unknown error");
}
}
}
// compile+execute code within () as debug_watch_value = ( code )
// show value (or err msg)
}
else if (curChar>0 && (isalnum(curChar) || curChar == '_' || curChar == '.' || curChar == '#'))
{
const int bytex = WDL_utf8_charpos_to_bytepos(p,m_curs_x);
const char *lp=p+bytex;
const char *rp=lp + WDL_utf8_charpos_to_bytepos(lp,1);
while (lp >= p && *lp > 0 && (isalnum(*lp) || *lp == '_' || (*lp == '.' && (lp==p || lp[-1]!='.')))) lp--;
if (lp < p || *lp != '#') lp++;
while (*rp && *rp > 0 && (isalnum(*rp) || *rp == '_' || (*rp == '.' && rp[1] != '.'))) rp++;
if (*lp == '#' && rp > lp+1)
{
WDL_FastString n;
lp++;
n.Set(lp,(int)(rp-lp));
int idx;
if ((idx=peek_get_named_string_value(n.Get(),buf,sizeof(buf)))>=0) snprintf(sstr,sizeof(sstr),"#%s(%d)=%s",n.Get(),idx,buf);
else snprintf(sstr,sizeof(sstr),"#%s not found",n.Get());
}
else if (*lp > 0 && (isalpha(*lp) || *lp == '_') && rp > lp)
{
WDL_FastString n;
n.Set(lp,(int)(rp-lp));
if (c==KEY_F1)
{
if (m_suggestion.GetLength())
goto help_from_sug;
on_help(n.Get(),0);
return;
}
int f = peek_get_token_info(n.Get(),sstr,sizeof(sstr),~0,-1);
if (!f) snprintf(sstr,sizeof(sstr),"'%s' NOT FOUND",n.Get());
}
}
}
if (c==KEY_F1)
{
help_from_sug:
WDL_FastString t;
if (m_suggestion.GetLength())
{
const char *p = m_suggestion.Get();
int l;
for (l = 0; isalnum(p[l]) || p[l] == '_' || p[l] == '.'; l ++);
if (l>0) t.Set(m_suggestion.Get(),l);
}
on_help(t.GetLength() > 2 ? t.Get() : NULL,(int)curChar);
return;
}
setCursor();
draw_message(sstr);
}
void EEL_Editor::draw_bottom_line()
{
#define BOLD(x) { attrset(COLOR_BOTTOMLINE|A_BOLD); addstr(x); attrset(COLOR_BOTTOMLINE&~A_BOLD); }
addstr("ma"); BOLD("T"); addstr("ch");
BOLD(" S"); addstr("ave");
if (peek_get_VM())
{
addstr(" pee"); BOLD("K");
}
if (GetTabCount()>1)
{
addstr(" | tab: ");
BOLD("[], F?"); addstr("=switch ");
BOLD("W"); addstr("=close");
}
#undef BOLD
}
#define CTRL_KEY_DOWN (GetAsyncKeyState(VK_CONTROL)&0x8000)
#define SHIFT_KEY_DOWN (GetAsyncKeyState(VK_SHIFT)&0x8000)
#define ALT_KEY_DOWN (GetAsyncKeyState(VK_MENU)&0x8000)
static const char *suggestion_help_text = "(up/down to select, tab to insert)";
static const char *suggestion_help_text2 = "(tab or return to insert)";
static LRESULT WINAPI suggestionProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
EEL_Editor *editor;
switch (uMsg)
{
case WM_DESTROY:
editor = (EEL_Editor *)GetWindowLongPtr(hwnd,GWLP_USERDATA);
if (editor) editor->m_suggestion_hwnd = NULL;
break;
case WM_LBUTTONDOWN:
case WM_MOUSEMOVE:
editor = (EEL_Editor *)GetWindowLongPtr(hwnd,GWLP_USERDATA);
if (editor)
{
win32CursesCtx *ctx = (win32CursesCtx *)editor->m_cursesCtx;
if (ctx && ctx->m_font_h)
{
RECT r;
GetClientRect(hwnd,&r);
SetForegroundWindow(GetParent(hwnd));
SetFocus(GetParent(hwnd));
const int max_vis = r.bottom / ctx->m_font_h - 1, sel = editor->m_suggestion_hwnd_sel;
int hit = GET_Y_LPARAM(lParam) / ctx->m_font_h;
if (hit >= max_vis) return 0;
if (sel >= max_vis) hit += 1 + sel - max_vis;
if (uMsg == WM_LBUTTONDOWN && !SHIFT_KEY_DOWN && !ALT_KEY_DOWN && !CTRL_KEY_DOWN)
{
editor->m_suggestion_hwnd_sel = hit;
editor->onChar('\t');
}
else if (sel != hit)
{
editor->m_suggestion_hwnd_sel = hit;
InvalidateRect(hwnd,NULL,FALSE);
char sug[512];
sug[0]=0;
const char *p = editor->m_suggestion_list.get(hit);
if (p && editor->peek_get_token_info(p,sug,sizeof(sug),~0,-1))
{
editor->m_suggestion.Set(sug);
editor->draw_top_line();
editor->setCursor();
}
}
}
}
return 0;
case WM_PAINT:
editor = (EEL_Editor *)GetWindowLongPtr(hwnd,GWLP_USERDATA);
if (editor)
{
PAINTSTRUCT ps;
if (BeginPaint(hwnd,&ps))
{
RECT r;
GetClientRect(hwnd,&r);
win32CursesCtx *ctx = (win32CursesCtx *)editor->m_cursesCtx;
HBRUSH br = CreateSolidBrush(ctx->colortab[WDL_CursesEditor::COLOR_TOPLINE][1]);
FillRect(ps.hdc,&r,br);
DeleteObject(br);
suggested_matchlist *ml = &editor->m_suggestion_list;
HGDIOBJ oldObj = SelectObject(ps.hdc,ctx->mOurFont);
SetBkMode(ps.hdc,TRANSPARENT);
const int fonth = wdl_max(ctx->m_font_h,1);
const int maxv = r.bottom / fonth - 1;
const int selpos = wdl_max(editor->m_suggestion_hwnd_sel,0);
int ypos = 0;
const bool show_scores = (GetAsyncKeyState(VK_SHIFT)&0x8000) && (GetAsyncKeyState(VK_CONTROL)&0x8000) && (GetAsyncKeyState(VK_MENU)&0x8000);
for (int x = (selpos >= maxv ? 1+selpos-maxv : 0); x < ml->get_size() && ypos <= r.bottom-fonth*2; x ++)
{
int mode, score;
const char *p = ml->get(x,&mode,&score);
if (WDL_NORMALLY(p))
{
const bool sel = x == selpos;
SetTextColor(ps.hdc,ctx->colortab[
(mode == suggested_matchlist::MODE_VAR ? WDL_CursesEditor::COLOR_TOPLINE :
mode == suggested_matchlist::MODE_USERFUNC ? WDL_CursesEditor::SYNTAX_FUNC2 :
mode == suggested_matchlist::MODE_REGVAR ? WDL_CursesEditor::SYNTAX_REGVAR :
WDL_CursesEditor::SYNTAX_KEYWORD)
| (sel ? A_BOLD:0)][0]);
RECT tr = {4, ypos, r.right-4, ypos+fonth };
DrawTextUTF8(ps.hdc,p,-1,&tr,DT_SINGLELINE|DT_NOPREFIX|DT_TOP|DT_LEFT);
if (show_scores)
{
char tmp[128];
snprintf(tmp,sizeof(tmp),"(%d)",score);
DrawTextUTF8(ps.hdc,tmp,-1,&tr,DT_SINGLELINE|DT_NOPREFIX|DT_TOP|DT_RIGHT);
}
}
ypos += fonth;
}
{
const COLORREF mix = ((ctx->colortab[WDL_CursesEditor::COLOR_TOPLINE][1]&0xfefefe)>>1) +
((ctx->colortab[WDL_CursesEditor::COLOR_TOPLINE][0]&0xfefefe)>>1);
SetTextColor(ps.hdc,mix);
RECT tr = {4, r.bottom-fonth, r.right-4, r.bottom };
DrawTextUTF8(ps.hdc,
editor->m_suggestion_hwnd_sel >= 0 ? suggestion_help_text2 : suggestion_help_text,
-1,&tr,DT_SINGLELINE|DT_NOPREFIX|DT_TOP|DT_CENTER);
}
SelectObject(ps.hdc,oldObj);
EndPaint(hwnd,&ps);
}
}
return 0;
}
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
void EEL_Editor::open_import_line()
{
WDL_FastString *txtstr=m_text.Get(m_curs_y);
const char *txt=txtstr?txtstr->Get():NULL;
char fnp[2048];
if (txt && line_has_openable_file(txt,WDL_utf8_charpos_to_bytepos(txt,m_curs_x),fnp,sizeof(fnp)))
{
WDL_CursesEditor::OpenFileInTab(fnp);
}
}
int EEL_Editor::onChar(int c)
{
if ((m_ui_state == UI_STATE_NORMAL || m_ui_state == UI_STATE_MESSAGE) &&
(c == 'K'-'A'+1 || c == 'S'-'A'+1 || c == 'R'-'A'+1 || !SHIFT_KEY_DOWN) && !ALT_KEY_DOWN) switch (c)
{
case KEY_F1:
if (CTRL_KEY_DOWN) break;
case 'K'-'A'+1:
doWatchInfo(c);
return 0;
case 'S'-'A'+1:
{
WDL_DestroyCheck chk(&destroy_check);
if(updateFile())
{
if (chk.isOK())
draw_message("Error writing file, changes not saved!");
}
if (chk.isOK())
setCursor();
}
return 0;
// case 'I': note stupidly we map Ctrl+I to VK_TAB, bleh
case 'R'-'A'+1:
if (!SHIFT_KEY_DOWN) break;
if (!m_selecting)
{
open_import_line();
}
return 0;
case KEY_F4:
case 'T'-'A'+1:
doParenMatching();
return 0;
}
int rv = 0;
int do_sug = (g_eel_editor_max_vis_suggestions > 0 &&
m_ui_state == UI_STATE_NORMAL &&
!m_selecting && m_top_margin > 0 &&
(c == 'L'-'A'+1 || (!CTRL_KEY_DOWN && !ALT_KEY_DOWN))) ? 1 : 0;
bool did_fuzzy = false;
char sug[1024];
sug[0]=0;
if (do_sug)
{
if (m_suggestion_hwnd)
{
// insert if tab or shift+enter or (enter if arrow-navigated)
if ((c == '\t' && !SHIFT_KEY_DOWN) ||
(c == '\r' && (m_suggestion_hwnd_sel>=0 || SHIFT_KEY_DOWN)))
{
char buf[512];
int sug_mode;
const char *ptr = m_suggestion_list.get(wdl_max(m_suggestion_hwnd_sel,0), &sug_mode);
lstrcpyn_safe(buf,ptr?ptr:"",sizeof(buf));
DestroyWindow(m_suggestion_hwnd);
WDL_FastString *l=m_text.Get(m_curs_y);
if (buf[0] && l &&
WDL_NORMALLY(m_suggestion_tokpos>=0 && m_suggestion_tokpos < l->GetLength()) &&
WDL_NORMALLY(m_suggestion_toklen>0) &&
WDL_NORMALLY(m_suggestion_tokpos+m_suggestion_toklen <= l->GetLength()))
{
preSaveUndoState();
l->DeleteSub(m_suggestion_tokpos,m_suggestion_toklen);
l->Insert(buf,m_suggestion_tokpos);
int pos = m_suggestion_tokpos + strlen(buf);
if (sug_mode == suggested_matchlist::MODE_FUNC || sug_mode == suggested_matchlist::MODE_USERFUNC)
{
if (pos >= l->GetLength() || l->Get()[pos] != '(')
l->Insert("(",pos++);
}
m_curs_x = WDL_utf8_bytepos_to_charpos(l->Get(),pos);
draw();
saveUndoState();
setCursor();
goto run_suggest;
}
return 0;
}
if ((c == KEY_UP || c==KEY_DOWN || c == KEY_NPAGE || c == KEY_PPAGE) && !SHIFT_KEY_DOWN)
{
m_suggestion_hwnd_sel = wdl_max(m_suggestion_hwnd_sel,0) +
(c==KEY_UP ? -1 : c==KEY_DOWN ? 1 : c==KEY_NPAGE ? 4 : -4);
if (m_suggestion_hwnd_sel >= m_suggestion_list.get_size())
m_suggestion_hwnd_sel = m_suggestion_list.get_size()-1;
if (m_suggestion_hwnd_sel < 0)
m_suggestion_hwnd_sel=0;
InvalidateRect(m_suggestion_hwnd,NULL,FALSE);
const char *p = m_suggestion_list.get(m_suggestion_hwnd_sel);
if (p) peek_get_token_info(p,sug,sizeof(sug),~0,m_curs_y);
goto finish_sug;
}
}
if (c==27 ||
c=='L'-'A'+1 ||
c=='\r' ||
c=='\t' ||
(c>=KEY_DOWN && c<= KEY_F12 && c!=KEY_DC)) do_sug = 2; // no fuzzy window
else if (c=='\b' && !m_suggestion_hwnd) do_sug=2; // backspace will update but won't show suggestions
}
rv = WDL_CursesEditor::onChar(c);
run_suggest:
if (do_sug)
{
WDL_FastString *l=m_text.Get(m_curs_y);
if (l)
{
const int MAX_TOK=512;
struct {
const char *tok;
int toklen;
} token_list[MAX_TOK];
const char *cursor = l->Get() + WDL_utf8_charpos_to_bytepos(l->Get(),m_curs_x);
int ntok = 0;
{
const char *p = l->Get(), *endp = p + l->GetLength();
int state = m_suggestion_curline_comment_state, toklen = 0, bcnt = 0, pcnt = 0;
const char *tok;
// if no parens/brackets are open, use a peekable token that starts at cursor
while ((tok=sh_tokenize(&p,endp,&toklen,&state)) && cursor > tok-(!pcnt && !bcnt && (tok[0] < 0 || tok[0] == '_' || isalpha(tok[0]))))
{
if (!state)
{
if (WDL_NOT_NORMALLY(ntok >= MAX_TOK))
{
memmove(token_list,token_list+1,sizeof(token_list) - sizeof(token_list[0]));
ntok--;
}
switch (*tok)
{
case '[': bcnt++; break;
case ']': bcnt--; break;
case '(': pcnt++; break;
case ')': pcnt--; break;
}
token_list[ntok].tok = tok;
token_list[ntok].toklen = toklen;
ntok++;
}
}
}
int t = ntok;
int comma_cnt = 0;
while (--t >= 0)
{
const char *tok = token_list[t].tok;
int toklen = token_list[t].toklen;
const int lc = tok[0], ac = lc==')' ? '(' : lc==']' ? '[' : 0;
if (ac)
{
int cnt=1;
while (--t>=0)
{
const int c = token_list[t].tok[0];
if (c == lc) cnt++;
else if (c == ac && !--cnt) break;
}
if (t > 0)
{
const int c = token_list[t-1].tok[0];
if (c != ',' && c != ')' && c != ']') t--;
continue;
}
}
if (t<0) break;
if (tok[0] == ',') comma_cnt++;
else if ((tok[0] < 0 || tok[0] == '_' || isalpha(tok[0])) && (cursor <= tok + toklen || (t < ntok-1 && token_list[t+1].tok[0] == '(')))
{
// if cursor is within or at end of token, or is a function (followed by open-paren)
char buf[512];
lstrcpyn_safe(buf,tok,wdl_min(toklen+1, sizeof(buf)));
if (peek_get_token_info(buf,sug,sizeof(sug),~0,m_curs_y))
{
if (comma_cnt > 0)
{
// hide previous parameters from sug's parameter fields so we know which parameters
// we are (hopefully on)
char *pstart = sug;
while (*pstart && *pstart != '(') pstart++;
if (*pstart == '(') pstart++;
int comma_pos = 0;
char *p = pstart;
while (comma_pos < comma_cnt)
{
while (*p == ' ') p++;
while (*p && *p != ',' && *p != ')') p++;
if (*p == ')') break;
if (*p) p++;
comma_pos++;
}
if (*p && *p != ')')
{
*pstart=0;
lstrcpyn_safe(buf,p,sizeof(buf));
snprintf_append(sug,sizeof(sug), "... %s",buf);
}
}
break;
}
// only use token up to cursor for suggestions
if (cursor >= tok && cursor <= tok+toklen)
{
toklen = (int) (cursor-tok);
lstrcpyn_safe(buf,tok,wdl_min(toklen+1, sizeof(buf)));
}
if (c == '\b' && cursor == tok)
{
}
else if (do_sug != 2 && t == ntok-1 && toklen >= 3 && cursor <= tok + toklen)
{
m_suggestion_list.clear();
get_suggested_token_names(buf,~0,&m_suggestion_list);
win32CursesCtx *ctx = (win32CursesCtx *)m_cursesCtx;
if (m_suggestion_list.get_size()>0 &&
WDL_NORMALLY(ctx->m_hwnd) && WDL_NORMALLY(ctx->m_font_w) && WDL_NORMALLY(ctx->m_font_h))
{
m_suggestion_toklen = toklen;
m_suggestion_tokpos = (int)(tok-l->Get());
m_suggestion_hwnd_sel = -1;
if (!m_suggestion_hwnd)
{
#ifdef _WIN32
static HINSTANCE last_inst;
const char *classname = "eel_edit_predicto";
HINSTANCE inst = (HINSTANCE)GetWindowLongPtr(ctx->m_hwnd,GWLP_HINSTANCE);
if (inst != last_inst)
{
last_inst = inst;
WNDCLASS wc={CS_DBLCLKS,suggestionProc,};
wc.lpszClassName=classname;
wc.hInstance=inst;
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
RegisterClass(&wc);
}
m_suggestion_hwnd = CreateWindowEx(0,classname,"", WS_CHILD, 0,0,0,0, ctx->m_hwnd, NULL, inst, NULL);
#else
m_suggestion_hwnd = CreateDialogParam(NULL,NULL,ctx->m_hwnd, suggestionProc, 0);
#endif
if (m_suggestion_hwnd) SetWindowLongPtr(m_suggestion_hwnd,GWLP_USERDATA,(LPARAM)this);
}
if (m_suggestion_hwnd)
{
const int fontw = ctx->m_font_w, fonth = ctx->m_font_h;
int xpos = (WDL_utf8_bytepos_to_charpos(l->Get(),m_suggestion_tokpos) - m_offs_x) * fontw;
RECT par_cr;
GetClientRect(ctx->m_hwnd,&par_cr);
int use_w = (int)strlen(suggestion_help_text);
int use_h = (wdl_min(g_eel_editor_max_vis_suggestions,m_suggestion_list.get_size()) + 1)*fonth;
for (int x = 0; x < m_suggestion_list.get_size(); x ++)
{
const char *p = m_suggestion_list.get(x);
if (WDL_NORMALLY(p!=NULL))
{
const int l = (int) strlen(p);
if (l > use_w) use_w=l;
}
}
use_w = 8 + use_w * fontw;
if (use_w > par_cr.right - xpos)
{
xpos = wdl_max(par_cr.right - use_w,0);
use_w = par_cr.right - xpos;
}
const int cursor_line_y = ctx->m_cursor_y * fonth;
int ypos = cursor_line_y + fonth;
if (ypos + use_h > par_cr.bottom)
{
if (cursor_line_y-fonth > par_cr.bottom - ypos)
{
// more room at the top, but enough?
ypos = cursor_line_y - use_h;
if (ypos<fonth)
{
ypos = fonth;
use_h = cursor_line_y-fonth;
}
}
else
use_h = par_cr.bottom - ypos;
}
SetWindowPos(m_suggestion_hwnd,NULL,xpos,ypos,use_w,use_h, SWP_NOZORDER|SWP_NOACTIVATE);
InvalidateRect(m_suggestion_hwnd,NULL,FALSE);
ShowWindow(m_suggestion_hwnd,SW_SHOWNA);
}
did_fuzzy = true;
const char *p = m_suggestion_list.get(wdl_max(m_suggestion_hwnd_sel,0));
if (p && peek_get_token_info(p,sug,sizeof(sug),~0,m_curs_y)) break;
}
}
}
}
}
}
if (!did_fuzzy && m_suggestion_hwnd) DestroyWindow(m_suggestion_hwnd);
finish_sug:
if (strcmp(sug,m_suggestion.Get()) && m_ui_state == UI_STATE_NORMAL)
{
m_suggestion.Set(sug);
if (sug[0])
{
m_suggestion_x=m_curs_x;
m_suggestion_y=m_curs_y;
draw_top_line();
setCursor();
}
}
if (!sug[0] && m_suggestion_y>=0 && m_ui_state == UI_STATE_NORMAL)
{
m_suggestion_x=m_suggestion_y=-1;
m_suggestion.Set("");
if (m_top_margin>0) draw_top_line();
else draw();
setCursor();
}
return rv;
}
void EEL_Editor::draw_top_line()
{
if (m_curs_x >= m_suggestion_x && m_curs_y == m_suggestion_y && m_suggestion.GetLength() && m_ui_state == UI_STATE_NORMAL)
{
const char *p=m_suggestion.Get();
char str[512];
if (WDL_utf8_get_charlen(m_suggestion.Get()) > COLS)
{
int l = WDL_utf8_charpos_to_bytepos(m_suggestion.Get(),COLS-4);
if (l > sizeof(str)-6) l = sizeof(str)-6;
lstrcpyn(str, m_suggestion.Get(), l+1);
strcat(str, "...");
p=str;
}
attrset(COLOR_TOPLINE|A_BOLD);
bkgdset(COLOR_TOPLINE);
move(0, 0);
addstr(p);
clrtoeol();
attrset(0);
bkgdset(0);
}
else
{
m_suggestion_x=m_suggestion_y=-1;
if (m_suggestion.GetLength()) m_suggestion.Set("");
WDL_CursesEditor::draw_top_line();
}
}
void EEL_Editor::onRightClick(HWND hwnd)
{
WDL_LogicalSortStringKeyedArray<int> flist(m_case_sensitive);
int i;
if (!(GetAsyncKeyState(VK_CONTROL)&0x8000))
{
m_code_func_cache_lines = -1; // invalidate cache
ensure_code_func_cache_valid();
for (i = 0; i < m_code_func_cache.GetSize(); i ++)
{
const char *p = m_code_func_cache.Get(i);
const int line = *(int *)p;
p += sizeof(int);
const char *q = p+strlen(p)+1;
char buf[512];
snprintf(buf,sizeof(buf),"%s%s",p,q);
flist.AddUnsorted(buf,line);
p += 4;
}
}
if (flist.GetSize())
{
flist.Resort();
if (m_case_sensitive) flist.Resort(WDL_LogicalSortStringKeyedArray<int>::cmpistr);
HMENU hm=CreatePopupMenu();
int pos=0;
for (i=0; i < flist.GetSize(); ++i)
{
const char* fname=NULL;
int line=flist.Enumerate(i, &fname);
InsertMenu(hm, pos++, MF_STRING|MF_BYPOSITION, line+1, fname);
}
POINT p;
GetCursorPos(&p);
int ret=TrackPopupMenu(hm, TPM_NONOTIFY|TPM_RETURNCMD, p.x, p.y, 0, hwnd, NULL);
DestroyMenu(hm);
if (ret > 0)
{
GoToLine(ret-1,true);
}
}
else
{
doWatchInfo(0);
}
}
void EEL_Editor::ensure_code_func_cache_valid()
{
const char *prefix = m_function_prefix;
if (!prefix || !*prefix) return;
const DWORD now = GetTickCount();
if (m_text.GetSize()==m_code_func_cache_lines && (now-m_code_func_cache_time)<5000) return;
m_code_func_cache_lines = m_text.GetSize();
m_code_func_cache_time = now;
m_code_func_cache.Empty(true,free);
const int prefix_len = (int) strlen(m_function_prefix);
for (int i=0; i < m_text.GetSize(); ++i)
{
WDL_FastString* s=m_text.Get(i);
if (WDL_NORMALLY(s))
{
const char *p = s->Get();
while (*p)
{
if (m_case_sensitive ? !strncmp(p,prefix,prefix_len) : !strnicmp(p,prefix,prefix_len))
{
p+=prefix_len;
while (*p == ' ') p++;
if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || *p == '_')
{
const char *q = p+1;
while ((*q >= '0' && *q <= '9') ||
(*q >= 'a' && *q <= 'z') ||
(*q >= 'A' && *q <= 'Z') ||
*q == ':' || // lua
*q == '_' || *q == '.') q++;
const char *endp = q;
while (*q == ' ') q++;
if (*q == '(')
{
const char *endq = q;
while (*endq && *endq != ')') endq++;
if (*endq) endq++;
const char *r = endq;
while (*r == ' ') r++;
const int p_len = (int) (endp - p);
const int q_len = (int) (endq - q);
const int r_len = (int) strlen(r);
// add function
char *v = (char *)malloc(sizeof(int) + p_len + q_len + r_len + 3), *wr = v;
if (WDL_NORMALLY(v))
{
*(int *)wr = i; wr += sizeof(int);
lstrcpyn_safe(wr,p,p_len+1); wr += p_len+1;
lstrcpyn_safe(wr,q,q_len+1); wr += q_len+1;
lstrcpyn_safe(wr,r,r_len+1); wr += r_len+1;
m_code_func_cache.Add(v);
}
p = r; // continue parsing after parentheses
}
}
}
if (*p) p++;
}
}
}
}
#ifdef WDL_IS_FAKE_CURSES
LRESULT EEL_Editor::onMouseMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_LBUTTONDBLCLK:
if (m_suggestion_hwnd) DestroyWindow(m_suggestion_hwnd);
if (CURSES_INSTANCE && CURSES_INSTANCE->m_font_w && CURSES_INSTANCE->m_font_h)
{
const int y = ((short)HIWORD(lParam)) / CURSES_INSTANCE->m_font_h - m_top_margin;
//const int x = ((short)LOWORD(lParam)) / CURSES_INSTANCE->m_font_w + m_offs_x;
WDL_FastString *fs=m_text.Get(y + m_paneoffs_y[m_curpane]);
if (fs && y >= 0)
{
if (!strncmp(fs->Get(),"import",6) && isspace(fs->Get()[6]))
{
open_import_line();
return 1;
}
}
// ctrl+doubleclicking a function goes to it
if (CTRL_KEY_DOWN)
{
WDL_FastString *l=m_text.Get(m_curs_y);
if (l)
{
const char *p = l->Get(), *endp = p + l->GetLength(), *cursor = p + WDL_utf8_charpos_to_bytepos(p,m_curs_x);
int state = 0, toklen = 0;
const char *tok;
while ((tok=sh_tokenize(&p,endp,&toklen,&state)) && cursor > tok+toklen);
if (tok && cursor <= tok+toklen)
{
ensure_code_func_cache_valid();
while (toklen > 0)
{
for (int i = 0; i < m_code_func_cache.GetSize(); i ++)
{
const char *p = m_code_func_cache.Get(i);
int line = *(int *)p;
p+=sizeof(int);
if (line != m_curs_y && strlen(p) == toklen && (m_case_sensitive ? !strncmp(p,tok,toklen) : !strnicmp(p,tok,toklen)))
{
GoToLine(line,true);
return 0;
}
}
// try removing any foo. prefixes
while (toklen > 0 && *tok != '.') { tok++; toklen--; }
tok++;
toklen--;
}
}
}
}
}
break;
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
if (m_suggestion_hwnd) DestroyWindow(m_suggestion_hwnd);
break;
}
return WDL_CursesEditor::onMouseMessage(hwnd,uMsg,wParam,lParam);
}
#endif
| 62,133
| 24,338
|
/* Copyright 2017 The Apollo 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 "modules/map/hdmap/adapter/xml_parser/lanes_xml_parser.h"
#include "modules/map/hdmap/adapter/xml_parser/util_xml_parser.h"
namespace {
double ToMPS(double speed) { return speed * 1000.0 / 3600.0; }
bool IsReferenceLane(int lane_id) { return lane_id == 0; }
}; // namespace
namespace apollo {
namespace hdmap {
namespace adapter {
Status LanesXmlParser::Parse(const tinyxml2::XMLElement& xml_node,
const std::string& road_id,
std::vector<RoadSectionInternal>* sections) {
CHECK_NOTNULL(sections);
const auto lanes_node = xml_node.FirstChildElement("lanes");
CHECK_NOTNULL(lanes_node);
const tinyxml2::XMLElement* sub_node =
lanes_node->FirstChildElement("laneSection");
CHECK_NOTNULL(sub_node);
size_t section_cnt = 0;
while (sub_node) {
RoadSectionInternal section_internal;
std::string section_id = std::to_string(++section_cnt);
section_internal.id = section_id;
section_internal.section.mutable_id()->set_id(section_id);
RETURN_IF_ERROR(ParseLaneSection(*sub_node, §ion_internal.lanes));
RETURN_IF_ERROR(ParseSectionBoundary(
*sub_node,
section_internal.section.mutable_boundary()->mutable_outer_polygon()));
sections->push_back(section_internal);
sub_node = sub_node->NextSiblingElement("laneSection");
}
CHECK_GT(sections->size(), 0);
return Status::OK();
}
Status LanesXmlParser::ParseSectionBoundary(
const tinyxml2::XMLElement& xml_node, PbBoundaryPolygon* boundary) {
CHECK_NOTNULL(boundary);
auto boundaries_node = xml_node.FirstChildElement("boundaries");
if (boundaries_node == nullptr) {
std::string err_msg = "Error parse boundaries";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
auto sub_node = boundaries_node->FirstChildElement("boundary");
while (sub_node) {
PbBoundaryEdge* boundary_edge = boundary->add_edge();
RETURN_IF_ERROR(
UtilXmlParser::ParseCurve(*sub_node, boundary_edge->mutable_curve()));
std::string type;
int checker = UtilXmlParser::QueryStringAttribute(*sub_node, "type", &type);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse boundary type";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
PbBoundaryEdgeType boundary_type;
RETURN_IF_ERROR(ToPbBoundaryType(type, &boundary_type));
boundary_edge->set_type(boundary_type);
sub_node = sub_node->NextSiblingElement("boundary");
}
return Status::OK();
}
Status LanesXmlParser::ToPbBoundaryType(const std::string& type,
PbBoundaryEdgeType* boundary_type) {
CHECK_NOTNULL(boundary_type);
std::string upper_type = UtilXmlParser::ToUpper(type);
if (upper_type == "LEFTBOUNDARY") {
*boundary_type = hdmap::BoundaryEdge::LEFT_BOUNDARY;
} else if (upper_type == "RIGHTBOUNDARY") {
*boundary_type = hdmap::BoundaryEdge::RIGHT_BOUNDARY;
} else {
*boundary_type = hdmap::BoundaryEdge::NORMAL;
}
return Status::OK();
}
Status LanesXmlParser::ParseLaneSection(const tinyxml2::XMLElement& xml_node,
std::vector<LaneInternal>* lanes) {
CHECK_NOTNULL(lanes);
// left
const tinyxml2::XMLElement* sub_node = xml_node.FirstChildElement("left");
if (sub_node) {
sub_node = sub_node->FirstChildElement("lane");
while (sub_node) {
LaneInternal lane_internal;
RETURN_IF_ERROR(ParseLane(*sub_node, &lane_internal));
*(lane_internal.lane.mutable_left_boundary()) =
lane_internal.lane.right_boundary();
lane_internal.lane.clear_right_boundary();
if (lanes->size() > 0) {
PbLane& left_neighbor_lane = lanes->back().lane;
*(left_neighbor_lane.mutable_right_boundary()) =
lane_internal.lane.left_boundary();
}
lanes->push_back(lane_internal);
sub_node = sub_node->NextSiblingElement("lane");
}
}
// center
LaneInternal reference_lane_internal;
sub_node = xml_node.FirstChildElement("center");
CHECK_NOTNULL(sub_node);
sub_node = sub_node->FirstChildElement("lane");
CHECK_NOTNULL(sub_node);
RETURN_IF_ERROR(ParseLane(*sub_node, &reference_lane_internal));
*(reference_lane_internal.lane.mutable_left_boundary()) =
reference_lane_internal.lane.right_boundary();
if (lanes->size() > 0) {
PbLane& left_neighbor_lane = lanes->back().lane;
*(left_neighbor_lane.mutable_right_boundary()) =
reference_lane_internal.lane.left_boundary();
}
// right
sub_node = xml_node.FirstChildElement("right");
if (sub_node) {
sub_node = sub_node->FirstChildElement("lane");
PbLane* left_neighbor_lane = &reference_lane_internal.lane;
while (sub_node) {
// PbLane lane
LaneInternal lane_internal;
RETURN_IF_ERROR(ParseLane(*sub_node, &lane_internal));
*(lane_internal.lane.mutable_left_boundary()) =
left_neighbor_lane->right_boundary();
lanes->push_back(lane_internal);
left_neighbor_lane = &lanes->back().lane;
sub_node = sub_node->NextSiblingElement("lane");
}
}
return Status::OK();
}
Status LanesXmlParser::ParseLane(const tinyxml2::XMLElement& xml_node,
LaneInternal* lane_internal) {
CHECK_NOTNULL(lane_internal);
PbLane* lane = &lane_internal->lane;
// lane id
int id = 0;
int checker = xml_node.QueryIntAttribute("id", &id);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse lane id";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
std::string lane_id;
checker = UtilXmlParser::QueryStringAttribute(xml_node, "uid", &lane_id);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse lane uid";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
lane->mutable_id()->set_id(lane_id);
// lane type
std::string lane_type;
checker = UtilXmlParser::QueryStringAttribute(xml_node, "type", &lane_type);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse lane type.";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
PbLaneType pb_lane_type;
Status success = ToPbLaneType(lane_type, &pb_lane_type);
if (!success.ok()) {
std::string err_msg = "Error convert lane type to pb lane type.";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
lane->set_type(pb_lane_type);
// border
const tinyxml2::XMLElement* sub_node = xml_node.FirstChildElement("border");
if (sub_node) {
PbLaneBoundary* lane_boundary = lane->mutable_right_boundary();
CHECK(lane_boundary != nullptr);
success =
UtilXmlParser::ParseCurve(*sub_node, lane_boundary->mutable_curve());
if (!success.ok()) {
std::string err_msg = "Error parse lane border";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
lane_boundary->set_length(
UtilXmlParser::CurveLength(*lane_boundary->mutable_curve()));
bool is_virtual = false;
std::string virtual_border = "FALSE";
checker = UtilXmlParser::QueryStringAttribute(*sub_node, "virtual",
&virtual_border);
if (checker == tinyxml2::XML_SUCCESS) {
if (virtual_border == "TRUE") {
is_virtual = true;
}
}
lane_boundary->set_virtual_(is_virtual);
}
// road mark
if (sub_node) {
sub_node = sub_node->FirstChildElement("borderType");
}
while (sub_node) {
PbLaneBoundary* lane_boundary = lane->mutable_right_boundary();
PbLaneBoundaryTypeType boundary_type;
success = ParseLaneBorderMark(*sub_node, &boundary_type);
if (!success.ok()) {
std::string err_msg = "Error parse lane border type";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
double s_offset = 0.0;
checker = sub_node->QueryDoubleAttribute("sOffset", &s_offset);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse lane boundary type offset.";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
auto lane_boundary_type = lane_boundary->add_boundary_type();
lane_boundary_type->set_s(s_offset);
lane_boundary_type->add_types(boundary_type);
sub_node = sub_node->NextSiblingElement("borderType");
}
// reference line
if (IsReferenceLane(id)) {
return Status::OK();
}
// turn type
std::string turn_type;
checker =
UtilXmlParser::QueryStringAttribute(xml_node, "turnType", &turn_type);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse lane turn type.";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
PbTurnType pb_turn_type;
success = ToPbTurnType(turn_type, &pb_turn_type);
if (!success.ok()) {
std::string err_msg = "Error convert turn type to pb turn type.";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
lane->set_turn(pb_turn_type);
// direction
RETURN_IF_ERROR(ParseDirection(xml_node, lane));
// link
sub_node = xml_node.FirstChildElement("link");
if (sub_node) {
ParseLaneLink(*sub_node, lane);
}
// center curve
RETURN_IF_ERROR(ParseCenterCurve(xml_node, lane));
// speed
RETURN_IF_ERROR(ParseSpeed(xml_node, lane));
// sample association
RETURN_IF_ERROR(ParseSampleAssociates(xml_node, lane));
// road sample association
RETURN_IF_ERROR(ParseRoadSampleAssociates(xml_node, lane));
// overlap object
ParseObjectOverlapGroup(xml_node, &lane_internal->overlap_objects);
// overlap signal
ParseSignalOverlapGroup(xml_node, &lane_internal->overlap_signals);
// overlap junction
ParseJunctionOverlapGroup(xml_node, &lane_internal->overlap_junctions);
// overlap lane
ParseLaneOverlapGroup(xml_node, &lane_internal->overlap_lanes);
return Status::OK();
}
Status LanesXmlParser::ParseDirection(const tinyxml2::XMLElement& xml_node,
PbLane* lane) {
CHECK_NOTNULL(lane);
std::string direction;
int checker =
UtilXmlParser::QueryStringAttribute(xml_node, "direction", &direction);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse lane direction.";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
PbLaneDirection pb_lane_direction;
Status success = ToPbDirection(direction, &pb_lane_direction);
if (!success.ok()) {
std::string err_msg = "Error convert direction to pb direction";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
lane->set_direction(pb_lane_direction);
return Status::OK();
}
Status LanesXmlParser::ParseCenterCurve(const tinyxml2::XMLElement& xml_node,
PbLane* lane) {
CHECK_NOTNULL(lane);
auto sub_node = xml_node.FirstChildElement("centerLine");
if (!sub_node) {
std::string err_msg = "Error parse lane center curve";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
PbCurve* center_curve = lane->mutable_central_curve();
Status success = UtilXmlParser::ParseCurve(*sub_node, center_curve);
if (!success.ok()) {
std::string err_msg = "Error parse lane center curve";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
lane->set_length(UtilXmlParser::CurveLength(*center_curve));
return Status::OK();
}
Status LanesXmlParser::ParseSpeed(const tinyxml2::XMLElement& xml_node,
PbLane* lane) {
double max_speed = 0.0;
auto sub_node = xml_node.FirstChildElement("speed");
if (sub_node) {
int checker = sub_node->QueryDoubleAttribute("max", &max_speed);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse lane speed attribute";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
lane->set_speed_limit(ToMPS(max_speed));
}
return Status::OK();
}
Status LanesXmlParser::ParseSampleAssociates(
const tinyxml2::XMLElement& xml_node, PbLane* lane) {
CHECK_NOTNULL(lane);
auto sub_node = xml_node.FirstChildElement("sampleAssociates");
if (sub_node == nullptr) {
std::string err_msg = "Error parse sample associates";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
sub_node = sub_node->FirstChildElement("sampleAssociate");
if (sub_node == nullptr) {
std::string err_msg = "Error parse sample associate";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
while (sub_node) {
double left_width = 0.0;
double right_width = 0.0;
double s = 0.0;
int checker = sub_node->QueryDoubleAttribute("sOffset", &s);
checker += sub_node->QueryDoubleAttribute("leftWidth", &left_width);
checker += sub_node->QueryDoubleAttribute("rightWidth", &right_width);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse lane sample associate attribute";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
auto left_sample = lane->add_left_sample();
left_sample->set_s(s);
left_sample->set_width(left_width);
auto right_sample = lane->add_right_sample();
right_sample->set_s(s);
right_sample->set_width(right_width);
sub_node = sub_node->NextSiblingElement("sampleAssociate");
}
return Status::OK();
}
Status LanesXmlParser::ParseRoadSampleAssociates(
const tinyxml2::XMLElement& xml_node, PbLane* lane) {
CHECK_NOTNULL(lane);
auto sub_node = xml_node.FirstChildElement("roadSampleAssociations");
if (sub_node == nullptr) {
std::string err_msg = "Error parse road sample associations";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
sub_node = sub_node->FirstChildElement("sampleAssociation");
if (sub_node == nullptr) {
std::string err_msg = "Error parse road sample association";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
while (sub_node) {
double left_width = 0.0;
double right_width = 0.0;
double s = 0.0;
int checker = sub_node->QueryDoubleAttribute("sOffset", &s);
checker += sub_node->QueryDoubleAttribute("leftWidth", &left_width);
checker += sub_node->QueryDoubleAttribute("rightWidth", &right_width);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse road sample association attribute";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
auto left_road_sample = lane->add_left_road_sample();
left_road_sample->set_s(s);
left_road_sample->set_width(left_width);
auto right_road_sample = lane->add_right_road_sample();
right_road_sample->set_s(s);
right_road_sample->set_width(right_width);
sub_node = sub_node->NextSiblingElement("sampleAssociation");
}
return Status::OK();
}
Status LanesXmlParser::ParseObjectOverlapGroup(
const tinyxml2::XMLElement& xml_node,
std::vector<OverlapWithLane>* object_overlaps) {
CHECK_NOTNULL(object_overlaps);
auto object_overlap = xml_node.FirstChildElement("objectOverlapGroup");
if (object_overlap) {
auto sub_node = object_overlap->FirstChildElement("objectReference");
while (sub_node) {
std::string object_id;
double start_s = 0.0;
double end_s = 0.0;
int checker =
UtilXmlParser::QueryStringAttribute(*sub_node, "id", &object_id);
checker += sub_node->QueryDoubleAttribute("startOffset", &start_s);
checker += sub_node->QueryDoubleAttribute("endOffset", &end_s);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse lane object overlap";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
bool is_merge = false;
checker = sub_node->QueryBoolAttribute("isMerge", &is_merge);
if (checker != tinyxml2::XML_SUCCESS) {
is_merge = false;
}
OverlapWithLane overlap_with_lane;
overlap_with_lane.object_id = object_id;
overlap_with_lane.start_s = start_s;
overlap_with_lane.end_s = end_s;
overlap_with_lane.is_merge = is_merge;
RETURN_IF_ERROR(
ParseRegionOverlap(*sub_node, &overlap_with_lane.region_overlaps));
if (overlap_with_lane.region_overlaps.size() > 0) {
UtilXmlParser::QueryStringAttribute(
*sub_node, "regionOverlapId", &overlap_with_lane.region_overlap_id);
}
object_overlaps->push_back(overlap_with_lane);
sub_node = sub_node->NextSiblingElement("objectReference");
}
}
return Status::OK();
}
Status LanesXmlParser::ParseSignalOverlapGroup(
const tinyxml2::XMLElement& xml_node,
std::vector<OverlapWithLane>* signal_overlaps) {
CHECK_NOTNULL(signal_overlaps);
auto signal_overlap = xml_node.FirstChildElement("signalOverlapGroup");
if (signal_overlap) {
auto sub_node = signal_overlap->FirstChildElement("signalReference");
while (sub_node) {
std::string object_id;
double start_s = 0.0;
double end_s = 0.0;
int checker =
UtilXmlParser::QueryStringAttribute(*sub_node, "id", &object_id);
checker += sub_node->QueryDoubleAttribute("startOffset", &start_s);
checker += sub_node->QueryDoubleAttribute("endOffset", &end_s);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse lane signal overlap";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
bool is_merge = false;
checker = sub_node->QueryBoolAttribute("isMerge", &is_merge);
if (checker != tinyxml2::XML_SUCCESS) {
is_merge = false;
}
OverlapWithLane overlap_with_lane;
overlap_with_lane.object_id = object_id;
overlap_with_lane.start_s = start_s;
overlap_with_lane.end_s = end_s;
overlap_with_lane.is_merge = is_merge;
signal_overlaps->push_back(overlap_with_lane);
sub_node = sub_node->NextSiblingElement("signalReference");
}
}
return Status::OK();
}
Status LanesXmlParser::ParseJunctionOverlapGroup(
const tinyxml2::XMLElement& xml_node,
std::vector<OverlapWithLane>* junction_overlaps) {
CHECK_NOTNULL(junction_overlaps);
auto overlap_group = xml_node.FirstChildElement("junctionOverlapGroup");
if (overlap_group) {
auto sub_node = overlap_group->FirstChildElement("junctionReference");
while (sub_node) {
std::string object_id;
double start_s = 0.0;
double end_s = 0.0;
int checker =
UtilXmlParser::QueryStringAttribute(*sub_node, "id", &object_id);
checker += sub_node->QueryDoubleAttribute("startOffset", &start_s);
checker += sub_node->QueryDoubleAttribute("endOffset", &end_s);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse lane junction overlap";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
bool is_merge = false;
checker = sub_node->QueryBoolAttribute("isMerge", &is_merge);
if (checker != tinyxml2::XML_SUCCESS) {
is_merge = false;
}
OverlapWithLane overlap_with_lane;
overlap_with_lane.object_id = object_id;
overlap_with_lane.start_s = start_s;
overlap_with_lane.end_s = end_s;
overlap_with_lane.is_merge = is_merge;
junction_overlaps->push_back(overlap_with_lane);
sub_node = sub_node->NextSiblingElement("junctionReference");
}
}
return Status::OK();
}
Status LanesXmlParser::ParseLaneOverlapGroup(
const tinyxml2::XMLElement& xml_node,
std::vector<OverlapWithLane>* lane_overlaps) {
CHECK_NOTNULL(lane_overlaps);
auto overlap_node = xml_node.FirstChildElement("laneOverlapGroup");
if (overlap_node) {
auto sub_node = overlap_node->FirstChildElement("laneReference");
while (sub_node) {
std::string lane_id;
double start_s = 0.0;
double end_s = 0.0;
int checker =
UtilXmlParser::QueryStringAttribute(*sub_node, "id", &lane_id);
checker += sub_node->QueryDoubleAttribute("startOffset", &start_s);
checker += sub_node->QueryDoubleAttribute("endOffset", &end_s);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error parse lane lane overlap";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
bool is_merge = false;
checker = sub_node->QueryBoolAttribute("isMerge", &is_merge);
if (checker != tinyxml2::XML_SUCCESS) {
is_merge = false;
}
OverlapWithLane overlap_with_lane;
overlap_with_lane.object_id = lane_id;
overlap_with_lane.start_s = start_s;
overlap_with_lane.end_s = end_s;
overlap_with_lane.is_merge = is_merge;
lane_overlaps->push_back(overlap_with_lane);
sub_node = sub_node->NextSiblingElement("laneReference");
}
}
return Status::OK();
}
Status LanesXmlParser::ToPbLaneType(const std::string& type,
PbLaneType* lane_type) {
CHECK_NOTNULL(lane_type);
std::string upper_str = UtilXmlParser::ToUpper(type);
if (upper_str == "NONE") {
*lane_type = hdmap::Lane::NONE;
} else if (upper_str == "DRIVING") {
*lane_type = hdmap::Lane::CITY_DRIVING;
} else if (upper_str == "BIKING") {
*lane_type = hdmap::Lane::BIKING;
} else if (upper_str == "PARKING") {
*lane_type = hdmap::Lane::PARKING;
} else if (upper_str == "SHOULDER") {
*lane_type = hdmap::Lane::SHOULDER;
} else if (upper_str == "SIDEWALK") {
*lane_type = hdmap::Lane::SIDEWALK;
} else {
std::string err_msg = "Error or unsupport lane type:" + type;
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
return Status::OK();
}
Status LanesXmlParser::ToPbTurnType(const std::string& type,
PbTurnType* pb_turn_type) {
CHECK_NOTNULL(pb_turn_type);
std::string upper_str = UtilXmlParser::ToUpper(type);
if (upper_str == "NOTURN") {
*pb_turn_type = hdmap::Lane::NO_TURN;
} else if (upper_str == "LEFTTURN") {
*pb_turn_type = hdmap::Lane::LEFT_TURN;
} else if (upper_str == "RIGHTTURN") {
*pb_turn_type = hdmap::Lane::RIGHT_TURN;
} else if (upper_str == "UTURN") {
*pb_turn_type = hdmap::Lane::U_TURN;
} else {
std::string err_msg = "Error or unsupport turn type:" + type;
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
return Status::OK();
}
Status LanesXmlParser::ToPbDirection(const std::string& type,
PbLaneDirection* pb_direction) {
CHECK_NOTNULL(pb_direction);
std::string upper_str = UtilXmlParser::ToUpper(type);
if (upper_str == "FORWARD") {
*pb_direction = hdmap::Lane::FORWARD;
} else if (upper_str == "BACKWARD") {
*pb_direction = hdmap::Lane::BACKWARD;
} else if (upper_str == "BIDIRECTION") {
*pb_direction = hdmap::Lane::BIDIRECTION;
} else {
std::string err_msg = "Error or unsupport dirction:" + type;
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
return Status::OK();
}
void LanesXmlParser::ParseLaneLink(const tinyxml2::XMLElement& xml_node,
PbLane* lane) {
CHECK_NOTNULL(lane);
const tinyxml2::XMLElement* sub_node =
xml_node.FirstChildElement("predecessor");
while (sub_node) {
std::string lane_id;
int checker =
UtilXmlParser::QueryStringAttribute(*sub_node, "id", &lane_id);
if (checker == tinyxml2::XML_SUCCESS) {
PbID* pb_lane_id = lane->add_predecessor_id();
pb_lane_id->set_id(lane_id);
}
sub_node = sub_node->NextSiblingElement("predecessor");
}
sub_node = xml_node.FirstChildElement("successor");
while (sub_node) {
std::string lane_id;
int checker =
UtilXmlParser::QueryStringAttribute(*sub_node, "id", &lane_id);
if (checker == tinyxml2::XML_SUCCESS) {
PbID* pb_lane_id = lane->add_successor_id();
pb_lane_id->set_id(lane_id);
}
sub_node = sub_node->NextSiblingElement("successor");
}
sub_node = xml_node.FirstChildElement("neighbor");
while (sub_node) {
std::string side;
std::string direction;
std::string lane_id;
int checker =
UtilXmlParser::QueryStringAttribute(*sub_node, "id", &lane_id);
checker += UtilXmlParser::QueryStringAttribute(*sub_node, "side", &side);
checker +=
UtilXmlParser::QueryStringAttribute(*sub_node, "direction", &direction);
if (checker == tinyxml2::XML_SUCCESS) {
if (side == "left") {
if (direction == "same") {
lane->add_left_neighbor_forward_lane_id()->set_id(lane_id);
} else {
lane->add_left_neighbor_reverse_lane_id()->set_id(lane_id);
}
} else if (side == "right") {
if (direction == "same") {
lane->add_right_neighbor_forward_lane_id()->set_id(lane_id);
} else {
lane->add_right_neighbor_reverse_lane_id()->set_id(lane_id);
}
}
}
sub_node = sub_node->NextSiblingElement("neighbor");
}
sub_node = xml_node.FirstChildElement("selfReverse");
while (sub_node) {
std::string lane_id;
int checker =
UtilXmlParser::QueryStringAttribute(*sub_node, "id", &lane_id);
if (checker == tinyxml2::XML_SUCCESS) {
lane->add_self_reverse_lane_id()->set_id(lane_id);
}
sub_node = sub_node->NextSiblingElement("selfReverse");
}
}
Status LanesXmlParser::ParseLaneBorderMark(
const tinyxml2::XMLElement& xml_node,
PbLaneBoundaryTypeType* boundary_type) {
CHECK_NOTNULL(boundary_type);
std::string type;
std::string color;
int checker = UtilXmlParser::QueryStringAttribute(xml_node, "type", &type);
checker += UtilXmlParser::QueryStringAttribute(xml_node, "color", &color);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error to parse lane border mark";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
Status success = ToPbLaneMarkType(type, color, boundary_type);
if (!success.ok()) {
std::string err_msg = "fail to convert to pb lane border mark";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
return Status::OK();
}
Status LanesXmlParser::ToPbLaneMarkType(const std::string& type,
const std::string& color,
PbLaneBoundaryTypeType* boundary_type) {
CHECK_NOTNULL(boundary_type);
std::string upper_type = UtilXmlParser::ToUpper(type);
std::string upper_color = UtilXmlParser::ToUpper(color);
if (upper_type == "CURB") {
*boundary_type = hdmap::LaneBoundaryType::CURB;
return Status::OK();
}
if (upper_type == "NONE") {
*boundary_type = hdmap::LaneBoundaryType::UNKNOWN;
return Status::OK();
}
if (upper_color == "YELLOW") {
if (upper_type == "SOLID") {
*boundary_type = hdmap::LaneBoundaryType::SOLID_YELLOW;
} else if (upper_type == "BROKEN") {
*boundary_type = hdmap::LaneBoundaryType::DOTTED_YELLOW;
} else {
std::string err_msg = "Error or unsupport lane boundary type";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
} else if (upper_color == "WHITE") {
if (upper_type == "SOLID") {
*boundary_type = hdmap::LaneBoundaryType::SOLID_WHITE;
} else if (upper_type == "BROKEN") {
*boundary_type = hdmap::LaneBoundaryType::DOTTED_WHITE;
} else {
std::string err_msg = "Error or unsupport lane boundary type";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
} else {
std::string err_msg = "Error or unsupport lane boundary color.";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
return Status::OK();
}
Status LanesXmlParser::ParseRegionOverlap(
const tinyxml2::XMLElement& xml_node,
std::vector<PbRegionOverlap>* region_overlaps) {
CHECK_NOTNULL(region_overlaps);
auto region_overlap_node = xml_node.FirstChildElement("regionOverlap");
while (region_overlap_node != nullptr) {
PbRegionOverlap region_overlap;
std::string region_overlap_id;
int checker = UtilXmlParser::QueryStringAttribute(*region_overlap_node,
"id", ®ion_overlap_id);
if (checker != tinyxml2::XML_SUCCESS) {
std::string err_msg = "Error to parse region overlap id";
return Status(apollo::common::ErrorCode::HDMAP_DATA_ERROR, err_msg);
}
region_overlap.mutable_id()->set_id(region_overlap_id);
auto outline_node = region_overlap_node->FirstChildElement("outline");
while (outline_node != nullptr) {
RETURN_IF_ERROR(UtilXmlParser::ParseOutline(
*outline_node, region_overlap.add_polygon()));
outline_node = outline_node->NextSiblingElement("outline");
}
region_overlap_node =
region_overlap_node->NextSiblingElement("regionOverlap");
region_overlaps->emplace_back(region_overlap);
}
return Status::OK();
}
} // namespace adapter
} // namespace hdmap
} // namespace apollo
| 29,952
| 10,275
|
#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest.h"
#include <cstdio>
#include <backward.hpp>
namespace veg {
int argc = 0;
char** argv = nullptr;
} // namespace veg
auto main(int argc, char** argv) -> int {
veg::argc = argc;
veg::argv = argv;
char argname[] = "--veg-death-assertion-id";
if (argc >= 3 && //
(std::strcmp(argv[argc - 2], argname) == 0)) {
std::FILE* _{};
_ = std::freopen("/dev/null", "w", stderr);
_ = std::freopen("/dev/null", "w", stdout);
} else {
backward::SignalHandling const sh;
}
return doctest::Context(argc, argv).run();
}
| 577
| 249
|
////////////////////////////////////////////////////////////////////////////////
// Name: scope.cpp
// Purpose: Implementation of class wex::scope
// Author: Anton van Wezenbeek
// Copyright: (c) 2020-2021 Anton van Wezenbeek
////////////////////////////////////////////////////////////////////////////////
#include <algorithm>
#include <wex/log.h>
#include <wex/stc.h>
#include "scope.h"
wex::scope::scope(stc* s)
: m_stc(s)
{
}
void wex::scope::check_levels(check_t type)
{
bool changed = false;
const auto level(m_stc->get_fold_level());
const auto size(m_filters.size());
if (type[LEVEL_DOWN] && size >= 1 && level < size - 1)
{
m_filters.erase(m_filters.begin() + level + 1, m_filters.end());
changed = true;
log::debug("scope::check_levels erased level")
<< size - m_filters.size() << "current:" << level
<< "size:" << m_filters.size();
}
if (!changed && type[LEVEL_UP] && level >= size)
{
map_t m;
m[std::string()] = ctags_entry();
m_filters.insert(m_filters.end(), level - size + 1, m);
changed = true;
log::debug("scope::check_levels inserted level")
<< m_filters.size() - size << "current:" << level
<< "size:" << m_filters.size();
}
if (changed)
{
m_it = m_filters[level].end();
}
}
const std::string wex::scope::class_name(const std::string& name) const
{
const auto level(m_stc->get_fold_level());
if (m_filters.empty() || level > m_filters.size())
{
return std::string();
}
log::debug("scope::class_name") << name << level << m_filters[level].size();
if (const auto& it = iterator(name); !end())
{
return it->second.class_name();
}
else
{
return std::string();
}
}
bool wex::scope::end() const
{
const auto level(m_stc->get_fold_level());
return level >= m_filters.size() || m_it == m_filters[level].end();
}
bool wex::scope::find(const std::string& text)
{
m_it = iterator(text);
return !end();
}
wex::ctags_entry& wex::scope::get(const std::string& text)
{
if (m_filters.empty())
{
sync();
}
const auto level(m_stc->get_fold_level());
return m_filters[level][text];
}
void wex::scope::insert(const std::string& text, const ctags_entry& ce)
{
assert(!text.empty());
const auto level(m_stc->get_fold_level());
m_filters[level].insert({text, ce});
find(text);
log::debug("scope::insert") << text << level << ce;
}
wex::scope::map_t::const_iterator
wex::scope::iterator(const std::string& text) const
{
const auto level(m_stc->get_fold_level());
if (text.empty())
{
return m_filters[level].end();
}
for (int i = std::min(level, m_filters.size() - 1); i >= 0; i--)
{
if (const auto& it = m_filters[i].find(text); it != m_filters[i].end())
{
return it;
}
}
return m_filters[level].end();
}
void wex::scope::sync()
{
log::debug("scope::sync");
check_levels();
}
| 2,910
| 1,080
|
/* $Id: blast_test_util.hpp 354597 2012-02-28 16:45:09Z ucko $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
* National Center for Biotechnology Information
*
* This software/database is a "United States Government Work" under the
* terms of the United States Copyright Act. It was written as part of
* the author's official duties as a United States Government employee and
* thus cannot be copyrighted. This software/database is freely available
* to the public for use. The National Library of Medicine and the U.S.
* Government have not placed any restriction on its use or reproduction.
*
* Although all reasonable efforts have been taken to ensure the accuracy
* and reliability of the software and data, the NLM and the U.S.
* Government do not and cannot warrant the performance or results that
* may be obtained by using this software or data. The NLM and the U.S.
* Government disclaim all warranties, express or implied, including
* warranties of performance, merchantability or fitness for any particular
* purpose.
*
* Please cite the author in any work or product based on this material.
*
* ===========================================================================
*
* Author: Christiam Camacho
*
*/
/** @file blast_test_util.hpp
* Utilities to develop and debug unit tests for BLAST
*/
#ifndef _BLAST_TEST_UTIL_HPP
#define _BLAST_TEST_UTIL_HPP
#include <string>
#include <exception>
#include <assert.h>
#include <corelib/ncbistd.hpp>
#include <serial/serial.hpp>
#include <serial/objostr.hpp>
#include <util/random_gen.hpp>
#include <util/format_guess.hpp>
#include <serial/serial.hpp>
#include <objtools/data_loaders/blastdb/bdbloader.hpp>
#ifndef ASSERT
#define ASSERT assert
#endif
// forward declarations
namespace ncbi {
namespace objects {
class CSeq_id;
class CSeq_align_set;
class CSeqVector;
class CScope;
class CObjectManager;
}
namespace blast {
struct SSeqLoc;
}
}
namespace TestUtil {
// Random integer generator for use with std::generate
#if defined(__ICC) || defined(NCBI_OS_IRIX) || defined(__clang__)
template <int lowest_value = 0, int highest_value = INT_MAX>
#else
template <int lowest_value = 0, int highest_value = ncbi::CRandom::GetMax()>
#endif
struct CRandomIntGen {
CRandomIntGen() : m_Gen(::time(0)) {}
int operator()() {
return m_Gen.GetRand(lowest_value, highest_value);
}
private:
ncbi::CRandom m_Gen;
};
ncbi::objects::CSeq_id* GenerateRandomSeqid_Gi();
template <class T>
ncbi::CRef<T> ReadObject(const std::string& filename) {
ncbi::CNcbiIfstream in(filename.c_str());
if ( !in ) {
throw std::runtime_error("Failed to open " + filename);
}
ncbi::CRef<T> retval(new T);
switch (ncbi::CFormatGuess().Format(in)) {
case ncbi::CFormatGuess::eTextASN:
in >> ncbi::MSerial_AsnText >> *retval;
break;
case ncbi::CFormatGuess::eBinaryASN:
in >> ncbi::MSerial_AsnBinary >> *retval;
break;
case ncbi::CFormatGuess::eXml:
in >> ncbi::MSerial_Xml >> *retval;
break;
default:
throw std::runtime_error("Unsupported format");
}
return retval;
}
/// Convenience template function to print ASN.1 objects to a new file
template <class T>
void PrintTextAsn1Object(std::string filename, T* obj) {
std::ofstream out(filename.c_str());
if ( !out )
throw std::runtime_error("Could not open " + filename);
out << ncbi::MSerial_AsnText << *obj;
}
/** Converts bl2seq and blast style seq-align-sets to the seq-align-set format
* that the new formatter understands (same flat format as C toolkit
* seq-aligns) */
ncbi::CRef<ncbi::objects::CSeq_align_set>
FlattenSeqAlignSet(const ncbi::objects::CSeq_align_set& sset);
/// Assumes that the sas argument is a bl2seq and blast style seq-align-set
void PrintFormattedSeqAlign(std::ostream& out,
const ncbi::objects::CSeq_align_set* sas,
ncbi::objects::CScope& scope);
/// Endianness independent hash function.
///
/// This function computes a hash value for an array of any primitive
/// type. The hash assumes the data is the array is in "host" order
/// with respect to endianness and should produce the same value on
/// any platform for the same numerical values of the array
/// elements.<P>
///
/// The algorithm attempts to be robust against changes in values in
/// the array, the length of the array, zeroes appended to the array),
/// and will not normally be fooled by naturally occurring patterns in
/// the buffer. 9However, it is not intended to be secure against
/// deliberate attempts to produce a collision).<P>
///
/// The size of an element of the array must be uniform and is
/// specified as an argument to the function. It must exactly divide
/// the byte length of the array. If the size element is specified as
/// 1, no swapping will be done. This can be used to hash a string.
///
/// @param buffer
/// Points to the beginning of the array.
/// @param byte_length
/// The length of the array in bytes.
/// @param swap_size
/// The size of one array element (specify 1 to disable swapping).
/// @param hash_seed.
/// The starting value of the hash.
Uint4 EndianIndependentBufferHash(const char * buffer,
Uint4 byte_length,
Uint4 swap_size = 1,
Uint4 hash_seed = 1);
/** Class which registers the BLAST database and Genbank data loaders as a
* non-default data loaders with the object manager upon construction.
* Designed so that the scopes created by this object are configured properly
* to obtain the sequences in the expected priorities in the BLAST code.
*/
class CBlastOM
{
public:
enum ELocation {
eRemote,
eLocal
};
typedef ncbi::CBlastDbDataLoader::EDbType EDbType;
CBlastOM(const std::string& dbname, EDbType db_type, ELocation location = eLocal);
/// Create a new scope with the default set to the BLAST database data
/// loader for the BLAST database specified in the constructor (if found),
/// then set to the Genbank data loader
ncbi::CRef<ncbi::objects::CScope> NewScope();
/// Removes the BLAST database data loader from the object manager.
void RevokeBlastDbDataLoader();
private:
ncbi::CRef<ncbi::objects::CObjectManager> m_ObjMgr;
std::string m_BlastDbLoaderName;
std::string m_GbLoaderName;
void x_InitBlastDatabaseDataLoader(const std::string& dbname,
EDbType dbtype,
ELocation location);
void x_InitGenbankDataLoader();
};
}
#endif // _BLAST_TEST_UTIL_HPP
| 6,931
| 2,082
|
//****************************************************************************
//**
//** kybrd.cpp
//** -Keyboard driver
//**
//****************************************************************************
//============================================================================
// IMPLEMENTATION HEADERS
//============================================================================
#include <string.h>
#include <ctype.h>
#include <hal.h>
#include "kybrd.h"
//============================================================================
// IMPLEMENTATION PRIVATE DEFINITIONS / ENUMERATIONS / SIMPLE TYPEDEFS
//============================================================================
// keyboard encoder ------------------------------------------
enum KYBRD_ENCODER_IO {
KYBRD_ENC_INPUT_BUF = 0x60,
KYBRD_ENC_CMD_REG = 0x60
};
enum KYBRD_ENC_CMDS {
KYBRD_ENC_CMD_SET_LED = 0xED,
KYBRD_ENC_CMD_ECHO = 0xEE,
KYBRD_ENC_CMD_SCAN_CODE_SET = 0xF0,
KYBRD_ENC_CMD_ID = 0xF2,
KYBRD_ENC_CMD_AUTODELAY = 0xF3,
KYBRD_ENC_CMD_ENABLE = 0xF4,
KYBRD_ENC_CMD_RESETWAIT = 0xF5,
KYBRD_ENC_CMD_RESETSCAN = 0xF6,
KYBRD_ENC_CMD_ALL_AUTO = 0xF7,
KYBRD_ENC_CMD_ALL_MAKEBREAK = 0xF8,
KYBRD_ENC_CMD_ALL_MAKEONLY = 0xF9,
KYBRD_ENC_CMD_ALL_MAKEBREAK_AUTO = 0xFA,
KYBRD_ENC_CMD_SINGLE_AUTOREPEAT = 0xFB,
KYBRD_ENC_CMD_SINGLE_MAKEBREAK = 0xFC,
KYBRD_ENC_CMD_SINGLE_BREAKONLY = 0xFD,
KYBRD_ENC_CMD_RESEND = 0xFE,
KYBRD_ENC_CMD_RESET = 0xFF
};
// keyboard controller ---------------------------------------
enum KYBRD_CTRL_IO {
KYBRD_CTRL_STATS_REG= 0x64,
KYBRD_CTRL_CMD_REG = 0x64
};
enum KYBRD_CTRL_STATS_MASK {
KYBRD_CTRL_STATS_MASK_OUT_BUF = 1, //00000001
KYBRD_CTRL_STATS_MASK_IN_BUF = 2, //00000010
KYBRD_CTRL_STATS_MASK_SYSTEM = 4, //00000100
KYBRD_CTRL_STATS_MASK_CMD_DATA = 8, //00001000
KYBRD_CTRL_STATS_MASK_LOCKED = 0x10, //00010000
KYBRD_CTRL_STATS_MASK_AUX_BUF = 0x20, //00100000
KYBRD_CTRL_STATS_MASK_TIMEOUT = 0x40, //01000000
KYBRD_CTRL_STATS_MASK_PARITY = 0x80 //10000000
};
enum KYBRD_CTRL_CMDS {
KYBRD_CTRL_CMD_READ = 0x20,
KYBRD_CTRL_CMD_WRITE = 0x60,
KYBRD_CTRL_CMD_SELF_TEST = 0xAA,
KYBRD_CTRL_CMD_INTERFACE_TEST = 0xAB,
KYBRD_CTRL_CMD_DISABLE = 0xAD,
KYBRD_CTRL_CMD_ENABLE = 0xAE,
KYBRD_CTRL_CMD_READ_IN_PORT = 0xC0,
KYBRD_CTRL_CMD_READ_OUT_PORT = 0xD0,
KYBRD_CTRL_CMD_WRITE_OUT_PORT = 0xD1,
KYBRD_CTRL_CMD_READ_TEST_INPUTS = 0xE0,
KYBRD_CTRL_CMD_SYSTEM_RESET = 0xFE,
KYBRD_CTRL_CMD_MOUSE_DISABLE = 0xA7,
KYBRD_CTRL_CMD_MOUSE_ENABLE = 0xA8,
KYBRD_CTRL_CMD_MOUSE_PORT_TEST = 0xA9,
KYBRD_CTRL_CMD_MOUSE_WRITE = 0xD4
};
// scan error codes ------------------------------------------
enum KYBRD_ERROR {
KYBRD_ERR_BUF_OVERRUN = 0,
KYBRD_ERR_ID_RET = 0x83AB,
KYBRD_ERR_BAT = 0xAA, //note: can also be L. shift key make code
KYBRD_ERR_ECHO_RET = 0xEE,
KYBRD_ERR_ACK = 0xFA,
KYBRD_ERR_BAT_FAILED = 0xFC,
KYBRD_ERR_DIAG_FAILED = 0xFD,
KYBRD_ERR_RESEND_CMD = 0xFE,
KYBRD_ERR_KEY = 0xFF
};
//============================================================================
// IMPLEMENTATION PRIVATE CLASS PROTOTYPES / EXTERNAL CLASS REFERENCES
//============================================================================
//============================================================================
// IMPLEMENTATION PRIVATE STRUCTURES / UTILITY CLASSES
//============================================================================
//============================================================================
// IMPLEMENTATION REQUIRED EXTERNAL REFERENCES (AVOID)
//============================================================================
//============================================================================
// IMPLEMENTATION PRIVATE DATA
//============================================================================
//! current scan code
static char _scancode;
//! lock keys
static bool _numlock, _scrolllock, _capslock;
//! shift, alt, and ctrl keys current state
static bool _shift, _alt, _ctrl;
//! set if keyboard error
static int _kkybrd_error = 0;
//! set if the Basic Assurance Test (BAT) failed
static bool _kkybrd_bat_res = false;
//! set if diagnostics failed
static bool _kkybrd_diag_res = false;
//! set if system should resend last command
static bool _kkybrd_resend_res = false;
//! set if keyboard is disabled
static bool _kkybrd_disable = false;
//! original xt scan code set. Array index==make code
//! change what keys the scan code corrospond to if your scan code set is different
static int _kkybrd_scancode_std [] = {
//! key scancode
KEY_UNKNOWN, //0
KEY_ESCAPE, //1
KEY_1, //2
KEY_2, //3
KEY_3, //4
KEY_4, //5
KEY_5, //6
KEY_6, //7
KEY_7, //8
KEY_8, //9
KEY_9, //0xa
KEY_0, //0xb
KEY_MINUS, //0xc
KEY_EQUAL, //0xd
KEY_BACKSPACE, //0xe
KEY_TAB, //0xf
KEY_Q, //0x10
KEY_W, //0x11
KEY_E, //0x12
KEY_R, //0x13
KEY_T, //0x14
KEY_Y, //0x15
KEY_U, //0x16
KEY_I, //0x17
KEY_O, //0x18
KEY_P, //0x19
KEY_LEFTBRACKET,//0x1a
KEY_RIGHTBRACKET,//0x1b
KEY_RETURN, //0x1c
KEY_LCTRL, //0x1d
KEY_A, //0x1e
KEY_S, //0x1f
KEY_D, //0x20
KEY_F, //0x21
KEY_G, //0x22
KEY_H, //0x23
KEY_J, //0x24
KEY_K, //0x25
KEY_L, //0x26
KEY_SEMICOLON, //0x27
KEY_QUOTE, //0x28
KEY_GRAVE, //0x29
KEY_LSHIFT, //0x2a
KEY_BACKSLASH, //0x2b
KEY_Z, //0x2c
KEY_X, //0x2d
KEY_C, //0x2e
KEY_V, //0x2f
KEY_B, //0x30
KEY_N, //0x31
KEY_M, //0x32
KEY_COMMA, //0x33
KEY_DOT, //0x34
KEY_SLASH, //0x35
KEY_RSHIFT, //0x36
KEY_KP_ASTERISK,//0x37
KEY_RALT, //0x38
KEY_SPACE, //0x39
KEY_CAPSLOCK, //0x3a
KEY_F1, //0x3b
KEY_F2, //0x3c
KEY_F3, //0x3d
KEY_F4, //0x3e
KEY_F5, //0x3f
KEY_F6, //0x40
KEY_F7, //0x41
KEY_F8, //0x42
KEY_F9, //0x43
KEY_F10, //0x44
KEY_KP_NUMLOCK, //0x45
KEY_SCROLLLOCK, //0x46
KEY_HOME, //0x47
KEY_KP_8, //0x48 //keypad up arrow
KEY_PAGEUP, //0x49
KEY_KP_2, //0x50 //keypad down arrow
KEY_KP_3, //0x51 //keypad page down
KEY_KP_0, //0x52 //keypad insert key
KEY_KP_DECIMAL, //0x53 //keypad delete key
KEY_UNKNOWN, //0x54
KEY_UNKNOWN, //0x55
KEY_UNKNOWN, //0x56
KEY_F11, //0x57
KEY_F12 //0x58
};
//! invalid scan code. Used to indicate the last scan code is not to be reused
const int INVALID_SCANCODE = 0;
//============================================================================
// INTERFACE DATA
//============================================================================
//============================================================================
// IMPLEMENTATION PRIVATE FUNCTION PROTOTYPES
//============================================================================
uint8_t kybrd_ctrl_read_status ();
void kybrd_ctrl_send_cmd (uint8_t);
uint8_t kybrd_enc_read_buf ();
void kybrd_enc_send_cmd (uint8_t);
void _cdecl i86_kybrd_irq ();
//============================================================================
// IMPLEMENTATION PRIVATE FUNCTIONS
//============================================================================
//! read status from keyboard controller
uint8_t kybrd_ctrl_read_status () {
return inportb (KYBRD_CTRL_STATS_REG);
}
//! send command byte to keyboard controller
void kybrd_ctrl_send_cmd (uint8_t cmd) {
//! wait for kkybrd controller input buffer to be clear
while (1)
if ( (kybrd_ctrl_read_status () & KYBRD_CTRL_STATS_MASK_IN_BUF) == 0)
break;
outportb (KYBRD_CTRL_CMD_REG, cmd);
}
//! read keyboard encoder buffer
uint8_t kybrd_enc_read_buf () {
return inportb (KYBRD_ENC_INPUT_BUF);
}
//! send command byte to keyboard encoder
void kybrd_enc_send_cmd (uint8_t cmd) {
//! wait for kkybrd controller input buffer to be clear
while (1)
if ( (kybrd_ctrl_read_status () & KYBRD_CTRL_STATS_MASK_IN_BUF) == 0)
break;
//! send command byte to kybrd encoder
outportb (KYBRD_ENC_CMD_REG, cmd);
}
//! keyboard interrupt handler
void _cdecl i86_kybrd_irq () {
_asm add esp, 12
_asm pushad
_asm cli
static bool _extended = false;
int code = 0;
//! read scan code only if the kkybrd controller output buffer is full (scan code is in it)
if (kybrd_ctrl_read_status () & KYBRD_CTRL_STATS_MASK_OUT_BUF) {
//! read the scan code
code = kybrd_enc_read_buf ();
//! is this an extended code? If so, set it and return
if (code == 0xE0 || code == 0xE1)
_extended = true;
else {
//! either the second byte of an extended scan code or a single byte scan code
_extended = false;
//! test if this is a break code (Original XT Scan Code Set specific)
if (code & 0x80) { //test bit 7
//! covert the break code into its make code equivelant
code -= 0x80;
//! grab the key
int key = _kkybrd_scancode_std [code];
//! test if a special key has been released & set it
switch (key) {
case KEY_LCTRL:
case KEY_RCTRL:
_ctrl = false;
break;
case KEY_LSHIFT:
case KEY_RSHIFT:
_shift = false;
break;
case KEY_LALT:
case KEY_RALT:
_alt = false;
break;
}
}
else {
//! this is a make code - set the scan code
_scancode = code;
//! grab the key
int key = _kkybrd_scancode_std [code];
//! test if user is holding down any special keys & set it
switch (key) {
case KEY_LCTRL:
case KEY_RCTRL:
_ctrl = true;
break;
case KEY_LSHIFT:
case KEY_RSHIFT:
_shift = true;
break;
case KEY_LALT:
case KEY_RALT:
_alt = true;
break;
case KEY_CAPSLOCK:
_capslock = (_capslock) ? false : true;
kkybrd_set_leds (_numlock, _capslock, _scrolllock);
break;
case KEY_KP_NUMLOCK:
_numlock = (_numlock) ? false : true;
kkybrd_set_leds (_numlock, _capslock, _scrolllock);
break;
case KEY_SCROLLLOCK:
_scrolllock = (_scrolllock) ? false : true;
kkybrd_set_leds (_numlock, _capslock, _scrolllock);
break;
}
}
}
//! watch for errors
switch (code) {
case KYBRD_ERR_BAT_FAILED:
_kkybrd_bat_res = false;
break;
case KYBRD_ERR_DIAG_FAILED:
_kkybrd_diag_res = false;
break;
case KYBRD_ERR_RESEND_CMD:
_kkybrd_resend_res = true;
break;
}
}
//! tell hal we are done
interruptdone(0);
//! return from interrupt handler
_asm sti
_asm popad
_asm iretd
}
//============================================================================
// INTERFACE FUNCTIONS
//============================================================================
//! returns scroll lock state
bool kkybrd_get_scroll_lock () {
return _scrolllock;
}
//! returns num lock state
bool kkybrd_get_numlock () {
return _numlock;
}
//! returns caps lock state
bool kkybrd_get_capslock () {
return _capslock;
}
//! returns status of control key
bool kkybrd_get_ctrl () {
return _ctrl;
}
//! returns status of alt key
bool kkybrd_get_alt () {
return _alt;
}
//! returns status of shift key
bool kkybrd_get_shift () {
return _shift;
}
//! tells driver to ignore last resend request
void kkybrd_ignore_resend () {
_kkybrd_resend_res = false;
}
//! return if system should redo last commands
bool kkybrd_check_resend () {
return _kkybrd_resend_res;
}
//! return diagnostics test result
bool kkybrd_get_diagnostic_res () {
return _kkybrd_diag_res;
}
//! return BAT test result
bool kkybrd_get_bat_res () {
return _kkybrd_bat_res;
}
//! return last scan code
uint8_t kkybrd_get_last_scan () {
return _scancode;
}
//! sets leds
void kkybrd_set_leds (bool num, bool caps, bool scroll) {
uint8_t data = 0;
//! set or clear the bit
data = (scroll) ? (data | 1) : (data & 1);
data = (num) ? (num | 2) : (num & 2);
data = (caps) ? (num | 4) : (num & 4);
//! send the command -- update keyboard Light Emetting Diods (LEDs)
kybrd_enc_send_cmd (KYBRD_ENC_CMD_SET_LED);
kybrd_enc_send_cmd (data);
}
//! get last key stroke
KEYCODE kkybrd_get_last_key () {
return (_scancode!=INVALID_SCANCODE) ? ((KEYCODE)_kkybrd_scancode_std [_scancode]) : (KEY_UNKNOWN);
}
//! discards last scan
void kkybrd_discard_last_key () {
_scancode = INVALID_SCANCODE;
}
//! convert key to an ascii character
char kkybrd_key_to_ascii (KEYCODE code) {
uint8_t key = code;
//! insure key is an ascii character
if (isascii (key)) {
//! if shift key is down or caps lock is on, make the key uppercase
if (_shift || _capslock)
if (key >= 'a' && key <= 'z')
key -= 32;
if (_shift && !_capslock)
if (key >= '0' && key <= '9')
switch (key) {
case '0':
key = KEY_RIGHTPARENTHESIS;
break;
case '1':
key = KEY_EXCLAMATION;
break;
case '2':
key = KEY_AT;
break;
case '3':
key = KEY_EXCLAMATION;
break;
case '4':
key = KEY_HASH;
break;
case '5':
key = KEY_PERCENT;
break;
case '6':
key = KEY_CARRET;
break;
case '7':
key = KEY_AMPERSAND;
break;
case '8':
key = KEY_ASTERISK;
break;
case '9':
key = KEY_LEFTPARENTHESIS;
break;
}
else {
switch (key) {
case KEY_COMMA:
key = KEY_LESS;
break;
case KEY_DOT:
key = KEY_GREATER;
break;
case KEY_SLASH:
key = KEY_QUESTION;
break;
case KEY_SEMICOLON:
key = KEY_COLON;
break;
case KEY_QUOTE:
key = KEY_QUOTEDOUBLE;
break;
case KEY_LEFTBRACKET :
key = KEY_LEFTCURL;
break;
case KEY_RIGHTBRACKET :
key = KEY_RIGHTCURL;
break;
case KEY_GRAVE:
key = KEY_TILDE;
break;
case KEY_MINUS:
key = KEY_UNDERSCORE;
break;
case KEY_PLUS:
key = KEY_EQUAL;
break;
case KEY_BACKSLASH:
key = KEY_BAR;
break;
}
}
//! return the key
return key;
}
//! scan code != a valid ascii char so no convertion is possible
return 0;
}
//! disables the keyboard
void kkybrd_disable () {
kybrd_ctrl_send_cmd (KYBRD_CTRL_CMD_DISABLE);
_kkybrd_disable = true;
}
//! enables the keyboard
void kkybrd_enable () {
kybrd_ctrl_send_cmd (KYBRD_CTRL_CMD_ENABLE);
_kkybrd_disable = false;
}
//! returns true if keyboard is disabled
bool kkybrd_is_disabled () {
return _kkybrd_disable;
}
//! reset the system
void kkybrd_reset_system () {
//! writes 11111110 to the output port (sets reset system line low)
kybrd_ctrl_send_cmd (KYBRD_CTRL_CMD_WRITE_OUT_PORT);
kybrd_enc_send_cmd (0xfe);
}
//! run self test
bool kkybrd_self_test () {
//! send command
kybrd_ctrl_send_cmd (KYBRD_CTRL_CMD_SELF_TEST);
//! wait for output buffer to be full
while (1)
if (kybrd_ctrl_read_status () & KYBRD_CTRL_STATS_MASK_OUT_BUF)
break;
//! if output buffer == 0x55, test passed
return (kybrd_enc_read_buf () == 0x55) ? true : false;
}
//! prepares driver for use
void kkybrd_install (int irq) {
//! Install our interrupt handler (irq 1 uses interrupt 33)
setvect (irq, i86_kybrd_irq);
//! assume BAT test is good. If there is a problem, the IRQ handler where catch the error
_kkybrd_bat_res = true;
_scancode = 0;
//! set lock keys and led lights
_numlock = _scrolllock = _capslock = false;
kkybrd_set_leds (false, false, false);
//! shift, ctrl, and alt keys
_shift = _alt = _ctrl = false;
}
//============================================================================
// INTERFACE CLASS BODIES
//============================================================================
//****************************************************************************
//**
//** END[kybrd.cpp]
//**
//****************************************************************************
| 16,440
| 7,974
|
#include <string>
#include <stdio.h>
#include <list>
#include <set>
#include <algorithm>
#include "GumboInterface.h"
#include "string_buffer.h"
#include "error.h"
#include "StringUtil.h"
#include "UrlUtil.h"
//#include "pcrecpp.h"
namespace future {
static std::set<std::string> init_set(const char** arr, int lenth) {
std::set<std::string> ret;
for (int i = 0; i < lenth; i++) {
ret.insert(std::string(arr[i]));
}
return ret;
}
static const char*arr_nonbreaking[42] = { "a", "abbr", "acronym", "b", "bdo",
"big", "br", "button", "cite", "code", "del", "dfn", "em", "font", "i",
"image", "img", "input", "ins", "kbd", "label", "map", "nobr",
"object", "q", "ruby", "rt", "s", "samp", "select", "small", "span",
"strike", "strong", "sub", "sup", "textarea", "tt", "u", "var", "wbr",
"mbp:nu" };
static std::set<std::string> nonbreaking_inline = init_set(arr_nonbreaking, 42);
static const char*arr_preserve_whitespace[4] = { "pre", "textarea", "script",
"style" };
static std::set<std::string> preserve_whitespace = init_set(
arr_preserve_whitespace, 4);
static const char*arr_special_handling[2] = { "html", "body" };
static std::set<std::string> special_handling = init_set(arr_special_handling,
2);
static const char*arr_no_entity_sub[2] = { "script", "style" };
static std::set<std::string> no_entity_sub = init_set(arr_no_entity_sub, 2);
static const char*arr_void_tags[29] = { "area", "base", "basefont", "bgsound",
"br", "col", "command", "embed", "event-source", "frame", "hr", "img",
"input", "keygen", "link", "meta", "param", "source", "spacer",
"track", "wbr", "mbp:pagebreak", "mglyph", "mspace", "mprescripts",
"none", "maligngroup", "malignmark", "msline" };
static std::set<std::string> void_tags = init_set(arr_void_tags, 29);
static const char*arr_structural_tags[24] = { "article", "aside", "blockquote",
"body", "canvas", "colgroup", "div", "dl", "figure", "footer", "head",
"header", "hr", "html", "ol", "section", "table", "tbody", "tfoot",
"thead", "td", "th", "tr", "ul" };
static std::set<std::string> structural_tags =
init_set(arr_structural_tags, 24);
static const char*arr_other_text_holders[18] = { "address", "caption", "dd",
"div", "dt", "h1", "h2", "h3", "h4", "h5", "h6", "legend", "li",
"option", "p", "td", "th", "title" };
static std::set<std::string> other_text_holders = init_set(
arr_other_text_holders, 18);
static const char*arr_manifest_properties[5] = { "math", "nav", "script",
"svg", "epub:switch" };
static std::set<std::string> manifest_properties = init_set(
arr_manifest_properties, 5);
static const char*arr_href_src_tags[17] = { "a", "area", "audio", "base",
"embed", "font-face-uri", "frame", "iframe", "image", "img", "input",
"link", "object", "script", "source", "track", "video" };
static std::set<std::string> href_src_tags = init_set(arr_href_src_tags, 17);
static const char POUND_SIGN = '#';
static const char FORWARD_SLASH = '/';
static const std::string aSRC = std::string("src");
static const std::string aHREF = std::string("href");
static const std::string aPOSTER = std::string("poster");
static const std::string aDATA = std::string("data");
std::map<std::string, std::string> EmptyHash = std::map<std::string,
std::string>();
// These need to match the GumboAttributeNamespaceEnum sequence
static const char *attribute_nsprefixes[4] = { "", "xlink:", "xml:", "xmlns:" };
// Note: m_output contains the gumbo output tree which
// has data structures with pointers into the original source
// buffer passed in!!!!!!
// This source buffer is provided by the m_utf8src std::string
// which should always exist unchanged alongside the output tree
// Do NOT change or delete m_utf8src once set until after you
// have properly destroyed the gumbo output tree
GumboInterface::GumboInterface(const std::string &source,
const std::string &version) :
m_source(source), m_output(NULL), m_utf8src(""),
m_sourceupdates(EmptyHash), m_newcsslinks(""), m_currentdir(""),
m_newbody(""), m_hasnbsp(false), m_version(version) {
}
GumboInterface::GumboInterface(const std::string &source,
const std::string &version,
const std::map<std::string, std::string> & source_updates) :
m_source(source), m_output(NULL), m_utf8src(""),
m_sourceupdates(source_updates), m_newcsslinks(""),
m_currentdir(""), m_newbody(""), m_hasnbsp(false),
m_version(version) {
}
GumboInterface::~GumboInterface() {
if (m_output != NULL) {
gumbo_destroy_output(m_output);
m_output = NULL;
m_utf8src = "";
}
}
void GumboInterface::parse() {
if (!m_source.empty() && (m_output == NULL)) {
std::string three("3");
if (!StringUtil::startWith(m_version, three)) {
m_hasnbsp = StringUtil::contains(m_source, std::string(" "));
}
m_utf8src = m_source;
// remove any xml header line and any trailing whitespace
if (m_utf8src.compare(0, 5, "<?xml") == 0) {
size_t end = m_utf8src.find_first_of('>', 5);
end = m_utf8src.find_first_not_of("\n\r\t\v\f ", end + 1);
m_utf8src.erase(0, end);
}
// In case we ever have to revert to earlier versions, please note the following
// additional initialization is needed because Microsoft Visual Studio 2013 (and earlier?)
// do not properly initialize myoptions from the static const kGumboDefaultOptions defined
// in the gumbo library. Instead whatever was in memory at the time is used causing random
// issues later on so if reverting remember to keep these specific changes as the bug
// they work around took a long long time to track down
GumboOptions myoptions = kGumboDefaultOptions;
myoptions.tab_stop = 4;
myoptions.use_xhtml_rules = true;
myoptions.stop_on_first_error = false;
myoptions.max_errors = -1;
// GumboInterface::m_mutex.lock();
m_output = gumbo_parse_with_options(&myoptions, m_utf8src.data(),
m_utf8src.length());
// GumboInterface::m_mutex.unlock();
}
}
std::string GumboInterface::repair() {
std::string result = "";
if (!m_source.empty()) {
if (m_output == NULL) {
parse();
}
std::string utf8out = serialize(m_output->document);
rtrim(utf8out);
result = std::string("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
+ utf8out;
}
return result;
}
std::string GumboInterface::getxhtml() {
std::string result = "";
if (!m_source.empty()) {
if (m_output == NULL) {
parse();
}
std::string utf8out = serialize(m_output->document);
rtrim(utf8out);
result = std::string("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
+ utf8out;
}
return result;
}
std::string GumboInterface::prettyprint(std::string indent_chars) {
std::string result = "";
if (!m_source.empty()) {
if (m_output == NULL) {
parse();
}
std::string ind = indent_chars;
std::string utf8out = prettyprint(m_output->document, 0, ind);
rtrim(utf8out);
result = std::string("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
+ utf8out;
}
return result;
}
std::list<std::string> GumboInterface::get_all_properties() {
std::list<std::string> properties;
if (!m_source.empty()) {
if (m_output == NULL) {
parse();
}
properties = get_properties(m_output->root);
}
return properties;
}
std::string GumboInterface::perform_source_updates(
const std::string& my_current_book_relpath) {
m_currentdir = my_current_book_relpath;
std::string result = "";
if (!m_source.empty()) {
if (m_output == NULL) {
parse();
}
enum UpdateTypes doupdates = SourceUpdates;
std::string utf8out = serialize(m_output->document, doupdates);
rtrim(utf8out);
result = std::string("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
+ utf8out;
}
return result;
}
std::string GumboInterface::perform_style_updates(
const std::string& my_current_book_relpath) {
//m_currentdir = QFileInfo(my_current_book_relpath).dir().path();
std::string result = "";
if (!m_source.empty()) {
if (m_output == NULL) {
parse();
}
enum UpdateTypes doupdates = StyleUpdates;
std::string utf8out = serialize(m_output->document, doupdates);
rtrim(utf8out);
result = std::string("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
+ utf8out;
}
return result;
}
std::string GumboInterface::perform_link_updates(const std::string& newcsslinks) {
m_newcsslinks = newcsslinks;
std::string result = "";
if (!m_source.empty()) {
if (m_output == NULL) {
parse();
}
enum UpdateTypes doupdates = LinkUpdates;
std::string utf8out = serialize(m_output->document, doupdates);
rtrim(utf8out);
result = std::string("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
+ utf8out;
}
return result;
}
GumboNode * GumboInterface::get_root_node() {
if (!m_source.empty()) {
if (m_output == NULL) {
parse();
}
}
return m_output->root;
}
std::string GumboInterface::get_body_contents() {
if (!m_source.empty()) {
if (m_output == NULL) {
parse();
}
}
std::list<GumboTag> tags = std::list<GumboTag>();
tags.push_back(GUMBO_TAG_BODY);
std::list<GumboNode*> nodes = get_all_nodes_with_tags(tags);
if (nodes.size() != 1) {
return std::string();
}
enum UpdateTypes doupdates = NoUpdates;
std::string results = serialize_contents(nodes.front(), doupdates);
return results;
}
std::list<std::string> GumboInterface::get_properties(GumboNode* node) {
if (node->type != GUMBO_NODE_ELEMENT) {
return std::list<std::string>();
}
std::list<std::string> properties;
std::string tagname = get_tag_name(node);
if (in_set(manifest_properties, tagname)) {
properties.push_back(tagname);
}
GumboAttribute* attr = gumbo_get_attribute(&node->v.element.attributes,
"src");
if (attr) {
properties.push_back(std::string("remote-resources"));
}
GumboVector* children = &node->v.element.children;
for (unsigned int i = 0; i < children->length; ++i) {
std::list<std::string> ret = get_properties(
static_cast<GumboNode*> (children->data[i]));
properties.merge(ret);
}
return properties;
}
std::string GumboInterface::get_qwebpath_to_node(GumboNode* node) {
std::list<std::string> path_pieces;
GumboNode* anode = node;
while (anode && !((anode->type == GUMBO_NODE_ELEMENT)
&& (anode->v.element.tag == GUMBO_TAG_HTML))) {
GumboNode* myparent = anode->parent;
std::string parent_name = get_tag_name(myparent);
int index;
std::string aname = get_tag_name(anode);
if (aname == "#text") {
index = anode->index_within_parent;
} else {
// need to find child num in parent as if only elements exist
GumboVector* children = &myparent->v.element.children;
int elnum = 0;
for (unsigned int i = 0; i < children->length; i++) {
GumboNode* child = static_cast<GumboNode*> (children->data[i]);
if (i == anode->index_within_parent) {
break;
}
if ((child->type == GUMBO_NODE_ELEMENT) || (child->type
== GUMBO_NODE_TEMPLATE)) {
elnum++;
}
}
index = elnum;
}
path_pieces.push_back(parent_name + " " + StringUtil::int2str(index));
anode = myparent;
}
std::string ret;
for (std::list<std::string>::iterator iter = path_pieces.begin(); iter
!= path_pieces.end(); iter++) {
ret.append(*iter);
ret.append(",");
}
return ret;
}
GumboNode* GumboInterface::get_node_from_qwebpath(std::string webpath) {
return NULL;
}
std::list<unsigned int> GumboInterface::get_path_to_node(GumboNode* node) {
std::list<unsigned int> apath = std::list<unsigned int>();
GumboNode* anode = node;
while (anode && !((anode->type == GUMBO_NODE_ELEMENT)
&& (anode->v.element.tag == GUMBO_TAG_HTML))) {
apath.push_back(anode->index_within_parent);
anode = anode->parent;
}
return apath;
}
GumboNode* GumboInterface::get_node_from_path(std::list<unsigned int> &apath) {
GumboNode* dest = get_root_node();
unsigned int childnum = 0;
for (std::list<unsigned int>::iterator iter = apath.begin(); iter
!= apath.end(); iter++, childnum++) {
if ((dest->type == GUMBO_NODE_ELEMENT) || (dest->type
== GUMBO_NODE_TEMPLATE)) {
GumboVector* children = &dest->v.element.children;
if (childnum < children->length) {
dest = static_cast<GumboNode*> (children->data[childnum]);
} else {
break;
}
} else {
break;
}
}
return dest;
}
std::string GumboInterface::perform_body_updates(const std::string & new_body) {
std::string result = "";
if (!m_source.empty()) {
if (m_output == NULL) {
parse();
}
}
std::list<GumboTag> tags = std::list<GumboTag>();
tags.push_back(GUMBO_TAG_BODY);
std::list<GumboNode*> nodes = get_all_nodes_with_tags(tags);
if (nodes.size() != 1) {
return std::string();
}
m_newbody = new_body;
enum UpdateTypes doupdates = BodyUpdates;
std::string utf8out = serialize(m_output->document, doupdates);
result = std::string("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
+ utf8out;
m_newbody = "";
return result;
}
std::list<GumboWellFormedError> GumboInterface::error_check() {
std::list<GumboWellFormedError> errlist;
int line_offset = 0;
// In case we ever have to revert to earlier versions, please note the following
// additional initialization is needed because Microsoft Visual Studio 2013 (and earlier?)
// do not properly initialize myoptions from the static const kGumboDefaultOptions defined
// in the gumbo library. Instead whatever was in memory at the time is used causing random
// issues later on so if reverting remember to keep these specific changes as the bug
// they work around took a long long time to track down
GumboOptions myoptions = kGumboDefaultOptions;
myoptions.tab_stop = 4;
myoptions.use_xhtml_rules = true;
myoptions.stop_on_first_error = false;
myoptions.max_errors = -1;
if (!m_source.empty() && (m_output == NULL)) {
m_utf8src = m_source;
// remove any xml header line and trailing whitespace
if (m_utf8src.compare(0, 5, "<?xml") == 0) {
size_t end = m_utf8src.find_first_of('>', 0);
end = m_utf8src.find_first_not_of("\n\r\t\v\f ", end + 1);
m_utf8src.erase(0, end);
line_offset++;
}
// add in epub version specific doctype if missing
if ((m_utf8src.compare(0, 9, "<!DOCTYPE") != 0) && (m_utf8src.compare(
0, 9, "<!doctype") != 0)) {
std::string three("3");
if (StringUtil::startWith(m_version, three)) {
m_utf8src.insert(0, "<!DOCTYPE html>\n");
} else {
m_utf8src.insert(
0,
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n\n");
}
line_offset--;
}
m_output = gumbo_parse_with_options(&myoptions, m_utf8src.data(),
m_utf8src.length());
}
// qDebug() << QString::fromStdString(m_utf8src);
const GumboVector* errors = &m_output->errors;
for (unsigned int i = 0; i < errors->length; ++i) {
GumboError* er = static_cast<GumboError*> (errors->data[i]);
GumboWellFormedError gperror;
gperror.line = er->position.line + line_offset;
;
gperror.column = er->position.column;
// unsigned int typenum = er->type;
GumboStringBuffer text;
gumbo_string_buffer_init(&text);
gumbo_error_to_string(er, &text);
std::string errmsg(text.data, text.length);
gperror.message = errmsg;
// qDebug() << gperror.message;
gumbo_string_buffer_destroy(&text);
errlist.push_back(gperror);
}
return errlist;
}
std::list<GumboNode*> GumboInterface::get_all_nodes_with_attribute(
const std::string& attname) {
std::list<GumboNode*> nodes;
if (!m_source.empty()) {
if (m_output == NULL) {
parse();
}
nodes = get_nodes_with_attribute(m_output->root, attname.c_str());
}
return nodes;
}
std::list<GumboNode*> GumboInterface::get_nodes_with_attribute(GumboNode* node,
const char * attname) {
if (node->type != GUMBO_NODE_ELEMENT) {
return std::list<GumboNode*>();
}
std::list<GumboNode*> nodes;
GumboAttribute* attr = gumbo_get_attribute(&node->v.element.attributes,
attname);
if (attr) {
nodes.push_back(node);
}
GumboVector* children = &node->v.element.children;
for (unsigned int i = 0; i < children->length; ++i) {
std::list<GumboNode*> ret = get_nodes_with_attribute(
static_cast<GumboNode*> (children->data[i]), attname);
nodes.merge(ret);
}
return nodes;
}
std::list<std::string> GumboInterface::get_all_values_for_attribute(
const std::string& attname) {
std::list<std::string> attrvals;
if (!m_source.empty()) {
if (m_output == NULL) {
parse();
}
attrvals = get_values_for_attr(m_output->root, attname.c_str());
}
return attrvals;
}
std::list<std::string> GumboInterface::get_values_for_attr(GumboNode* node,
const char* attr_name) {
if (node->type != GUMBO_NODE_ELEMENT) {
return std::list<std::string>();
}
std::list<std::string> attr_vals;
GumboAttribute* attr = gumbo_get_attribute(&node->v.element.attributes,
attr_name);
if (attr != NULL) {
attr_vals.push_back(attr->value);
}
GumboVector* children = &node->v.element.children;
for (unsigned int i = 0; i < children->length; ++i) {
std::list<std::string> ret = get_values_for_attr(
static_cast<GumboNode*> (children->data[i]), attr_name);
attr_vals.merge(ret);
}
return attr_vals;
}
std::map<std::string, std::string> GumboInterface::get_attributes_of_node(
GumboNode* node) {
std::map<std::string, std::string> node_atts;
if (node->type != GUMBO_NODE_ELEMENT) {
return node_atts;
}
const GumboVector * attribs = &node->v.element.attributes;
for (unsigned int i = 0; i < attribs->length; ++i) {
GumboAttribute* attr = static_cast<GumboAttribute*> (attribs->data[i]);
std::string key = get_attribute_name(attr);
std::string val = attr->value;
node_atts[key] = val;
}
return node_atts;
}
std::string GumboInterface::get_local_text_of_node(GumboNode* node) {
std::string node_text;
if (node->type != GUMBO_NODE_ELEMENT) {
return node_text;
}
// handle br tag as special case element tag with a text value
GumboTag tag = node->v.element.tag;
if (tag == GUMBO_TAG_BR) {
node_text = "\n";
return node_text;
}
GumboVector* children = &node->v.element.children;
for (unsigned int i = 0; i < children->length; ++i) {
GumboNode* child = static_cast<GumboNode*> (children->data[i]);
if (child->type == GUMBO_NODE_TEXT) {
node_text += child->v.text.text;
} else if (child->type == GUMBO_NODE_WHITESPACE) {
// keep all whitespace to keep as close to original as possible
node_text += child->v.text.text;
} else if (child->type == GUMBO_NODE_CDATA) {
node_text += child->v.text.text;
} else if (child->type == GUMBO_NODE_ELEMENT) {
node_text += get_local_text_of_node(child);
}
}
return node_text;
}
std::string GumboInterface::get_text_of_node(GumboNode* node) {
std::string node_text;
if (node->type == GUMBO_NODE_TEXT) {
node_text = std::string(node->v.text.text);
}
return node_text;
}
std::list<GumboNode*> GumboInterface::get_all_nodes_with_tag(GumboTag tag) {
std::list<GumboTag> tags;
tags.push_back(tag);
return get_all_nodes_with_tags(tags);
}
std::list<GumboNode*> GumboInterface::get_all_nodes_with_tags(
const std::list<GumboTag> & tags) {
std::list<GumboNode*> nodes;
if (!m_source.empty()) {
if (m_output == NULL) {
parse();
}
nodes = get_nodes_with_tags(m_output->root, tags);
}
return nodes;
}
std::list<GumboNode*> GumboInterface::get_nodes_with_tags(GumboNode* node,
const std::list<GumboTag> & tags) {
if (node->type != GUMBO_NODE_ELEMENT) {
return std::list<GumboNode*>();
}
std::list<GumboNode*> nodes;
GumboTag tag = node ->v.element.tag;
if (find(tags.begin(), tags.end(), tag) != tags.end()) {
nodes.push_back(node);
}
GumboVector* children = &node->v.element.children;
for (unsigned int i = 0; i < children->length; ++i) {
std::list<GumboNode*> ret = get_nodes_with_tags(
static_cast<GumboNode*> (children->data[i]), tags);
nodes.merge(ret);
}
return nodes;
}
std::list<GumboNode*> GumboInterface::get_all_nodes(GumboNode* node) {
std::list<GumboNode*> ret;
ret.push_back(node);
if (node->type == GUMBO_NODE_ELEMENT) {
GumboVector* children = &node->v.element.children;
for (unsigned int i = 0; i < children->length; i++) {
std::list<GumboNode*> childrenNodes = get_all_nodes(
static_cast<GumboNode *> (children->data[i]));
ret.merge(childrenNodes);
}
}
return ret;
}
bool GumboInterface::in_set(std::set<std::string> &s, std::string &key) {
return s.find(key) != s.end();
}
void GumboInterface::rtrim(std::string &s) {
s.erase(s.find_last_not_of(" \n\r\t\v\f") + 1);
}
void GumboInterface::ltrim(std::string &s) {
s.erase(0, s.find_first_not_of(" \n\r\t\v\f"));
}
void GumboInterface::ltrimnewlines(std::string &s) {
s.erase(0, s.find_first_not_of("\n\r"));
}
// delete everything up to and including the newline
void GumboInterface::newlinetrim(std::string &s) {
size_t pos = s.find("\n");
if (pos != std::string::npos) {
s.erase(0, pos + 1);
}
}
void GumboInterface::condense_whitespace(std::string &s) {
size_t n = s.length();
std::string val;
val.reserve(n);
std::string wspace = " \n\r\t\v\f";
char last_c = 'x';
for (size_t i = 0; i < n; i++) {
char c = s.at(i);
if (wspace.find(c) != std::string::npos) {
c = ' ';
}
if ((c != ' ') || (last_c != ' ')) {
val.push_back(c);
}
last_c = c;
}
s = val;
}
void GumboInterface::replace_all(std::string &s, const char * s1,
const char * s2) {
std::string t1(s1);
size_t len = t1.length();
size_t pos = s.find(t1);
while (pos != std::string::npos) {
s.replace(pos, len, s2);
pos = s.find(t1, pos + len);
}
}
std::string GumboInterface::update_attribute_value(const std::string &attvalue) {
std::string result = attvalue;
std::string attpath = UrlUtil::UrlDecode(attvalue);
std::size_t fragpos = attpath.rfind(POUND_SIGN);
bool has_fragment = fragpos != std::string::npos;
std::string fragment = "";
if (has_fragment) {
fragment = attpath.substr(fragpos, attpath.length() - fragpos);
attpath = attpath.substr(0, fragpos);
}
std::string search_key = attpath;
std::string new_href;
if (m_sourceupdates.find(search_key) != m_sourceupdates.end()) {
new_href = m_sourceupdates.at(search_key);
}
if (!new_href.empty()) {
new_href += fragment;
result = new_href;
}
return result;
}
std::string GumboInterface::update_style_urls(const std::string &source) {
std::string result = source;
// pcrecpp::RE_Options opt;
// opt.set_utf8(true);
// opt.set_caseless(true);
// opt.set_multiline(true);
// const std::string
// EXTRACT_STYLE_URL(
// "(?:(?:src|background|background-image|list-style|list-style-image|border-image|border-image-source|content)\\s*:|@import)\\s*"
// "[^;\\}\\(\"']*"
// "(?:"
// "url\\([\"']?([^\\(\\)\"']*)[\"']?\\)"
// "|"
// "[\"']([^\\(\\)\"']*)[\"']"
// ")");
//
// const std::string
// MATCH_STYLE_URL(
// "((src|background|background-image|list-style|list-style-image|border-image|border-image-source|content)(\\s*:|@import)(\\s*"
// "[^;\\}\\(\"']*"
// "url\\([\"']?([^\\(\\)\"']*)[\"']?\\)"
// "|"
// "[\"']([^\\(\\)\"']*)[\"']"
// "))");
//
// const std::string REPLACE_URL = ":.*(url\\s*\\([^\\)]+\\))";
// pcrecpp::RE reMatch = pcrecpp::RE(MATCH_STYLE_URL, opt);
// pcrecpp::RE reExtract = pcrecpp::RE(EXTRACT_STYLE_URL, opt);
// pcrecpp::RE reReplace = pcrecpp::RE(REPLACE_URL, opt);
// std::string findStr;
// std::string findStrCopy;
// std::string findStrExtract;
// pcrecpp::StringPiece inSp(source);
// pcrecpp::StringPiece inSpExtract(source);
//
// while(reMatch.FindAndConsume(&inSp, &findStr)){
// findStrCopy = findStr;
// reExtract.FindAndConsume(&inSpExtract, &findStrExtract);
// std::string new_href;
// if (m_sourceupdates.find(findStrExtract) != m_sourceupdates.end()) {
// new_href = m_sourceupdates.at(findStrExtract);
// reReplace.Replace(std::string(":url(")+ new_href + ")",&findStrCopy);
// result.erase(result.size() - inSp.size() - findStr.size(),findStr.size());
// result.insert(result.size() - inSp.size(),findStrCopy.c_str());
// }
// }
return result;
}
std::string GumboInterface::substitute_xml_entities_into_text(
const std::string &text) {
std::string result = text;
// replacing & must come first
replace_all(result, "&", "&");
replace_all(result, "<", "<");
replace_all(result, ">", ">");
// convert non-breaking spaces to entities to prevent their loss for later editing
// See the strange//buggy behaviour of Qt QTextDocument toPlainText() routine
if (m_hasnbsp) {
replace_all(result, "\xc2\xa0", " ");
} else {
replace_all(result, "\xc2\xa0", " ");
}
return result;
}
std::string GumboInterface::substitute_xml_entities_into_attributes(char quote,
const std::string &text) {
std::string result = substitute_xml_entities_into_text(text);
if (quote == '"') {
replace_all(result, "\"", """);
} else if (quote == '\'') {
replace_all(result, "'", "'");
}
return result;
}
std::string GumboInterface::get_tag_name(GumboNode *node) {
std::string tagname;
if (node->type == GUMBO_NODE_DOCUMENT) {
tagname = "#document";
return tagname;
} else if ((node->type == GUMBO_NODE_TEXT) || (node->type
== GUMBO_NODE_WHITESPACE)) {
tagname = "#text";
return tagname;
} else if (node->type == GUMBO_NODE_CDATA) {
tagname = "#cdata";
return tagname;
}
tagname = gumbo_normalized_tagname(node->v.element.tag);
if ((tagname.empty()) || (node->v.element.tag_namespace
== GUMBO_NAMESPACE_SVG)) {
// set up to examine original text of tag.
GumboStringPiece gsp = node->v.element.original_tag;
gumbo_tag_from_original_text(&gsp);
// special handling for some svg tag names.
if (node->v.element.tag_namespace == GUMBO_NAMESPACE_SVG) {
const char * data = gumbo_normalize_svg_tagname(&gsp);
// NOTE: data may not be null-terminated!
// since case change only - length must be same as original
// if no replacement found returns null, not original tag!
if (data != NULL) {
return std::string(data, gsp.length);
}
}
if (tagname.empty()) {
return std::string(gsp.data, gsp.length);
}
}
return tagname;
}
// if missing leave it alone
// if epub3 docytpe use it otherwise set it to epub2 docytpe
std::string GumboInterface::build_doctype(GumboNode *node) {
std::string two("2");
std::string three("3");
std::string results = "";
if (StringUtil::startWith(m_version, two)) {
results.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n");
results.append(
" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n\n");
return results;
} else if (StringUtil::startWith(m_version, three)) {
results.append("<!DOCTYPE html>\n\n");
return results;
}
if (node->v.document.has_doctype) {
std::string name(node->v.document.name);
std::string pi(node->v.document.public_identifier);
std::string si(node->v.document.system_identifier);
if ((name == "html") && pi.empty() && si.empty()) {
results.append("<!DOCTYPE html>\n\n");
return results;
} else {
results.append(
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n");
results.append(
" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n\n");
}
}
return results;
}
// deal properly with foreign namespaced attributes
std::string GumboInterface::get_attribute_name(GumboAttribute * at) {
std::string attr_name = at->name;
GumboAttributeNamespaceEnum attr_ns = at->attr_namespace;
if ((attr_ns == GUMBO_ATTR_NAMESPACE_NONE) || (attr_name == "xmlns")) {
return attr_name;
}
attr_name = std::string(attribute_nsprefixes[attr_ns]) + attr_name;
return attr_name;
}
std::string GumboInterface::build_attributes(GumboAttribute * at,
bool no_entities, bool run_src_updates, bool run_style_updates) {
std::string atts = " ";
std::string name = get_attribute_name(at);
std::string local_name = at->name;
atts.append(name);
std::string attvalue = at->value;
if (run_src_updates && (local_name == aHREF || local_name == aSRC
|| local_name == aPOSTER || local_name == aDATA)) {
attvalue = update_attribute_value(attvalue);
}
if (run_style_updates && (local_name == "style")) {
attvalue = update_style_urls(attvalue);
}
// we handle empty attribute values like so: alt=""
char quote = '"';
std::string qs = "\"";
// verify an original value existed since we create our own attributes
// and if so determine the original quote character used if any
if (at->original_value.data) {
if ((!attvalue.empty()) || (at->original_value.data[0] == '"')
|| (at->original_value.data[0] == '\'')) {
quote = at->original_value.data[0];
if (quote == '\'')
qs = std::string("'");
if (quote == '"')
qs = std::string("\"");
}
}
atts.append("=");
atts.append(qs);
if (no_entities) {
atts.append(attvalue);
} else {
atts.append(substitute_xml_entities_into_attributes(quote, attvalue));
}
atts.append(qs);
return atts;
}
// serialize children of a node
// may be invoked recursively
std::string GumboInterface::serialize_contents(GumboNode* node,
enum UpdateTypes doupdates) {
std::string contents = "";
std::string tagname = get_tag_name(node);
bool no_entity_substitution = in_set(no_entity_sub, tagname);
bool keep_whitespace = in_set(preserve_whitespace, tagname);
bool is_inline = in_set(nonbreaking_inline, tagname);
bool is_structural = in_set(structural_tags, tagname);
// build up result for each child, recursively if need be
GumboVector* children = &node->v.element.children;
bool inject_newline = false;
bool in_head_without_title = (tagname == "head");
for (unsigned int i = 0; i < children->length; ++i) {
GumboNode* child = static_cast<GumboNode*> (children->data[i]);
if (child->type == GUMBO_NODE_TEXT) {
std::string text;
if (no_entity_substitution) {
text = std::string(child->v.text.text);
} else {
text = substitute_xml_entities_into_text(
std::string(child->v.text.text));
}
if (inject_newline && !text.empty() && (text.at(0) == '\n'))
text.erase(0, 1);
inject_newline = false;
contents.append(text);
} else if (child->type == GUMBO_NODE_ELEMENT || child->type
== GUMBO_NODE_TEMPLATE) {
contents.append(serialize(child, doupdates));
inject_newline = false;
std::string childname = get_tag_name(child);
if (in_head_without_title && (childname == "title"))
in_head_without_title = false;
if (!is_inline && !keep_whitespace && !in_set(nonbreaking_inline,
childname) && is_structural) {
contents.append("\n");
inject_newline = true;
}
} else if (child->type == GUMBO_NODE_WHITESPACE) {
// try to keep all whitespace to keep as close to original as possible
std::string wspace = std::string(child->v.text.text);
if (inject_newline) {
newlinetrim(wspace);
inject_newline = false;
}
contents.append(wspace);
inject_newline = false;
} else if (child->type == GUMBO_NODE_CDATA) {
contents.append(
"<![CDATA[" + std::string(child->v.text.text) + "]]>");
inject_newline = false;
} else if (child->type == GUMBO_NODE_COMMENT) {
contents.append("<!--" + std::string(child->v.text.text) + "-->");
} else {
fprintf(stderr, "unknown element of type: %d\n", child->type);
inject_newline = false;
}
}
if (in_head_without_title)
contents.append("<title></title>");
return contents;
}
// serialize a GumboNode back to html/xhtml
// may be invoked recursively
std::string GumboInterface::serialize(GumboNode* node,
enum UpdateTypes doupdates) {
// special case the document node
if (node->type == GUMBO_NODE_DOCUMENT) {
std::string results = build_doctype(node);
results.append(serialize_contents(node, doupdates));
return results;
}
std::string close = "";
std::string closeTag = "";
std::string atts = "";
std::string tagname = get_tag_name(node);
bool need_special_handling = in_set(special_handling, tagname);
bool is_void_tag = in_set(void_tags, tagname);
bool no_entity_substitution = in_set(no_entity_sub, tagname);
bool is_href_src_tag = in_set(href_src_tags, tagname);
bool in_xml_ns = node->v.element.tag_namespace != GUMBO_NAMESPACE_HTML;
// bool is_inline = in_set(nonbreaking_inline, tagname);
// build attr string
const GumboVector * attribs = &node->v.element.attributes;
for (unsigned int i = 0; i < attribs->length; ++i) {
GumboAttribute* at = static_cast<GumboAttribute*> (attribs->data[i]);
atts.append(
build_attributes(at, no_entity_substitution,
((doupdates & SourceUpdates) && is_href_src_tag),
(doupdates & StyleUpdates)));
}
// Make sure that the xmlns attribute exists as an html tag attribute
if (tagname == "html") {
if (atts.find("xmlns=") == std::string::npos) {
atts.append(" xmlns=\"http://www.w3.org/1999/xhtml\"");
}
}
// determine contents
std::string contents;
if ((tagname == "body") && (doupdates & BodyUpdates)) {
contents = m_newbody;
} else {
// serialize your contents
contents = serialize_contents(node, doupdates);
}
// determine closing tag type
std::string testcontents = contents;
ltrim(testcontents);
if (is_void_tag || (in_xml_ns && testcontents.empty())) {
close = "/";
} else {
closeTag = "</" + tagname + ">";
}
if ((doupdates & StyleUpdates) && (tagname == "style")
&& (node->parent->type == GUMBO_NODE_ELEMENT)
&& (node->parent->v.element.tag == GUMBO_TAG_HEAD)) {
contents = update_style_urls(contents);
}
if (need_special_handling) {
ltrimnewlines(contents);
rtrim(contents);
contents.append("\n");
}
// build results
std::string results;
if ((doupdates & LinkUpdates) && (tagname == "link") && (node->parent->type
== GUMBO_NODE_ELEMENT) && (node->parent->v.element.tag
== GUMBO_TAG_HEAD)) {
return "";
}
results.append("<" + tagname + atts + close + ">");
if (need_special_handling)
results.append("\n");
results.append(contents);
if ((doupdates & LinkUpdates) && (tagname == "head")) {
results.append(m_newcsslinks);
}
results.append(closeTag);
if (need_special_handling)
results.append("\n");
return results;
}
std::string GumboInterface::prettyprint_contents(GumboNode* node, int lvl,
const std::string indent_chars) {
std::string contents = "";
std::string tagname = get_tag_name(node);
bool no_entity_substitution = in_set(no_entity_sub, tagname);
bool keep_whitespace = in_set(preserve_whitespace, tagname);
bool is_inline = in_set(nonbreaking_inline, tagname);
bool is_structural = in_set(structural_tags, tagname);
char c = indent_chars.at(0);
int n = indent_chars.length();
std::string indent_space = std::string((lvl - 1) * n, c);
char last_char = 'x';
bool contains_block_tags = false;
GumboVector* children = &node->v.element.children;
if (is_structural || (tagname == "#document"))
last_char = '\n';
bool in_head_without_title = (tagname == "head");
for (unsigned int i = 0; i < children->length; ++i) {
GumboNode* child = static_cast<GumboNode*> (children->data[i]);
if (child->type == GUMBO_NODE_TEXT) {
std::string val;
if (no_entity_substitution) {
val = std::string(child->v.text.text);
} else {
val = substitute_xml_entities_into_text(
std::string(child->v.text.text));
}
// if child of a structual element is text and follows a newline, indent it properly
if (is_structural && last_char == '\n') {
contents.append(indent_space);
ltrim(val);
}
if (!keep_whitespace && !is_structural) {
// okay to condense whitespace
condense_whitespace(val);
}
contents.append(val);
} else if (child->type == GUMBO_NODE_ELEMENT || child->type
== GUMBO_NODE_TEMPLATE) {
std::string val = prettyprint(child, lvl, indent_chars);
std::string childname = get_tag_name(child);
if (in_head_without_title && (childname == "title"))
in_head_without_title = false;
if (!in_set(nonbreaking_inline, childname)) {
contains_block_tags = true;
if (last_char != '\n') {
contents.append("\n");
if (tagname != "head" && tagname != "html")
contents.append("\n");
last_char = '\n';
}
}
// if child of a structual element is inline and follows a newline, indent it properly
if (is_structural && in_set(nonbreaking_inline, childname)
&& (last_char == '\n')) {
contents.append(indent_space);
ltrim(val);
}
contents.append(val);
} else if (child->type == GUMBO_NODE_WHITESPACE) {
if (keep_whitespace) {
std::string wspace = std::string(child->v.text.text);
contents.append(wspace);
} else if (is_inline || in_set(other_text_holders, tagname)) {
if (std::string(" \t\v\f\r\n").find(last_char)
== std::string::npos) {
contents.append(std::string(" "));
}
}
} else if (child->type == GUMBO_NODE_CDATA) {
contents.append(
"<![CDATA[" + std::string(child->v.text.text) + "]]>");
} else if (child->type == GUMBO_NODE_COMMENT) {
contents.append("<!--" + std::string(child->v.text.text) + "-->");
} else {
fprintf(stderr, "unknown element of type: %d\n", child->type);
}
// update last character of current contents
if (!contents.empty()) {
last_char = contents.at(contents.length() - 1);
}
}
// inject epmpty title into head if one is missing
if (in_head_without_title) {
if (last_char != '\n')
contents.append("\n");
contents.append(indent_space + "<title></title>\n");
last_char = '\n';
}
// treat inline tags containing block tags like a block tag
if (is_inline && contains_block_tags) {
if (last_char != '\n')
contents.append("\n\n");
contents.append(indent_space);
}
return contents;
}
// prettyprint a GumboNode back to html/xhtml
// may be invoked recursively
std::string GumboInterface::prettyprint(GumboNode* node, int lvl,
const std::string indent_chars) {
// special case the document node
if (node->type == GUMBO_NODE_DOCUMENT) {
std::string results = build_doctype(node);
results.append(prettyprint_contents(node, lvl + 1, indent_chars));
return results;
}
std::string tagname = get_tag_name(node);
std::string parentname = get_tag_name(node->parent);
bool in_head = (parentname == "head");
bool is_structural = in_set(structural_tags, tagname);
bool is_inline = in_set(nonbreaking_inline, tagname);
bool in_xml_ns = node->v.element.tag_namespace != GUMBO_NAMESPACE_HTML;
// build attr string
std::string atts = "";
bool no_entity_substitution = in_set(no_entity_sub, tagname);
const GumboVector * attribs = &node->v.element.attributes;
for (unsigned int i = 0; i < attribs->length; ++i) {
GumboAttribute* at = static_cast<GumboAttribute*> (attribs->data[i]);
atts.append(build_attributes(at, no_entity_substitution));
}
bool is_void_tag = in_set(void_tags, tagname);
// get tag contents
std::string contents = "";
if (!is_void_tag) {
if (is_structural && tagname != "html") {
contents = prettyprint_contents(node, lvl + 1, indent_chars);
} else {
contents = prettyprint_contents(node, lvl, indent_chars);
}
}
bool keep_whitespace = in_set(preserve_whitespace, tagname);
if (!keep_whitespace && !is_inline) {
rtrim(contents);
}
std::string testcontents = contents;
ltrim(testcontents);
bool single = is_void_tag || (in_xml_ns && testcontents.empty());
char c = indent_chars.at(0);
int n = indent_chars.length();
std::string indent_space = std::string((lvl - 1) * n, c);
// handle self-closed tags with no contents first
if (single) {
std::string selfclosetag = "<" + tagname + atts + "/>";
if (is_inline) {
// always add newline after br tags when they are children of structural tags
if ((tagname == "br") && in_set(structural_tags, parentname)) {
selfclosetag.append("\n");
if (!in_head && (tagname != "html"))
selfclosetag.append("\n");
}
return selfclosetag;
}
if (!in_head && (tagname != "html"))
selfclosetag.append("\n");
return indent_space + selfclosetag + "\n";
}
// Handle the general case
std::string results;
std::string starttag = "<" + tagname + atts + ">";
std::string closetag = "</" + tagname + ">";
if (is_structural) {
results = indent_space + starttag;
if (!contents.empty()) {
results.append("\n" + contents + "\n" + indent_space);
}
results.append(closetag + "\n");
if (!in_head && (tagname != "html"))
results.append("\n");
} else if (is_inline) {
results = starttag;
results.append(contents);
results.append(closetag);
} else /** all others */{
results = indent_space + starttag;
if (!keep_whitespace) {
ltrim(contents);
}
results.append(contents);
results.append(closetag + "\n");
if (!in_head && (tagname != "html"))
results.append("\n");
}
return results;
}
}
| 42,083
| 16,580
|
/**
* @cond doxygenLibsbmlInternal
*
* @file CompartmentOutsideCycles.cpp
* @brief Ensures no cycles exist via a Compartment's 'outside' attribute.
* @author Ben Bornstein
*
* <!--------------------------------------------------------------------------
* This file is part of libSBML. Please visit http://sbml.org for more
* information about SBML, and the latest version of libSBML.
*
* Copyright (C) 2020 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. University of Heidelberg, Heidelberg, Germany
* 3. University College London, London, UK
*
* Copyright (C) 2019 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. University of Heidelberg, Heidelberg, Germany
*
* Copyright (C) 2013-2018 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
* 3. University of Heidelberg, Heidelberg, Germany
*
* Copyright (C) 2009-2013 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
*
* Copyright (C) 2006-2008 by the California Institute of Technology,
* Pasadena, CA, USA
*
* Copyright (C) 2002-2005 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. Japan Science and Technology Agency, Japan
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation. A copy of the license agreement is provided
* in the file named "LICENSE.txt" included with this software distribution
* and also available online as http://sbml.org/software/libsbml/license.html
* ---------------------------------------------------------------------- -->*/
#include <sbml/Model.h>
#include <sbml/Compartment.h>
#include <sbml/util/IdList.h>
#include "CompartmentOutsideCycles.h"
/** @cond doxygenIgnored */
using namespace std;
/** @endcond */
LIBSBML_CPP_NAMESPACE_BEGIN
/*
* Creates a new Constraint with the given @p id.
*/
CompartmentOutsideCycles::CompartmentOutsideCycles ( unsigned int id,
Validator& v ) :
TConstraint<Model>(id, v)
{
}
/*
* Destroys this Constraint.
*/
CompartmentOutsideCycles::~CompartmentOutsideCycles ()
{
}
/*
* Checks that no Compartments in Model have a cycle via their 'outside'
* attribute.
*
* Sets mHolds to true if no cycles are found, false otherwise.
*/
void
CompartmentOutsideCycles::check_ (const Model& m, const Model&)
{
for (unsigned int n = 0; n < m.getNumCompartments(); n++)
{
checkForCycle(m, m.getCompartment(n));
}
mCycles.clear();
}
/*
* Checks for a cycle by following Compartment c's 'outside' attribute. If
* a cycle is found, it is added to the list of found cycles, mCycles.
*/
void
CompartmentOutsideCycles::checkForCycle (const Model& m, const Compartment* c)
{
IdList visited;
while (c != NULL && !isInCycle(c))
{
const string& id = c->getId();
if ( visited.contains(id) )
{
visited.removeIdsBefore(id);
mCycles.push_back(visited);
logCycle(c, visited);
break;
}
visited.append(id);
c = c->isSetOutside() ? m.getCompartment( c->getOutside() ) : NULL;
}
}
/*
* Function Object: Returns true if Compartment c is contained in the given
* IdList cycle.
*/
struct CycleContains
{
CycleContains (const Compartment* c) : id(c->getId()) { }
bool operator() (const IdList& lst) const
{
return lst.contains(id);
}
const string& id;
};
/*
* @return @c true if Compartment c is contained in one of the already found
* cycles, false otherwise.
*/
bool
CompartmentOutsideCycles::isInCycle (const Compartment* c)
{
vector<IdList>::iterator end = mCycles.end();
return find_if(mCycles.begin(), end, CycleContains(c)) != end;
}
/*
* Logs a message about a cycle found starting at Compartment c.
*/
void
CompartmentOutsideCycles::logCycle (const Compartment* c, const IdList& cycle)
{
//msg =
// "A <compartment> may not enclose itself through a chain of references "
// "involving the 'outside' field. This means that a compartment cannot "
// "have its own identifier as the value of 'outside', nor can it point to "
// "another compartment whose 'outside' field points directly or indirectly "
// "to the compartment. (References: L2V1 erratum 11; L2V2 Section 4.7.7.) ";
msg = "Compartment '" + c->getId() + "' encloses itself";
if (cycle.size() > 1)
{
IdList::const_iterator iter = cycle.begin();
IdList::const_iterator end = cycle.end();
msg += " via '" + *iter++ + "'";
while (iter != end) msg += " -> '" + *iter++ + "'";
msg += " -> '" + c->getId() + "'";
}
msg += '.';
logFailure(*c);
}
LIBSBML_CPP_NAMESPACE_END
/** @endcond */
| 5,116
| 1,652
|
//-----------------------------------------------
//
// This file is part of the Siv3D Engine.
//
// Copyright (c) 2008-2021 Ryo Suzuki
// Copyright (c) 2016-2021 OpenSiv3D Project
//
// Licensed under the MIT License.
//
//-----------------------------------------------
# pragma once
# include "../Common.hpp"
namespace s3d
{
/// @brief 物体の種類に関するフラグ
enum class P2BodyType : uint8
{
/// @brief 物体は常に固定され、力の影響を受けません。地面や壁などに使います。
Static,
/// @brief 物体は力の影響を受けませんが、移動することができます。動く床などに使います。
Kinematic,
/// @brief 物体は力の影響を受けて動き回ります。
Dynamic
};
/// @brief `P2BodyType::Static` の省略表記です。
inline constexpr P2BodyType P2Static = P2BodyType::Static;
/// @brief `P2BodyType::Kinematic` の省略表記です。
inline constexpr P2BodyType P2Kinematic = P2BodyType::Kinematic;
/// @brief `P2BodyType::Dynamic` の省略表記です。
inline constexpr P2BodyType P2Dynamic = P2BodyType::Dynamic;
}
| 884
| 459
|
#include "system_management.h"
std::ofstream fileout("log");
System_resource::System_resource()
{
sysinfo(&memInfo);
totalVirtualMem = memInfo.totalram;
totalVirtualMem += memInfo.totalswap;
totalVirtualMem *= memInfo.mem_unit;
totalPhysMem = memInfo.totalram;
totalPhysMem *= memInfo.mem_unit;
}
uint64_t System_resource::getTotalVirtualMem()
{
return totalVirtualMem;
}
uint64_t System_resource::getVirtualMemUsed()
{
virtualMemUsed = memInfo.totalram - memInfo.freeram;
virtualMemUsed += memInfo.totalswap - memInfo.freeswap;
virtualMemUsed *= memInfo.mem_unit;
return virtualMemUsed;
}
uint64_t System_resource::getTotalPhysMem()
{
return totalPhysMem;
}
uint64_t System_resource::getPhysMemUsed()
{
physMemUsed = memInfo.totalram - memInfo.freeram;
physMemUsed *= memInfo.mem_unit;
return physMemUsed;
}
System_resource system_resource;
| 860
| 320
|