hexsha stringlengths 40 40 | size int64 19 11.4M | ext stringclasses 13
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 270 | max_stars_repo_name stringlengths 5 110 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 3 270 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 9 | max_issues_count float64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 270 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 9 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 19 11.4M | avg_line_length float64 1.93 229k | max_line_length int64 12 688k | alphanum_fraction float64 0.07 0.99 | matches listlengths 1 10 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
30c3b777b14cbcd1c324403a23d0f49f5e2b9a8d | 1,198 | cpp | C++ | cpp/3755.cpp | jinhan814/BOJ | 47d2a89a2602144eb08459cabac04d036c758577 | [
"MIT"
] | 9 | 2021-01-15T13:36:39.000Z | 2022-02-23T03:44:46.000Z | cpp/3755.cpp | jinhan814/BOJ | 47d2a89a2602144eb08459cabac04d036c758577 | [
"MIT"
] | 1 | 2021-07-31T17:11:26.000Z | 2021-08-02T01:01:03.000Z | cpp/3755.cpp | jinhan814/BOJ | 47d2a89a2602144eb08459cabac04d036c758577 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
#define fastio cin.tie(0)->sync_with_stdio(0)
using namespace std;
using pii = pair<int, int>;
template<typename T = int, typename F = less<T>>
struct Priority_queue {
Priority_queue() = default;
Priority_queue(const F& f) : insert(f), erase(f) {}
T Top() { __Erase(); return insert.top(); }
void Insert(T val) { __Erase(); insert.push(val); }
void Erase(T val) { __Erase(); erase.push(val); }
size_t size() { __Erase(); return insert.size(); }
bool empty() { __Erase(); return insert.empty(); }
private:
priority_queue<T, vector<T>, F> insert, erase;
void __Erase() {
while (erase.size() && insert.top() == erase.top())
insert.pop(), erase.pop();
}
};
int main() {
fastio;
Priority_queue<pii> PQ1;
Priority_queue<pii, greater<pii>> PQ2;
for (int t, a, b; cin >> t && t;) {
if (t == 1) cin >> a >> b, PQ1.Insert({ b, a }), PQ2.Insert({ b, a });
else if (t == 2) {
if (PQ1.empty()) cout << 0 << '\n';
else cout << PQ1.Top().second << '\n', PQ2.Erase(PQ1.Top()), PQ1.Erase(PQ1.Top());
}
else if (t == 3) {
if (PQ2.empty()) cout << 0 << '\n';
else cout << PQ2.Top().second << '\n', PQ1.Erase(PQ2.Top()), PQ2.Erase(PQ2.Top());
}
}
} | 30.717949 | 85 | 0.59015 | [
"vector"
] |
30cd2eae1bb20ed999cdd1be4d10c52963c23c91 | 6,153 | cpp | C++ | framework/Input/Sources/ModuleInput.cpp | Daniel-Mietchen/kigs | 92ab6deaf3e947465781a400c5a791ee171876c8 | [
"MIT"
] | null | null | null | framework/Input/Sources/ModuleInput.cpp | Daniel-Mietchen/kigs | 92ab6deaf3e947465781a400c5a791ee171876c8 | [
"MIT"
] | null | null | null | framework/Input/Sources/ModuleInput.cpp | Daniel-Mietchen/kigs | 92ab6deaf3e947465781a400c5a791ee171876c8 | [
"MIT"
] | null | null | null | #include "PrecompiledHeaders.h"
#include "ModuleInput.h"
#include "InputDevice.h"
#include "Timer.h"
#include "Core.h"
#include "Window.h"
#include "TouchInputEventManager.h"
#ifdef WIN32
#define USE_VIRTUAL_SENSORS 1
#else
#define USE_VIRTUAL_SENSORS 0
#endif
#if USE_VIRTUAL_SENSORS
#include "VirtualSensors.h"
#endif
IMPLEMENT_CLASS_INFO(ModuleInput)
IMPLEMENT_CONSTRUCTOR(ModuleInput)
{
}
void ModuleInput::Init(KigsCore* core, const kstl::vector<CoreModifiableAttribute*>* params)
{
BaseInit(core, "Input", params);
DECLARE_FULL_CLASS_INFO(core, TouchInputEventManager, TouchInputEventManager, Input);
core->RegisterMainModuleList(this, InputModuleCoreIndex);
#ifdef _KIGS_ONLY_STATIC_LIB_
RegisterDynamic(PlatformInputModuleInit(core, params));
#endif
#if USE_VIRTUAL_SENSORS
DECLARE_FULL_CLASS_INFO(core, VirtualGyroscope, GyroscopeDevice, ModuleInput);
DECLARE_FULL_CLASS_INFO(core, VirtualAccelerometer, AccelerometerDevice, ModuleInput);
CMSP cm = KigsCore::GetInstanceOf("virtual_gyroscope", "GyroscopeDevice");
cm->GetRef();
cm = KigsCore::GetInstanceOf("virtual_accelerometer", "AccelerometerDevice");
cm->GetRef();
#endif
// search for mouse, joystick and keyboard
kstl::vector<CMSP> instances;
kstl::vector<CMSP>::iterator it;
instances = GetInstances("MouseDevice");
it = instances.begin();
if (it != instances.end())
{
mMouse = (MouseDevice*)(*it).get();
}
instances = GetInstances("SpatialInteractionDevice");
it = instances.begin();
if (it != instances.end())
{
mSpatialInteraction = (SpatialInteractionDevice*)(*it).get();
}
instances = GetInstances("MultiTouchDevice");
it = instances.begin();
if (it != instances.end())
{
mMultiTouch = (MultiTouchDevice*)(*it).get();
}
instances = GetInstances("AccelerometerDevice");
it = instances.begin();
if (it != instances.end())
{
mAccelerometer = (AccelerometerDevice*)(*it).get();
}
instances = GetInstances("GyroscopeDevice");
it = instances.begin();
if (it != instances.end())
{
mGyroscope = (GyroscopeDevice*)(*it).get();
}
instances = GetInstances("GeolocationDevice");
it = instances.begin();
if (it != instances.end())
{
mGeolocation = (GeolocationDevice*)(*it).get();
}
instances = GetInstances("CompassDevice");
it = instances.begin();
if (it != instances.end())
{
mCompass = (CompassDevice*)(*it).get();
}
instances = GetInstances("KeyboardDevice");
it = instances.begin();
if (it != instances.end())
{
mKeyboard = (KeyboardDevice*)(*it).get();
}
instances = GetInstances("JoystickDevice");
if (instances.size())
{
mJoysticks.resize(instances.size());
}
int index = 0;
for (it = instances.begin(); it != instances.end(); it++)
{
mJoysticks[index++] = (JoystickDevice*)(*it).get();
}
// create TouchInputEventManager
mTouchManager = KigsCore::GetInstanceOf("toucheventmanager", "TouchInputEventManager");
mTouchManager->Init();
}
void ModuleInput::Close()
{
#if USE_VIRTUAL_SENSORS
kstl::vector<CMSP> L_instances= CoreModifiable::GetInstancesByName("GyroscopeDevice", "virtual_gyroscope");
auto itr = L_instances.begin();
auto end = L_instances.end();
for (; itr != end; ++itr)
(*itr)->Destroy();
L_instances = CoreModifiable::GetInstancesByName("AccelerometerDevice", "virtual_accelerometer");
itr = L_instances.begin();
end = L_instances.end();
for(;itr!=end;++itr)
(*itr)->Destroy();
#endif
BaseClose();
}
void ModuleInput::Update(const Timer& timer, void* addParam)
{
BaseUpdate(timer, addParam);
kstl::list<WindowClick*>::iterator it;
for (it = mActiveWindows.begin(); it != mActiveWindows.end(); ++it)
{
WindowClick* theWC = (WindowClick*)*it;
theWC->update();
}
mTouchManager->CallUpdate(timer, addParam);
}
JoystickDevice* ModuleInput::GetJoystick(int index)
{
return mJoysticks[index];
}
void ModuleInput::WindowClickEvent(CoreModifiable *w, int buttonId, kfloat X, kfloat Y, bool isDown)
{
ModuleInput* theModuleInput = (ModuleInput*)KigsCore::Instance()->GetModule("ModuleInput");
WindowClick * lClick = theModuleInput->getWindowClick(w);
if (lClick)
lClick->setPos(buttonId, X, Y);
else
{
lClick = new WindowClick(w);
lClick->setPos(buttonId, X, Y);
theModuleInput->addWindowClick(lClick);
}
}
void ModuleInput::WindowDestroyEvent(CoreModifiable *w)
{
ModuleInput* theModuleInput = (ModuleInput*)KigsCore::Instance()->GetModule("ModuleInput");
WindowClick * lClick = theModuleInput->getWindowClick(w);
if (lClick)
theModuleInput->removeWindowClick(lClick);
}
bool ModuleInput::getActiveWindowPos(CoreModifiable *w, MouseDevice::MOUSE_BUTTONS buttonId, kfloat &X, kfloat &Y)
{
WindowClick *lClick = getWindowClick(w);
if (lClick)
lClick->getPos(buttonId, X, Y);
else
return false;
return true;
}
bool ModuleInput::addItem(const CMSP& item, ItemPosition pos DECLARE_LINK_NAME)
{
if (item->isSubType("Window"))
{
Window* lwindow = ((Window*)item.get());
lwindow->SetClickCallback(ModuleInput::WindowClickEvent);
lwindow->SetDestroyCallback(ModuleInput::WindowDestroyEvent);
}
return ModuleBase::addItem(item, pos PASS_LINK_NAME(linkName));
}
void ModuleInput::registerTouchEvent(CoreModifiable* item, const kstl::string& calledMethod, const kstl::string& eventName, unsigned int EmptyFlag)
{
InputEventType toregister;
bool eventFound = false;
if (eventName == "Click")
{
toregister = Click;
eventFound = true;
}
else if (eventName == "Swipe")
{
toregister = Swipe;
eventFound = true;
}
else if (eventName == "Pinch")
{
toregister = Pinch;
eventFound = true;
}
else if (eventName == "Scroll")
{
toregister = Scroll;
eventFound = true;
}
else if (eventName == "DragAndDrop")
{
toregister = DragAndDrop;
eventFound = true;
}
else if (eventName == "DirectTouch")
{
toregister = DirectTouch;
eventFound = true;
}
else
{
// check if it's an int (event id)
int result;
int test = sscanf(eventName.c_str(), "%d", &result);
if (test)
{
toregister = (InputEventType)result;
eventFound = true;
}
}
if(eventFound)
getTouchManager()->registerEvent(item, calledMethod, toregister, (InputEventManagementFlag)EmptyFlag);
}
| 23.484733 | 147 | 0.715586 | [
"vector"
] |
30cf783542b9044ad61b1c94f652ef4e848daff6 | 12,892 | cc | C++ | omd/versions/1.2.8p15.cre/share/check_mk/agents/windows/PerfCounterPdh.cc | NCAR/spol-nagios | 4f88bef953983050bc6568d3f1027615fbe223fb | [
"BSD-3-Clause"
] | null | null | null | omd/versions/1.2.8p15.cre/share/check_mk/agents/windows/PerfCounterPdh.cc | NCAR/spol-nagios | 4f88bef953983050bc6568d3f1027615fbe223fb | [
"BSD-3-Clause"
] | null | null | null | omd/versions/1.2.8p15.cre/share/check_mk/agents/windows/PerfCounterPdh.cc | NCAR/spol-nagios | 4f88bef953983050bc6568d3f1027615fbe223fb | [
"BSD-3-Clause"
] | null | null | null | // +------------------------------------------------------------------+
// | ____ _ _ __ __ _ __ |
// | / ___| |__ ___ ___| | __ | \/ | |/ / |
// | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
// | | |___| | | | __/ (__| < | | | | . \ |
// | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
// | |
// | Copyright Mathias Kettner 2015 mk@mathias-kettner.de |
// +------------------------------------------------------------------+
//
// This file is part of Check_MK.
// The official homepage is at http://mathias-kettner.de/check_mk.
//
// check_mk 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 in version 2. check_mk is distributed
// in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
// out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// PARTICULAR PURPOSE. See the GNU General Public License for more de-
// ails. You should have received a copy of the GNU General Public
// License along with GNU Make; see the file COPYING. If not, write
// to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA.
#include "PerfCounterPdh.h"
#include <pdhmsg.h>
#include <stdio.h>
#include <windows.h>
#include <sstream>
#include "stringutil.h"
#include <ctime>
// retrieve the next line from a multi-sz registry key
LPCWSTR get_next_multi_sz(const std::vector<wchar_t> &data, size_t &offset) {
LPCWSTR next = &data[offset];
size_t len = wcslen(next);
if ((len == 0) || (offset + len > data.size())) {
// the second condition would only happen with an invalid registry value
// but that's not
// unheard of
return NULL;
} else {
offset += len + 1;
return next;
}
}
std::vector<wchar_t> retrieve_perf_data(LPCWSTR name, bool local) {
std::vector<wchar_t> result;
DWORD counters_size = 0;
HKEY key = local ? HKEY_PERFORMANCE_NLSTEXT : HKEY_PERFORMANCE_TEXT;
// preflight
::RegQueryValueExW(key, name, NULL, NULL, (LPBYTE)&result[0],
&counters_size);
result.resize(counters_size);
// actual read op
::RegQueryValueExW(key, name, NULL, NULL, (LPBYTE)&result[0],
&counters_size);
return result;
}
std::map<int, std::wstring> perf_id_map(bool local) {
std::vector<wchar_t> names = retrieve_perf_data(L"Counter", local);
std::map<int, std::wstring> result;
size_t offset = 0;
for (;;) {
LPCWSTR id = get_next_multi_sz(names, offset);
LPCWSTR name = get_next_multi_sz(names, offset);
if ((id == NULL) || (name == NULL)) {
break;
}
result[wcstol(id, NULL, 10)] = name;
}
return result;
}
std::map<std::wstring, int> perf_name_map(bool local) {
std::vector<wchar_t> names = retrieve_perf_data(L"Counter", local);
std::map<std::wstring, int> result;
size_t offset = 0;
for (;;) {
LPCWSTR id = get_next_multi_sz(names, offset);
LPCWSTR name = get_next_multi_sz(names, offset);
if ((id == NULL) || (name == NULL)) {
break;
}
result[name] = wcstol(id, NULL, 10);
}
return result;
}
std::wstring resolve_perf_id(int id) {
std::wstring result;
DWORD buffer_size = 0;
PDH_STATUS status =
PdhLookupPerfNameByIndexW(NULL, id, &result[0], &buffer_size);
if ((DWORD)status == PDH_MORE_DATA) {
result.resize(buffer_size);
status = PdhLookupPerfNameByIndexW(NULL, id, &result[0], &buffer_size);
}
if ((DWORD)status != ERROR_SUCCESS) {
throw std::runtime_error(get_win_error_as_string(status));
}
return result;
}
PerfCounterQuery::PerfCounterQuery() {
PDH_STATUS status = PdhOpenQuery(nullptr, 0, &_query);
if (status != ERROR_SUCCESS) {
std::ostringstream err;
err << "open query failed with 0x" << std::hex << status;
throw std::runtime_error(err.str());
}
_perf_name_index = perf_name_map(false);
std::map<int, std::wstring> local_perf_names = perf_id_map(true);
for (const auto &name_id : _perf_name_index) {
auto local_iter = local_perf_names.find(name_id.second);
if (local_iter != local_perf_names.end()) {
_translation_map[local_iter->second] = name_id.first;
}
}
}
PerfCounterQuery::~PerfCounterQuery() { PdhCloseQuery(_query); }
HCOUNTER PerfCounterQuery::addCounter(const std::wstring &path) {
auto iter = _counter.find(path);
if (iter != _counter.end()) {
return iter->second;
} else {
HCOUNTER counter;
PDH_STATUS status = PdhAddCounterW(_query, path.c_str(), 0, &counter);
if (status != ERROR_SUCCESS) {
printf("add counter status: %lx\n", (DWORD)status);
throw std::runtime_error(get_win_error_as_string(status));
}
return counter;
}
}
std::wstring PerfCounterQuery::makePath(const std::wstring &object,
const std::wstring instance,
const std::wstring &counter) {
std::wostringstream result;
result << "\\" << object << "(" << instance << ")"
<< "\\" << counter;
return result.str();
}
std::pair<StringList, StringList> PerfCounterQuery::enumerateObject(
LPCWSTR object_name_in) const {
std::wstring counterlist_buffer;
std::wstring instancelist_buffer;
DWORD counterlist_size = 0;
DWORD instancelist_size = 0;
std::wstring object_name(object_name_in);
PDH_STATUS status = PdhEnumObjectItemsW(
NULL, NULL, object_name.c_str(), &counterlist_buffer[0],
&counterlist_size, &instancelist_buffer[0], &instancelist_size,
PERF_DETAIL_WIZARD, 0);
if ((DWORD)status == PDH_CSTATUS_NO_OBJECT) {
// maybe the name is in english?
auto iter = _perf_name_index.find(object_name);
if (iter != _perf_name_index.end()) {
// bingo. resolve that name to local language
// and continue with that
object_name = resolve_perf_id(iter->second);
status = PdhEnumObjectItemsW(
NULL, NULL, object_name.c_str(), &counterlist_buffer[0],
&counterlist_size, &instancelist_buffer[0], &instancelist_size,
PERF_DETAIL_WIZARD, 0);
}
}
if ((DWORD)status == ERROR_SUCCESS) {
// our buffer size was 0. If the call does NOT ask for more buffer,
// there obviously is no such performance counter
return std::make_pair(StringList(), StringList());
} else if ((DWORD)status != PDH_MORE_DATA) {
throw std::runtime_error(get_win_error_as_string(status));
}
// Allocate the buffers and try the call again.
counterlist_buffer.resize(counterlist_size);
instancelist_buffer.resize(instancelist_size);
status = PdhEnumObjectItemsW(NULL, NULL, object_name.c_str(),
&counterlist_buffer[0], &counterlist_size,
&instancelist_buffer[0], &instancelist_size,
PERF_DETAIL_WIZARD, 0);
if (status != ERROR_SUCCESS) {
throw std::runtime_error(get_win_error_as_string(status));
}
StringList counterlist;
// the buffer contains a zero-terminted list of zero-terminated strings
for (LPCWSTR iter = &counterlist_buffer[0]; *iter != L'\0';
iter += wcslen(iter) + 1) {
counterlist.push_back(iter);
/* auto translation = _translation_map.find(iter);
if (translation != _translation_map.end()) {
counterlist.push_back(translation->second);
} else {
counterlist.push_back(iter);
}*/
}
StringList instancelist;
for (LPCWSTR iter = &instancelist_buffer[0]; *iter != L'\0';
iter += wcslen(iter) + 1) {
instancelist.push_back(iter);
}
return std::make_pair(counterlist, instancelist);
}
StringList PerfCounterQuery::enumerateObjects() const {
std::vector<wchar_t> buffer;
DWORD buffer_size = 0;
// this call can take several seconds, as it refreshes the whole list of
// performance counters
PDH_STATUS status = PdhEnumObjectsW(NULL, NULL, &buffer[0], &buffer_size,
PERF_DETAIL_WIZARD, TRUE);
if ((DWORD)status == PDH_MORE_DATA) {
// documentation says to add 1 to the buffer size on winxp.
++buffer_size;
buffer.resize(buffer_size);
status = PdhEnumObjectsW(NULL, NULL, &buffer[0], &buffer_size,
PERF_DETAIL_WIZARD, FALSE);
}
StringList result;
if (status == ERROR_SUCCESS) {
size_t offset = 0;
for (;;) {
LPCWSTR name = get_next_multi_sz(buffer, offset);
if (name == nullptr) {
break;
} else {
result.push_back(name);
}
}
return result;
} else {
throw std::runtime_error(get_win_error_as_string(status));
}
}
void PerfCounterQuery::execute() {
PDH_STATUS status = PdhCollectQueryData(_query);
if (((DWORD)status != ERROR_SUCCESS) &&
((DWORD)status != PDH_NO_MORE_DATA)) {
printf("query status: %x\n", (DWORD)status);
throw std::runtime_error(get_win_error_as_string(status));
}
}
std::wstring PerfCounterQuery::counterValue(LPCWSTR name) const {
auto iter = _counter.find(name);
if (iter == _counter.end()) {
throw std::runtime_error("invalid counter name");
}
return counterValue(iter->second);
}
std::wstring type_name(DWORD type_id) {
switch (type_id) {
case PERF_COUNTER_COUNTER:
return L"counter";
case PERF_COUNTER_TIMER:
return L"timer";
case PERF_COUNTER_QUEUELEN_TYPE:
return L"queuelen_type";
case PERF_COUNTER_BULK_COUNT:
return L"bulk_count";
case PERF_COUNTER_TEXT:
return L"text";
case PERF_COUNTER_RAWCOUNT:
return L"rawcount";
case PERF_COUNTER_LARGE_RAWCOUNT:
return L"large_rawcount";
case PERF_COUNTER_RAWCOUNT_HEX:
return L"rawcount_hex";
case PERF_COUNTER_LARGE_RAWCOUNT_HEX:
return L"large_rawcount_HEX";
case PERF_SAMPLE_FRACTION:
return L"sample_fraction";
case PERF_SAMPLE_COUNTER:
return L"sample_counter";
case PERF_COUNTER_NODATA:
return L"nodata";
case PERF_COUNTER_TIMER_INV:
return L"timer_inv";
case PERF_SAMPLE_BASE:
return L"sample_base";
case PERF_AVERAGE_TIMER:
return L"average_timer";
case PERF_AVERAGE_BASE:
return L"average_base";
case PERF_AVERAGE_BULK:
return L"average_bulk";
case PERF_100NSEC_TIMER:
return L"100nsec_timer";
case PERF_100NSEC_TIMER_INV:
return L"100nsec_timer_inv";
case PERF_COUNTER_MULTI_TIMER:
return L"multi_timer";
case PERF_COUNTER_MULTI_TIMER_INV:
return L"multi_timer_inV";
case PERF_COUNTER_MULTI_BASE:
return L"multi_base";
case PERF_100NSEC_MULTI_TIMER:
return L"100nsec_multi_timer";
case PERF_100NSEC_MULTI_TIMER_INV:
return L"100nsec_multi_timer_inV";
case PERF_RAW_FRACTION:
return L"raw_fraction";
case PERF_RAW_BASE:
return L"raw_base";
case PERF_ELAPSED_TIME:
return L"elapsed_time";
default: {
std::wostringstream str;
str << L"type(" << std::hex << type_id << L")";
return str.str();
} break;
}
}
std::wstring PerfCounterQuery::counterValue(HCOUNTER counter) const {
DWORD type;
PDH_RAW_COUNTER value;
PDH_STATUS status = PdhGetRawCounterValue(counter, &type, &value);
if (status != ERROR_SUCCESS) {
throw std::runtime_error(get_win_error_as_string(status));
}
std::wostringstream str;
str << value.FirstValue << "," << value.SecondValue << ","
<< value.MultiCount << "," << type_name(type);
return str.str();
}
std::wstring PerfCounterQuery::trans(const std::wstring &local_name) const {
auto iter = _translation_map.find(local_name);
if (iter != _translation_map.end()) {
return iter->second;
} else {
return local_name;
}
}
| 33.485714 | 80 | 0.592616 | [
"object",
"vector"
] |
30d0a433ac0fcf6ac1b707342f9cc87877f07034 | 5,694 | cpp | C++ | cpp/knn/patch.cpp | breadcrumbbuilds/bcws-psu-research | e541ffc050807186160a6b8d7cc6ac78fc9f3ddc | [
"Apache-2.0"
] | 6 | 2019-10-23T19:02:04.000Z | 2021-06-23T22:51:25.000Z | cpp/knn/patch.cpp | breadcrumbbuilds/bcws-psu-research | e541ffc050807186160a6b8d7cc6ac78fc9f3ddc | [
"Apache-2.0"
] | 142 | 2020-02-08T00:37:46.000Z | 2021-12-12T21:49:23.000Z | cpp/knn/patch.cpp | breadcrumbbuilds/bcws-psu-research | e541ffc050807186160a6b8d7cc6ac78fc9f3ddc | [
"Apache-2.0"
] | 4 | 2019-12-11T00:45:37.000Z | 2021-11-22T08:54:59.000Z | /* patch.cpp: tiling processing to feed into an ML-type code
- cut image data (and ground reference data) into small patches (nonoverlapping at this point)
- use majority voting scheme to assign label to each patch
- if patches are too large relative to the homogeneous areas of a patch, results will suffer
Assume this is the portion of the data to fit the "model" on: kinda the image data input here "is" the model..
*/
#include"../misc.h"
size_t nrow, ncol, nband, np; // image attributes
void accumulate(map<float, size_t> &m, float key){
if(m.count(key) < 1) m[key] = 0;
m[key] += 1; // histogram on $\mathbb{R}^1
}
// could add "stride" parameter later (increase patches towards moving window)
int main(int argc, char ** argv){
if(argc < 4) err("patch [input envi-type4 floating point stack bsq with gr] [# of groundref classes at end] [patch size]\n");
str bfn(argv[1]);
str hfn(hdr_fn(bfn));
size_t ps, nref;
hread(hfn, nrow, ncol, nband);
printf("nrow %zu ncol %zu nband %zu\n", nrow, ncol, nband);
float * dat = bread(bfn, nrow, ncol, nband); // read input data
np = nrow * ncol; // number of pixels
ps = atoi(argv[3]); // patch width / length: square patch
nref = atoi(argv[2]); // number of groundref classes one-hot encoded
size_t i, j, m, n;
if(ps >= nrow || ps >= ncol) err("patch size too big");
if(nref >= nband) err("check number of groundref bands");
size_t di, dj, k, ci;
size_t nb = nband - nref; // image data bands: total image bands, less # of ref bands
size_t floats_per_patch = ps * ps * nb; // floats per patch (image data)
float * patch = falloc(sizeof(float) * floats_per_patch);
int_write(ps, bfn + str("_ps"));
int_write(nb, bfn + str("_nb"));
// scale data into [0,1] before considering patches
float * d_min = falloc(nb);
float * d_max = falloc(nb);
float * r_k = falloc(nb);
for0(i, nb){
d_min[i] = FLT_MAX;
d_max[i] = FLT_MIN;
}
float d;
for0(i, np){
for0(k, nb){
d = dat[(np * k) + i];
if(d < d_min[k]) d_min[k] = d;
if(d > d_max[k]) d_max[k] = d;
}
}
for0(k, nb){
r_k[k] = 1. / (d_max[k] - d_min[k]);
printf("r_k[%zu] %f\n", k, r_k[k]);
}
printf("\n");
for0(i, np){
for0(k, nb){
m = (k * np) + i;
dat[m] = r_k[k] * (dat[m] - d_min[k]);
}
}
FILE * f_patch = wopen((bfn + str("_patch")).c_str()); // patch data
FILE * f_patch_i = wopen((bfn + str("_patch_i")).c_str()); // start row for patch
FILE * f_patch_j = wopen((bfn + str("_patch_j")).c_str()); // start col for patch
FILE * f_patch_label = (nref > 0) ? wopen((bfn + str("_patch_label")).c_str()) : NULL; // patch label
float max_k;
int no_match;
size_t truthed = 0;
size_t n_patches = 0;
size_t nontruthed = 0;
size_t max_c, n_match;
map<float, size_t> count; // count labels on a patch
// band-interleave-by-pixel, by patch!
for(i = 0; i <= nrow - (nrow % ps + ps); i += ps){
// start row for patch (stride parameter would be the step for this loop)
for(j = 0; j <= ncol - (ncol % ps + ps); j += ps){
ci = 0; // j is start col for patch
for0(di, ps){
m = i + di;
for0(dj, ps){
n = j + dj; // extract data on a patch (left->right to linear order)
for0(k, nb) patch[ci ++] = dat[(k * nrow * ncol) + (m * ncol) + n];
}
}
if(ci != ps * ps * nb) err("patch element count mismatch");
fwrite(&i, sizeof(size_t), 1, f_patch_i);
fwrite(&j, sizeof(size_t), 1, f_patch_j);
fwrite(patch, sizeof(float), floats_per_patch, f_patch);
if(nref > 0){
count.clear(); // count labels on each patch: mass for each label on the patch
for0(di, ps){
m = (i + di) * ncol;
for0(dj, ps){
n = (j + dj) + m;
no_match = true;
for0(k, nref){
if(dat[((k + nb) * np) + n] == 1.){
no_match = false;
accumulate(count, k + 1);
}
}
if(no_match) accumulate(count, 0); // default to 0 / null label
}
}
max_c = 0;
max_k = 0.;
map<float, size_t>::iterator it; // lazy match
for(it = count.begin(); it != count.end(); it++){
if(it->first > 0 && it->second > max_c){
max_c = it->second; // no leading class: doesn't count
max_k = it->first;
}
}
n_match = 0;
for(it = count.begin(); it != count.end(); it++) if(it->second == max_c) n_match ++;
if(max_c > 0){
truthed ++;
cout << count << " max_c " << max_c << endl;
if(n_match > 1) printf("\tWarning: patch had competing classes\n");
}
else nontruthed ++;
fwrite(&max_k, sizeof(float), 1, f_patch_label); // write patch label if there's groundref data
}
n_patches += 1;
}
}
printf("\n");
hread(hfn, nrow, ncol, nband);
printf("nrow %zu ncol %zu nband %zu\n", nrow, ncol, nband);
printf(" nwin: %zu\n", (size_t)ps);
printf(" image pixels: %zu\n", np);
printf(" pix per patch: %zu\n",(size_t)(ps * ps));
printf(" floats /patch: %zu\n", floats_per_patch);
printf(" est. patches:%zu\n", np / (ps * ps));
printf(" n_patches %zu\n", n_patches);
printf(" total patches: %zu\n", truthed + nontruthed);
printf(" truthed: %zu\t\t[%.2f / 100]\n", truthed, 100. * (float)(truthed) / ((float)(truthed + nontruthed)));
printf(" nontruthed: %zu\n", nontruthed);
fclose(f_patch); // patch data
fclose(f_patch_i); // patch start i
fclose(f_patch_j); // patch start j
if(nref > 0) fclose(f_patch_label); // patch label
free(patch);
return 0;
}
| 33.104651 | 127 | 0.567615 | [
"model"
] |
30d4c27f762d9e54cc55e5a32684cd5f15db908e | 2,150 | cpp | C++ | GeeksForGeeks/C Plus Plus/Convert_normal_BST_to_Balanced_BST.cpp | ankit-sr/Competitive-Programming | 3397b313b80a32a47cfe224426a6e9c7cf05dec2 | [
"MIT"
] | 4 | 2021-06-19T14:15:34.000Z | 2021-06-21T13:53:53.000Z | GeeksForGeeks/C Plus Plus/Convert_normal_BST_to_Balanced_BST.cpp | ankit-sr/Competitive-Programming | 3397b313b80a32a47cfe224426a6e9c7cf05dec2 | [
"MIT"
] | 2 | 2021-07-02T12:41:06.000Z | 2021-07-12T09:37:50.000Z | GeeksForGeeks/C Plus Plus/Convert_normal_BST_to_Balanced_BST.cpp | ankit-sr/Competitive-Programming | 3397b313b80a32a47cfe224426a6e9c7cf05dec2 | [
"MIT"
] | 3 | 2021-06-19T15:19:20.000Z | 2021-07-02T17:24:51.000Z | /*
Problem Statement:
-----------------
Given a BST (Binary Search Tree) that may be unbalanced, convert it into a balanced BST that has minimum possible height.
Examples :
Input:
30
/
20
/
10
Output:
20
/ \
10 30
Input:
4
/
3
/
2
/
1
Output:
3 3 2
/ \ / \ / \
1 4 OR 2 4 OR 1 3 OR ..
\ / \
2 1 4
Input:
4
/ \
3 5
/ \
2 6
/ \
1 7
Output:
4
/ \
2 6
/ \ / \
1 3 5 7
*/
// Link --> https://www.geeksforgeeks.org/convert-normal-bst-balanced-bst/
// Code:
#include <bits/stdc++.h>
using namespace std;
struct Node
{
int data;
struct Node *left, *right;
};
Node *create()
{
int data;
Node *tree;
tree = new Node;
cout << "\nEnter data to be inserted or type -1 : ";
cin >> data;
if (data == -1)
return 0;
tree->data = data;
cout << "Enter left child of " << data;
tree->left = create();
cout << "Enter right child of " << data;
tree->right = create();
return tree;
}
vector<int> v;
void preorder(Node *root)
{
if (root == NULL)
return;
cout << root->data << " ";
// To store the data.
v.push_back(root->data);
preorder(root->left);
preorder(root->right);
}
Node *Balanced_BST(int start, int end)
{
if (start > end)
return NULL;
int mid = (start + end) / 2;
Node *root = new Node;
root->data = v[mid];
root->left = Balanced_BST(start, mid - 1);
root->right = Balanced_BST(mid + 1, end);
return root;
}
int main()
{
Node *root = NULL;
root = create();
cout << "Preorder traversal of the tree is : ";
preorder(root);
// We will sort the array to create the balanced BST.
sort(v.begin(), v.end());
root = Balanced_BST(0, v.size() - 1);
cout << "\nPreorder traversal of the tree after balancing : ";
preorder(root);
return 0;
}
| 16.666667 | 121 | 0.472558 | [
"vector"
] |
30d999562bf1bf1ff492c859b4a2122ccbefb7cb | 659 | cpp | C++ | tatu2/container/any.cpp | AxlidinovJ/masalalar_C | ca48c0db29155016a729fbe23030d4a638175d9b | [
"MIT"
] | null | null | null | tatu2/container/any.cpp | AxlidinovJ/masalalar_C | ca48c0db29155016a729fbe23030d4a638175d9b | [
"MIT"
] | null | null | null | tatu2/container/any.cpp | AxlidinovJ/masalalar_C | ca48c0db29155016a729fbe23030d4a638175d9b | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
#include <algorithm>
#include <time.h>
using namespace std;
int main(){
vector<int> royxat;
vector<int> royxat2;
srand(time(0));
int n;
cout<<"n="; cin>>n;
for(int i=1; i<=n; i++){
royxat.push_back(10-rand()%30);
}
for(auto it = royxat.begin(); it!=royxat.end(); it++){
cout<<*it<<" ";
if(*it>0){
royxat2.push_back(*it);
}
}
cout<<"\n\n";
if(any_of(royxat.begin(), royxat.end(),[](int k){return k%5==0;})){
cout<<"5 ga karralilar bor";
}else{
cout<<"Mavjud emas";
}
cout<<"\n\nFaqat musbatlar";
for(auto it = royxat2.begin(); it!=royxat2.end(); it++){
cout<<*it<<" ";
}
} | 16.475 | 68 | 0.570561 | [
"vector"
] |
30dab073d8224066502f59a8cae866946a5bdfdf | 2,314 | cpp | C++ | 423_433_449_450_Shanti_Stupa_Simulation/ModelLoading/Textures.cpp | pradhanrajin42/Computer-Graphics-074-BEX | 4b52c85cc97fe9c951e517ef7e8d917281705aa8 | [
"MIT"
] | 5 | 2020-03-06T10:01:28.000Z | 2020-05-06T07:57:20.000Z | 423_433_449_450_Shanti_Stupa_Simulation/ModelLoading/Textures.cpp | pradhanrajin42/Computer-Graphics-074-BEX | 4b52c85cc97fe9c951e517ef7e8d917281705aa8 | [
"MIT"
] | 1 | 2020-03-06T02:51:50.000Z | 2020-03-06T04:33:30.000Z | 423_433_449_450_Shanti_Stupa_Simulation/ModelLoading/Textures.cpp | pradhanrajin42/Computer-Graphics-074-BEX | 4b52c85cc97fe9c951e517ef7e8d917281705aa8 | [
"MIT"
] | 29 | 2020-03-05T15:15:24.000Z | 2021-07-21T07:05:00.000Z | #include "GL\glew.h"
#include "Textures.h"
#include "src\vendor\stb_image\stb_image.h"
Textures::Textures(const std::string & filePath, bool transparent)
{
stbi_set_flip_vertically_on_load(1);
data = stbi_load(filePath.c_str(), &width, &height, &nrChannels, 0);
if (!data) std::cout << "Failed to Load Texture" << std::endl;
glGenTextures(1, &id);
glBindTexture(GL_TEXTURE_2D, id);
glTextureParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTextureParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (!transparent)glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
}
Textures::Textures(const std::vector<std::string> faces, bool transparent)
{
stbi_set_flip_vertically_on_load(1);
stbi_set_flip_vertically_on_load(false);
glGenTextures(1, &id);
glBindTexture(GL_TEXTURE_CUBE_MAP, id);
for (unsigned int i = 0; i < faces.size(); i++) {
data = stbi_load(faces[i].c_str(), &width, &height, &nrChannels, 0);
if (data) {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data
);
stbi_image_free(data);
}
else {
std::cout << "Cubemap texture failed to load at path: " << faces[i].c_str() << std::endl;
stbi_image_free(data);
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
}
}
void Textures::bindTextures()
{
glBindTexture(GL_TEXTURE_2D, id);
}
void Textures::unBindTextures()
{
glBindTexture(GL_TEXTURE_2D, 0);
}
void Textures::bindCubeTextures()
{
glBindTexture(GL_TEXTURE_CUBE_MAP, id);
}
void Textures::unBindCubeTextures()
{
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
}
Textures::~Textures()
{
stbi_image_free(data);
glDeleteTextures(1, &id);
}
| 31.27027 | 107 | 0.760588 | [
"vector"
] |
30e2dd4b663a351018b435a37be5a0588eb287a7 | 24,209 | cpp | C++ | src/server.cpp | ksatyaki/srnp | c876d0ceb4372e3739587a2c6d029b594d7d2ffa | [
"Unlicense"
] | 1 | 2019-10-14T15:45:39.000Z | 2019-10-14T15:45:39.000Z | src/server.cpp | ksatyaki/srnp | c876d0ceb4372e3739587a2c6d029b594d7d2ffa | [
"Unlicense"
] | null | null | null | src/server.cpp | ksatyaki/srnp | c876d0ceb4372e3739587a2c6d029b594d7d2ffa | [
"Unlicense"
] | null | null | null | /*
server.cpp
Copyright (C) 2015 Chittaranjan Srinivas Swaminathan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include "srnp/server.h"
namespace srnp
{
/** MASTERLINK CLASS **/
MasterLink::MasterLink(boost::asio::io_service& service, std::string master_ip, std::string master_port, boost::shared_ptr <ServerSession>& my_client_session, Server* server, int desired_owner_id):
socket_ (service),
my_client_session_ (my_client_session),
resolver_ (service),
master_ip_(master_ip),
master_port_(master_port)
{
tcp::resolver::query query(master_ip, master_port);
tcp::resolver::iterator endpoint_iterator_ = resolver_.resolve(query);
try {
//SRNP_PRINT_DEBUG << "HERE NOW!";
boost::asio::connect(socket_, endpoint_iterator_);
} catch (std::exception& ex) {
SRNP_PRINT_FATAL << "Exception when trying to connect to master: " << ex.what();
exit(0);
}
SRNP_PRINT_INFO << "Connected to master!\n";
indicatePresence(server, desired_owner_id);
// READ STUFF.
boost::asio::read (socket_, boost::asio::buffer(in_size_));
uint64_t data_size;
// Deserialize the length.
std::istringstream size_stream(std::string(in_size_.elems, in_size_.size()));
size_stream >> std::hex >> data_size;
boost::system::error_code error_co;
in_data_.resize(data_size);
boost::asio::read(socket_, boost::asio::buffer(in_data_), error_co);
// If we reach here, we are sure that we got a MasterMessage.
std::istringstream mm_stream(std::string(in_data_.data(), in_data_.size()));
boost::archive::text_iarchive header_archive(mm_stream);
//SRNP_PRINT_TRACE << "READ EVERTHING!";
header_archive >> mm_;
for(std::vector <ComponentInfo>::iterator iter = mm_.all_components.begin(); iter != mm_.all_components.end(); iter++)
{
//SRNP_PRINT_DEBUG << "[SERVER]: Adding these information";
//SRNP_PRINT_DEBUG << "[SERVER]: PORT: " << iter->port;
//SRNP_PRINT_DEBUG << "[SERVER]: OWNER: " << iter->owner;
//SRNP_PRINT_DEBUG << "[SERVER]: IP: " << iter->ip;
if(iter->ip.compare("127.0.0.1") == 0)
{
iter->ip = master_ip;
//SRNP_PRINT_DEBUG << "IP 127.0.0.1 should be changed to this: " << iter->ip;
}
}
server->owner() = mm_.owner;
//SRNP_PRINT_DEBUG << "[SERVER]: Owner ID: "<< server->owner();
}
void MasterLink::indicatePresence(Server* server, int desired_owner_id)
{
IndicatePresence indicatePresenceMsg;
if(desired_owner_id != -1)
{
indicatePresenceMsg.force_owner_id = true;
indicatePresenceMsg.owner_id = desired_owner_id;
}
// Calc port:
std::stringstream sss;
sss << server->getPort();
//SRNP_PRINT_DEBUG << "Port computed is: " << sss.str();
indicatePresenceMsg.port = sss.str();
// Serialize this message.
std::ostringstream indicate_msg_stream;
boost::archive::text_oarchive indicate_msg_archive (indicate_msg_stream);
indicate_msg_archive << indicatePresenceMsg;
std::string out_indicate_msg = indicate_msg_stream.str();
// SEND THE PORT WE ARE ON, FIRST. MOST IMPORTANT.
std::ostringstream size_stream;
size_stream << std::setw(sizeof(uint64_t)) << std::hex << out_indicate_msg.size();
std::string out_size = size_stream.str();
boost::system::error_code error_co;
boost::asio::write (socket_, boost::asio::buffer(out_size), error_co);
//SRNP_PRINT_DEBUG << "[MasterLink]: Writing port size to master_hub" << error_co.message();
boost::asio::write (socket_, boost::asio::buffer(out_indicate_msg), error_co);
//SRNP_PRINT_DEBUG << "[MasterLink]: Writing port to master_hub" << error_co.message();
}
void MasterLink::sendMMToOurClientAndWaitForUCMsg()
{
//SRNP_PRINT_TRACE << "\n!!!!!We are waiting!!!!!";
my_client_session_->sendMasterMsgToOurClient(mm_);
// Start listening for update components messages.
boost::asio::async_read(socket_, boost::asio::buffer(in_size_), boost::bind(&MasterLink::handleUpdateComponentsMsg, this, boost::asio::placeholders::error));
}
void MasterLink::handleUpdateComponentsMsg(const boost::system::error_code& e)
{
if(!e)
{
uint64_t data_size;
std::istringstream size_stream (std::string(in_size_.elems, in_size_.size()));
size_stream >> std::hex >> data_size;
in_data_.resize(data_size);
boost::system::error_code errore;
boost::asio::read(socket_, boost::asio::buffer(in_data_), errore);
//SRNP_PRINT_TRACE << "[Server]: Sync receive of UC message from MasterHub: " << errore.message();
std::istringstream uc_stream(std::string(in_data_.data(), in_data_.size()));
boost::archive::text_iarchive header_archive(uc_stream);
UpdateComponents uc;
header_archive >> uc;
//SRNP_PRINT_DEBUG << "[UpdateComponentsMsg]: IP: " << uc.component.ip;
//SRNP_PRINT_DEBUG << "[UpdateComponentsMsg]: OWNER: " << uc.component.owner;
//SRNP_PRINT_DEBUG << "[UpdateComponentsMsg]: PORT: " << uc.component.port;
if(uc.component.ip.compare("127.0.0.1") == 0)
{
uc.component.ip = master_ip_;
//SRNP_PRINT_DEBUG << "I changed ip to this: " << uc.component.ip;
}
my_client_session_->sendUpdateComponentsMsgToOurClient(uc);
boost::asio::async_read(socket_, boost::asio::buffer(in_size_), boost::bind(&MasterLink::handleUpdateComponentsMsg, this, boost::asio::placeholders::error));
}
else
{
SRNP_PRINT_FATAL << "Master seems disconnected! God we're in deadly peril.";
// Do something to attempt and reconnect.
}
}
/** SERVERSESSION CLASS **/
int ServerSession::session_counter = 0;
ServerSession::ServerSession (boost::asio::io_service& service, PairSpace& pair_space,
PairQueue& pair_queue, int& owner, Server* server) :
socket_ (service),
pair_queue_ (pair_queue),
pair_space_ (pair_space),
owner_ (owner),
server_ (server)
{
}
ServerSession::~ServerSession ()
{
socket_.close();
}
void ServerSession::handleReadHeaderSize (const boost::system::error_code& e)
{
//SRNP_PRINT_TRACE << "[In Server::handleReadHeaderSize]: We got error: " << e.message();
if(!e)
{
uint64_t header_size;
// Deserialize the length.
std::istringstream headersize_stream(std::string(in_header_size_buffer_.elems, sizeof(uint64_t)));
headersize_stream >> std::hex >> header_size;
//
in_header_buffer_.resize (header_size);
boost::asio::async_read(socket_, boost::asio::buffer(in_header_buffer_), boost::bind(&ServerSession::handleReadHeader, this, boost::asio::placeholders::error) );
}
else
{
ServerSession::session_counter--;
delete this;
}
}
void ServerSession::handleReadHeader (const boost::system::error_code& e)
{
//SRNP_PRINT_TRACE << "[Server::handleReadHeader]: We got error: " << e.message();
if(!e)
{
uint64_t data_size;
// Deserialize the length.
std::istringstream header_stream(std::string(in_header_buffer_.data(), in_header_buffer_.size()));
boost::archive::text_iarchive header_archive(header_stream);
MessageHeader header;
header_archive >> header;
//
if(header.type != MessageHeader::PAIR_NOCOPY)
in_data_buffer_.resize (header.length);
if(header.type == MessageHeader::PAIR_NOCOPY)
{
// CRITICAL SECTION!!!
pair_queue_.pair_queue_mutex.lock();
Pair tuple = pair_queue_.pair_queue.front();
pair_queue_.pair_queue.pop();
pair_queue_.pair_queue_mutex.unlock();
// Redundant. But no loss.
tuple.setOwner(owner_);
pair_space_.mutex.lock();
pair_space_.addPair(tuple);
Pair::ConstPtr pair_to_callback = Pair::ConstPtr(new Pair(*(pair_space_.getPairIteratorWithOwnerAndKey(tuple.getOwner(), tuple.getKey()))));
pair_space_.mutex.unlock();
if(pair_space_.u_callback_ != NULL) {
pair_space_.u_callback_(pair_to_callback);
}
if(pair_to_callback->callbacks_.size() != 0)
{
if(owner_ != -1) {
//SRNP_PRINT_DEBUG << "Making a simple callback";
for(std::map<CallbackHandle, Pair::CallbackFunction>::const_iterator i = pair_to_callback->callbacks_.begin(); i != pair_to_callback->callbacks_.end(); i++) {
i->second(pair_to_callback);
}
}
}
sendPairUpdateToClient(*pair_to_callback);
startReading();
}
else if(header.type == MessageHeader::PAIR_UPDATE)
{
boost::asio::async_read(socket_, boost::asio::buffer(in_data_buffer_), boost::bind(&ServerSession::handleReadPairUpdate, this, boost::asio::placeholders::error) );
}
else if(header.type == MessageHeader::SUBSCRIPTION)
{
boost::asio::async_read(socket_, boost::asio::buffer(in_data_buffer_), boost::bind(&ServerSession::handleReadSubscription, this, boost::asio::placeholders::error) );
}
else if(header.type == MessageHeader::PAIR)
{
boost::asio::async_read(socket_, boost::asio::buffer(in_data_buffer_), boost::bind(&ServerSession::handleReadPair, this, boost::asio::placeholders::error) );
}
}
else
{
ServerSession::session_counter--;
delete this;
}
}
void ServerSession::sendPairUpdateToClient(const Pair& to_up, int sub_only_one)
{
if(to_up.subscribers_.size() != 0)
{
std::string out_data_ = "";
// END
// Setup the message header.
srnp::MessageHeader header (0, srnp::MessageHeader::PAIR_UPDATE);
if(sub_only_one != -1)
{
//SRNP_PRINT_DEBUG << "Setting header to special value...";
header.type = MessageHeader::PAIR_UPDATE_2;
header.subscriber__ = sub_only_one;
}
// Serialize the data first so we know how large it is.
std::ostringstream header_archive_stream;
boost::archive::text_oarchive header_archive(header_archive_stream);
header_archive << header;
std::string out_header_ = header_archive_stream.str();
// END
// Prepare header length
std::ostringstream header_size_stream;
header_size_stream << std::setw(sizeof(uint64_t)) << std::hex << out_header_.size();
if (!header_size_stream || header_size_stream.str().size() != sizeof(uint64_t))
{
SRNP_PRINT_FATAL << "[sendPairUpdate]: Couldn't set stream size!";
}
std::string out_header_size_ = header_size_stream.str();
// CRITICAL SECTION!!!
// Be sure that once we have pushed into the queue, we should also send the data.
// Because if we don't, another thread could push to queue and send after we have
// just pushed. And on the receiving end, our member will be popped.
boost::mutex::scoped_lock scoped_mutex_lock(pair_queue_.pair_update_queue_mutex);
pair_queue_.pair_update_queue.push(to_up);
//SRNP_PRINT_DEBUG << "Queue push pui - pair update";
//SRNP_PRINT_DEBUG << "Writing Data To Client.";
boost::mutex::scoped_lock write_lock (server_->my_client_session()->socket_write_mutex);
server_->my_client_session()->sendDataToClient (out_header_size_, out_header_, out_data_);
//SRNP_PRINT_DEBUG << "SEND DATA pui - pair update";
}
//else
//SRNP_PRINT_DEBUG << "No Subscribers...";
}
bool ServerSession::sendDataToClient(const std::string& out_header_size, const std::string& out_header, const std::string& out_data)
{
boost::system::error_code error;
boost::asio::write(socket_, boost::asio::buffer(out_header_size), error);
//SRNP_PRINT_TRACE << "[sendPairUp]: Done writing header size. Error: " << error.message();
boost::asio::write(socket_, boost::asio::buffer(out_header), error);
//SRNP_PRINT_TRACE << "[sendPairUp]: Done writing header. Error: " << error.message();
if(out_data.size() != 0)
{
boost::asio::write(socket_, boost::asio::buffer(out_data), error);
//SRNP_PRINT_TRACE << "[sendPairUp]: Done writing data. Error: " << error.message();
}
if(!error)
return true;
else return false;
}
void ServerSession::handleReadPair(const boost::system::error_code& e)
{
if(!e)
{
std::istringstream data_stream (std::string(in_data_buffer_.data(), in_data_buffer_.size()));
boost::archive::text_iarchive data_archive(data_stream);
Pair tuple;
data_archive >> tuple;
tuple.setOwner(owner_);
pair_space_.mutex.lock();
pair_space_.addPair(tuple);
Pair::ConstPtr pair_to_callback = Pair::ConstPtr(new Pair(*(pair_space_.getPairIteratorWithOwnerAndKey(tuple.getOwner(), tuple.getKey()))));
pair_space_.mutex.unlock();
if(pair_space_.u_callback_ != NULL) {
pair_space_.u_callback_(pair_to_callback);
}
if(pair_to_callback->callbacks_.size() != 0)
{
if(owner_ != -1) {
//SRNP_PRINT_DEBUG << "Making a simple callback";
for(std::map<CallbackHandle, Pair::CallbackFunction>::const_iterator i = pair_to_callback->callbacks_.begin(); i != pair_to_callback->callbacks_.end(); i++) {
i->second(pair_to_callback);
}
}
}
sendPairUpdateToClient(*pair_to_callback);
startReading();
}
else
{
ServerSession::session_counter--;
delete this;
}
}
void ServerSession::handleReadSubscription(const boost::system::error_code& e)
{
if(!e)
{
std::istringstream data_stream (std::string(in_data_buffer_.data(), in_data_buffer_.size()));
boost::archive::text_iarchive data_archive(data_stream);
SubscriptionORCallback subscriptionORCallbackMsg;
data_archive >> subscriptionORCallbackMsg;
//SRNP_PRINT_DEBUG << "We got a subscription request: " << subscriptionORCallbackMsg.subscriber << ", " << subscriptionORCallbackMsg.key;
if(subscriptionORCallbackMsg.owner_id != this->owner_ && subscriptionORCallbackMsg.key.compare("*") != 0){
SRNP_PRINT_WARNING << "Got a subscription/cancellation message, not meant for us, but for: " << subscriptionORCallbackMsg.owner_id;
return;
}
if(subscriptionORCallbackMsg.subscriber == this->owner_) {
SRNP_PRINT_FATAL << "Got a subscription message from ourself!";
return;
}
boost::mutex::scoped_lock pair_space_lock(pair_space_.mutex);
//SRNP_PRINT_DEBUG << "Registering/cancelling a subscription on our own sweet pair.";
if(subscriptionORCallbackMsg.registering)
{
if(subscriptionORCallbackMsg.key.compare("*") == 0)
{
pair_space_.addSubscriptionToAll(subscriptionORCallbackMsg.subscriber);
const std::vector <Pair>& all_keys = pair_space_.getAllPairs();
for(std::vector <Pair>::const_iterator iter = all_keys.begin(); iter != all_keys.end(); iter++)
{
//SRNP_PRINT_DEBUG << "Sending a pair to subscriber fellow...";
if(iter->getOwner() == this->owner_)
{
//SRNP_PRINT_DEBUG << "Subscriber: " << subscriptionORCallbackMsg.subscriber;
this->server_->my_client_session()->sendPairUpdateToClient(*iter, subscriptionORCallbackMsg.subscriber);
}
}
}
else
{
pair_space_.addSubscription(subscriptionORCallbackMsg.owner_id, subscriptionORCallbackMsg.key, subscriptionORCallbackMsg.subscriber);
const std::vector <Pair>::const_iterator pairIterator = pair_space_.getPairIteratorWithOwnerAndKey(subscriptionORCallbackMsg.owner_id, subscriptionORCallbackMsg.key);
if(pairIterator->getType() != Pair::INVALID)
this->server_->my_client_session()->sendPairUpdateToClient(*pairIterator, subscriptionORCallbackMsg.subscriber);
else {
SRNP_PRINT_DEBUG << "We got subscription. But we don't send now. We haven't published it yet.";
}
}
}
else
{
if(subscriptionORCallbackMsg.key.compare("*") == 0)
pair_space_.removeSubscriptionToAll(subscriptionORCallbackMsg.subscriber);
else
pair_space_.removeSubscription(subscriptionORCallbackMsg.owner_id, subscriptionORCallbackMsg.key, subscriptionORCallbackMsg.subscriber);
}
startReading();
}
else
{
ServerSession::session_counter--;
delete this;
}
}
void ServerSession::handleReadPairUpdate (const boost::system::error_code& e)
{
if(!e)
{
std::istringstream data_stream (std::string(in_data_buffer_.data(), in_data_buffer_.size()));
boost::archive::text_iarchive data_archive(data_stream);
Pair tuple;
data_archive >> tuple;
//SRNP_PRINT_DEBUG << "We got a PairUpdate: " << tuple;
pair_space_.mutex.lock();
pair_space_.addPair(tuple);
Pair::ConstPtr pair_to_callback = Pair::ConstPtr(new Pair(*(pair_space_.getPairIteratorWithOwnerAndKey(tuple.getOwner(), tuple.getKey()))));
pair_space_.mutex.unlock();
if(pair_space_.u_callback_ != NULL) {
pair_space_.u_callback_(pair_to_callback);
}
if(pair_to_callback->callbacks_.size() != 0)
{
if(owner_ != -1) {
//SRNP_PRINT_DEBUG << "Making a simple callback";
for(std::map<CallbackHandle, Pair::CallbackFunction>::const_iterator i = pair_to_callback->callbacks_.begin(); i != pair_to_callback->callbacks_.end(); i++) {
i->second(pair_to_callback);
}
}
}
startReading();
}
else
{
ServerSession::session_counter--;
delete this;
}
}
void ServerSession::handleWrite (const boost::system::error_code& e)
{
if(!e)
{
boost::asio::async_read(socket_, boost::asio::buffer(in_header_buffer_), boost::bind(&ServerSession::handleReadHeader, this, boost::asio::placeholders::error) );
}
else
{
ServerSession::session_counter--;
delete this;
}
}
boost::system::error_code ServerSession::sendMasterMsgToOurClient(MasterMessage msg)
{
std::ostringstream msg_stream;
boost::archive::text_oarchive msg_archive(msg_stream);
msg_archive << msg;
out_msg_ = msg_stream.str();
// END
MessageHeader header;
header.length = out_msg_.size();
header.type = MessageHeader::MM;
std::ostringstream msg_header_stream;
boost::archive::text_oarchive msg_header_archive (msg_header_stream);
msg_header_archive << header;
out_header_ = msg_header_stream.str();
// Prepare header length
std::ostringstream size_stream;
size_stream << std::setw(sizeof(uint64_t)) << std::hex << out_header_.size();
if (!size_stream || size_stream.str().size() != sizeof(uint64_t))
{
// Something went wrong, inform the caller.
/*
boost::system::error_code error(boost::asio::error::invalid_argument);
socket_.io_service().post(boost::bind(handler, error));
return;
*/
}
out_size_ = size_stream.str();
boost::system::error_code error;
boost::asio::write(socket_, boost::asio::buffer(out_size_), error);
//SRNP_PRINT_DEBUG << "[MM SIZE]: Sent" << error.message();
boost::asio::write(socket_, boost::asio::buffer(out_header_), error);
//SRNP_PRINT_DEBUG << "[MM HEADER]: Sent" << error.message();
boost::asio::write(socket_, boost::asio::buffer(out_msg_), error);
//SRNP_PRINT_DEBUG << "[MM MSG]: Sent" << error.message();
return error;
}
boost::system::error_code ServerSession::sendUpdateComponentsMsgToOurClient(UpdateComponents msg)
{
// First Remove all subscriptions from this fellow.
if(msg.operation == UpdateComponents::REMOVE)
{
//pair_space_.mutexLock();
boost::mutex::scoped_lock pair_space_lock(pair_space_.mutex);
pair_space_.removeSubscriptionToAll(msg.component.owner);
//pair_space_.mutexUnlock();
}
std::ostringstream msg_stream;
boost::archive::text_oarchive msg_archive(msg_stream);
msg_archive << msg;
out_msg_ = msg_stream.str();
// END
MessageHeader header;
header.length = out_msg_.size();
header.type = MessageHeader::UC;
std::ostringstream msg_header_stream;
boost::archive::text_oarchive msg_header_archive (msg_header_stream);
msg_header_archive << header;
out_header_ = msg_header_stream.str();
// Prepare header length
std::ostringstream size_stream;
size_stream << std::setw(sizeof(uint64_t)) << std::hex << out_header_.size();
if (!size_stream || size_stream.str().size() != sizeof(uint64_t))
{
SRNP_PRINT_FATAL << "Couldn't set stream size.";
}
out_size_ = size_stream.str();
boost::system::error_code error;
boost::asio::write(socket_, boost::asio::buffer(out_size_), error);
//SRNP_PRINT_DEBUG << "[UC SIZE]: Sent", error.message();
boost::asio::write(socket_, boost::asio::buffer(out_header_), error);
//SRNP_PRINT_DEBUG << "[UC HEADER]: Sent", error.message();
boost::asio::write(socket_, boost::asio::buffer(out_msg_), error);
//SRNP_PRINT_DEBUG << "[UC MSG]: Sent", error.message();
return error;
}
Server::Server (boost::asio::io_service& service, std::string master_hub_ip, std::string master_hub_port, PairSpace& pair_space, PairQueue& pair_queue, int desired_owner_id) :
acceptor_ (service, tcp::endpoint(tcp::v4(), 0)),
strand_ (service),
heartbeat_timer_ (service, boost::posix_time::seconds(1)),
io_service_ (service),
owner_id_(-1),
pair_space_ (pair_space),
pair_queue_ (pair_queue),
master_ip_ (master_hub_ip),
master_port_ (master_hub_port)
{
port_ = acceptor_.local_endpoint().port();
if(!my_client_session_)
my_client_session_ = boost::shared_ptr <ServerSession> (new ServerSession(service, pair_space_, pair_queue_, owner_id_, this));
SRNP_PRINT_INFO << "Here we are folks. St. Alfonso's pancake breakfast!";
// Register a callback for accepting new connections.
acceptor_.async_accept (my_client_session_->socket(), boost::bind(&Server::handleAcceptedMyClientConnection, this, my_client_session_, desired_owner_id, boost::asio::placeholders::error));
// Register a callback for the timer. Called ever second.
heartbeat_timer_.async_wait (boost::bind(&Server::onHeartbeat, this));
// Start the spin thread.
startSpinThreads();
}
void Server::startSpinThreads()
{
for(int i = 0; i < 4; i++)
spin_thread_[i] = boost::thread (boost::bind(&boost::asio::io_service::run, &io_service_));
SRNP_PRINT_DEBUG << "Four separate listening threads have started.";
}
void Server::handleAcceptedMyClientConnection (boost::shared_ptr <ServerSession>& client_session, int desired_owner_id, const boost::system::error_code& e)
{
if(!e)
{
//SRNP_PRINT_DEBUG << "[SERVER]: We connected to our own client. On " << client_session->socket().remote_endpoint().port();
my_master_link_ = boost::shared_ptr <MasterLink> (new MasterLink(io_service_, master_ip_, master_port_, my_client_session_, this, desired_owner_id));
my_master_link_->sendMMToOurClientAndWaitForUCMsg();
client_session->startReading();
ServerSession::session_counter++;
ServerSession* new_session_ = new ServerSession(io_service_, pair_space_, pair_queue_, owner_id_, this);
acceptor_.async_accept (new_session_->socket(), boost::bind(&Server::handleAcceptedConnection, this, new_session_, boost::asio::placeholders::error));
}
else
{
ServerSession::session_counter--;
client_session.reset();
SRNP_PRINT_FATAL << "We couldn't connect to our own client. Sucks!";
}
}
void Server::handleAcceptedConnection (ServerSession* new_session, const boost::system::error_code& e)
{
if(!e)
{
//SRNP_PRINT_DEBUG << "[SERVER]: We, connect to " << new_session->socket().remote_endpoint().address().to_string()
//<< ":" << new_session->socket().remote_endpoint().port();
new_session->startReading();
ServerSession::session_counter++;
ServerSession* new_session_ = new ServerSession(io_service_, pair_space_, pair_queue_, owner_id_, this);
acceptor_.async_accept (new_session_->socket(), boost::bind(&Server::handleAcceptedConnection, this, new_session_, boost::asio::placeholders::error));
}
else
{
ServerSession::session_counter--;
delete new_session;
}
}
void Server::onHeartbeat()
{
// TODO: SEE IF EVERYTHING IS OK BEFORE DOING THIS!
elapsed_time_ += boost::posix_time::seconds(1);
heartbeat_timer_.expires_at(heartbeat_timer_.expires_at() + boost::posix_time::seconds(1));
heartbeat_timer_.async_wait (boost::bind(&Server::onHeartbeat, this));
//SRNP_PRINT_TRACE << "*********************************************************";
//SRNP_PRINT_TRACE << "[SERVER] Elapsed time: " << elapsed_time_ << std::endl;
//SRNP_PRINT_DEBUG << "[SERVER] Acceptor State: " << acceptor_.is_open() ? "Open" : "Closed";
//SRNP_PRINT_DEBUG << "[SERVER] No. of Active Sessions: " << ServerSession::session_counter;
//SRNP_PRINT_TRACE << "*********************************************************";
}
void Server::waitForEver()
{
//SRNP_PRINT_DEBUG << "Starting to wait forever...";
for(int i = 0; i < 4; i++)
{
spin_thread_[i].join();
}
}
Server::~Server()
{
//SRNP_PRINT_DEBUG << "SERVER CLOSES CLEANLY!";
}
} /* namespace srnp */
| 33.484094 | 197 | 0.720641 | [
"vector"
] |
30e3009a4aef9b7df5d6e5abeb7a03b81d26ab42 | 3,634 | cpp | C++ | matrix-oop/solution/exercise.cpp | lparolari/high-school-assignments | 4049c72f5b1b0bfe4dde865a40c256699c51cb5b | [
"MIT"
] | null | null | null | matrix-oop/solution/exercise.cpp | lparolari/high-school-assignments | 4049c72f5b1b0bfe4dde865a40c256699c51cb5b | [
"MIT"
] | 14 | 2020-07-21T09:33:36.000Z | 2021-05-31T16:28:08.000Z | matrix-oop/solution/exercise.cpp | lparolari/high-school-assignments | 4049c72f5b1b0bfe4dde865a40c256699c51cb5b | [
"MIT"
] | null | null | null | #include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Matrix {
////////////////////////////////////
// METODI PRIVATI
private:
int r; // righe
int c; // colonne
vector<int> data;
// Nota: per motivi progettuali è stato scelto di non
// permettere la modifica della matrice interna.
// Restituisce l'elemento in posizione i,j.
int get(int i, int j) {
return data[i * c + j];
}
////////////////////////////////////
// METODI PUBBLICI
public:
// Crea una matrice date solamente le dimensioni.
Matrix(int rows, int cols) {
r = rows;
c = cols;
}
// Crea una matrice data le righe, le colonne e i dati della matrice.
Matrix(int rows, int cols, vector<int> linearized_data) {
r = rows;
c = cols;
data = linearized_data;
}
// Restituisce la matrice sottoforma di stringa.
string to_string() {
string res = "";
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
res += std::to_string(get(i, j)) + " ";
}
res += '\n';
}
return res;
}
// Restituisce la matrice trasposta con nuova dimensione su righe e colonne.
Matrix reshape(int rows, int cols) {
// cosa succede se
// rows*cols != r*c
// dobbiamo controllare questo caso?
return Matrix(rows, cols, data);
}
// Restituisce la matrice trasposta.
Matrix transpose() {
vector<int> A;
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
A.push_back(get(j, i));
}
}
return Matrix(c, r, A);
}
// Restituisce una matrice tutta di zeri.
Matrix zeroes() {
vector<int> A;
for (int i = 0; i < r * c; i++) A.push_back(0);
return Matrix(r, c, A);
}
// Restituisce una matrice fatta di interi da 0 a r*c.
Matrix ints() {
vector<int> A;
for (int i = 0; i < r * c; i++) A.push_back(i);
return Matrix(r, c, A);
}
// Restituisce una matrice con valori random tra 0 e 9.
Matrix randoms() {
vector<int> A;
for (int i = 0; i < r * c; i++) A.push_back(rand() % 10);
return Matrix(r, c, A);
}
// Somma due matrici.
Matrix sum(Matrix y) {
vector<int> S;
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
S.push_back(get(i, j) + y.get(i, j));
}
}
return Matrix(r, c, S);
}
};
int main() {
// random seed (dovrebbe essere impostato nella matrice?)
srand(0);
Matrix m1(4, 4);
cout << "m1', dimensione: 4x4, valori: 0" << endl;
cout << m1.zeroes().to_string() << endl;
cout << "m1'', dimensione: 2x8, valori: 0" << endl;
cout << m1.zeroes().reshape(2, 8).to_string() << endl;
cout << "m1''', dimensione: 8x2, valori: 0" << endl;
cout << m1.zeroes().reshape(8, 2).to_string() << endl;
cout << endl;
Matrix m2(4, 4);
cout << "m2', dimensione: 4x4, valori: da 0 a 4*4" << endl;
cout << m2.ints().to_string() << endl;
cout << "m2'', dimensione: 4x4, valori: da 0 a 4x4, trasposta" << endl;
cout << m2.ints().transpose().to_string() << endl;
cout << endl;
Matrix m3(3, 3);
cout << "m3', dimensione: 3x3, valori: da 0 a 3*3" << endl;
cout << m3.ints().to_string() << endl;
cout << "m3'', dimensione: 3x3, valori: m3' + m3'" << endl;
cout << m3.ints().sum(m3.ints()).to_string() << endl;
return 0;
} | 27.323308 | 80 | 0.503027 | [
"vector"
] |
30e459e41582c371e727a02a0bdea7ba03d89cf3 | 6,132 | cpp | C++ | shore-sm-6.0.2/src/sm/tests/init_config_options.cpp | glycerine/shore-mt | 39f1802ba9588bc9d32d34386ed0193477f7e8d1 | [
"Spencer-94",
"Spencer-86",
"Xnet",
"Linux-OpenIB",
"Spencer-99",
"X11",
"CECILL-B"
] | 3 | 2016-07-15T08:22:56.000Z | 2019-10-10T02:26:08.000Z | shore-sm-6.0.2/src/sm/tests/init_config_options.cpp | glycerine/shore-mt | 39f1802ba9588bc9d32d34386ed0193477f7e8d1 | [
"Spencer-94",
"Spencer-86",
"Xnet",
"Linux-OpenIB",
"Spencer-99",
"X11",
"CECILL-B"
] | null | null | null | shore-sm-6.0.2/src/sm/tests/init_config_options.cpp | glycerine/shore-mt | 39f1802ba9588bc9d32d34386ed0193477f7e8d1 | [
"Spencer-94",
"Spencer-86",
"Xnet",
"Linux-OpenIB",
"Spencer-99",
"X11",
"CECILL-B"
] | 2 | 2020-12-23T06:49:23.000Z | 2021-03-05T07:00:28.000Z | /*<std-header orig-src='shore'>
$Id: init_config_options.cpp,v 1.5 2010/09/21 14:26:28 nhall Exp $
SHORE -- Scalable Heterogeneous Object REpository
Copyright (c) 1994-99 Computer Sciences Department, University of
Wisconsin -- Madison
All Rights Reserved.
Permission to use, copy, modify and distribute this software and its
documentation is hereby granted, provided that both the copyright
notice and this permission notice appear in all copies of the
software, derivative works or modified versions, and any portions
thereof, and that both notices appear in supporting documentation.
THE AUTHORS AND THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY
OF WISCONSIN - MADISON ALLOW FREE USE OF THIS SOFTWARE IN ITS
"AS IS" CONDITION, AND THEY DISCLAIM ANY LIABILITY OF ANY KIND
FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
This software was developed with support by the Advanced Research
Project Agency, ARPA order number 018 (formerly 8230), monitored by
the U.S. Army Research Laboratory under contract DAAB07-91-C-Q518.
Further funding for this work was provided by DARPA through
Rome Research Laboratory Contract No. F30602-97-2-0247.
*/
#include "w_defines.h"
/* -- do not edit anything above this line -- </std-header>*/
/**\anchor init_config_options_example */
/*
* This file illustrates processing of run-time options
* from the command line and from a file.
* The options are processed in a single static function,
* init_config_options.
*
* It is used by several of the storage manager examples.
*/
/* Since this file only deals with the SSM option package,
* rather than including sm_vas.h, just include what's needed for
* options:
*/
#include <w_stream.h>
#include <cstring>
#include "w.h"
#include "option.h"
#include <w_strstream.h>
/*
* init_config_options()
*
* The first argument, the options parameter,
* is the option group holding all the options. It must have
* been created by the caller.
*
* This is designed to be called by server-side code and
* by client-side code, so it uses a 3-level hierarchy for
* naming the options: example.<server-or-client>.<program-name>,
* where, presumably, the server-side code will be written to
* call this with the
* second argument, prog_type, to be "server", and the
* client-side code will use "client" for the prog_type argument.
* This function, however, doesn't care what the value of
* prog_type is; it just inserts it in the hierarchy.
*
* In the server-side case, because (presumably) the storage manager will be used,
* the storage manager options must have been added to the options group before this
* function is called.
*
* If the argc and argv parameters are argc and argv from main(), then the
* executables can be invoked with storage manager options on the command-line, e.g.,
* <argv0> -sm_logdir /tmp/logdir -sm_num_page_writers 4
*
* Recognized options will be located in argv and removed from the argv list, and
* argc is changed to reflect the removal, which is why it is passed by
* reference.
* After this function is used, the calling code can process the remainder
* of the command line without interference by storage manager option-value
* pairs.
*
* In this function, we have hard-wired the name of the file (EXAMPLE_SHORECONFIG) to be
* read for options values, and we have hard-wired the options' class hierarchy to be
* example.<prog_type>.<program-name>
*
* You might not want to use such a hierarchy -- if you don't have client- and server-
* side executables for the same "program", and if you don't want to collect
* options for different programs in the same file, you might dispense with the
* hierarchy.
*/
w_rc_t
init_config_options(
option_group_t& options,
const char* prog_type,
int& argc,
char** argv)
{
w_rc_t rc; // return code
// set prog_name to the file name of the program without the path
char* prog_name = strrchr(argv[0], '/');
if (prog_name == NULL) {
prog_name = argv[0];
} else {
prog_name += 1; /* skip the '/' */
if (prog_name[0] == '\0') {
prog_name = argv[0];
}
}
W_DO(options.add_class_level("example"));
W_DO(options.add_class_level(prog_type)); // server or client
W_DO(options.add_class_level(prog_name)); // program name
// read the example config file to set options
{
w_ostrstream err_stream;
const char* opt_file = "EXAMPLE_SHORECONFIG"; // option config file
option_file_scan_t opt_scan(opt_file, &options);
// Scan the file and override any default option settings.
// Options names must be spelled correctly
rc = opt_scan.scan(true /*override*/,
err_stream,
true /*option names must be complete and correct*/ );
if (rc.is_error()) {
cerr << "Error in reading option file: " << opt_file << endl;
cerr << "\t" << err_stream.c_str() << endl;
return rc;
}
}
// parse command line for more options.
if (!rc.is_error()) {
// parse command line
w_ostrstream err_stream;
rc = options.parse_command_line(
(const char **)argv,
argc,
2, /* minimum length of an option name*/
&err_stream /* send error messages here */
);
err_stream << ends;
if (rc.is_error()) {
cerr << "Error on Command line " << endl;
cerr << "\t" << w_error_t::error_string(rc.err_num()) << endl;
cerr << "\t" << err_stream.c_str() << endl;
return rc;
}
}
// check required options for values
{
w_ostrstream err_stream;
rc = options.check_required(&err_stream);
if (rc.is_error()) {
cerr << "These required options are not set:" << endl;
cerr << err_stream.c_str() << endl;
return rc;
}
}
return RCOK;
}
| 35.859649 | 89 | 0.659328 | [
"object"
] |
30e96ff0125b2a95be6326e925a0c65defc171f6 | 7,905 | cpp | C++ | ArrtModel/ViewModel/BlobExplorer/BlobExplorerModel.cpp | AleksandarTomicMs2/azure-remote-rendering-asset-tool | c3962231e02af6ff90c2867f51e7a3b20af8c592 | [
"MIT"
] | 42 | 2020-06-12T19:10:52.000Z | 2022-03-04T02:20:59.000Z | ArrtModel/ViewModel/BlobExplorer/BlobExplorerModel.cpp | AleksandarTomicMs2/azure-remote-rendering-asset-tool | c3962231e02af6ff90c2867f51e7a3b20af8c592 | [
"MIT"
] | 91 | 2020-06-12T12:10:46.000Z | 2022-03-02T13:46:00.000Z | ArrtModel/ViewModel/BlobExplorer/BlobExplorerModel.cpp | AleksandarTomicMs2/azure-remote-rendering-asset-tool | c3962231e02af6ff90c2867f51e7a3b20af8c592 | [
"MIT"
] | 10 | 2020-07-29T21:19:14.000Z | 2021-09-22T11:48:27.000Z | #include <Model/AzureStorageManager.h>
#include <Model/Log/LogHelpers.h>
#include <Model/StorageUtils/FileUploader.h>
#include <QDirIterator>
#include <ViewModel/BlobExplorer/BlobContainerSelectorModel.h>
#include <ViewModel/BlobExplorer/BlobExplorerModel.h>
#include <ViewModel/BlobExplorer/BlobsListModel.h>
#include <ViewModel/BlobExplorer/DirectoryProvider.h>
BlobExplorerModel::BlobExplorerModel(AzureStorageManager* storageManager, bool allowsUpload, bool directoryExplorer, const QString& allowedExtensions, QString uploadFileFilters, QString container, const QString& directory, QObject* parent)
: QObject(parent)
, m_allowsUpload(allowsUpload)
, m_storageManager(storageManager)
, m_fileUploader(new FileUploader([this](int remaining, bool thereWasAnError) { fileCountChanged(remaining, thereWasAnError); }))
, m_containerName(new Value<QString>(std::move(container), this))
, m_isDirectoryExplorer(directoryExplorer)
, m_uploadFileFilters(std::move(uploadFileFilters))
{
m_directoryProvider = new DirectoryProvider(storageManager, m_containerName, directory, this);
m_blobsListModel = new BlobsListModel(m_directoryProvider, storageManager, allowedExtensions, m_containerName, this);
connect(m_blobsListModel, &BlobsListModel::blobSelected, this,
[this](const QString& path, const QString& url) {
setSelectedBlob(path, url);
if (!m_isDirectoryExplorer)
{
submit();
}
});
connect(m_blobsListModel, &BlobsListModel::currentBlobChanged, this,
[this]() {
BlobsListModel::EntryType type;
QString path;
QString url;
m_blobsListModel->getCurrentItem(type, path, url);
if (m_isDirectoryExplorer && type == BlobsListModel::EntryType::Directory)
{
setSelectedBlob(path, url);
}
else if (!m_isDirectoryExplorer && type == BlobsListModel::EntryType::Model)
{
setSelectedBlob(path, url);
}
else
{
setSelectedBlob({}, {});
}
});
connect(m_directoryProvider, &DirectoryProvider::directoryChanged, this,
[this]() {
Q_EMIT directoryChanged();
});
}
BlobExplorerModel::BlobExplorerModel(AzureStorageManager* storageManager, bool allowsUpload, const QString& allowedExtensions, QString uploadFileFilters, QString container, const QString& directory, QObject* parent)
: BlobExplorerModel(storageManager, allowsUpload, false, allowedExtensions, std::move(uploadFileFilters), std::move(container), directory, parent)
{
}
BlobExplorerModel::BlobExplorerModel(AzureStorageManager* storageManager, QString container, const QString& directory, QObject* parent)
: BlobExplorerModel(storageManager, false, true, {}, {}, std::move(container), directory, parent)
{
}
void BlobExplorerModel::setContainer(const QString& containerName)
{
if (m_containerName->get() != containerName)
{
m_containerName->set(containerName);
m_directoryProvider->setDirectory({});
}
}
DirectoryProvider* BlobExplorerModel::getDirectoryModel() const
{
return m_directoryProvider;
}
BlobsListModel* BlobExplorerModel::getBlobsModel() const
{
return m_blobsListModel;
}
void BlobExplorerModel::setDirectory(const QString& directory)
{
m_directoryProvider->setDirectory(directory);
}
QString BlobExplorerModel::getDirectory() const
{
return m_directoryProvider->getDirectory();
}
void BlobExplorerModel::setSelectedBlob(QString path, QString url)
{
m_selectedBlobPath = std::move(path);
m_selectedBlobUrl = std::move(url);
Q_EMIT selectionChanged();
}
QString BlobExplorerModel::getSelectedBlobUrl() const
{
return m_selectedBlobUrl;
}
QString BlobExplorerModel::getSelectedBlobPath() const
{
return m_selectedBlobPath;
}
QString BlobExplorerModel::getSelectedRelativeBlobPath() const
{
return QString::fromStdWString(m_directoryProvider->getRelativePath(m_selectedBlobPath.toStdWString()));
}
bool BlobExplorerModel::acceptSelectedBlob() const
{
return !m_selectedBlobPath.isEmpty();
}
void BlobExplorerModel::submit()
{
Q_EMIT submitted();
}
QString BlobExplorerModel::getUploadStatus() const
{
if (m_totalFiles == 0)
{
return {};
}
else if (m_remainingFiles > 0)
{
return tr("Uploading %1/%2 files").arg(m_totalFiles - m_remainingFiles).arg(m_totalFiles);
}
else if (m_errorWhenUploadingFiles)
{
return tr("Upload failed (%1 files)").arg(m_totalFiles);
}
else
{
return tr("Upload completed (%1 files)").arg(m_totalFiles);
}
}
// upload a series of files and directory (local paths) to the current container and directory
void BlobExplorerModel::uploadBlobs(const QDir& rootDir, const QStringList& localPaths)
{
if (!m_allowsUpload)
{
return;
}
QStringList toUpload = getFullFileList(localPaths);
if (m_remainingFiles == 0)
{
// reset
m_totalFiles = 0;
m_errorWhenUploadingFiles = false;
}
m_totalFiles += localPaths.size();
// first try to create the container if it doesn't exist
QString containerName = m_containerName->get();
QString directory = getDirectory();
QPointer<BlobExplorerModel> thisPtr = this;
m_storageManager->createContainer(m_containerName->get(), [thisPtr, containerName, rootDir, localPaths, directory](bool succeeded) {
if (thisPtr)
{
if (succeeded)
{
auto container = thisPtr->m_storageManager->getContainerFromName(containerName);
thisPtr->m_fileUploader->uploadFilesAsync(rootDir, localPaths, container, directory);
}
else
{
qWarning(LoggingCategory::azureStorage) << tr("Could not create container: ") << containerName;
}
}
});
}
// it converts a set of files+directories to a list of files. Utility function used by the view to know how many files
// are actually going to be uploaded
QStringList BlobExplorerModel::getFullFileList(const QStringList& localPaths) const
{
QStringList fullFileList;
for (const auto& path : localPaths)
{
QDir dir(path);
if (dir.exists())
{
QDirIterator it(path, QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
while (it.hasNext())
{
it.next();
fullFileList.append(it.filePath());
}
}
else
{
if (QFileInfo::exists(path))
{
fullFileList.append(path);
}
}
}
return fullFileList;
}
// true if the exlorer allows blobs to be uploaded
bool BlobExplorerModel::allowsUpload() const
{
return m_allowsUpload;
}
QString BlobExplorerModel::getUploadFileFilters() const
{
return m_uploadFileFilters;
}
int BlobExplorerModel::getUploadProgress() const
{
if (m_remainingFiles == 0 || m_totalFiles == 0)
{
return -1;
}
else
{
return 100 - (100 * m_remainingFiles / m_totalFiles);
}
}
void BlobExplorerModel::fileCountChanged(int remainingFiles, bool errorWhenUploadingFiles)
{
m_remainingFiles = remainingFiles;
m_errorWhenUploadingFiles = (m_errorWhenUploadingFiles || errorWhenUploadingFiles);
if (m_remainingFiles == 0)
{
getBlobsModel()->refresh();
}
Q_EMIT uploadStatusChanged();
Q_EMIT uploadProgressChanged();
if (remainingFiles == 0)
{
Q_EMIT uploadFinished(!errorWhenUploadingFiles);
}
}
void BlobExplorerModel::refresh()
{
getBlobsModel()->refresh();
}
| 31.245059 | 239 | 0.667426 | [
"model"
] |
30e9a63d005ba68d350f5fc626afef648df3dfc0 | 3,929 | cc | C++ | src/drivers/devices/cpu/flowunit/model_decrypt_plugin/model_decrypt_plugin_test.cc | yamal-shang/modelbox | b2785568f4acd56d4922a793aa25516f883edc26 | [
"Apache-2.0"
] | 51 | 2021-09-24T08:57:44.000Z | 2022-03-31T09:12:46.000Z | src/drivers/devices/cpu/flowunit/model_decrypt_plugin/model_decrypt_plugin_test.cc | yamal-shang/modelbox | b2785568f4acd56d4922a793aa25516f883edc26 | [
"Apache-2.0"
] | 3 | 2022-02-22T07:13:02.000Z | 2022-03-30T02:03:40.000Z | src/drivers/devices/cpu/flowunit/model_decrypt_plugin/model_decrypt_plugin_test.cc | yamal-shang/modelbox | b2785568f4acd56d4922a793aa25516f883edc26 | [
"Apache-2.0"
] | 31 | 2021-11-29T02:22:39.000Z | 2022-03-15T03:05:24.000Z | /*
* Copyright 2021 The Modelbox Project 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 <dlfcn.h>
#include <gmock/gmock-actions.h>
#include <securec.h>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <memory>
#include <thread>
#include "driver_flow_test.h"
#include "flowunit_mockflowunit/flowunit_mockflowunit.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "model_decrypt_interface.h"
#include "modelbox/base/log.h"
#include "modelbox/base/status.h"
#include "modelbox/base/utils.h"
#include "modelbox/base/config.h"
#include "modelbox/buffer.h"
#define DLL_NAME_SUB "libmodelbox-unit-cpu-model-decrypt-plugin.so."
#define MODELBOX_VERSION_MAJORSTR(R) #R
#define MODELBOX_VERSION_MAJORSTRING(R) MODELBOX_VERSION_MAJORSTR(R)
#define DLL_NAME DLL_NAME_SUB MODELBOX_VERSION_MAJORSTRING(MODELBOX_VERSION_MAJOR)
using ::testing::_;
namespace modelbox {
typedef std::shared_ptr<DriverFactory> (*CreateDriverFactory)();
class ModelDecryptPluginTest : public testing::Test {
public:
ModelDecryptPluginTest() = default;
CreateDriverFactory driver_func_ = nullptr;
protected:
virtual void SetUp() {
auto ret = OpenDriver();
EXPECT_EQ(ret, STATUS_OK);
};
virtual void TearDown() {
if (driver_handler_) {
dlclose(driver_handler_);
}
};
private:
modelbox::Status OpenDriver();
void *driver_handler_ = nullptr;
};
modelbox::Status ModelDecryptPluginTest::OpenDriver() {
std::string so_path = TEST_DRIVER_DIR;
so_path.append("/").append(DLL_NAME);
driver_handler_ = dlopen(so_path.c_str(), RTLD_GLOBAL | RTLD_NOW);
if (driver_handler_ == nullptr) {
MBLOG_ERROR << "dll open fail :" << dlerror();
return STATUS_FAULT;
}
driver_func_ =
(CreateDriverFactory)dlsym(driver_handler_, "CreateDriverFactory");
if (driver_func_ == nullptr) {
MBLOG_ERROR << "dll func fail :" << dlerror();
return STATUS_FAULT;
}
return STATUS_OK;
}
TEST_F(ModelDecryptPluginTest, ModelDecryptTest) {
if (driver_func_ == nullptr) {
MBLOG_ERROR << "driver_func is null";
return;
}
// This test would be skipped, if no auth info is provided.
auto model_decrypt_func = std::dynamic_pointer_cast<IModelDecryptPlugin>(
driver_func_()->GetDriver());
std::shared_ptr<Configuration> config = std::make_shared<Configuration>();
config->SetProperty("encryption.rootkey",
"JRNd6slbpA08mRxnMwZZZJYBR5gHhtJASjgSiRNTiLgTNrC8DGEfKuYF"
"SDashsuU/eHB1ybr+Fm7kgjDcoCYk71nv4LIHrHZL6QZiVqL9CfT");
config->SetProperty("encryption.passwd",
"IudbJKZB+7lenEjHkPO+AaMmoloOv5MMDbbZwqPSTpsANBWF/C/"
"eDJGnDvARVpUV3EIgXm4oS28RBtNT27c+5Q==");
auto ret = model_decrypt_func->Init("", config);
EXPECT_EQ(ret, STATUS_OK);
std::string test_str("this is a test");
uint8_t enbuf[] = {0x87, 0xAC, 0xDD, 0x3D, 0x3F, 0x47, 0xCC, 0x87,
0x3C, 0x1A, 0x1B, 0x31, 0x3B, 0xB5, 0x34, 0x70};
char plainbuf[sizeof(enbuf) + EVP_MAX_BLOCK_LENGTH + 1];
int64_t plain_len = sizeof(plainbuf);
ret = model_decrypt_func->ModelDecrypt((uint8_t *)enbuf, sizeof(enbuf),
(uint8_t *)plainbuf, plain_len);
EXPECT_EQ(ret, STATUS_OK);
std::string result_str(plainbuf, plain_len);
EXPECT_EQ(result_str.compare(test_str), 0);
}
} // namespace modelbox | 32.741667 | 82 | 0.713668 | [
"model"
] |
30f54038e2ea6259b796ae5ffe09e52d4bc8b77b | 16,433 | cpp | C++ | common/tcp.cpp | zteo-phd-software/ironstack | 649f82ddcbb82831796fa2a1e1d1b8cc0f94a8e0 | [
"BSD-3-Clause"
] | null | null | null | common/tcp.cpp | zteo-phd-software/ironstack | 649f82ddcbb82831796fa2a1e1d1b8cc0f94a8e0 | [
"BSD-3-Clause"
] | null | null | null | common/tcp.cpp | zteo-phd-software/ironstack | 649f82ddcbb82831796fa2a1e1d1b8cc0f94a8e0 | [
"BSD-3-Clause"
] | null | null | null | #include "tcp.h"
// static initializers here
mutex tcp::lock;
tcp_global_info tcp::global_info;
map<uint16_t, int> tcp::listening_port_to_socket_mapping;
// constructor for the tcp object
tcp::tcp() {
socket_id = -1;
}
// destructor for tcp object
tcp::~tcp() {
close();
}
// makes a tcp connection
bool tcp::connect(const ip_port& address_and_port) {
// close any existing connection
close();
connection_info.clear();
// validate given input
if (address_and_port.is_nil()) {
printf("tcp::conect() error -- invalid address/port.\n");
return false;
}
// create socket
socket_id = socket(AF_INET, SOCK_STREAM, 0);
if (socket_id < 0) {
printf("tcp::connect() failed to create socket. reason: %s\n", strerror(errno));
return false;
}
struct sockaddr_in remote_sockaddr;
remote_sockaddr.sin_family = AF_INET;
remote_sockaddr.sin_addr.s_addr = address_and_port.get_address().get_as_be32();
remote_sockaddr.sin_port = htons(address_and_port.get_port());
// make the connection
if (::connect(socket_id, (struct sockaddr*) &remote_sockaddr, sizeof(remote_sockaddr)) < 0) {
if (errno != ENETUNREACH && errno != ETIMEDOUT) {
printf("tcp::connect() failed to connect. reason: %s\n", strerror(errno));
}
::close(socket_id);
socket_id = -1;
return false;
}
// store local ip address/port
struct sockaddr_in local_sockaddr;
socklen_t addr_len = sizeof(local_sockaddr);
if (getsockname(socket_id, (struct sockaddr*) &local_sockaddr, &addr_len) < 0) {
printf("tcp::connect() failed to get local sockaddr. reason: %s\n", strerror(errno));
::close(socket_id);
socket_id = -1;
return false;
}
connection_info.local_ip_address.set(inet_ntoa(local_sockaddr.sin_addr));
connection_info.local_port = ntohs(local_sockaddr.sin_port);
// store remote ip address/port
connection_info.remote_ip_address = address_and_port.get_address();
connection_info.remote_port = address_and_port.get_port();
// update other metadata
connection_info.connected = true;
connection_info.bytes_sent = 0;
connection_info.bytes_received = 0;
gettimeofday(&connection_info.connection_start_time, nullptr);
global_info.connections_active++;
return true;
}
// makes a connection, using old style
bool tcp::connect(const string& address, uint16_t port) {
ip_port address_and_port(address, port);
return connect(address_and_port);
}
// closes a tcp connection
void tcp::close() {
if (connection_info.is_connected()) {
::close(socket_id);
socket_id = -1;
connection_info.connected = false;
global_info.connections_active--;
}
}
// enables listening on a port, does not accept the next incoming connection
bool tcp::listen(uint16_t port) {
// if there's already a listen activity on the port, don't do listen() again
lock_guard<mutex> g(lock);
if (listening_port_to_socket_mapping.count(port) > 0) {
return false;
}
// create a socket
int server_socket = socket(AF_INET, SOCK_STREAM, 0);
if (server_socket == -1) {
printf("tcp::listen() failed -- socket creation failed. reason: %s\n", strerror(errno));
return false;
}
// set to reusable
struct sockaddr_in local_sockaddr;
int one = 1;
local_sockaddr.sin_family = AF_INET;
local_sockaddr.sin_addr.s_addr = htonl(INADDR_ANY);
local_sockaddr.sin_port = htons(port);
if (setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) == -1) {
printf("tcp::listen() failed -- could not bind to socket. reason: %s\n", strerror(errno));
::close(server_socket);
return false;
}
// bind socket to local sockaddr_in
if (bind(server_socket, (struct sockaddr*) &local_sockaddr, sizeof(local_sockaddr)) == -1) {
printf("tcp::listen() failed -- could not bind to socket. reason: %s\n", strerror(errno));
::close(server_socket);
return false;
}
// set to listen mode
if (::listen(server_socket, 15) == -1) {
printf("tcp::listen() failed -- could not listen on socket. reason: %s\n", strerror(errno));
::close(server_socket);
return false;
}
// insert to maps
listening_port_to_socket_mapping[port] = server_socket;
global_info.listening_ports[port] = true;
return true;
}
// stops listening on a port
void tcp::stop_listen(uint16_t port) {
lock_guard<mutex> g(lock);
auto iterator = listening_port_to_socket_mapping.find(port);
if (iterator != listening_port_to_socket_mapping.end()) {
::close(iterator->second);
listening_port_to_socket_mapping.erase(iterator);
auto iterator2 = global_info.listening_ports.find(port);
if (iterator2 != global_info.listening_ports.end()) {
global_info.listening_ports.erase(iterator2);
return;
}
}
}
// accepts a connection into this tcp connection
bool tcp::accept(uint16_t port) {
// close any existing conection
close();
connection_info.clear();
// look up the listening socket
int listening_socket = -1;
{
lock_guard<mutex> g(lock);
auto iterator = listening_port_to_socket_mapping.find(port);
if (iterator == listening_port_to_socket_mapping.end()) {
socket_id = -1;
return false;
}
listening_socket = iterator->second;
}
// try to accept the connection
struct sockaddr_in remote_sockaddr;
struct sockaddr_in local_sockaddr;
socklen_t address_len = sizeof(remote_sockaddr);
socket_id = ::accept(listening_socket, (struct sockaddr*) &remote_sockaddr, &address_len);
if (socket_id == -1) {
printf("tcp::accept() error -- failed to accept. reason: %s\n", strerror(errno));
return false;
}
// successfully connected. get local information
address_len = sizeof(local_sockaddr);
if (getsockname(socket_id, (struct sockaddr*) &local_sockaddr, &address_len) < 0) {
printf("tcp::connect() failed to get local sockaddr. reason: %s\n", strerror(errno));
::close(socket_id);
socket_id = -1;
return false;
}
// populate metadata
connection_info.local_ip_address.set(inet_ntoa(local_sockaddr.sin_addr));
connection_info.local_port = ntohs(local_sockaddr.sin_port);
connection_info.remote_ip_address.set(inet_ntoa(remote_sockaddr.sin_addr));
connection_info.remote_port = ntohs(remote_sockaddr.sin_port);
connection_info.connected = true;
connection_info.bytes_sent = 0;
connection_info.bytes_received = 0;
gettimeofday(&connection_info.connection_start_time, nullptr);
global_info.connections_active++;
return true;
}
// sets the name for this tcp connection
void tcp::set_name(const string& _name) {
name = _name;
}
// gets the name of this tcp connection
string tcp::get_name() const {
return name;
}
// sends an automemory without block delimiter
bool tcp::send_raw(const autobuf& payload) {
return send_raw(payload.get_content_ptr(), payload.size());
}
// sends a binary buffer without block delimiter
bool tcp::send_raw(const void* buf, int len) {
// sanity check
if (!connection_info.is_connected()) {
return false;
}
// setup send loop
int total_bytes_sent = 0;
int current_bytes_sent;
int bytes_to_send = 0;
while (total_bytes_sent < len) {
bytes_to_send = (len - total_bytes_sent) >= 1024 ? 1024 : len - total_bytes_sent;
while ((current_bytes_sent = ::send(socket_id, ((char*)buf)+total_bytes_sent,
bytes_to_send, MSG_NOSIGNAL)) == -1 && errno == EINTR);
if (current_bytes_sent <= 0) {
// permanent error or client disconnected
close();
return false;
}
total_bytes_sent += current_bytes_sent;
connection_info.bytes_sent += current_bytes_sent; // possible contention?
global_info.total_bytes_sent += current_bytes_sent; // possible contention?
}
return true;
}
// receives data into an automemory payload, no block delimiter
bool tcp::recv_raw(autobuf& payload, int timeout_ms) {
payload.clear();
if (!connection_info.is_connected()) {
return false;
}
if (timeout_ms >= 0 && !timeout_check(timeout_ms)) {
return false;
}
payload.create_empty_buffer(1024, false);
int bytes_received;
while((bytes_received = ::recv(socket_id, payload.get_content_ptr_mutable(), 1024, 0)) == -1 && errno == EINTR);
if (bytes_received <= 0) {
// permanent error or client disconnected
close();
return false;
}
payload.create_empty_buffer(bytes_received, false);
connection_info.bytes_received += bytes_received;
global_info.total_bytes_received += bytes_received;
return true;
}
// receives data into a binary buffer, no block delimiter
bool tcp::recv_raw(void* buf, int* buf_used, int len, int timeout_ms) {
if (!connection_info.is_connected()) {
return false;
}
if (timeout_ms >= 0 && !timeout_check(timeout_ms)) {
return false;
}
int bytes_received = ::recv(socket_id, buf, len, 0);
if (bytes_received <= 0) {
close();
return false;
}
*buf_used = bytes_received;
connection_info.bytes_received += bytes_received;
global_info.total_bytes_received += bytes_received;
return true;
}
// receives a fixed number of bytes from the socket or fail trying
bool tcp::recv_fixed_bytes(void* buf, int bytes_to_read, int timeout_ms) {
if (!connection_info.is_connected()) {
return false;
}
bool is_blocking = (timeout_ms == -1);
struct timeval start_time, current_time, difference_time;
gettimeofday(&start_time, nullptr);
int total_bytes_read = 0;
int current_bytes_read = 0;
int ms_elapsed;
int ms_remaining;
while(total_bytes_read < bytes_to_read) {
if (!is_blocking) {
gettimeofday(¤t_time, nullptr);
timersub(¤t_time, &start_time, &difference_time);
ms_elapsed = difference_time.tv_sec*1000 + difference_time.tv_usec/1000;
ms_remaining = timeout_ms - ms_elapsed;
if (ms_remaining < 0) return false;
if (!timeout_check(ms_remaining)) return false;
}
current_bytes_read = recv(socket_id, ((char*)buf)+total_bytes_read, bytes_to_read-total_bytes_read, 0);
if (current_bytes_read == -1 && errno == EINTR) {
continue;
} else if (current_bytes_read <= 0) {
close();
return false;
}
total_bytes_read += current_bytes_read;
connection_info.bytes_received += current_bytes_read;
global_info.total_bytes_received += current_bytes_read;
}
return true;
}
// read in a fixed number of bytes from the socket or fail trying
bool tcp::recv_fixed_bytes(autobuf& buf, int bytes_to_read, int timeout_ms) {
buf.create_empty_buffer(bytes_to_read, false);
bool status = recv_fixed_bytes(buf.get_content_ptr_mutable(), bytes_to_read, timeout_ms);
if (!status) buf.clear();
return status;
}
// reads until a token is located in the input
bool tcp::recv_until_token(autobuf& buf, const autobuf& token, int timeout_ms) {
buf.clear();
if (!connection_info.is_connected()) {
return false;
}
if (token.size() == 0) {
return true;
}
bool is_blocking = (timeout_ms == -1);
// determine minimum read size
int read_size = token.size();
char current_char;
bool mismatch;
int bytes_read = 0;
struct timeval start_time, current_time, difference_time;
gettimeofday(&start_time, nullptr);
int ms_elapsed, ms_remaining;
// read the first block
if (!recv_fixed_bytes(buf, read_size)) {
close();
return false;
}
while(1) {
// check buffer tail for substring
mismatch = false;
for (int counter = 0; counter < read_size; ++counter) {
if (buf[buf.size()-token.size()+counter] != token[counter]) {
mismatch = true;
break;
}
}
if (!mismatch) {
break;
}
// check for timeout if applicable
if (!is_blocking) {
gettimeofday(¤t_time, nullptr);
timersub(¤t_time, &start_time, &difference_time);
ms_elapsed = difference_time.tv_sec*1000 + difference_time.tv_usec/1000;
ms_remaining = timeout_ms - ms_elapsed;
if (ms_remaining < 0) return false;
if (!timeout_check(ms_remaining)) return false;
}
// read one more char
bytes_read = ::recv(socket_id, ¤t_char, 1, 0);
if (bytes_read < 0) {
if (errno == EINTR) {
continue;
} else {
close();
return false;
}
} else {
buf.append(¤t_char, 1);
++connection_info.bytes_received;
++global_info.total_bytes_received;
}
}
return true;
}
// reads until a token is located in the input, token supplied as a raw byte buffer
bool tcp::recv_until_token(autobuf& buf, const void* token, int token_size, int timeout_ms) {
autobuf _token;
_token.set_content(token, token_size);
return recv_until_token(buf, _token, timeout_ms);
}
// returns the raw socket descriptior
int tcp::get_fd() const {
return socket_id;
}
// gets information about the current connection
tcp_info tcp::get_connection_info() const {
return connection_info;
}
// tcp global information copy constructor
tcp_global_info::tcp_global_info(const tcp_global_info& other) {
connections_active = other.connections_active.load();
listening_ports = other.listening_ports;
total_bytes_sent = other.total_bytes_sent.load();
total_bytes_received = other.total_bytes_received.load();
}
// gets global statistics about the tcp subsystem
tcp_global_info tcp::get_global_info() {
tcp_global_info result;
lock_guard<mutex> g(lock);
return global_info;
}
// gets a copy of the ports being listened on
vector<uint16_t> tcp_global_info::get_listening_ports() const {
vector<uint16_t> result;
result.reserve(listening_ports.size());
for (const auto& it : listening_ports) {
result.push_back(it.first);
}
return result;
}
// constructor
epoll_set::epoll_set() {
fd = -1;
init();
}
// destructor
epoll_set::~epoll_set() {
close(fd);
}
// clear the epoll set
void epoll_set::clear() {
init();
}
// adds a socket to the epoll set
void epoll_set::add(const shared_ptr<tcp>& connection) {
if (connection == nullptr) {
printf("epoll_set::add() error -- tried to add an invalid connection.\n");
return;
}
int socket_id;
if ((socket_id = connection->get_fd()) == -1) {
return;
}
struct epoll_event event;
event.data.fd = socket_id;
event.events = EPOLLIN | EPOLLRDHUP;
if (epoll_ctl(fd, EPOLL_CTL_ADD, socket_id, &event) == -1) {
printf("epoll_set::add() error -- epoll_ctl() error: %s.\n", strerror(errno));
abort();
}
lock_guard<mutex> g(lock);
watch_set.insert(connection);
}
// removes a socket from the epoll set
void epoll_set::remove(const shared_ptr<tcp>& connection) {
if (connection == nullptr) {
printf("epoll_set::remove() error -- tried to remove an invalid connection.\n");
return;
}
lock_guard<mutex> g(lock);
shared_ptr<tcp> current;
int socket_id = connection->get_fd();
auto iterator = watch_set.begin();
while (iterator != watch_set.end()) {
if (iterator->unique() || *iterator == connection) {
iterator = watch_set.erase(iterator);
if (epoll_ctl(fd, EPOLL_CTL_DEL, socket_id, nullptr) == -1) {
printf("epoll_set::remove() error -- epoll_ctl() error: %s.\n", strerror(errno));
abort();
}
} else {
++iterator;
}
}
}
// checks for the sockets that are available for work
set<shared_ptr<tcp>> epoll_set::wait(int timeout_ms) {
struct epoll_event events[64];
set<shared_ptr<tcp>> result;
int ret;
if ((ret = epoll_wait(fd, events, sizeof(events)/sizeof(struct epoll_event), timeout_ms)) == -1) {
printf("epoll_set::wait() error -- epoll_wait() error: %s.\n", strerror(errno));
abort();
}
// grab the list of sockets that have events
set<int> active_fd;
for (int counter = 0; counter < ret; ++counter) {
active_fd.insert(events[counter].data.fd);
}
lock_guard<mutex> g(lock);
auto iterator = watch_set.begin();
while (iterator != watch_set.end()) {
if (iterator->unique()) {
if (epoll_ctl(fd, EPOLL_CTL_DEL, (*iterator)->get_fd(), nullptr) == -1) {
printf("epoll_set::remove() error -- epoll_ctl() error: %s.\n", strerror(errno));
abort();
}
iterator = watch_set.erase(iterator);
continue;
} else if (active_fd.count((*iterator)->get_fd()) > 0) {
result.insert(*iterator);
}
++iterator;
}
return result;
}
// used to create a new fd for the epoll set
void epoll_set::init() {
lock_guard<mutex> g(lock);
if (fd != -1) {
close(fd);
}
fd = epoll_create1(0);
if (fd == -1) {
printf("epoll_set() construction error -- %s\n", strerror(errno));
abort();
}
}
// used to check if a timeout occurred on the socket
bool tcp::timeout_check(int timeout_ms) {
int seconds = timeout_ms / 1000;
int useconds = (timeout_ms - (seconds*1000)) * 1000;
fd_set read_set;
FD_ZERO(&read_set);
FD_SET(socket_id, &read_set);
fd_set error_set;
FD_ZERO(&error_set);
FD_SET(socket_id, &error_set);
struct timeval tv;
tv.tv_sec = seconds;
tv.tv_usec = useconds;
return (select(socket_id+1, &read_set, nullptr, &error_set, &tv) > 0);
}
| 26.334936 | 113 | 0.714538 | [
"object",
"vector"
] |
a5025396dd122a6ea9b29116b66ee5fe12d668a7 | 4,268 | cpp | C++ | UbiGame_Blank/Source/Game/GameBoard.cpp | hzwr/Tower_Defense | 279e3e317760c90526001100a6b0dca4c82798e1 | [
"MIT"
] | 1 | 2021-09-28T14:13:45.000Z | 2021-09-28T14:13:45.000Z | UbiGame_Blank/Source/Game/GameBoard.cpp | hzwr/Tower_Defense | 279e3e317760c90526001100a6b0dca4c82798e1 | [
"MIT"
] | null | null | null | UbiGame_Blank/Source/Game/GameBoard.cpp | hzwr/Tower_Defense | 279e3e317760c90526001100a6b0dca4c82798e1 | [
"MIT"
] | null | null | null | #include "GameBoard.h"
#include "GameEngine/GameEngineMain.h"
#include "Game\Entities\Player.h"
#include "Game\Entities\Enemy.h"
#include "GameEngine/EntitySystem/Components/TextRenderComponent.h"
#include "Game/Components/AttackComponent/HealthComponent.h"
using namespace Game;
GameBoard::GameBoard()
{
m_player = new Player();
m_player->SetPos(sf::Vector2f(16.0f, 16.0f));
m_player->SetSize(sf::Vector2f(40.0f, 40.0f));
GameEngine::GameEngineMain::GetInstance()->AddEntity(m_player);
m_text = new GameEngine::Entity();
m_text->SetPos(sf::Vector2f(860.0f, 738.0f));
GameEngine::GameEngineMain::GetInstance()->AddEntity(m_text);
GameEngine::TextRenderComponent *textRenderComponent = m_text->AddComponent<GameEngine::TextRenderComponent>();
textRenderComponent->SetFont("ARCADECLASSIC.ttf");
textRenderComponent->SetCharacterSizePixels(45);
textRenderComponent->SetColor(sf::Color(132, 111, 100, 255));
textRenderComponent->SetString("Player!");
textRenderComponent->SetZLevel(3);
m_scoreText = new GameEngine::Entity();
m_scoreText->SetPos(sf::Vector2f(380.0f, 6.0f));
GameEngine::GameEngineMain::GetInstance()->AddEntity(m_scoreText);
GameEngine::TextRenderComponent *scoreTextRenderComponent = m_scoreText->AddComponent<GameEngine::TextRenderComponent>();
scoreTextRenderComponent->SetFont("ARCADECLASSIC.ttf");
scoreTextRenderComponent->SetCharacterSizePixels(45);
scoreTextRenderComponent->SetColor(sf::Color(132, 111, 100, 255));
scoreTextRenderComponent->SetString("Player!");
scoreTextRenderComponent->SetZLevel(3);
CreateBackGround();
}
GameBoard::~GameBoard()
{
}
void GameBoard::Update()
{
if (m_player->GetComponent<Game::HealthComponent>() == nullptr)
{
if (!is_gameOver)
{
CreateGameOverBackGround();
is_gameOver = true;
}
}
const float deltaTime = GameEngine::GameEngineMain::GetTimeDelta();
timeElapsed += deltaTime;
if (m_enemyGenCooldown < 0 && timeElapsed <= 20)
{
auto enemy = new Enemy();
enemy->SetPos(sf::Vector2f(2.0f, 122.0f+rand()%30-15.0f));
enemy->SetSize(sf::Vector2f(32.0f, 32.0f));
GameEngine::GameEngineMain::GetInstance()->AddEntity(enemy);
m_enemyGenCooldown = 1.5f + rand() %2;
}
else if (m_enemyGenCooldown < 0 && timeElapsed > 20)
{
auto enemy = new Enemy();
enemy->SetPos(sf::Vector2f(2.0f, 122.0f + rand() % 30 - 15.0f));
enemy->SetSize(sf::Vector2f(32.0f, 32.0f));
GameEngine::GameEngineMain::GetInstance()->AddEntity(enemy);
m_enemyGenCooldown = 1.f + rand() % 2;
}
m_enemyGenCooldown -= deltaTime;
// Update "money"
m_text->GetComponent< GameEngine::TextRenderComponent>()->SetString(std::to_string(m_money));
// Update score
m_scoreText->GetComponent< GameEngine::TextRenderComponent>()->SetString("Score " + std::to_string(m_score));
}
void GameBoard::CreateBackGround()
{
GameEngine::Entity *bgEntity = new GameEngine::Entity();
GameEngine::SpriteRenderComponent *render = bgEntity->AddComponent<GameEngine::SpriteRenderComponent>();
render->SetTexture(GameEngine::eTexture::BG);
render->SetZLevel(0);
bgEntity->SetPos(sf::Vector2f(500.f, 400.f));
bgEntity->SetSize(sf::Vector2f(1000.f, 800.f));
GameEngine::GameEngineMain::GetInstance()->AddEntity(bgEntity);
m_backGround = bgEntity;
}
void GameBoard::CreateGameOverBackGround()
{
GameEngine::Entity *bgEntity = new GameEngine::Entity();
GameEngine::SpriteRenderComponent *render = bgEntity->AddComponent<GameEngine::SpriteRenderComponent>();
render->SetTexture(GameEngine::eTexture::failBg);
render->SetZLevel(10);
bgEntity->SetPos(sf::Vector2f(500.f, 400.f));
bgEntity->SetSize(sf::Vector2f(1000.f, 800.f));
GameEngine::GameEngineMain::GetInstance()->AddEntity(bgEntity);
m_backGround = bgEntity;
m_finalScore= new GameEngine::Entity();
m_finalScore->SetPos(sf::Vector2f(372.0f, 542.0f));
GameEngine::GameEngineMain::GetInstance()->AddEntity(m_finalScore);
GameEngine::TextRenderComponent *textRenderComponent = m_finalScore->AddComponent<GameEngine::TextRenderComponent>();
textRenderComponent->SetFont("ARCADECLASSIC.ttf");
textRenderComponent->SetCharacterSizePixels(45);
textRenderComponent->SetColor(sf::Color(132, 111, 100, 255));
textRenderComponent->SetString("Your Score " + std::to_string(m_score));
textRenderComponent->SetZLevel(11);
} | 33.873016 | 122 | 0.751406 | [
"render"
] |
a514195f9d4195e0970234327205cd5d28cdda45 | 13,221 | cpp | C++ | TAO/tao/PortableServer/Servant_Upcall.cpp | cflowe/ACE | 5ff60b41adbe1772372d1a43bcc1f2726ff8f810 | [
"DOC"
] | 36 | 2015-01-10T07:27:33.000Z | 2022-03-07T03:32:08.000Z | TAO/tao/PortableServer/Servant_Upcall.cpp | cflowe/ACE | 5ff60b41adbe1772372d1a43bcc1f2726ff8f810 | [
"DOC"
] | 2 | 2018-08-13T07:30:51.000Z | 2019-02-25T03:04:31.000Z | TAO/tao/PortableServer/Servant_Upcall.cpp | cflowe/ACE | 5ff60b41adbe1772372d1a43bcc1f2726ff8f810 | [
"DOC"
] | 38 | 2015-01-08T14:12:06.000Z | 2022-01-19T08:33:00.000Z | // $Id: Servant_Upcall.cpp 94802 2011-10-20 09:46:10Z mcorino $
#include "tao/PortableServer/Object_Adapter.h"
#include "tao/PortableServer/Servant_Upcall.h"
#include "tao/PortableServer/Root_POA.h"
#include "tao/PortableServer/Default_Servant_Dispatcher.h"
#include "tao/PortableServer/Collocated_Object_Proxy_Broker.h"
#include "tao/PortableServer/Active_Object_Map_Entry.h"
#include "tao/PortableServer/ForwardRequestC.h"
// -- TAO Include --
#include "tao/ORB.h"
#include "tao/ORB_Core.h"
#include "tao/debug.h"
#if !defined (__ACE_INLINE__)
# include "tao/PortableServer/Servant_Upcall.inl"
#endif /* __ACE_INLINE__ */
#include "ace/OS_NS_string.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
namespace TAO
{
namespace Portable_Server
{
Servant_Upcall::Servant_Upcall (TAO_ORB_Core *oc)
: object_adapter_ (0),
poa_ (0),
servant_ (0),
state_ (INITIAL_STAGE),
system_id_ (TAO_POA_OBJECT_ID_BUF_SIZE, 0, system_id_buf_),
user_id_ (0),
current_context_ (),
#if (TAO_HAS_MINIMUM_POA == 0)
cookie_ (0),
operation_ (0),
#endif /* TAO_HAS_MINIMUM_POA == 0 */
active_object_map_entry_ (0)
{
TAO_Object_Adapter *object_adapter =
dynamic_cast<TAO_Object_Adapter *>(oc->poa_adapter ());
this->object_adapter_ = object_adapter;
}
int
Servant_Upcall::prepare_for_upcall (
const TAO::ObjectKey &key,
const char *operation,
CORBA::Object_out forward_to)
{
while (1)
{
bool wait_occurred_restart_call = false;
int const result =
this->prepare_for_upcall_i (key,
operation,
forward_to,
wait_occurred_restart_call);
if (result == TAO_Adapter::DS_FAILED &&
wait_occurred_restart_call)
{
// We ended up waiting on a condition variable. The POA
// state may have changed while we are waiting. Therefore,
// we need to call prepare_for_upcall_i() again. We also
// need to cleanup the state of the upcall object before
// continuing.
this->upcall_cleanup ();
continue;
}
else
{
return result;
}
}
}
int
Servant_Upcall::prepare_for_upcall_i (
const TAO::ObjectKey &key,
const char *operation,
CORBA::Object_out forward_to,
bool &wait_occurred_restart_call)
{
// Acquire the object adapter lock first.
int result = this->object_adapter_->lock ().acquire ();
if (result == -1)
// Locking error.
throw ::CORBA::OBJ_ADAPTER ();
// We have acquired the object adapter lock. Record this for later
// use.
this->state_ = OBJECT_ADAPTER_LOCK_ACQUIRED;
// Check if a non-servant upcall is in progress. If a non-servant
// upcall is in progress, wait for it to complete. Unless of
// course, the thread making the non-servant upcall is this thread.
this->object_adapter_->wait_for_non_servant_upcalls_to_complete ();
// Locate the POA.
this->object_adapter_->locate_poa (key, this->system_id_, this->poa_);
// Check the state of the POA.
this->poa_->check_state ();
// Setup current for this request.
this->current_context_.setup (this->poa_, key);
// Increase <poa->outstanding_requests_> for the duration of finding
// the POA, finding the servant, and making the upcall.
this->poa_->increment_outstanding_requests ();
// We have setup the POA Current. Record this for later use.
this->state_ = POA_CURRENT_SETUP;
#if (TAO_HAS_MINIMUM_CORBA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
try
{
#endif /* TAO_HAS_MINIMUM_CORBA */
// Lookup the servant.
this->servant_ =
this->poa_->locate_servant_i (operation,
this->system_id_,
*this,
this->current_context_,
wait_occurred_restart_call);
if (wait_occurred_restart_call)
return TAO_Adapter::DS_FAILED;
#if (TAO_HAS_MINIMUM_CORBA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
}
catch (const ::PortableServer::ForwardRequest& forward_request)
{
forward_to =
CORBA::Object::_duplicate (forward_request.forward_reference.in ());
return TAO_Adapter::DS_FORWARD;
}
#else
ACE_UNUSED_ARG (forward_to);
#endif /* TAO_HAS_MINIMUM_CORBA */
// Now that we know the servant.
this->current_context_.servant (this->servant_);
// For servants from Servant Locators, there is no active object map
// entry.
if (this->active_object_map_entry ())
this->current_context_.priority (this->active_object_map_entry ()->priority_);
if (this->state_ != OBJECT_ADAPTER_LOCK_RELEASED)
{
// Release the object adapter lock.
this->object_adapter_->lock ().release ();
// We have release the object adapter lock. Record this for
// later use.
this->state_ = OBJECT_ADAPTER_LOCK_RELEASED;
}
// Serialize servants (if appropriate).
this->single_threaded_poa_setup ();
// We have acquired the servant lock. Record this for later use.
this->state_ = SERVANT_LOCK_ACQUIRED;
// After this point, <this->servant_> is ready for dispatching.
return TAO_Adapter::DS_OK;
}
void
Servant_Upcall::pre_invoke_remote_request (TAO_ServerRequest &req)
{
this->object_adapter_->servant_dispatcher_->pre_invoke_remote_request (
this->poa (),
this->priority (),
req,
this->pre_invoke_state_);
}
void
Servant_Upcall::pre_invoke_collocated_request (void)
{
this->object_adapter_->servant_dispatcher_->pre_invoke_collocated_request (
this->poa (),
this->priority (),
this->pre_invoke_state_);
}
void
Servant_Upcall::post_invoke (void)
{
this->object_adapter_->servant_dispatcher_->post_invoke (
this->poa (),
this->pre_invoke_state_);
}
Servant_Upcall::Pre_Invoke_State::Pre_Invoke_State (void)
: state_ (NO_ACTION_REQUIRED),
original_native_priority_ (0),
original_CORBA_priority_ (0)
{
}
::TAO_Root_POA *
Servant_Upcall::lookup_POA (const TAO::ObjectKey &key)
{
// Acquire the object adapter lock first.
if (this->object_adapter_->lock ().acquire () == -1)
// Locking error.
throw ::CORBA::OBJ_ADAPTER ();
// We have acquired the object adapter lock. Record this for later
// use.
this->state_ = OBJECT_ADAPTER_LOCK_ACQUIRED;
// Check if a non-servant upcall is in progress. If a non-servant
// upcall is in progress, wait for it to complete. Unless of
// course, the thread making the non-servant upcall is this thread.
this->object_adapter_->wait_for_non_servant_upcalls_to_complete ();
// Locate the POA.
this->object_adapter_->locate_poa (key, this->system_id_, this->poa_);
return this->poa_;
}
Servant_Upcall::~Servant_Upcall (void)
{
this->upcall_cleanup ();
}
void
Servant_Upcall::upcall_cleanup (void)
{
this->post_invoke ();
switch (this->state_)
{
case SERVANT_LOCK_ACQUIRED:
// Unlock servant (if appropriate).
this->single_threaded_poa_cleanup ();
/* FALLTHRU */
case OBJECT_ADAPTER_LOCK_RELEASED:
// Cleanup servant locator related state. Note that because
// this operation does not change any Object Adapter related
// state, it is ok to call it outside the lock.
this->post_invoke_servant_cleanup ();
// Since the object adapter lock was released, we must acquire
// it.
//
// Note that errors are ignored here since we cannot do much
// with it.
this->object_adapter_->lock ().acquire ();
// Check if a non-servant upcall is in progress. If a
// non-servant upcall is in progress, wait for it to complete.
// Unless of course, the thread making the non-servant upcall is
// this thread.
this->object_adapter_->wait_for_non_servant_upcalls_to_complete_no_throw ();
// Cleanup servant related state.
this->servant_cleanup ();
/* FALLTHRU */
case POA_CURRENT_SETUP:
// Cleanup POA related state.
this->poa_cleanup ();
// Teardown current for this request.
this->current_context_.teardown ();
/* FALLTHRU */
case OBJECT_ADAPTER_LOCK_ACQUIRED:
// Finally, since the object adapter lock was acquired, we must
// release it.
this->object_adapter_->lock ().release ();
/* FALLTHRU */
case INITIAL_STAGE:
default:
// @@ Keep compiler happy, the states above are the only
// possible ones.
break;
}
}
void
Servant_Upcall::post_invoke_servant_cleanup (void)
{
this->poa_->post_invoke_servant_cleanup (this->current_context_.object_id (),
*this);
}
void
Servant_Upcall::single_threaded_poa_setup (void)
{
#if (TAO_HAS_MINIMUM_POA == 0)
// Serialize servants (if necessary).
//
// Note that this lock must be acquired *after* the object adapter
// lock has been released. This is necessary since we cannot block
// waiting for the servant lock while holding the object adapter
// lock. Otherwise, the thread that wants to release this lock will
// not be able to do so since it can't acquire the object adapterx
// lock.
if (this->poa_->enter() == -1)
// Locking error.
throw ::CORBA::OBJ_ADAPTER ();
#endif /* !TAO_HAS_MINIMUM_POA == 0 */
}
void
Servant_Upcall::single_threaded_poa_cleanup (void)
{
#if (TAO_HAS_MINIMUM_POA == 0)
// Since the servant lock was acquired, we must release it.
int const result = this->poa_->exit ();
ACE_UNUSED_ARG (result);
#endif /* TAO_HAS_MINIMUM_POA == 0 */
}
void
Servant_Upcall::increment_servant_refcount (void)
{
// Cleanup servant related stuff.
if (this->active_object_map_entry_ != 0)
++this->active_object_map_entry_->reference_count_;
}
void
Servant_Upcall::servant_cleanup (void)
{
// Cleanup servant related stuff.
if (this->active_object_map_entry_ != 0)
{
// Decrement the reference count.
CORBA::UShort const new_count =
--this->active_object_map_entry_->reference_count_;
if (new_count == 0)
{
try
{
this->poa_->cleanup_servant (
this->active_object_map_entry_->servant_,
this->active_object_map_entry_->user_id_);
}
catch (...)
{
// Ignore errors from servant cleanup ....
}
if (this->poa_->waiting_servant_deactivation() > 0)
{
// Wakeup all waiting threads.
this->poa_->servant_deactivation_condition_.broadcast ();
}
}
}
}
void
Servant_Upcall::poa_cleanup (void)
{
// Decrease <poa->outstanding_requests_> now that the upcall
// is complete.
//
// Note that the object adapter lock is acquired before
// <POA::outstanding_requests_> is decreased.
CORBA::ULong outstanding_requests =
this->poa_->decrement_outstanding_requests ();
// Check if all pending requests are over.
if (outstanding_requests == 0)
{
// If locking is enabled and some thread is waiting in POA::destroy.
if (this->poa_->wait_for_completion_pending_)
{
// Wakeup all waiting threads.
this->poa_->outstanding_requests_condition_.broadcast ();
}
// Note that there is no need to check for
// <non_servant_upcall_in_progress> since it is not possible for
// non-servant upcalls to be in progress at this point.
if (this->poa_->waiting_destruction_)
{
try
{
this->poa_->complete_destruction_i ();
}
catch (const ::CORBA::Exception& ex)
{
// Ignore exceptions
ex._tao_print_exception ("TAO_POA::~complete_destruction_i");
}
this->poa_ = 0;
}
}
}
}
}
TAO_END_VERSIONED_NAMESPACE_DECL
| 31.705036 | 90 | 0.594206 | [
"object"
] |
a51b20df2435eabdf575eb5f982ec6a2f51a9797 | 4,292 | cpp | C++ | src/Gam/File.cpp | alexeevdv/libfalltergeist | dfa2604df3559d28cd7ca6dd3725b22e9d0cf0f1 | [
"MIT"
] | 6 | 2015-02-15T06:40:32.000Z | 2021-08-23T21:41:14.000Z | src/Gam/File.cpp | alexeevdv/libfalltergeist | dfa2604df3559d28cd7ca6dd3725b22e9d0cf0f1 | [
"MIT"
] | 6 | 2015-08-11T14:53:12.000Z | 2015-10-11T18:50:47.000Z | src/Gam/File.cpp | falltergeist/libfalltergeist | dfa2604df3559d28cd7ca6dd3725b22e9d0cf0f1 | [
"MIT"
] | 9 | 2015-02-12T07:30:08.000Z | 2020-09-03T17:46:50.000Z | /*
* The MIT License (MIT)
*
* Copyright (c) 2012-2015 Falltergeist developers
*
* 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.
*/
// C++ standard includes
#include <vector>
#include <algorithm>
// libfalltergeist includes
#include "../Gam/File.h"
#include "../Exception.h"
// Third party includes
namespace libfalltergeist
{
namespace Gam
{
File::File(Dat::Entry* datFileEntry) : Dat::Item(datFileEntry)
{
_initialize();
}
File::File(std::ifstream* stream) : Dat::Item(stream)
{
_initialize();
}
File::~File()
{
}
void File::_initialize()
{
if (_initialized) return;
Dat::Item::_initialize();
Dat::Item::setPosition(0);
unsigned int i = 0;
unsigned char ch;
std::string line;
while (i != this->size())
{
*this >> ch; i++;
if (ch != 0x0D) // \r
{
line += ch;
}
else
{
this->skipBytes(1); i++;// 0x0A \n
_parseLine(line);
line.clear();
}
}
if (line.length() != 0)
{
_parseLine(line);
}
}
void File::_parseLine(std::string line)
{
// отрезаем всё что после комментариев
if(line.find("//") != std::string::npos)
{
line = line.substr(0, line.find("//"));
}
// rtrim
line.erase(std::find_if(line.rbegin(), line.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), line.end());
if (line.length() == 0) return;
if (line == "GAME_GLOBAL_VARS:")
{
_GVARmode = true;
return;
}
if (line == "MAP_GLOBAL_VARS:")
{
_MVARmode = true;
return;
}
std::string name = line.substr(0, line.find(":="));
std::string value = line.substr(line.find(":=")+2,line.find(";")-line.find(":=")-2);
// rtrim
name.erase(std::find_if(name.rbegin(), name.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), name.end());
if (_GVARmode)
{
_GVARS.insert(std::make_pair(name, std::stoi(value)));
return;
}
else if(_MVARmode)
{
_MVARS.insert(std::make_pair(name, std::stoi(value)));
return;
}
else
{
throw Exception("File::_initialize() - unknown mode");
}
}
std::map<std::string, int>* File::GVARS()
{
_initialize();
return &_GVARS;
}
std::map<std::string, int>* File::MVARS()
{
_initialize();
return &_MVARS;
}
int File::GVAR(std::string name)
{
if (_GVARS.find(name) != _GVARS.end())
{
return _GVARS.at(name);
}
throw Exception("File::GVAR(name) - GVAR not found:" + name);
}
int File::MVAR(std::string name)
{
if (_MVARS.find(name) != _MVARS.end())
{
return _MVARS.at(name);
}
throw Exception("File::MVAR(name) - MVAR not found:" + name);
}
int File::GVAR(unsigned int number)
{
unsigned int i = 0;
for (auto gvar : _GVARS)
{
if (i == number) return gvar.second;
i++;
}
throw Exception("File::GVAR(number) - not found: " + std::to_string(number));
}
int File::MVAR(unsigned int number)
{
unsigned int i = 0;
for (auto mvar : _MVARS)
{
if (i == number) return mvar.second;
i++;
}
throw Exception("File::MVAR(number) - not found: " + std::to_string(number));
}
}
}
| 23.453552 | 125 | 0.604846 | [
"vector"
] |
a520b207c5c21647d5cbf0fc8ce3e8e11b2ed8cc | 11,540 | cpp | C++ | SarvLibrary/Kmerize/gerbil/src/gerbil/SequenceSplitter.cpp | cwright7101/llvm_sarvavid | 7567d617a7be78fecfde71ab04ebd8e9506a64e4 | [
"MIT"
] | 37 | 2017-01-04T12:31:47.000Z | 2022-03-11T08:47:32.000Z | SarvLibrary/Kmerize/gerbil/src/gerbil/SequenceSplitter.cpp | cwright7101/llvm_sarvavid | 7567d617a7be78fecfde71ab04ebd8e9506a64e4 | [
"MIT"
] | 18 | 2016-05-06T07:58:48.000Z | 2022-02-17T04:11:17.000Z | SarvLibrary/Kmerize/gerbil/src/gerbil/SequenceSplitter.cpp | cwright7101/llvm_sarvavid | 7567d617a7be78fecfde71ab04ebd8e9506a64e4 | [
"MIT"
] | 13 | 2016-05-16T12:52:50.000Z | 2022-03-02T19:26:50.000Z | /*
* SequenceSplitter.cpp
*
* Created on: 20.05.2015
* Author: marius
*/
#include "../../include/gerbil/SequenceSplitter.h"
#define SS_MMER_UNDEFINED 0x80000000
#define SS_BIN_UNDEFINED 0xffff
#define SS_MMER_VAL_UNDEFINED 0x80000000
gerbil::SequenceSplitter::SequenceSplitter(
const uint32 &superBundlesNumber, // number of SUperBundles
SyncSwapQueueMPMC<ReadBundle>* readBundleSyncQueue, // Queue with Bundles of reads
const uint8 &splitterThreadsNumber, // Number of SplitterThreads
const uint32_t &k, // size of k-mer
const uint8 &m, // Size of m-mer (minimizer)
const uint_tfn &tempFilesNumber, // Number of tempFiles
const bool &norm
): _norm(norm), _k(k), _m(m), _tempFilesNumber(tempFilesNumber), _splitterThreadCount(splitterThreadsNumber),
_readBundleSyncQueue(readBundleSyncQueue), _leftSuperBundles(NULL), _baseNumbers(0)
{
_superBundleQueues = new SyncSwapQueueMPSC<SuperBundle>*[SB_WRITER_THREADS_NUMBER];
for(uint i = 0; i < SB_WRITER_THREADS_NUMBER; ++i)
_superBundleQueues[i] = new SyncSwapQueueMPSC<SuperBundle>(superBundlesNumber / SB_WRITER_THREADS_NUMBER);
_splitterThreads = new std::thread*[_splitterThreadCount];
uint32 mMerNumber = 1 << (2 *_m); // 4^m
_mVal = new uint32[mMerNumber];
_mToBin = new uint_tfn[mMerNumber];
}
gerbil::SequenceSplitter::~SequenceSplitter() {
for(uint i = 0; i < SB_WRITER_THREADS_NUMBER; ++i)
delete _superBundleQueues[i];
delete[] _superBundleQueues;
delete[] _splitterThreads;
delete[] _mVal;
delete[] _mToBin;
}
gerbil::SyncSwapQueueMPSC<gerbil::SuperBundle>** gerbil::SequenceSplitter::getSuperBundleQueues() {
return _superBundleQueues;
}
uint32_t gerbil::SequenceSplitter::invMMer(const uint32_t &mmer){
uint32 rev = 0;
uint32 immer = ~mmer;
for(uint32 i = 0 ; i < _m ; ++i)
{
rev <<= 2;
rev |= immer & 0x3;
immer >>= 2;
}
return rev;
}
// kmc2 strategy
bool gerbil::SequenceSplitter::isAllowed(uint32 mmer) {
if(mmer > invMMer(mmer))
return false;
if(mmer == (0xaaaaaaaa >> (2 * (16 - _m + 2)))) // AAGGG..G
return false;
if(mmer== (0x55555555 >> (2 * (16 - _m + 2)))) // AACCC..C
return false;
for (uint32 j = 0; j < _m - 3; ++j)
if ((mmer & 0xf) == 0) // AA inside
return false;
else
mmer >>= 2;
if ((mmer & 0xf) == 0) // *AA prefix
return false;
if (mmer == 0) // AAA prefix
return false;
if (mmer == 0x04) // ACA prefix
return false;
return true;
}
void gerbil::SequenceSplitter::detMMerHisto() {
const uint32 mMersNumber = 1 << (2 * _m);
// kmc2 strategy
std::vector<std::pair<uint32_t,uint32_t>> kMerFrequencies;
for(uint32 mmer = 0; mmer < mMersNumber; ++mmer)
kMerFrequencies.push_back(std::make_pair(isAllowed(mmer) ? mmer : 0xffffffffu, mmer));
std::sort(kMerFrequencies.begin(), kMerFrequencies.end());
uint32 rank = 0;
for (std::vector<std::pair<uint32_t,uint32_t>>::iterator it = kMerFrequencies.begin() ; it != kMerFrequencies.end(); ++it) {
_mVal[it->second] = rank++;
}
// pyramid-shaped distribution
uint32 bfnx2 = 2 * _tempFilesNumber;
uint32 mMN = mMersNumber - mMersNumber % bfnx2;
int32 p = mMN / bfnx2;
for(uint32 i = 0; i < mMersNumber; ++i)
if(_mVal[i] < mMN){
int32 d = _mVal[i] / bfnx2;
int32 m = (_mVal[i] + d * bfnx2 / p) % bfnx2;
int32 x = m - (int32)_tempFilesNumber;
_mToBin[i] = x < 0 ? -x - 1 : x;
}
else
_mToBin[i] = _tempFilesNumber - 1 - (_mVal[i] % _tempFilesNumber);
}
void gerbil::SequenceSplitter::process() {
// calculate statistics
detMMerHisto();
_leftSuperBundles = new SuperBundle**[_tempFilesNumber];
for(uint i(0); i < _tempFilesNumber; ++i)
_leftSuperBundles[i] = new SuperBundle*[_splitterThreadCount];
// split reads to s-mers
for(uint i = 0; i < _splitterThreadCount; ++i)
_splitterThreads[i] = new std::thread([this](uint id){
processThread(id);
}, i);
}
void gerbil::SequenceSplitter::join() {
for(uint i = 0; i < _splitterThreadCount; ++i) {
_splitterThreads[i]->join();
delete _splitterThreads[i];
}
SuperBundle* lastSuperBundle;
// merge left superbundles
for(uint_tfn tempFileId(0); tempFileId < _tempFilesNumber; ++tempFileId) {
lastSuperBundle = _leftSuperBundles[tempFileId][0];
// merge all superbundles for unique file
for(size_t tId(1); tId < _splitterThreadCount; ++tId) {
// copy low to big
if(lastSuperBundle->getSize() < _leftSuperBundles[tempFileId][tId]->getSize())
std::swap(lastSuperBundle, _leftSuperBundles[tempFileId][tId]);
// merge
if(!lastSuperBundle->merge(*_leftSuperBundles[tempFileId][tId])) {
// store at fail
lastSuperBundle->finalize();
if(!lastSuperBundle->isEmpty())
_superBundleQueues[tempFileId % SB_WRITER_THREADS_NUMBER]->swapPush(lastSuperBundle);
std::swap(lastSuperBundle, _leftSuperBundles[tempFileId][tId]);
}
}
// store last superbundle
lastSuperBundle->finalize();
if(!lastSuperBundle->isEmpty())
_superBundleQueues[tempFileId % SB_WRITER_THREADS_NUMBER]->swapPush(lastSuperBundle);
}
// finalize all queues
for(uint i = 0; i < SB_WRITER_THREADS_NUMBER; ++i)
_superBundleQueues[i]->finalize();
// free memory
for(uint_tfn tempFileId(0); tempFileId < _tempFilesNumber; ++tempFileId) {
for(size_t tId(1); tId < _splitterThreadCount; ++tId)
delete _leftSuperBundles[tempFileId][tId];
delete[] _leftSuperBundles[tempFileId];
}
delete[] _leftSuperBundles;
}
void gerbil::SequenceSplitter::print() {
printf("number of bases : %12lu\n", _baseNumbers.load());
}
//private
/*
* adds a s-mer to the corresponding SuperBundle
* if necessary, the SuperBundle is stored in the queue
*/
#define SS_SAVE_S_MER { \
curTempFileId = bins[min_val_pos]; \
if(!curSuperBundles[curTempFileId]->add(rb->data + i - smer_c - _k + 1, smer_c + _k - 1, _k)) { \
curSuperBundles[curTempFileId]->finalize(); \
IF_MESS_SEQUENCESPLITTER(sw.hold();) \
_superBundleQueues[curTempFileId % SB_WRITER_THREADS_NUMBER]->swapPush(curSuperBundles[curTempFileId]); \
IF_MESS_SEQUENCESPLITTER(sw.proceed();) \
curSuperBundles[curTempFileId]->tempFileId = curTempFileId; \
curSuperBundles[curTempFileId]->add(rb->data + i - smer_c - _k + 1, smer_c + _k - 1, _k); \
}}
/*
* 0x0 => A, a
* 0x1 => C, c
* 0x2 => G, g
* 0x3 => T, t
* 0x4 => 'N', 'n', '.'
* 0x5 => 'E' (end of line)
* 0xf => others (Error)
*/
const gerbil::byte baseToByteA[256] = {
0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x4, 0xf,
0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
0xf, 0x0, 0xf, 0x1, 0xf, 0x5, 0xf, 0x2, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x4, 0xf,
0xf, 0xf, 0xf, 0xf, 0x3, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
0xf, 0x0, 0xf, 0x1, 0xf, 0xf, 0xf, 0x2, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x4, 0xf,
0xf, 0xf, 0xf, 0xf, 0x3, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,
0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf
};
void gerbil::SequenceSplitter::processThread(const uint &id) {
IF_MESS_SEQUENCESPLITTER(
StopWatch sw(CLOCK_THREAD_CPUTIME_ID);
sw.start();
)
ReadBundle* rb = new ReadBundle;
uint32 rc;
byte* reads_p_end;
byte* cur_p;
byte cur;
uint32 mmer;
uint32 inv_mmer;
uint32 m_mask = 0;
for(uint i = 0; i < _m; ++i)
m_mask = (m_mask << 2) | 0x3;
const byte inv[4] = {0x3, 0x2, 0x1, 0x0};
uint32* bins = new uint32[READ_BUNDLE_SIZE_B];
uint32* bins_p;
uint32* mmerval = new uint32[READ_BUNDLE_SIZE_B];
uint32* mmerval_p;
uint32 reads_size;
uint32 mmer_min;
uint64 baseNumbers(0);
byte ic;
SuperBundle** curSuperBundles = new SuperBundle*[_tempFilesNumber];
for(uint_tfn i = 0; i < _tempFilesNumber; ++i) {
curSuperBundles[i] = new SuperBundle();
curSuperBundles[i]->tempFileId = i;
}
while(_readBundleSyncQueue->swapPop(rb)) {
#ifdef DEB_SS_LOG_RB
rb->print();
#endif
rc = *(rb->readsCount);
reads_size = *(rb->readOffsets - rc);
reads_p_end = rb->data + reads_size;
cur_p = rb->data;
ic = _m;
mmer = 0;
inv_mmer = 0;
mmerval_p = mmerval;
bins_p = bins;
// save mmer values
for(; cur_p < reads_p_end; ++cur_p, ++mmerval_p, ++bins_p) {
*cur_p = (cur = baseToByteA[*cur_p]);
if(ic)
--ic;
if(cur < (byte)0x4) {
mmer = ((mmer << 2) | cur) & m_mask;
inv_mmer = (inv_mmer >> 2) | (inv[cur] << (2*(_m-1)));
++baseNumbers;
}
else {
ic = _m;
}
if(ic) {
*mmerval_p = SS_MMER_VAL_UNDEFINED;
*bins_p = SS_BIN_UNDEFINED;
}
else {
mmer_min = (!_norm || mmer < inv_mmer) ? mmer : inv_mmer;
*mmerval_p = _mVal[mmer_min];
*bins_p = _mToBin[mmer_min];
}
}
//
uint32 min_val = SS_MMER_VAL_UNDEFINED;
uint32 min_val_pos = 0;
uint cur_val;
int32 smer_c = (uint32) _m - _k;
uint_tfn curTempFileId;
for(uint32 i(_m - 1); i < reads_size; ++i) {
cur_val = mmerval[i];
if(cur_val == SS_MMER_VAL_UNDEFINED) {
// completed s-mer --> undefined minimizer (e.g. end of read)
// save the last smer
if(smer_c > 0) {
SS_SAVE_S_MER;
}
smer_c = _m - _k;
if(rb->data[i] > (byte)0x3) {
// jump
i += _m - 1;
}
min_val = SS_MMER_VAL_UNDEFINED;
}
else if(min_val == SS_MMER_VAL_UNDEFINED) {
// beginning of a new s-mer
min_val = cur_val;
min_val_pos = i;
++smer_c;
}
else if(min_val == cur_val) {
// extended s-mer --> equal minimizer
min_val_pos = i;
++smer_c;
}
else if(cur_val < min_val) {
// extended s-mer --> better minimizer, but same bin
// completed s-mer --> better minimizer
if(smer_c > 0 && bins[min_val_pos] != bins[i]) {
// save the last s-mer
SS_SAVE_S_MER;
smer_c = 1;
}
else
++smer_c;
min_val = cur_val;
min_val_pos = i;
}
else if(i - min_val_pos > _k - _m || smer_c > 512) {
//else if(i - min_val_pos > _k - _m) {
// completed s-mer --> minimizer is out of range
// save last s-mer
if(smer_c > 0) {
SS_SAVE_S_MER;
smer_c = 1;
}
else
++smer_c;
min_val = cur_val;
min_val_pos = i;
for(uint x = _k - _m; x > 0 ; --x)
if(mmerval[i - x] < min_val) {
min_val = mmerval[i - x];
min_val_pos = i - x;
}
}
else {
// extended s-mer --> current minimizer is still the best
++smer_c;
}
}
rb->clear();
}
_baseNumbers += baseNumbers;
for(uint_tfn i = 0; i < _tempFilesNumber; ++i)
_leftSuperBundles[i][id] = curSuperBundles[i];
// free memory
delete rb;
delete[] bins;
delete[] mmerval;
delete[] curSuperBundles;
IF_MESS_SEQUENCESPLITTER(
sw.stop();
printf("splitter[%2u]: %.3f s\n", id, sw.get_s());
)
}
| 29.06801 | 125 | 0.638995 | [
"vector"
] |
a52815e7f80395e9adda627511fbaf660b744343 | 22,918 | cpp | C++ | src/drivers/cc2500/cc2500_main.cpp | Dapingguo001/wenzhou_university-1.6.5 | 0af9f059c5f1e32cc085392659b391d38455ca92 | [
"BSD-3-Clause"
] | null | null | null | src/drivers/cc2500/cc2500_main.cpp | Dapingguo001/wenzhou_university-1.6.5 | 0af9f059c5f1e32cc085392659b391d38455ca92 | [
"BSD-3-Clause"
] | null | null | null | src/drivers/cc2500/cc2500_main.cpp | Dapingguo001/wenzhou_university-1.6.5 | 0af9f059c5f1e32cc085392659b391d38455ca92 | [
"BSD-3-Clause"
] | null | null | null | #include "cc2500.h"
#include <drivers/device/spi.h>
#include <px4_config.h>
#include <stm32_gpio.h>
#include <lib/geo/geo.h>
#include <mathlib/mathlib.h>
#include <drivers/drv_hrt.h>
#include <nuttx/config.h>
#include <uORB/topics/cc2500_message.h>
#include <uORB/topics/vehicle_global_position.h>
#include <uORB/topics/home_position.h>
#include <uORB/topics/mission_result.h>
#include <uORB/topics/control_state.h>
#include <uORB/topics/vehicle_gps_position.h>
extern "C" __EXPORT int cc2500_main(int argc, char *argv[]);
#define cc2500_SPI_BUS_SPEED 2*1000*1000
#define cc2500_spi_bus 4
#define cc2500_spi_bus_cs 2 //对应的CS
#define CC2500_MAX_EXCHANGE_DATA 255
#define SPI_CS_LOW px4_arch_gpiowrite(GPIO_PORTC|GPIO_PIN14,0)
#define SPI_CS_HIGH px4_arch_gpiowrite(GPIO_PORTC|GPIO_PIN14,1);
#define WRITE_SINGLE 0x00
#define WRITE_BURST 0x40
#define READ_SINGLE 0x80
#define READ_BURST 0xC0
#ifndef __TI_CC_CC1100_CC2500_H
#define __TI_CC_CC1100_CC2500_H
// Configuration Registers 配置寄存器
#define TI_CCxxx0_IOCFG2 0x00 // GDO2 output pin configuration
#define TI_CCxxx0_IOCFG1 0x01 // GDO1 output pin configuration
#define TI_CCxxx0_IOCFG0 0x02 // GDO0 output pin configuration
#define TI_CCxxx0_FIFOTHR 0x03 // RX FIFO and TX FIFO thresholds
#define TI_CCxxx0_SYNC1 0x04 // Sync word, high byte
#define TI_CCxxx0_SYNC0 0x05 // Sync word, low byte
#define TI_CCxxx0_PKTLEN 0x06 // Packet length
#define TI_CCxxx0_PKTCTRL1 0x07 // Packet automation control
#define TI_CCxxx0_PKTCTRL0 0x08 // Packet automation control
#define TI_CCxxx0_ADDR 0x09 // Device address
#define TI_CCxxx0_CHANNR 0x0A // Channel number
#define TI_CCxxx0_FSCTRL1 0x0B // Frequency synthesizer control
#define TI_CCxxx0_FSCTRL0 0x0C // Frequency synthesizer control
#define TI_CCxxx0_FREQ2 0x0D // Frequency control word, high byte
#define TI_CCxxx0_FREQ1 0x0E // Frequency control word, middle byte
#define TI_CCxxx0_FREQ0 0x0F // Frequency control word, low byte
#define TI_CCxxx0_MDMCFG4 0x10 // Modem configuration
#define TI_CCxxx0_MDMCFG3 0x11 // Modem configuration
#define TI_CCxxx0_MDMCFG2 0x12 // Modem configuration
#define TI_CCxxx0_MDMCFG1 0x13 // Modem configuration
#define TI_CCxxx0_MDMCFG0 0x14 // Modem configuration
#define TI_CCxxx0_DEVIATN 0x15 // Modem deviation setting
#define TI_CCxxx0_MCSM2 0x16 // Main Radio Cntrl State Machine config
#define TI_CCxxx0_MCSM1 0x17 // Main Radio Cntrl State Machine config
#define TI_CCxxx0_MCSM0 0x18 // Main Radio Cntrl State Machine config
#define TI_CCxxx0_FOCCFG 0x19 // Frequency Offset Compensation config
#define TI_CCxxx0_BSCFG 0x1A // Bit Synchronization configuration
#define TI_CCxxx0_AGCCTRL2 0x1B // AGC control
#define TI_CCxxx0_AGCCTRL1 0x1C // AGC control
#define TI_CCxxx0_AGCCTRL0 0x1D // AGC control
#define TI_CCxxx0_WOREVT1 0x1E // High byte Event 0 timeout
#define TI_CCxxx0_WOREVT0 0x1F // Low byte Event 0 timeout
#define TI_CCxxx0_WORCTRL 0x20 // Wake On Radio control
#define TI_CCxxx0_FREND1 0x21 // Front end RX configuration
#define TI_CCxxx0_FREND0 0x22 // Front end TX configuration
#define TI_CCxxx0_FSCAL3 0x23 // Frequency synthesizer calibration
#define TI_CCxxx0_FSCAL2 0x24 // Frequency synthesizer calibration
#define TI_CCxxx0_FSCAL1 0x25 // Frequency synthesizer calibration
#define TI_CCxxx0_FSCAL0 0x26 // Frequency synthesizer calibration
#define TI_CCxxx0_RCCTRL1 0x27 // RC oscillator configuration
#define TI_CCxxx0_RCCTRL0 0x28 // RC oscillator configuration
#define TI_CCxxx0_FSTEST 0x29 // Frequency synthesizer cal control
#define TI_CCxxx0_PTEST 0x2A // Production test
#define TI_CCxxx0_AGCTEST 0x2B // AGC test
#define TI_CCxxx0_TEST2 0x2C // Various test settings
#define TI_CCxxx0_TEST1 0x2D // Various test settings
#define TI_CCxxx0_TEST0 0x2E // Various test settings
// Strobe commands 命令滤波
#define TI_CCxxx0_SRES 0x30 // Reset chip.
#define TI_CCxxx0_SFSTXON 0x31 // Enable/calibrate freq synthesizer
#define TI_CCxxx0_SXOFF 0x32 // Turn off crystal oscillator.
#define TI_CCxxx0_SCAL 0x33 // Calibrate freq synthesizer & disable
#define TI_CCxxx0_SRX 0x34 // Enable RX.
#define TI_CCxxx0_STX 0x35 // Enable TX.
#define TI_CCxxx0_SIDLE 0x36 // Exit RX / TX
#define TI_CCxxx0_SAFC 0x37 // AFC adjustment of freq synthesizer
#define TI_CCxxx0_SWOR 0x38 // Start automatic RX polling sequence
#define TI_CCxxx0_SPWD 0x39 // Enter pwr down mode when CSn goes hi
#define TI_CCxxx0_SFRX 0x3A // Flush the RX FIFO buffer.
#define TI_CCxxx0_SFTX 0x3B // Flush the TX FIFO buffer.
#define TI_CCxxx0_SWORRST 0x3C // Reset real time clock.
#define TI_CCxxx0_SNOP 0x3D // No operation.
// Status registers 状态寄存器
#define TI_CCxxx0_PARTNUM 0x30 // Part number
#define TI_CCxxx0_VERSION 0x31 // Current version number
#define TI_CCxxx0_FREQEST 0x32 // Frequency offset estimate
#define TI_CCxxx0_LQI 0x33 // Demodulator estimate for link quality
#define TI_CCxxx0_RSSI 0x34 // Received signal strength indication
#define TI_CCxxx0_MARCSTATE 0x35 // Control state machine state
#define TI_CCxxx0_WORTIME1 0x36 // High byte of WOR timer
#define TI_CCxxx0_WORTIME0 0x37 // Low byte of WOR timer
#define TI_CCxxx0_PKTSTATUS 0x38 // Current GDOx status and packet status
#define TI_CCxxx0_VCO_VC_DAC 0x39 // Current setting from PLL cal module
#define TI_CCxxx0_TXBYTES 0x3A // Underflow and # of bytes in TXFIFO
#define TI_CCxxx0_RXBYTES 0x3B // Overflow and # of bytes in RXFIFO
#define TI_CCxxx0_NUM_RXBYTES 0x7F // Mask "# of bytes" field in _RXBYTES
// Other memory locations
#define TI_CCxxx0_PATABLE 0x3E
#define TI_CCxxx0_TXFIFO 0x3F
#define TI_CCxxx0_RXFIFO 0x3F
// Masks for appended status bytes
#define TI_CCxxx0_LQI_RX 0x01 // Position of LQI byte
#define TI_CCxxx0_CRC_OK 0x80 // Mask "CRC_OK" bit within LQI byte
// Definitions to support burst/single access:
#define TI_CCxxx0_WRITE_BURST 0x40
#define TI_CCxxx0_READ_SINGLE 0x80
#define TI_CCxxx0_READ_BURST 0xC0
#endif
namespace cc2500
{
CC2500 *g_cc2500;
}
CC2500::CC2500(int bus, spi_dev_e device):
SPI("cc2500",nullptr, bus, device, SPIDEV_MODE0, cc2500_SPI_BUS_SPEED),
_task_should_exit(false),
cc2500_spi_bus_high(false)
{
}
CC2500::~CC2500()
{
_task_should_exit = true;
}
int
CC2500::init(){
int ret ;
ret = TI_CC_SPISetup();
if (ret != OK) {
DEVICE_DEBUG("SPI init failed");
return -EIO;
}
TI_CC_PowerupResetCCxxxx();
writeRFSettings();
//TI_CC_SPIStrobe(TI_CCxxx0_SRX);
ASSERT(_cc2500_task == -1);
/* start the task */
_cc2500_task = px4_task_spawn_cmd("cc2500",
SCHED_DEFAULT,
SCHED_PRIORITY_DEFAULT + 5,
1800,
(px4_main_t)&CC2500::task_main_trampoline,
nullptr);
if (_cc2500_task < 0) {
warn("task start failed");
return -errno;
}
return OK;
}
void
CC2500::task_main_trampoline()
{
cc2500::g_cc2500->run();
}
void
CC2500::run()
{
bool cc2500_message_updated = false;
bool global_pos_updated = false;
bool home_position_updated = false;
bool mission_result__updated = false;
bool ctrl_state_updated = false;
bool gps_pos_updated = false;
char p_buf[30] = {18,1,0,1,2,3,4,5};
uint32_t temp32;
uint16_t temp16;
char *p;
math::Matrix<3, 3> _R; /**< rotation matrix from attitude quaternions */
int _cc2500_message_pub = orb_subscribe(ORB_ID(cc2500_message));
memset(&_cc2500_message, 0, sizeof(_cc2500_message));
int global_pos_sub = orb_subscribe(ORB_ID(vehicle_global_position));
memset(&_global_pos, 0, sizeof(_global_pos));
int gps_pos_sub = orb_subscribe(ORB_ID(vehicle_gps_position));
memset(&_gps_pos, 0, sizeof(_gps_pos));
int home_pos_sub = orb_subscribe(ORB_ID(home_position));
memset(&_home_pos, 0, sizeof(_home_pos));
int mission_result_pub = orb_subscribe(ORB_ID(mission_result));
memset(&_mission_result, 0, sizeof(_mission_result));
int _ctrl_state_sub = orb_subscribe(ORB_ID(control_state));;
memset(&_ctrl_state, 0, sizeof(_ctrl_state));
// bool flag_pwm = false;
//char read_byte;
while(!_task_should_exit)
{
usleep(50000);
orb_check(_cc2500_message_pub, &cc2500_message_updated);
if (cc2500_message_updated) {
orb_copy(ORB_ID(cc2500_message), _cc2500_message_pub, &_cc2500_message);
_cc2500_send_location_data_packet = _cc2500_message.cc2500_send_location_data_packet;
}
orb_check(global_pos_sub, &global_pos_updated);
if (global_pos_updated) {
orb_copy(ORB_ID(vehicle_global_position), global_pos_sub, &_global_pos);
}
orb_check(gps_pos_sub, &gps_pos_updated);
if (gps_pos_updated) {
orb_copy(ORB_ID(vehicle_gps_position), gps_pos_sub, &_gps_pos);
}
orb_check(home_pos_sub, &home_position_updated);
if (home_position_updated) {
orb_copy(ORB_ID(home_position), home_pos_sub, &_home_pos);
home_position_altitude = _home_pos.alt;
}
orb_check(mission_result_pub, &mission_result__updated);
if (mission_result__updated) {
orb_copy(ORB_ID(mission_result), mission_result_pub, &_mission_result);
}
orb_check(_ctrl_state_sub, &ctrl_state_updated);
if (ctrl_state_updated) {
orb_copy(ORB_ID(control_state), _ctrl_state_sub, &_ctrl_state);
math::Quaternion q_att(_ctrl_state.q[0], _ctrl_state.q[1], _ctrl_state.q[2], _ctrl_state.q[3]);
_R = q_att.to_dcm();
math::Vector<3> euler_angles;
euler_angles = _R.to_euler();
_yaw = euler_angles(2);
if(_yaw < 0)
{
_yaw = 2 * 3.1415926f + _yaw;
}
}
/*if(global_pos_updated)
{
location_data_packet.lattitude = (uint32_t)((float)(_global_pos.lat) * 2147483648.0f / 3.1415926f);
location_data_packet.longtitude = (uint32_t)((float)(_global_pos.lon) * 2147483648.0f / 3.1415926f);
location_data_packet.global_altitude = (uint32_t)(_global_pos.alt * 100.0f);
location_data_packet.altitude = (uint32_t)((float)(_global_pos.alt - home_position_altitude) * 100.0f);
location_data_packet.yaw = (uint16_t)((_global_pos.yaw) * 65536.0f / (2.0f * 3.1415926f));
}*/
// temp32 = (uint32_t)((float)(_global_pos.lon) / 180.0f * 2147483648.0f);
temp32 = (uint32_t)((float)(_gps_pos.lon / 1e7) / 180.0f * 2147483648.0f);
p = (char*)(&temp32);
for(int i=0; i<4; i++)
{
p_buf[2+i] = (*(p+i));
}
// temp32 = (uint32_t)((float)(_global_pos.lat) /180.0f * 2147483648.0f);
temp32 = (uint32_t)((float)(_gps_pos.lat / 1e7) /180.0f * 2147483648.0f);
p = (char*)(&temp32);
for(int i=0; i<4; i++)
{
p_buf[6+i] = (*(p+i));
}
temp32 = (uint32_t)(_global_pos.alt * 100.0f);
p = (char*)(&temp32);
for(int i=0; i<4; i++)
{
p_buf[10+i] = (*(p+i));
}
temp16 = (uint16_t)((_yaw) * 65536.0f / (2.0f * 3.1415926f));
p = (char*)(&temp16);
p_buf[14] = *p;
p_buf[15] = *(p+1);
//temp32 = (uint32_t)((float)(_global_pos.alt - home_position_altitude) * 100.0f);
//_mission_result.seq_reached = 2;
temp16 = (uint16_t)(_mission_result.seq_reached);
p = (char*)(&temp16);
for(int i=0; i<4; i++)
{
p_buf[16+i] = (*(p+i));
}
if(_cc2500_send_location_data_packet)
{
//::printf("yuwenbin........................test.......\n");
RFSendPacket(p_buf,30);
}
//read_byte = TI_CC_SPIReadReg(TI_CCxxx0_MDMCFG2);
//::printf("yuewenbin..........test........%d\n",read_byte);
/* if(flag_pwm)
{
flag_pwm = false;
px4_arch_gpiowrite((GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN14),true);
}
else
{
flag_pwm = true;
px4_arch_gpiowrite((GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN14),false);
}*/
}
}
void
CC2500::Wait_CC_Ready(void)
{
uint32_t delaytime;
px4_arch_configgpio(GPIO_INPUT|GPIO_PORTE|GPIO_PIN5|GPIO_FLOAT|GPIO_SPEED_50MHz); //
delaytime = hrt_absolute_time() + 2000; //延迟2ms
while(stm32_gpioread(GPIO_PORTE|GPIO_PIN5))
{
if((delaytime-hrt_absolute_time())&0x80000000)
break;
}
px4_arch_configgpio(GPIO_SPI4_MISO);
}
// Delay function. # of CPU cycles delayed is similar to "cycles". Specifically,
// it's ((cycles-15) % 6) + 15. Not exact, but gives a sense of the real-time
// delay. Also, if MCLK ~1MHz, "cycles" is similar to # of useconds delayed.
void
CC2500::TI_CC_Wait(unsigned int cycles)
{
while(cycles>15) // 15 cycles consumed by overhead
cycles = cycles - 6; // 6 cycles consumed each iteration
}
uint8_t
CC2500::SPI_CC_SendByte(uint8_t byte)
{
Wait_CC_Ready();
transfer(&byte,&byte,1);
return byte;
}
uint8_t
CC2500::TI_CC_SPISetup(void)
{
uint8_t ret;
ret = SPI::init();
if (ret != OK) {
DEVICE_DEBUG("SPI init failed");
//return -EIO;
}
px4_arch_configgpio(GPIO_OUTPUT|GPIO_PORTC|GPIO_PIN14|GPIO_FLOAT|GPIO_SPEED_50MHz); //配置PC14作为CS线
return OK;
}
void
CC2500::TI_CC_SPIWriteReg(char addr, char value)
{
uint8_t data[CC2500_MAX_EXCHANGE_DATA];
data[0] = (uint8_t)(addr | WRITE_SINGLE);
data[1] = (uint8_t)(value);
Wait_CC_Ready();
transfer(data,data,2);
}
void
CC2500::TI_CC_SPIWriteBurstReg(char addr, char *buffer, char count)
{
uint8_t data[CC2500_MAX_EXCHANGE_DATA];
data[0] = (uint8_t)(addr | WRITE_BURST);
for(int i = 0;i <count; i++)
{
data[i+1] = (uint8_t)(buffer[i]);
}
Wait_CC_Ready();
transfer(data,data,count+1);
}
char
CC2500::TI_CC_SPIReadReg(char addr)
{
uint8_t data[CC2500_MAX_EXCHANGE_DATA];
data[0] = addr | READ_SINGLE;
data[1] = 0;
Wait_CC_Ready();
transfer(data,data, 2);
return (char)(data[1]);
}
void
CC2500::TI_CC_SPIReadBurstReg(char addr, char *buffer, char count)
{
uint8_t data[CC2500_MAX_EXCHANGE_DATA];
data[0] = (uint8_t)(addr | READ_BURST);
for(int i = 0;i <count; i++)
{
data[i+1] = 0;
}
Wait_CC_Ready();
transfer(data,data,count+1);
for(int i = 0;i <count; i++)
{
buffer[i] = data[i+1];
}
}
// For status/strobe addresses, the BURST bit selects between status registers
// and command strobes.
char
CC2500::TI_CC_SPIReadStatus(char addr)
{
uint8_t data[2];
data[0] = (uint8_t)(addr | READ_SINGLE);
data[1] = (uint8_t)(0);
transfer(data,data,2);
return (char)(data[1]);
}
void
CC2500::TI_CC_SPIStrobe(char strobe)
{
Wait_CC_Ready();
SPI_CC_SendByte(strobe);
}
void
CC2500::TI_CC_PowerupResetCCxxxx(void)
{
SPI_CS_HIGH;
TI_CC_Wait(3000);
SPI_CS_LOW;
TI_CC_Wait(6000);
SPI_CS_HIGH;
TI_CC_Wait(4500);
SPI_CS_LOW; // /CS enable
Wait_CC_Ready();
TI_CC_Wait(4500);
SPI_CC_SendByte(TI_CCxxx0_SRES);
TI_CC_Wait(4500);
SPI_CS_HIGH;
}
void
CC2500::GDO0_Init(void)
{
}
void
CC2500::writeRFSettings(void) //2.4Gs
{
GDO0_Init();
char PaTabel[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
TI_CC_SPIWriteReg(TI_CCxxx0_IOCFG2, 0x1B); // GDO2 output pin config.�����½��ؽ����������ر���ȡ
TI_CC_SPIWriteReg(TI_CCxxx0_IOCFG0, 0x06); // GDO0 output pin config.��ͬ���ʻ㱻����/�յ�ʱ�����������ݰ�ĩ�˷�����
TI_CC_SPIWriteReg(TI_CCxxx0_PKTLEN, 0xFF); // Packet length.���ݰ�����
TI_CC_SPIWriteReg(TI_CCxxx0_PKTCTRL1, 0x05); // Packet automation control.״̬�ֽ�RSSI��LQI��CRC����OK��Ǹ��������ݰ�β�ˣ���ַ��飬�㲥
TI_CC_SPIWriteReg(TI_CCxxx0_PKTCTRL0, 0x05); // Packet automation control.����CRCУ���ɱ䳤���ݰ���ͬ���ʻ���һ��λ�������ݰ�����
TI_CC_SPIWriteReg(TI_CCxxx0_ADDR, 0x01); // Device address.���ݰ�����ʱʹ�õĵ�ַ
TI_CC_SPIWriteReg(TI_CCxxx0_CHANNR, 0x00); // Channel number.�ŵ���
TI_CC_SPIWriteReg(TI_CCxxx0_FSCTRL1, 0x06); // Freq synthesizer control.
TI_CC_SPIWriteReg(TI_CCxxx0_FSCTRL0, 0x00); // Freq synthesizer control.
TI_CC_SPIWriteReg(TI_CCxxx0_FREQ2, 0x5D); // Freq control word, high byte ����Ϊ2438MHz
TI_CC_SPIWriteReg(TI_CCxxx0_FREQ1, 0x93); // Freq control word, mid byte.
TI_CC_SPIWriteReg(TI_CCxxx0_FREQ0, 0xB1); // Freq control word, low byte.
TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG4, 0x78); // Modem configuration. ���ƽ��������
TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG3, 0x93); // Modem configuration.
TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG2, 0x03); // Modem configuration.
TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG1, 0x22); // Modem configuration.
TI_CC_SPIWriteReg(TI_CCxxx0_MDMCFG0, 0xF8); // Modem configuration.
TI_CC_SPIWriteReg(TI_CCxxx0_DEVIATN, 0x44); // Modem dev (when FSK mod en)
TI_CC_SPIWriteReg(TI_CCxxx0_MCSM1 , 0x3F); //MainRadio Cntrl State Machine
TI_CC_SPIWriteReg(TI_CCxxx0_MCSM0 , 0x18); //MainRadio Cntrl State Machine ���ݰ����պ���뷢��״̬���ź���RSSI���£������ŵ����ز�������
TI_CC_SPIWriteReg(TI_CCxxx0_FOCCFG, 0x16); // Freq Offset Compens. Config
TI_CC_SPIWriteReg(TI_CCxxx0_BSCFG, 0x6C); // Bit synchronization config.
TI_CC_SPIWriteReg(TI_CCxxx0_AGCCTRL2, 0x43); // AGC control.
TI_CC_SPIWriteReg(TI_CCxxx0_AGCCTRL1, 0x40); // AGC control.
TI_CC_SPIWriteReg(TI_CCxxx0_AGCCTRL0, 0x91); // AGC control.
TI_CC_SPIWriteReg(TI_CCxxx0_FREND1, 0x56); // Front end RX configuration.
TI_CC_SPIWriteReg(TI_CCxxx0_FREND0, 0x10); // Front end RX configuration.
TI_CC_SPIWriteReg(TI_CCxxx0_FSCAL3, 0xA9); // Frequency synthesizer cal.
TI_CC_SPIWriteReg(TI_CCxxx0_FSCAL2, 0x0A); // Frequency synthesizer cal.
TI_CC_SPIWriteReg(TI_CCxxx0_FSCAL1, 0x00); // Frequency synthesizer cal.
TI_CC_SPIWriteReg(TI_CCxxx0_FSCAL0, 0x11); // Frequency synthesizer cal.
TI_CC_SPIWriteReg(TI_CCxxx0_FSTEST, 0x59); // Frequency synthesizer cal.
TI_CC_SPIWriteReg(TI_CCxxx0_TEST2, 0x88); // Various test settings.
TI_CC_SPIWriteReg(TI_CCxxx0_TEST1, 0x31); // Various test settings.
TI_CC_SPIWriteReg(TI_CCxxx0_TEST0, 0x0B); // Various test settings.
TI_CC_SPIWriteBurstReg(TI_CCxxx0_PATABLE,PaTabel,8);
TI_CC_SPIStrobe(TI_CCxxx0_SFRX);
TI_CC_SPIStrobe(TI_CCxxx0_SFTX);
TI_CC_SPIStrobe(TI_CCxxx0_SIDLE);
}
void
CC2500::RFSendPacket(char *txBuffer, char size)
{
TI_CC_SPIStrobe(TI_CCxxx0_SIDLE);
TI_CC_SPIStrobe(TI_CCxxx0_SFTX);
TI_CC_SPIWriteBurstReg(TI_CCxxx0_TXFIFO, txBuffer, size); // Write TX data
TI_CC_SPIStrobe(TI_CCxxx0_STX);
}
//-----------------------------------------------------------------------------
// char RFReceivePacket(char *rxBuffer, char *length)
//
// DESCRIPTION:
// Receives a packet of variable length (first byte in the packet must be the
// length byte). The packet length should not exceed the RXFIFO size. To use
// this function, APPEND_STATUS in the PKTCTRL1 register must be enabled. It
// is assumed that the function is called after it is known that a packet has
// been received; for example, in response to GDO0 going low when it is
// configured to output packet reception status.
//
// The RXBYTES register is first read to ensure there are bytes in the FIFO.
// This is done because the GDO signal will go high even if the FIFO is flushed
// due to address filtering, CRC filtering, or packet length filtering.
//
// ARGUMENTS:
// char *rxBuffer
// Pointer to the buffer where the incoming data should be stored
// char *length
// Pointer to a variable containing the size of the buffer where the
// incoming data should be stored. After this function returns, that
// variable holds the packet length.
//
// RETURN VALUE:
// char
// 0x80: CRC OK
// 0x00: CRC NOT OK (or no pkt was put in the RXFIFO due to filtering)
//-----------------------------------------------------------------------------
char
CC2500::RFReceivePacket(char *rxBuffer, char *length, unsigned char *RSSI)
{
char status[2];
char pktLen;
if ((TI_CC_SPIReadStatus(TI_CCxxx0_RXBYTES) & TI_CCxxx0_NUM_RXBYTES))
{
pktLen = TI_CC_SPIReadReg(TI_CCxxx0_RXFIFO); // Read length byte
if (pktLen <= *length) // If pktLen size <= rxBuffer
{
TI_CC_SPIReadBurstReg(TI_CCxxx0_RXFIFO, rxBuffer, pktLen); // Pull data
*length = pktLen; // Return the actual size
TI_CC_SPIReadBurstReg(TI_CCxxx0_RXFIFO, status, 2);
// Read appended status bytes
*RSSI = status[0];
TI_CC_SPIStrobe(TI_CCxxx0_SFRX);
TI_CC_SPIStrobe(TI_CCxxx0_SIDLE);
return (char)(status[TI_CCxxx0_LQI_RX]&TI_CCxxx0_CRC_OK);
} // Return CRC_OK bit
else
{
*length = pktLen; // Return the large size
TI_CC_SPIStrobe(TI_CCxxx0_SFRX); // Flush RXFIFO
TI_CC_SPIStrobe(TI_CCxxx0_SIDLE);
return 0; // Error
}
}
else
return 0; // Error
}
int
cc2500_main(int argc, char *argv[])
{
if (!strcmp(argv[1], "start")) {
if (cc2500::g_cc2500 != nullptr) {
PX4_WARN("already running");
return 1;
}
cc2500::g_cc2500= new CC2500(cc2500_spi_bus, (spi_dev_e)(2)); //bus: 使能SPI_CS
if(cc2500::g_cc2500->init() != OK){
delete cc2500::g_cc2500;
}
}
return 1;
} | 33.752577 | 130 | 0.643948 | [
"vector"
] |
a52b0c88f9b62c60455073f0499e64a65c438318 | 400 | cpp | C++ | Notes_Week9/Stack/stackSTL.cpp | WeiChienHsu/CS165 | 65e95efc90415c8acc707e2d544eb384d3982e18 | [
"MIT"
] | 1 | 2019-01-06T22:36:01.000Z | 2019-01-06T22:36:01.000Z | Notes_Week9/Stack/stackSTL.cpp | WeiChienHsu/CS165 | 65e95efc90415c8acc707e2d544eb384d3982e18 | [
"MIT"
] | null | null | null | Notes_Week9/Stack/stackSTL.cpp | WeiChienHsu/CS165 | 65e95efc90415c8acc707e2d544eb384d3982e18 | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
#include <stack>
int main() {
std::stack<double> dStack;
for(double x = 2; x < 9; x++) {
std::cout << "Pushing " << x << std::endl;
dStack.push(x);
}
std::cout << "The size of the stack is: ";
std::cout << dStack.size() << std::endl;
while(!dStack.empty()) {
std::cout << dStack.top() << std::endl;
dStack.pop();
}
return 0;
} | 19.047619 | 46 | 0.5475 | [
"vector"
] |
a52d2dce4e9e3413022f1afb02e31fae689b6fd0 | 6,052 | hpp | C++ | modules/scene_manager/include/sensor_msgs/msg/range__struct.hpp | Omnirobotic/godot | d50b5d047bbf6c68fc458c1ad097321ca627185d | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | 1 | 2020-05-19T14:33:49.000Z | 2020-05-19T14:33:49.000Z | ros2_mod_ws/install/include/sensor_msgs/msg/range__struct.hpp | mintforpeople/robobo-ros2-ios-port | 1a5650304bd41060925ebba41d6c861d5062bfae | [
"Apache-2.0"
] | 3 | 2019-11-14T12:20:06.000Z | 2020-08-07T13:51:10.000Z | modules/scene_manager/include/sensor_msgs/msg/range__struct.hpp | Omnirobotic/godot | d50b5d047bbf6c68fc458c1ad097321ca627185d | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | null | null | null | // generated from rosidl_generator_cpp/resource/msg__struct.hpp.em
// generated code does not contain a copyright notice
#ifndef SENSOR_MSGS__MSG__RANGE__STRUCT_HPP_
#define SENSOR_MSGS__MSG__RANGE__STRUCT_HPP_
// Protect against ERROR being predefined on Windows, in case somebody defines a
// constant by that name.
#if defined(_WIN32) && defined(ERROR)
#undef ERROR
#endif
#include <rosidl_generator_cpp/bounded_vector.hpp>
#include <rosidl_generator_cpp/message_initialization.hpp>
#include <algorithm>
#include <array>
#include <memory>
#include <string>
#include <vector>
// include message dependencies
#include "std_msgs/msg/header.hpp" // header
#ifndef _WIN32
# define DEPRECATED_sensor_msgs_msg_Range __attribute__((deprecated))
#else
# define DEPRECATED_sensor_msgs_msg_Range __declspec(deprecated)
#endif
namespace sensor_msgs
{
namespace msg
{
// message struct
template<class ContainerAllocator>
struct Range_
{
using Type = Range_<ContainerAllocator>;
explicit Range_(rosidl_generator_cpp::MessageInitialization _init = rosidl_generator_cpp::MessageInitialization::ALL)
: header(_init)
{
if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
rosidl_generator_cpp::MessageInitialization::ZERO == _init)
{
this->radiation_type = 0;
}
if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
rosidl_generator_cpp::MessageInitialization::ZERO == _init)
{
this->field_of_view = 0.0f;
this->min_range = 0.0f;
this->max_range = 0.0f;
this->range = 0.0f;
}
}
explicit Range_(const ContainerAllocator & _alloc, rosidl_generator_cpp::MessageInitialization _init = rosidl_generator_cpp::MessageInitialization::ALL)
: header(_alloc, _init)
{
if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
rosidl_generator_cpp::MessageInitialization::ZERO == _init)
{
this->radiation_type = 0;
}
if (rosidl_generator_cpp::MessageInitialization::ALL == _init ||
rosidl_generator_cpp::MessageInitialization::ZERO == _init)
{
this->field_of_view = 0.0f;
this->min_range = 0.0f;
this->max_range = 0.0f;
this->range = 0.0f;
}
}
// field types and members
using _header_type =
std_msgs::msg::Header_<ContainerAllocator>;
_header_type header;
using _radiation_type_type =
uint8_t;
_radiation_type_type radiation_type;
using _field_of_view_type =
float;
_field_of_view_type field_of_view;
using _min_range_type =
float;
_min_range_type min_range;
using _max_range_type =
float;
_max_range_type max_range;
using _range_type =
float;
_range_type range;
// setters for named parameter idiom
Type * set__header(
const std_msgs::msg::Header_<ContainerAllocator> & _arg)
{
this->header = _arg;
return this;
}
Type * set__radiation_type(
const uint8_t & _arg)
{
this->radiation_type = _arg;
return this;
}
Type * set__field_of_view(
const float & _arg)
{
this->field_of_view = _arg;
return this;
}
Type * set__min_range(
const float & _arg)
{
this->min_range = _arg;
return this;
}
Type * set__max_range(
const float & _arg)
{
this->max_range = _arg;
return this;
}
Type * set__range(
const float & _arg)
{
this->range = _arg;
return this;
}
// constant declarations
static constexpr uint8_t ULTRASOUND =
0u;
static constexpr uint8_t INFRARED =
1u;
// pointer types
using RawPtr =
sensor_msgs::msg::Range_<ContainerAllocator> *;
using ConstRawPtr =
const sensor_msgs::msg::Range_<ContainerAllocator> *;
using SharedPtr =
std::shared_ptr<sensor_msgs::msg::Range_<ContainerAllocator>>;
using ConstSharedPtr =
std::shared_ptr<sensor_msgs::msg::Range_<ContainerAllocator> const>;
template<typename Deleter = std::default_delete<
sensor_msgs::msg::Range_<ContainerAllocator>>>
using UniquePtrWithDeleter =
std::unique_ptr<sensor_msgs::msg::Range_<ContainerAllocator>, Deleter>;
using UniquePtr = UniquePtrWithDeleter<>;
template<typename Deleter = std::default_delete<
sensor_msgs::msg::Range_<ContainerAllocator>>>
using ConstUniquePtrWithDeleter =
std::unique_ptr<sensor_msgs::msg::Range_<ContainerAllocator> const, Deleter>;
using ConstUniquePtr = ConstUniquePtrWithDeleter<>;
using WeakPtr =
std::weak_ptr<sensor_msgs::msg::Range_<ContainerAllocator>>;
using ConstWeakPtr =
std::weak_ptr<sensor_msgs::msg::Range_<ContainerAllocator> const>;
// pointer types similar to ROS 1, use SharedPtr / ConstSharedPtr instead
// NOTE: Can't use 'using' here because GNU C++ can't parse attributes properly
typedef DEPRECATED_sensor_msgs_msg_Range
std::shared_ptr<sensor_msgs::msg::Range_<ContainerAllocator>>
Ptr;
typedef DEPRECATED_sensor_msgs_msg_Range
std::shared_ptr<sensor_msgs::msg::Range_<ContainerAllocator> const>
ConstPtr;
// comparison operators
bool operator==(const Range_ & other) const
{
if (this->header != other.header) {
return false;
}
if (this->radiation_type != other.radiation_type) {
return false;
}
if (this->field_of_view != other.field_of_view) {
return false;
}
if (this->min_range != other.min_range) {
return false;
}
if (this->max_range != other.max_range) {
return false;
}
if (this->range != other.range) {
return false;
}
return true;
}
bool operator!=(const Range_ & other) const
{
return !this->operator==(other);
}
}; // struct Range_
// alias to use template instance with default allocator
using Range =
sensor_msgs::msg::Range_<std::allocator<void>>;
// constant definitions
template<typename ContainerAllocator>
constexpr uint8_t Range_<ContainerAllocator>::ULTRASOUND;
template<typename ContainerAllocator>
constexpr uint8_t Range_<ContainerAllocator>::INFRARED;
} // namespace msg
} // namespace sensor_msgs
#endif // SENSOR_MSGS__MSG__RANGE__STRUCT_HPP_
| 27.139013 | 154 | 0.714475 | [
"vector"
] |
a532ee7d33c7247a2ce748fc39122f2dad622d1a | 2,015 | cpp | C++ | main.cpp | Sanaxen/N3LP | 06526ba558231c5973d26a5f2b876a9379dc4502 | [
"MIT"
] | null | null | null | main.cpp | Sanaxen/N3LP | 06526ba558231c5973d26a5f2b876a9379dc4502 | [
"MIT"
] | null | null | null | main.cpp | Sanaxen/N3LP | 06526ba558231c5973d26a5f2b876a9379dc4502 | [
"MIT"
] | null | null | null | #include "EncDec.hpp"
#include <iostream>
#include <random>
#ifdef USE_TEXT_COLOR
#include "util/text_color.hpp"
#endif
int main(int argc, char** argv){
const std::string src = "./corpus/sample.en";
const std::string tgt = "./corpus/sample.ja";
const std::string srcDev = "./corpus/sample.en.dev";
const std::string tgtDev = "./corpus/sample.ja.dev";
#ifdef USE_TEXT_COLOR
console_create();
#endif
FILE* fp_model = fopen("model/model.bin", "r");
if (fp_model == NULL)
{
FILE* fp = fopen((src + "_").c_str(), "r");
if (fp == NULL) return -1;
char* buf = new char[4096];
int linenum = 0;
std::vector<std::string> srcLine;
std::vector<std::string> tgtLine;
while (fgets(buf, 4096, fp) != NULL)
{
srcLine.push_back(buf);
linenum++;
}
fclose(fp);
fp = fopen((tgt + "_").c_str(), "r");
if (fp == NULL) return -1;
while (fgets(buf, 4096, fp) != NULL)
{
tgtLine.push_back(buf);
}
fclose(fp);
std::mt19937 mt;
std::uniform_real_distribution<> rand01(0.0, 1.0);
FILE* fp1 = fopen((srcDev + "_").c_str(), "w");
if (fp1 == NULL) return -1;
FILE* fp2 = fopen((tgtDev + "_").c_str(), "w");
if (fp2 == NULL) return -1;
FILE* fp3 = fopen((src + "_").c_str(), "w");
if (fp3 == NULL) return -1;
FILE* fp4 = fopen((tgt + "_").c_str(), "w");
if (fp4 == NULL) return -1;
for (int i = 0; i < srcLine.size(); i++)
{
if (rand01(mt) < 0.25)
{
fprintf(fp1, "%s", srcLine[i].c_str());
fprintf(fp2, "%s", tgtLine[i].c_str());
}
else
{
fprintf(fp3, "%s", srcLine[i].c_str());
fprintf(fp4, "%s", tgtLine[i].c_str());
}
}
fclose(fp1);
fclose(fp2);
fclose(fp3);
fclose(fp4);
wakati("sample.ja_", "sample.ja");
wakati("sample.en_", "sample.en");
wakati("sample.ja.dev_", "sample.ja.dev");
wakati("sample.en.dev_", "sample.en.dev");
}
if (fp_model )fclose(fp_model);
Eigen::initParallel();
EncDec::demo(src, tgt, srcDev, tgtDev);
return 0;
}
| 21.902174 | 54 | 0.568238 | [
"vector",
"model"
] |
a5343f8bdc48bdaa89e9e4bc87e311227d7540e6 | 5,281 | cpp | C++ | tests/integration/inplace_tests/add_0_ip_test.cpp | gglin001/popart | 3225214343f6d98550b6620e809a3544e8bcbfc6 | [
"MIT"
] | 61 | 2020-07-06T17:11:46.000Z | 2022-03-12T14:42:51.000Z | tests/integration/inplace_tests/add_0_ip_test.cpp | gglin001/popart | 3225214343f6d98550b6620e809a3544e8bcbfc6 | [
"MIT"
] | 1 | 2021-02-25T01:30:29.000Z | 2021-11-09T11:13:14.000Z | tests/integration/inplace_tests/add_0_ip_test.cpp | gglin001/popart | 3225214343f6d98550b6620e809a3544e8bcbfc6 | [
"MIT"
] | 6 | 2020-07-15T12:33:13.000Z | 2021-11-07T06:55:00.000Z | // Copyright (c) 2019 Graphcore Ltd. All rights reserved.
#define BOOST_TEST_MODULE Add0InplaceTest
#include <../test_runner.hpp>
#include <boost/test/unit_test.hpp>
#include <elementwisebinary_testcase.hpp>
#include <popart/op/add.hpp>
#include <popart/patterns/pattern.hpp>
#include <popart/tensors.hpp>
using namespace popart;
// Test case class for testing inplacing of AddOp
class AddInplaceTestCase : public ElementWiseBinaryTestCase {
public:
OperatorIdentifier basicOp() const final { return Onnx::AiOnnx::OpSet9::Add; }
bool hasLhsOp() const final { return true; }
OperatorIdentifier lhsOp() const final {
return Onnx::CustomOperators::AddLhsInplace;
}
bool hasRhsOp() const final { return true; }
OperatorIdentifier rhsOp() const final {
return Onnx::CustomOperators::AddRhsInplace;
}
TensorId insertOp(AiOnnxOpset9 &opset,
const TensorId &a,
const TensorId &b) const final {
return opset.add({a, b});
}
};
// Basic case where arg0 and arg1 have matching shape
// (2x2) + (2x2)
BOOST_AUTO_TEST_CASE(Inplace_add0) {
TestData data{/* A = */ {1, 2, 3, 4},
/* B = */ {2, 3, 4, 5},
/* out = */ {3, 5, 7, 9},
/* shape(A) = */ {2, 2},
/* shape(B) = */ {2, 2},
/* shape(out) = */ {2, 2}};
AddInplaceTestCase testCase;
testCase.checkBasicOpIsInplaced(data);
}
// Arg0 is larger than arg1
// (2x2) + (1x2)
BOOST_AUTO_TEST_CASE(Inplace_add1) {
TestData data{/* A = */ {1, 2, 3, 4},
/* B = */ {2, 3},
/* out = */ {3, 5, 5, 7},
/* shape(A) = */ {2, 2},
/* shape(B) = */ {1, 2},
/* shape(out) = */ {2, 2}};
AddInplaceTestCase testCase;
testCase.checkBasicOpIsLhsInplaced(data);
}
// Arg1 is larger than arg0
// (1x2) + (2x2)
BOOST_AUTO_TEST_CASE(Inplace_add2) {
TestData data{/* A = */ {2, 3},
/* B = */ {1, 2, 3, 4},
/* out = */ {3, 5, 5, 7},
/* shape(A) = */ {1, 2},
/* shape(B) = */ {2, 2},
/* shape(out) = */ {2, 2}};
AddInplaceTestCase testCase;
testCase.checkBasicOpIsRhsInplaced(data);
}
// Arg0 and arg1 are of different ranks
// (2x2) + (2)
BOOST_AUTO_TEST_CASE(Inplace_add3) {
TestData data{/* A = */ {1, 2, 3, 4},
/* B = */ {2, 3},
/* out = */ {3, 5, 5, 7},
/* shape(A) = */ {2, 2},
/* shape(B) = */ {2},
/* shape(out) = */ {2, 2}};
AddInplaceTestCase testCase;
testCase.checkBasicOpIsLhsInplaced(data);
}
// Arg0 and arg1 are of different ranks
// (2) + (2x2)
BOOST_AUTO_TEST_CASE(Inplace_add4) {
TestData data{/* A = */ {2, 3},
/* B = */ {1, 2, 3, 4},
/* out = */ {3, 5, 5, 7},
/* shape(A) = */ {2},
/* shape(B) = */ {2, 2},
/* shape(out) = */ {2, 2}};
AddInplaceTestCase testCase;
testCase.checkBasicOpIsRhsInplaced(data);
}
// Checking AddOp fwdRegMap
BOOST_AUTO_TEST_CASE(Add_fwdRegMap0) { AddInplaceTestCase().checkFwdRegMap(); }
// Checking AddOp fwdRegMap
BOOST_AUTO_TEST_CASE(Add_bwdRegMap0) { AddInplaceTestCase().checkBwdRegMap(); }
// Check AddOp::inplacePriorityDefault priorities
// sides that connect two convolutions
BOOST_AUTO_TEST_CASE(Inplace_add5) {
auto run_test = [&](OperatorIdentifier opid, bool include_relu) {
TensorInfo info_1188{"FLOAT", std::vector<int64_t>{1, 1, 8, 8}};
TensorInfo info_1144{"FLOAT", std::vector<int64_t>{1, 1, 4, 4}};
TensorInfo info_1122{"FLOAT", std::vector<int64_t>{1, 1, 2, 2}};
TestRunner runner;
runner.patterns =
Patterns(PatternsLevel::NoPatterns).enableRuntimeAsserts(false);
runner.patterns.enableInPlace(true);
runner.patterns.enableUpdateInplacePrioritiesForIpu(true);
runner.buildModel([&](Builder &builder) {
auto aiOnnx = builder.aiOnnxOpset9();
auto in0 = builder.addInputTensor(info_1188);
auto w0 = builder.addInputTensor(info_1122);
auto i1 = aiOnnx.identity({builder.addInputTensor(info_1144)});
auto w1 = aiOnnx.identity({builder.addInputTensor(info_1122)});
auto c0 = aiOnnx.conv({in0, w0}, {1, 1}, 1, {2, 2}, {0, 0, 0, 0}, {2, 2});
// Order the inputs depending on whether we want the lhs inplace or rhs
// inplace version
auto a0 = [&]() {
if (opid == Onnx::CustomOperators::AddLhsInplace) {
return aiOnnx.add({c0, i1});
} else {
return aiOnnx.add({i1, c0});
}
}();
if (include_relu) {
a0 = aiOnnx.relu({a0});
}
auto c1 = aiOnnx.conv({a0, w1}, {1, 1}, 1, {2, 2}, {0, 0, 0, 0}, {2, 2});
auto out = aiOnnx.identity({c1});
builder.addOutputTensor(out);
return out;
});
runner.checkIr([&](Ir &ir) {
BOOST_CHECK(ir.opsOfType(Onnx::AiOnnx::OpSet9::Add).size() == 0);
BOOST_CHECK(ir.opsOfType(opid).size() == 1);
});
};
run_test(Onnx::CustomOperators::AddLhsInplace, false);
run_test(Onnx::CustomOperators::AddRhsInplace, false);
run_test(Onnx::CustomOperators::AddLhsInplace, true);
run_test(Onnx::CustomOperators::AddRhsInplace, true);
}
| 31.434524 | 80 | 0.579246 | [
"shape",
"vector"
] |
a53b911c2ed6622764a6fa03f4bcf96390eaf15e | 862 | cpp | C++ | math/linear_divisors1.cpp | warwick965/competitive-programming | 78074365eff204b0331410a98f32cf41962e9644 | [
"MIT"
] | null | null | null | math/linear_divisors1.cpp | warwick965/competitive-programming | 78074365eff204b0331410a98f32cf41962e9644 | [
"MIT"
] | null | null | null | math/linear_divisors1.cpp | warwick965/competitive-programming | 78074365eff204b0331410a98f32cf41962e9644 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
#define MAXN (int)1e6
int divisors[MAXN+1];
int lp[MAXN+1];
void sieve(){
for(int i = 1;i <= MAXN;i++) {
divisors[i] = i+1;
lp[i] = i;
}
divisors[1] = 1;
vector<int>primes;
for(int i = 2;i <= MAXN;i++){
if (divisors[i] == i+1) primes.push_back(i);
for(auto p:primes){
if (i*p > MAXN) break;
if (i % p == 0){
int n = i/lp[i];
lp[i*p] = lp[i]*p;
divisors[i*p] = divisors[n]*(lp[i*p]*p-1)/(p-1);
break;
}
else {
divisors[i*p] = divisors[i]*divisors[p];
lp[i*p] = p;
}
}
}
}
int main(){
sieve();
int x;cin>>x;
// Sum of divisors
cout << divisors[x] << endl;
return 0;
}
| 18.340426 | 64 | 0.411833 | [
"vector"
] |
a53f5341c1495d2ae3c648bd9f04c6270c7b1595 | 2,657 | cpp | C++ | tests/process_test.cpp | Xiretza/UHDM | cb162e76f641f0a860a95bb5d39a7d6585fb72f5 | [
"Apache-2.0"
] | 72 | 2019-12-28T14:55:39.000Z | 2022-03-24T10:59:35.000Z | tests/process_test.cpp | jrrk2/UHDM | d8a9a0ea31d0400d944cb98e25f29e51dab63fa7 | [
"Apache-2.0"
] | 86 | 2020-01-08T14:06:10.000Z | 2021-06-10T04:46:43.000Z | tests/process_test.cpp | jrrk2/UHDM | d8a9a0ea31d0400d944cb98e25f29e51dab63fa7 | [
"Apache-2.0"
] | 16 | 2019-12-16T19:58:58.000Z | 2021-06-28T09:46:49.000Z | #include <iostream>
#include "gtest/gtest.h"
#include "uhdm/uhdm.h"
#include "uhdm/vpi_visitor.h"
using namespace UHDM;
#include "uhdm/vpi_visitor.h"
// This builds a simple design:
// module m1;
// always @(posedge clk)
// out = 1;
// end
// endmodule
static std::vector<vpiHandle> buildSimpleAlawysDesign(Serializer* s) {
std::vector<vpiHandle> designs;
// Design building
design* d = s->MakeDesign();
d->VpiName("design_process");
module* m1 = s->MakeModule();
m1->VpiTopModule(true);
m1->VpiDefName("M1");
m1->VpiName("u1");
m1->VpiParent(d);
m1->VpiFile("fake1.sv");
m1->VpiLineNo(10);
// always @(posedge clk) begin
always* proc_always = s->MakeAlways();
begin* begin_block = s->MakeBegin();
proc_always->Stmt(begin_block);
proc_always->Module(m1);
VectorOfprocess_stmt* processes = s->MakeProcess_stmtVec();
processes->push_back(proc_always);
// @(posedge clk)
event_control* at = s->MakeEvent_control();
ref_obj* clk = s->MakeRef_obj();
clk->VpiName("clk");
tchk_term* posedge_clk = s->MakeTchk_term();
posedge_clk->VpiEdge(vpiPosedge);
posedge_clk->Expr(clk);
VectorOfany* simple_exp_vec = s->MakeAnyVec();
simple_exp_vec->push_back(posedge_clk);
clk->VpiUses(simple_exp_vec);
at->VpiCondition(clk);
// out = 1;
VectorOfany* statements = s->MakeAnyVec();
ref_obj* lhs_rf = s->MakeRef_obj();
lhs_rf->VpiName("out");
assignment* assign1 = s->MakeAssignment();
assign1->Lhs(lhs_rf);
constant* c1 = s->MakeConstant();
s_vpi_value val;
val.format = vpiIntVal;
val.value.integer = 1;
c1->VpiValue(VpiValue2String(&val));
assign1->Rhs(c1);
at->Stmt(assign1);
statements->push_back(at);
begin_block->Stmts(statements);
m1->Process(processes);
VectorOfmodule* v1 = s->MakeModuleVec();
v1->push_back(m1);
d->AllModules(v1);
package* p1 = s->MakePackage();
p1->VpiDefName("P0");
VectorOfpackage* v3 = s->MakePackageVec();
v3->push_back(p1);
d->AllPackages(v3);
vpiHandle dh = s->MakeUhdmHandle(uhdmdesign, d);
designs.push_back(dh);
char name[]{"u1"};
vpiHandle obj_h = vpi_handle_by_name(name, dh);
EXPECT_NE(obj_h, nullptr);
return designs;
}
TEST(SerializationProcess, ProcessSerialization) {
Serializer serializer;
const std::string orig = visit_designs(buildSimpleAlawysDesign(&serializer));
const std::string filename = testing::TempDir() + "/surelog_process.uhdm";
serializer.Save(filename);
const std::vector<vpiHandle> restoredDesigns = serializer.Restore(filename);
const std::string restored = visit_designs(restoredDesigns);
EXPECT_EQ(orig, restored);
}
// TODO: other, object level tests ?
| 26.57 | 79 | 0.695521 | [
"object",
"vector"
] |
a54ac8b08284db73ab076f739850cfd1a897238f | 5,502 | cpp | C++ | target_obejct_detector/src/target_object_recognizer.cpp | CIR-KIT/human_detector | 1f0d26004d3cd960feb672770a4b6d97958ed200 | [
"MIT"
] | 6 | 2016-12-28T01:44:09.000Z | 2022-03-11T02:06:55.000Z | target_obejct_detector/src/target_object_recognizer.cpp | CIR-KIT/human_detector | 1f0d26004d3cd960feb672770a4b6d97958ed200 | [
"MIT"
] | 6 | 2016-11-22T13:36:22.000Z | 2018-01-26T12:02:19.000Z | target_obejct_detector/src/target_object_recognizer.cpp | CIR-KIT/human_detector | 1f0d26004d3cd960feb672770a4b6d97958ed200 | [
"MIT"
] | 6 | 2017-07-26T00:37:35.000Z | 2021-12-16T16:20:49.000Z | #include <target_object_recognizer.h>
TargetObject::TargetObject(geometry_msgs::PoseStamped transed_pose,
jsk_recognition_msgs::BoundingBox box)
: box_(box), counter_(0)
{
box_.header = transed_pose.header;
box_.pose = transed_pose.pose;
}
TargetObject::~TargetObject()
{
}
geometry_msgs::Pose TargetObject::getPose()
{
return box_.pose;
}
jsk_recognition_msgs::BoundingBox TargetObject::getBox()
{
box_.header.frame_id = "map";
return box_;
}
void TargetObject::addTargetObject(geometry_msgs::PoseStamped transed_pose,
jsk_recognition_msgs::BoundingBox new_box)
{
jsk_recognition_msgs::BoundingBox box_buf; geometry_msgs::Pose buf;
box_buf.pose.position.x = box_.pose.position.x + transed_pose.pose.position.x;
box_buf.pose.position.y = box_.pose.position.y + transed_pose.pose.position.y;
box_buf.pose.orientation.x = box_.pose.orientation.x + transed_pose.pose.orientation.x;
box_buf.pose.orientation.y = box_.pose.orientation.y + transed_pose.pose.orientation.y;
box_buf.pose.orientation.z = box_.pose.orientation.z + transed_pose.pose.orientation.z;
box_buf.pose.orientation.w = box_.pose.orientation.w + transed_pose.pose.orientation.w;
box_buf.dimensions.x = box_.dimensions.x + new_box.dimensions.x;
box_buf.dimensions.y = box_.dimensions.y + new_box.dimensions.y;
box_buf.dimensions.z = box_.dimensions.z + new_box.dimensions.z;
box_.pose.position.x = box_buf.pose.position.x / 2.0;
box_.pose.position.y = box_buf.pose.position.y / 2.0;
box_.pose.orientation.x = box_buf.pose.orientation.x / 2.0;
box_.pose.orientation.y = box_buf.pose.orientation.y / 2.0;
box_.pose.orientation.z = box_buf.pose.orientation.z / 2.0;
box_.pose.orientation.w = box_buf.pose.orientation.w / 2.0;
box_.dimensions.x = box_buf.dimensions.x / 2.0;
box_.dimensions.y = box_buf.dimensions.y / 2.0;
box_.dimensions.z = box_buf.dimensions.z / 2.0;
// box_.pose = transed_pose.pose;
// box_.header = transed_pose.header;
// box_.dimensions = new_box.dimensions;
// pose_ = new_pose;
}
int TargetObject::getCounter()
{
return counter_;
}
void TargetObject::addCounter()
{
counter_++;
}
TargetObjectRecognizer::TargetObjectRecognizer(ros::NodeHandle nh)
: nh_(nh),
rate_(10)
{
detected_sub_ = nh_.subscribe("/clustering_result", 1, &TargetObjectRecognizer::detectedCallback, this);
recognized_pub_ = nh_.advertise<jsk_recognition_msgs::BoundingBoxArray>("/recognized_result", 1);
robotpose_sub_ = nh_.subscribe("/amcl_pose", 1, &TargetObjectRecognizer::robotPoseCallback, this);
}
TargetObjectRecognizer::~TargetObjectRecognizer()
{
}
void TargetObjectRecognizer::detectedCallback(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &detected_objects)
{
{
boost::mutex::scoped_lock(robot_pose_mutex_);
for (size_t i = 0; i < detected_objects->boxes.size(); ++i) {
bool is_stored(false);
geometry_msgs::PoseStamped in_pose;
in_pose.pose = detected_objects->boxes[i].pose;
in_pose.header = detected_objects->boxes[i].header;
geometry_msgs::PoseStamped out_pose;
try {
tf_.transformPose("map", in_pose, out_pose);
} catch (tf::TransformException &ex) {
ROS_ERROR("%s",ex.what());
}
for (size_t j = 0; j < target_object_candidates_.size(); ++j) {
double dist = this->calcDistance(target_object_candidates_[j].getPose(),
out_pose.pose);
if (dist < 1.0) {
target_object_candidates_[j].addCounter();
target_object_candidates_[j].addTargetObject(out_pose,
detected_objects->boxes[i]);
is_stored = true;
}
}
if (! is_stored) {
target_object_candidates_.push_back(TargetObject(out_pose,
detected_objects->boxes[i]));
}
}
jsk_recognition_msgs::BoundingBoxArray box_array;
for (size_t i = 0; i < target_object_candidates_.size(); ++i) {
if(target_object_candidates_[i].getCounter() > 5){
box_array.boxes.push_back(target_object_candidates_[i].getBox());
}
}
ROS_INFO_STREAM("target object candidates : " << target_object_candidates_.size());
box_array.header.stamp = ros::Time::now();
box_array.header.frame_id = "map";
recognized_pub_.publish(box_array);
}
}
void TargetObjectRecognizer::robotPoseCallback(const geometry_msgs::PoseWithCovarianceStamped::ConstPtr& amcl_pose)
{
//robotの位置をサブスクライブして、バッファにいれる(要mutex)
{
boost::mutex::scoped_lock(robot_pose_mutex_);
latest_robot_pose_ = *amcl_pose;
// 最新のロボットの位置と比較してn[m]離れててかつcounterがしきい値以下ならその候補は消す
for (std::vector<TargetObject>::iterator it = target_object_candidates_.begin(); it != target_object_candidates_.end(); ) {
double dist_from_robot = this->calcDistance(it->getPose(), latest_robot_pose_.pose.pose);
if(dist_from_robot >= 5.0 && it->getCounter() < 3)
{
it = target_object_candidates_.erase(it);
continue;
}
it++;
}
}
}
void TargetObjectRecognizer::run()
{
while(nh_.ok()){
ros::spinOnce();
rate_.sleep();
}
}
double TargetObjectRecognizer::calcDistance(geometry_msgs::Pose pose_1, geometry_msgs::Pose pose_2)
{
double dist = sqrt(pow(pose_1.position.x - pose_2.position.x, 2)
+ pow(pose_1.position.y - pose_2.position.y, 2));
return dist;
}
| 35.496774 | 127 | 0.685932 | [
"object",
"vector"
] |
a54c6e03bbe0183d06911031d18d3865f3557dd3 | 88,762 | cpp | C++ | gen/blink/bindings/modules/v8/V8ServiceWorkerGlobalScope.cpp | gergul/MiniBlink | 7a11c52f141d54d5f8e1a9af31867cd120a2c3c4 | [
"Apache-2.0"
] | 8 | 2019-05-05T16:38:05.000Z | 2021-11-09T11:45:38.000Z | gen/blink/bindings/modules/v8/V8ServiceWorkerGlobalScope.cpp | gergul/MiniBlink | 7a11c52f141d54d5f8e1a9af31867cd120a2c3c4 | [
"Apache-2.0"
] | null | null | null | gen/blink/bindings/modules/v8/V8ServiceWorkerGlobalScope.cpp | gergul/MiniBlink | 7a11c52f141d54d5f8e1a9af31867cd120a2c3c4 | [
"Apache-2.0"
] | 4 | 2018-12-14T07:52:46.000Z | 2021-06-11T18:06:09.000Z | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
#include "config.h"
#include "V8ServiceWorkerGlobalScope.h"
#include "gen/blink/modules/ServiceWorkerGlobalScopeCoreConstructors.h"
#include "gen/blink/modules/ServiceWorkerGlobalScopeModulesConstructors.h"
#include "bindings/core/v8/Dictionary.h"
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/ScriptPromise.h"
#include "bindings/core/v8/ScriptState.h"
#include "bindings/core/v8/V8AbstractEventListener.h"
#include "bindings/core/v8/V8Blob.h"
#include "bindings/core/v8/V8CustomEvent.h"
#include "bindings/core/v8/V8DOMConfiguration.h"
#include "bindings/core/v8/V8DOMException.h"
#include "bindings/core/v8/V8Event.h"
#include "bindings/core/v8/V8EventListenerList.h"
#include "bindings/core/v8/V8EventSource.h"
#include "bindings/core/v8/V8EventTarget.h"
#include "bindings/core/v8/V8File.h"
#include "bindings/core/v8/V8FileList.h"
#include "bindings/core/v8/V8FileReader.h"
#include "bindings/core/v8/V8FileReaderSync.h"
#include "bindings/core/v8/V8FormData.h"
#include "bindings/core/v8/V8HiddenValue.h"
#include "bindings/core/v8/V8ImageData.h"
#include "bindings/core/v8/V8MessageChannel.h"
#include "bindings/core/v8/V8MessageEvent.h"
#include "bindings/core/v8/V8MessagePort.h"
#include "bindings/core/v8/V8ObjectConstructor.h"
#include "bindings/core/v8/V8PromiseRejectionEvent.h"
#include "bindings/core/v8/V8ReadableByteStream.h"
#include "bindings/core/v8/V8ReadableStream.h"
#include "bindings/core/v8/V8URL.h"
#include "bindings/core/v8/V8WorkerGlobalScope.h"
#include "bindings/core/v8/V8WorkerLocation.h"
#include "bindings/core/v8/V8WorkerNavigator.h"
#include "bindings/modules/v8/UnionTypesModules.h"
#include "bindings/modules/v8/V8Cache.h"
#include "bindings/modules/v8/V8CacheStorage.h"
#include "bindings/modules/v8/V8CircularGeofencingRegion.h"
#include "bindings/modules/v8/V8Client.h"
#include "bindings/modules/v8/V8Clients.h"
#include "bindings/modules/v8/V8CloseEvent.h"
#include "bindings/modules/v8/V8CrossOriginConnectEvent.h"
#include "bindings/modules/v8/V8CrossOriginServiceWorkerClient.h"
#include "bindings/modules/v8/V8Crypto.h"
#include "bindings/modules/v8/V8CryptoKey.h"
#include "bindings/modules/v8/V8ExtendableEvent.h"
#include "bindings/modules/v8/V8FetchEvent.h"
#include "bindings/modules/v8/V8GeofencingEvent.h"
#include "bindings/modules/v8/V8Headers.h"
#include "bindings/modules/v8/V8IDBCursor.h"
#include "bindings/modules/v8/V8IDBCursorWithValue.h"
#include "bindings/modules/v8/V8IDBDatabase.h"
#include "bindings/modules/v8/V8IDBFactory.h"
#include "bindings/modules/v8/V8IDBIndex.h"
#include "bindings/modules/v8/V8IDBKeyRange.h"
#include "bindings/modules/v8/V8IDBObjectStore.h"
#include "bindings/modules/v8/V8IDBOpenDBRequest.h"
#include "bindings/modules/v8/V8IDBRequest.h"
#include "bindings/modules/v8/V8IDBTransaction.h"
#include "bindings/modules/v8/V8IDBVersionChangeEvent.h"
#include "bindings/modules/v8/V8NetworkInformation.h"
#include "bindings/modules/v8/V8Notification.h"
#include "bindings/modules/v8/V8NotificationEvent.h"
#include "bindings/modules/v8/V8PeriodicSyncEvent.h"
#include "bindings/modules/v8/V8PeriodicSyncManager.h"
#include "bindings/modules/v8/V8PeriodicSyncRegistration.h"
#include "bindings/modules/v8/V8PermissionStatus.h"
#include "bindings/modules/v8/V8Permissions.h"
#include "bindings/modules/v8/V8PushEvent.h"
#include "bindings/modules/v8/V8PushManager.h"
#include "bindings/modules/v8/V8PushMessageData.h"
#include "bindings/modules/v8/V8PushSubscription.h"
#include "bindings/modules/v8/V8Request.h"
#include "bindings/modules/v8/V8Response.h"
#include "bindings/modules/v8/V8ServicePort.h"
#include "bindings/modules/v8/V8ServicePortCollection.h"
#include "bindings/modules/v8/V8ServicePortConnectEvent.h"
#include "bindings/modules/v8/V8ServiceWorkerGlobalScope.h"
#include "bindings/modules/v8/V8ServiceWorkerRegistration.h"
#include "bindings/modules/v8/V8StashedMessagePort.h"
#include "bindings/modules/v8/V8StashedPortCollection.h"
#include "bindings/modules/v8/V8SubtleCrypto.h"
#include "bindings/modules/v8/V8SyncEvent.h"
#include "bindings/modules/v8/V8SyncManager.h"
#include "bindings/modules/v8/V8SyncRegistration.h"
#include "bindings/modules/v8/V8TextDecoder.h"
#include "bindings/modules/v8/V8TextEncoder.h"
#include "bindings/modules/v8/V8WebSocket.h"
#include "bindings/modules/v8/V8WindowClient.h"
#include "core/dom/ContextFeatures.h"
#include "core/dom/Document.h"
#include "modules/background_sync/ServiceWorkerGlobalScopeSync.h"
#include "modules/geofencing/ServiceWorkerGlobalScopeGeofencing.h"
#include "modules/navigatorconnect/ServiceWorkerGlobalScopeNavigatorConnect.h"
#include "modules/notifications/ServiceWorkerGlobalScopeNotifications.h"
#include "modules/push_messaging/ServiceWorkerGlobalScopePush.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/TraceEvent.h"
#include "wtf/GetPtr.h"
#include "wtf/RefPtr.h"
namespace blink {
// Suppress warning: global constructors, because struct WrapperTypeInfo is trivial
// and does not depend on another global objects.
#if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors"
#endif
const WrapperTypeInfo V8ServiceWorkerGlobalScope::wrapperTypeInfo = { gin::kEmbedderBlink, V8ServiceWorkerGlobalScope::domTemplate, V8ServiceWorkerGlobalScope::refObject, V8ServiceWorkerGlobalScope::derefObject, V8ServiceWorkerGlobalScope::trace, 0, 0, V8ServiceWorkerGlobalScope::preparePrototypeObject, V8ServiceWorkerGlobalScope::installConditionallyEnabledProperties, "ServiceWorkerGlobalScope", &V8WorkerGlobalScope::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::InheritFromEventTarget, WrapperTypeInfo::Independent, WrapperTypeInfo::WillBeGarbageCollectedObject };
#if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
#pragma clang diagnostic pop
#endif
// This static member must be declared by DEFINE_WRAPPERTYPEINFO in ServiceWorkerGlobalScope.h.
// For details, see the comment of DEFINE_WRAPPERTYPEINFO in
// bindings/core/v8/ScriptWrappable.h.
const WrapperTypeInfo& ServiceWorkerGlobalScope::s_wrapperTypeInfo = V8ServiceWorkerGlobalScope::wrapperTypeInfo;
namespace ServiceWorkerGlobalScopeV8Internal {
template<class CallbackInfo>
static bool ServiceWorkerGlobalScopeCreateDataProperty(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const CallbackInfo& info)
{
ASSERT(info.This()->IsObject());
return v8CallBoolean(v8::Local<v8::Object>::Cast(info.This())->CreateDataProperty(info.GetIsolate()->GetCurrentContext(), name, v8Value));
}
static void ServiceWorkerGlobalScopeConstructorAttributeSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
do {
v8::Local<v8::Value> data = info.Data();
ASSERT(data->IsExternal());
V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
if (!perContextData)
break;
const WrapperTypeInfo* wrapperTypeInfo = WrapperTypeInfo::unwrap(data);
if (!wrapperTypeInfo)
break;
ServiceWorkerGlobalScopeCreateDataProperty(v8String(info.GetIsolate(), wrapperTypeInfo->interfaceName), v8Value, info);
} while (false); // do ... while (false) just for use of break
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void clientsAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
RawPtr<ServiceWorkerClients> cppValue(impl->clients());
if (cppValue && DOMDataStore::setReturnValue(info.GetReturnValue(), cppValue.get()))
return;
v8::Local<v8::Value> v8Value(toV8(cppValue.get(), holder, info.GetIsolate()));
if (!v8Value.IsEmpty()) {
V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString(info.GetIsolate(), "clients"), v8Value);
v8SetReturnValue(info, v8Value);
}
}
static void clientsAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::clientsAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void registrationAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
RawPtr<ServiceWorkerRegistration> cppValue(impl->registration());
if (cppValue && DOMDataStore::setReturnValue(info.GetReturnValue(), cppValue.get()))
return;
v8::Local<v8::Value> v8Value(toV8(cppValue.get(), holder, info.GetIsolate()));
if (!v8Value.IsEmpty()) {
V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString(info.GetIsolate(), "registration"), v8Value);
v8SetReturnValue(info, v8Value);
}
}
static void registrationAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::registrationAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void portsAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
RawPtr<StashedPortCollection> cppValue(impl->ports());
if (cppValue && DOMDataStore::setReturnValue(info.GetReturnValue(), cppValue.get()))
return;
v8::Local<v8::Value> v8Value(toV8(cppValue.get(), holder, info.GetIsolate()));
if (!v8Value.IsEmpty()) {
V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString(info.GetIsolate(), "ports"), v8Value);
v8SetReturnValue(info, v8Value);
}
}
static void portsAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::portsAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onactivateAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
EventListener* cppValue(impl->onactivate());
v8SetReturnValue(info, cppValue ? v8::Local<v8::Value>(V8AbstractEventListener::cast(cppValue)->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null(info.GetIsolate())));
}
static void onactivateAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::onactivateAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onactivateAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
moveEventListenerToNewWrapper(info.GetIsolate(), holder, impl->onactivate(), v8Value, V8ServiceWorkerGlobalScope::eventListenerCacheIndex);
impl->setOnactivate(V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
}
static void onactivateAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> v8Value = info[0];
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
ServiceWorkerGlobalScopeV8Internal::onactivateAttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onfetchAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
EventListener* cppValue(impl->onfetch());
v8SetReturnValue(info, cppValue ? v8::Local<v8::Value>(V8AbstractEventListener::cast(cppValue)->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null(info.GetIsolate())));
}
static void onfetchAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::onfetchAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onfetchAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
moveEventListenerToNewWrapper(info.GetIsolate(), holder, impl->onfetch(), v8Value, V8ServiceWorkerGlobalScope::eventListenerCacheIndex);
impl->setOnfetch(V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
}
static void onfetchAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> v8Value = info[0];
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
ServiceWorkerGlobalScopeV8Internal::onfetchAttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void oninstallAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
EventListener* cppValue(impl->oninstall());
v8SetReturnValue(info, cppValue ? v8::Local<v8::Value>(V8AbstractEventListener::cast(cppValue)->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null(info.GetIsolate())));
}
static void oninstallAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::oninstallAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void oninstallAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
moveEventListenerToNewWrapper(info.GetIsolate(), holder, impl->oninstall(), v8Value, V8ServiceWorkerGlobalScope::eventListenerCacheIndex);
impl->setOninstall(V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
}
static void oninstallAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> v8Value = info[0];
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
ServiceWorkerGlobalScopeV8Internal::oninstallAttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onmessageAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
EventListener* cppValue(impl->onmessage());
v8SetReturnValue(info, cppValue ? v8::Local<v8::Value>(V8AbstractEventListener::cast(cppValue)->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null(info.GetIsolate())));
}
static void onmessageAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::onmessageAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onmessageAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
moveEventListenerToNewWrapper(info.GetIsolate(), holder, impl->onmessage(), v8Value, V8ServiceWorkerGlobalScope::eventListenerCacheIndex);
impl->setOnmessage(V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
}
static void onmessageAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> v8Value = info[0];
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
ServiceWorkerGlobalScopeV8Internal::onmessageAttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onsyncAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
EventListener* cppValue(ServiceWorkerGlobalScopeSync::onsync(*impl));
v8SetReturnValue(info, cppValue ? v8::Local<v8::Value>(V8AbstractEventListener::cast(cppValue)->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null(info.GetIsolate())));
}
static void onsyncAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::onsyncAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onsyncAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
moveEventListenerToNewWrapper(info.GetIsolate(), holder, ServiceWorkerGlobalScopeSync::onsync(*impl), v8Value, V8ServiceWorkerGlobalScope::eventListenerCacheIndex);
ServiceWorkerGlobalScopeSync::setOnsync(*impl, V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
}
static void onsyncAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> v8Value = info[0];
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
ServiceWorkerGlobalScopeV8Internal::onsyncAttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onperiodicsyncAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
EventListener* cppValue(ServiceWorkerGlobalScopeSync::onperiodicsync(*impl));
v8SetReturnValue(info, cppValue ? v8::Local<v8::Value>(V8AbstractEventListener::cast(cppValue)->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null(info.GetIsolate())));
}
static void onperiodicsyncAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::onperiodicsyncAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onperiodicsyncAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
moveEventListenerToNewWrapper(info.GetIsolate(), holder, ServiceWorkerGlobalScopeSync::onperiodicsync(*impl), v8Value, V8ServiceWorkerGlobalScope::eventListenerCacheIndex);
ServiceWorkerGlobalScopeSync::setOnperiodicsync(*impl, V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
}
static void onperiodicsyncAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> v8Value = info[0];
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
ServiceWorkerGlobalScopeV8Internal::onperiodicsyncAttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void ongeofenceenterAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
EventListener* cppValue(ServiceWorkerGlobalScopeGeofencing::ongeofenceenter(*impl));
v8SetReturnValue(info, cppValue ? v8::Local<v8::Value>(V8AbstractEventListener::cast(cppValue)->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null(info.GetIsolate())));
}
static void ongeofenceenterAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::ongeofenceenterAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void ongeofenceenterAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
moveEventListenerToNewWrapper(info.GetIsolate(), holder, ServiceWorkerGlobalScopeGeofencing::ongeofenceenter(*impl), v8Value, V8ServiceWorkerGlobalScope::eventListenerCacheIndex);
ServiceWorkerGlobalScopeGeofencing::setOngeofenceenter(*impl, V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
}
static void ongeofenceenterAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> v8Value = info[0];
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
ServiceWorkerGlobalScopeV8Internal::ongeofenceenterAttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void ongeofenceleaveAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
EventListener* cppValue(ServiceWorkerGlobalScopeGeofencing::ongeofenceleave(*impl));
v8SetReturnValue(info, cppValue ? v8::Local<v8::Value>(V8AbstractEventListener::cast(cppValue)->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null(info.GetIsolate())));
}
static void ongeofenceleaveAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::ongeofenceleaveAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void ongeofenceleaveAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
moveEventListenerToNewWrapper(info.GetIsolate(), holder, ServiceWorkerGlobalScopeGeofencing::ongeofenceleave(*impl), v8Value, V8ServiceWorkerGlobalScope::eventListenerCacheIndex);
ServiceWorkerGlobalScopeGeofencing::setOngeofenceleave(*impl, V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
}
static void ongeofenceleaveAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> v8Value = info[0];
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
ServiceWorkerGlobalScopeV8Internal::ongeofenceleaveAttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void oncrossoriginconnectAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
EventListener* cppValue(ServiceWorkerGlobalScopeNavigatorConnect::oncrossoriginconnect(*impl));
v8SetReturnValue(info, cppValue ? v8::Local<v8::Value>(V8AbstractEventListener::cast(cppValue)->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null(info.GetIsolate())));
}
static void oncrossoriginconnectAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::oncrossoriginconnectAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void oncrossoriginconnectAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
moveEventListenerToNewWrapper(info.GetIsolate(), holder, ServiceWorkerGlobalScopeNavigatorConnect::oncrossoriginconnect(*impl), v8Value, V8ServiceWorkerGlobalScope::eventListenerCacheIndex);
ServiceWorkerGlobalScopeNavigatorConnect::setOncrossoriginconnect(*impl, V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
}
static void oncrossoriginconnectAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> v8Value = info[0];
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
ServiceWorkerGlobalScopeV8Internal::oncrossoriginconnectAttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void oncrossoriginmessageAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
EventListener* cppValue(ServiceWorkerGlobalScopeNavigatorConnect::oncrossoriginmessage(*impl));
v8SetReturnValue(info, cppValue ? v8::Local<v8::Value>(V8AbstractEventListener::cast(cppValue)->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null(info.GetIsolate())));
}
static void oncrossoriginmessageAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::oncrossoriginmessageAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void oncrossoriginmessageAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
moveEventListenerToNewWrapper(info.GetIsolate(), holder, ServiceWorkerGlobalScopeNavigatorConnect::oncrossoriginmessage(*impl), v8Value, V8ServiceWorkerGlobalScope::eventListenerCacheIndex);
ServiceWorkerGlobalScopeNavigatorConnect::setOncrossoriginmessage(*impl, V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
}
static void oncrossoriginmessageAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> v8Value = info[0];
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
ServiceWorkerGlobalScopeV8Internal::oncrossoriginmessageAttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onnotificationclickAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
EventListener* cppValue(ServiceWorkerGlobalScopeNotifications::onnotificationclick(*impl));
v8SetReturnValue(info, cppValue ? v8::Local<v8::Value>(V8AbstractEventListener::cast(cppValue)->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null(info.GetIsolate())));
}
static void onnotificationclickAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::onnotificationclickAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onnotificationclickAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
moveEventListenerToNewWrapper(info.GetIsolate(), holder, ServiceWorkerGlobalScopeNotifications::onnotificationclick(*impl), v8Value, V8ServiceWorkerGlobalScope::eventListenerCacheIndex);
ServiceWorkerGlobalScopeNotifications::setOnnotificationclick(*impl, V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
}
static void onnotificationclickAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> v8Value = info[0];
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
ServiceWorkerGlobalScopeV8Internal::onnotificationclickAttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onnotificationerrorAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
EventListener* cppValue(ServiceWorkerGlobalScopeNotifications::onnotificationerror(*impl));
v8SetReturnValue(info, cppValue ? v8::Local<v8::Value>(V8AbstractEventListener::cast(cppValue)->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null(info.GetIsolate())));
}
static void onnotificationerrorAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::onnotificationerrorAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onnotificationerrorAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
moveEventListenerToNewWrapper(info.GetIsolate(), holder, ServiceWorkerGlobalScopeNotifications::onnotificationerror(*impl), v8Value, V8ServiceWorkerGlobalScope::eventListenerCacheIndex);
ServiceWorkerGlobalScopeNotifications::setOnnotificationerror(*impl, V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
}
static void onnotificationerrorAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> v8Value = info[0];
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
ServiceWorkerGlobalScopeV8Internal::onnotificationerrorAttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onpushAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
EventListener* cppValue(ServiceWorkerGlobalScopePush::onpush(*impl));
v8SetReturnValue(info, cppValue ? v8::Local<v8::Value>(V8AbstractEventListener::cast(cppValue)->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null(info.GetIsolate())));
}
static void onpushAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
ServiceWorkerGlobalScopeV8Internal::onpushAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void onpushAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(holder);
moveEventListenerToNewWrapper(info.GetIsolate(), holder, ServiceWorkerGlobalScopePush::onpush(*impl), v8Value, V8ServiceWorkerGlobalScope::eventListenerCacheIndex);
ServiceWorkerGlobalScopePush::setOnpush(*impl, V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate));
}
static void onpushAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Value> v8Value = info[0];
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
ServiceWorkerGlobalScopeV8Internal::onpushAttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void fetchMethodPromise(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionState)
{
if (UNLIKELY(info.Length() < 1)) {
setMinimumArityTypeError(exceptionState, 1, info.Length());
return;
}
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(info.Holder());
RequestOrUSVString input;
Dictionary init;
{
V8RequestOrUSVString::toImpl(info.GetIsolate(), info[0], input, exceptionState);
if (exceptionState.hadException())
return;
if (!isUndefinedOrNull(info[1]) && !info[1]->IsObject()) {
exceptionState.throwTypeError("parameter 2 ('init') is not an object.");
return;
}
init = Dictionary(info[1], info.GetIsolate(), exceptionState);
if (exceptionState.hadException())
return;
}
ScriptState* scriptState = ScriptState::current(info.GetIsolate());
ScriptPromise result = impl->fetch(scriptState, input, init, exceptionState);
if (exceptionState.hadException()) {
return;
}
v8SetReturnValue(info, result.v8Value());
}
static void fetchMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "fetch", "ServiceWorkerGlobalScope", info.Holder(), info.GetIsolate());
fetchMethodPromise(info, exceptionState);
if (exceptionState.hadException())
v8SetReturnValue(info, exceptionState.reject(ScriptState::current(info.GetIsolate())).v8Value());
}
static void fetchMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
ServiceWorkerGlobalScopeV8Internal::fetchMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void closeMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "close", "ServiceWorkerGlobalScope", info.Holder(), info.GetIsolate());
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(info.Holder());
impl->close(exceptionState);
if (exceptionState.hadException()) {
exceptionState.throwIfNeeded();
return;
}
}
static void closeMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
ServiceWorkerGlobalScopeV8Internal::closeMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void skipWaitingMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ServiceWorkerGlobalScope* impl = V8ServiceWorkerGlobalScope::toImpl(info.Holder());
ScriptState* scriptState = ScriptState::current(info.GetIsolate());
ScriptPromise result = impl->skipWaiting(scriptState);
v8SetReturnValue(info, result.v8Value());
}
static void skipWaitingMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
ServiceWorkerGlobalScopeV8Internal::skipWaitingMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
} // namespace ServiceWorkerGlobalScopeV8Internal
// Suppress warning: global constructors, because AttributeConfiguration is trivial
// and does not depend on another global objects.
#if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors"
#endif
static const V8DOMConfiguration::AttributeConfiguration V8ServiceWorkerGlobalScopeAttributes[] = {
{"Blob", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8Blob::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"CustomEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8CustomEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"DOMException", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8DOMException::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"Event", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8Event::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"EventSource", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8EventSource::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"EventTarget", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8EventTarget::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"File", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8File::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"FileList", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8FileList::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"FileReader", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8FileReader::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"FileReaderSync", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8FileReaderSync::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"FormData", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8FormData::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"ImageData", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8ImageData::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"MessageChannel", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8MessageChannel::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"MessageEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8MessageEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"MessagePort", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8MessagePort::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"ReadableByteStream", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8ReadableByteStream::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"ReadableStream", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8ReadableStream::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"URL", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8URL::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"WorkerGlobalScope", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8WorkerGlobalScope::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"WorkerLocation", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8WorkerLocation::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"WorkerNavigator", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8WorkerNavigator::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"Cache", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8Cache::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"CacheStorage", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8CacheStorage::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"Client", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8Client::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"Clients", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8Clients::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"CloseEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8CloseEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"Crypto", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8Crypto::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"CryptoKey", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8CryptoKey::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"ExtendableEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8ExtendableEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"FetchEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8FetchEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"Headers", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8Headers::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"IDBCursor", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8IDBCursor::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"IDBCursorWithValue", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8IDBCursorWithValue::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"IDBDatabase", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8IDBDatabase::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"IDBFactory", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8IDBFactory::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"IDBIndex", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8IDBIndex::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"IDBKeyRange", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8IDBKeyRange::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"IDBObjectStore", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8IDBObjectStore::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"IDBOpenDBRequest", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8IDBOpenDBRequest::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"IDBRequest", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8IDBRequest::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"IDBTransaction", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8IDBTransaction::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"IDBVersionChangeEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8IDBVersionChangeEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"Request", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8Request::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"Response", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8Response::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"ServiceWorkerGlobalScope", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8ServiceWorkerGlobalScope::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"ServiceWorkerRegistration", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8ServiceWorkerRegistration::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"SubtleCrypto", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8SubtleCrypto::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"TextDecoder", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8TextDecoder::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"TextEncoder", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8TextEncoder::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
{"WebSocket", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8WebSocket::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder},
};
#if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
#pragma clang diagnostic pop
#endif
static const V8DOMConfiguration::AccessorConfiguration V8ServiceWorkerGlobalScopeAccessors[] = {
{"clients", ServiceWorkerGlobalScopeV8Internal::clientsAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"registration", ServiceWorkerGlobalScopeV8Internal::registrationAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"onactivate", ServiceWorkerGlobalScopeV8Internal::onactivateAttributeGetterCallback, ServiceWorkerGlobalScopeV8Internal::onactivateAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"onfetch", ServiceWorkerGlobalScopeV8Internal::onfetchAttributeGetterCallback, ServiceWorkerGlobalScopeV8Internal::onfetchAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"oninstall", ServiceWorkerGlobalScopeV8Internal::oninstallAttributeGetterCallback, ServiceWorkerGlobalScopeV8Internal::oninstallAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"onmessage", ServiceWorkerGlobalScopeV8Internal::onmessageAttributeGetterCallback, ServiceWorkerGlobalScopeV8Internal::onmessageAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
};
static const V8DOMConfiguration::MethodConfiguration V8ServiceWorkerGlobalScopeMethods[] = {
{"fetch", ServiceWorkerGlobalScopeV8Internal::fetchMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
{"close", ServiceWorkerGlobalScopeV8Internal::closeMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
{"skipWaiting", ServiceWorkerGlobalScopeV8Internal::skipWaitingMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
};
static void installV8ServiceWorkerGlobalScopeTemplate(v8::Local<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
{
functionTemplate->ReadOnlyPrototype();
v8::Local<v8::Signature> defaultSignature;
defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "ServiceWorkerGlobalScope", V8WorkerGlobalScope::domTemplate(isolate), V8ServiceWorkerGlobalScope::internalFieldCount,
V8ServiceWorkerGlobalScopeAttributes, WTF_ARRAY_LENGTH(V8ServiceWorkerGlobalScopeAttributes),
V8ServiceWorkerGlobalScopeAccessors, WTF_ARRAY_LENGTH(V8ServiceWorkerGlobalScopeAccessors),
V8ServiceWorkerGlobalScopeMethods, WTF_ARRAY_LENGTH(V8ServiceWorkerGlobalScopeMethods));
v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
ALLOW_UNUSED_LOCAL(instanceTemplate);
v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
ALLOW_UNUSED_LOCAL(prototypeTemplate);
if (RuntimeEnabledFeatures::navigatorConnectEnabled()) {
static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration =\
{"ports", ServiceWorkerGlobalScopeV8Internal::portsAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAccessor(isolate, instanceTemplate, prototypeTemplate, functionTemplate, defaultSignature, accessorConfiguration);
}
if (RuntimeEnabledFeatures::backgroundSyncEnabled()) {
static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration =\
{"onsync", ServiceWorkerGlobalScopeV8Internal::onsyncAttributeGetterCallback, ServiceWorkerGlobalScopeV8Internal::onsyncAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAccessor(isolate, instanceTemplate, prototypeTemplate, functionTemplate, defaultSignature, accessorConfiguration);
}
if (RuntimeEnabledFeatures::backgroundSyncEnabled()) {
static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration =\
{"onperiodicsync", ServiceWorkerGlobalScopeV8Internal::onperiodicsyncAttributeGetterCallback, ServiceWorkerGlobalScopeV8Internal::onperiodicsyncAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAccessor(isolate, instanceTemplate, prototypeTemplate, functionTemplate, defaultSignature, accessorConfiguration);
}
if (RuntimeEnabledFeatures::geofencingEnabled()) {
static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration =\
{"ongeofenceenter", ServiceWorkerGlobalScopeV8Internal::ongeofenceenterAttributeGetterCallback, ServiceWorkerGlobalScopeV8Internal::ongeofenceenterAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAccessor(isolate, instanceTemplate, prototypeTemplate, functionTemplate, defaultSignature, accessorConfiguration);
}
if (RuntimeEnabledFeatures::geofencingEnabled()) {
static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration =\
{"ongeofenceleave", ServiceWorkerGlobalScopeV8Internal::ongeofenceleaveAttributeGetterCallback, ServiceWorkerGlobalScopeV8Internal::ongeofenceleaveAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAccessor(isolate, instanceTemplate, prototypeTemplate, functionTemplate, defaultSignature, accessorConfiguration);
}
if (RuntimeEnabledFeatures::navigatorConnectEnabled()) {
static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration =\
{"oncrossoriginconnect", ServiceWorkerGlobalScopeV8Internal::oncrossoriginconnectAttributeGetterCallback, ServiceWorkerGlobalScopeV8Internal::oncrossoriginconnectAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAccessor(isolate, instanceTemplate, prototypeTemplate, functionTemplate, defaultSignature, accessorConfiguration);
}
if (RuntimeEnabledFeatures::navigatorConnectEnabled()) {
static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration =\
{"oncrossoriginmessage", ServiceWorkerGlobalScopeV8Internal::oncrossoriginmessageAttributeGetterCallback, ServiceWorkerGlobalScopeV8Internal::oncrossoriginmessageAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAccessor(isolate, instanceTemplate, prototypeTemplate, functionTemplate, defaultSignature, accessorConfiguration);
}
if (RuntimeEnabledFeatures::serviceWorkerNotificationsEnabled()) {
static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration =\
{"onnotificationclick", ServiceWorkerGlobalScopeV8Internal::onnotificationclickAttributeGetterCallback, ServiceWorkerGlobalScopeV8Internal::onnotificationclickAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAccessor(isolate, instanceTemplate, prototypeTemplate, functionTemplate, defaultSignature, accessorConfiguration);
}
if (RuntimeEnabledFeatures::serviceWorkerNotificationsEnabled()) {
static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration =\
{"onnotificationerror", ServiceWorkerGlobalScopeV8Internal::onnotificationerrorAttributeGetterCallback, ServiceWorkerGlobalScopeV8Internal::onnotificationerrorAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAccessor(isolate, instanceTemplate, prototypeTemplate, functionTemplate, defaultSignature, accessorConfiguration);
}
if (RuntimeEnabledFeatures::pushMessagingEnabled()) {
static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration =\
{"onpush", ServiceWorkerGlobalScopeV8Internal::onpushAttributeGetterCallback, ServiceWorkerGlobalScopeV8Internal::onpushAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAccessor(isolate, instanceTemplate, prototypeTemplate, functionTemplate, defaultSignature, accessorConfiguration);
}
if (RuntimeEnabledFeatures::promiseRejectionEventEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"PromiseRejectionEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8PromiseRejectionEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::promiseRejectionEventEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"PromiseRejectionEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8PromiseRejectionEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::backgroundSyncEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"PeriodicSyncEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8PeriodicSyncEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::backgroundSyncEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"PeriodicSyncManager", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8PeriodicSyncManager::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::backgroundSyncEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"PeriodicSyncRegistration", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8PeriodicSyncRegistration::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::backgroundSyncEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"SyncEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8SyncEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::backgroundSyncEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"SyncManager", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8SyncManager::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::backgroundSyncEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"SyncRegistration", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8SyncRegistration::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::geofencingEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"CircularGeofencingRegion", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8CircularGeofencingRegion::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::geofencingEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"GeofencingEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8GeofencingEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::navigatorConnectEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"CrossOriginConnectEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8CrossOriginConnectEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::navigatorConnectEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"CrossOriginServiceWorkerClient", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8CrossOriginServiceWorkerClient::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::navigatorConnectEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"ServicePortCollection", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8ServicePortCollection::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::navigatorConnectEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"ServicePortConnectEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8ServicePortConnectEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::navigatorConnectEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"ServicePort", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8ServicePort::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::navigatorConnectEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"StashedMessagePort", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8StashedMessagePort::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::navigatorConnectEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"StashedPortCollection", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8StashedPortCollection::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::networkInformationEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"NetworkInformation", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8NetworkInformation::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::notificationsEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"Notification", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8Notification::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::permissionsEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"PermissionStatus", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8PermissionStatus::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::permissionsEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"Permissions", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8Permissions::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::pushMessagingDataEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"PushMessageData", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8PushMessageData::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::pushMessagingEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"PushEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8PushEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::pushMessagingEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"PushManager", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8PushManager::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::pushMessagingEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"PushSubscription", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8PushSubscription::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::serviceWorkerClientAttributesEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"WindowClient", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8WindowClient::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
if (RuntimeEnabledFeatures::serviceWorkerNotificationsEnabled()) {
static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\
{"NotificationEvent", v8ConstructorAttributeGetter, ServiceWorkerGlobalScopeV8Internal::ServiceWorkerGlobalScopeConstructorAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8NotificationEvent::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototypeTemplate, attributeConfiguration);
}
functionTemplate->SetHiddenPrototype(true);
// Custom toString template
functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
}
v8::Local<v8::FunctionTemplate> V8ServiceWorkerGlobalScope::domTemplate(v8::Isolate* isolate)
{
return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8ServiceWorkerGlobalScopeTemplate);
}
bool V8ServiceWorkerGlobalScope::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolate)
{
return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
}
v8::Local<v8::Object> V8ServiceWorkerGlobalScope::findInstanceInPrototypeChain(v8::Local<v8::Value> v8Value, v8::Isolate* isolate)
{
return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
}
ServiceWorkerGlobalScope* V8ServiceWorkerGlobalScope::toImplWithTypeCheck(v8::Isolate* isolate, v8::Local<v8::Value> value)
{
return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value)) : 0;
}
void V8ServiceWorkerGlobalScope::refObject(ScriptWrappable* scriptWrappable)
{
#if !ENABLE(OILPAN)
scriptWrappable->toImpl<ServiceWorkerGlobalScope>()->ref();
#endif
}
void V8ServiceWorkerGlobalScope::derefObject(ScriptWrappable* scriptWrappable)
{
#if !ENABLE(OILPAN)
scriptWrappable->toImpl<ServiceWorkerGlobalScope>()->deref();
#endif
}
} // namespace blink
| 87.450246 | 635 | 0.813163 | [
"object"
] |
a55079cd6d77c08737254fb005e3cc0a6222e05b | 354 | hpp | C++ | FootCommander.hpp | noayair/WarGame | 04a20acd669dc4f3cd6088f7149c5b5caecd660e | [
"MIT"
] | null | null | null | FootCommander.hpp | noayair/WarGame | 04a20acd669dc4f3cd6088f7149c5b5caecd660e | [
"MIT"
] | null | null | null | FootCommander.hpp | noayair/WarGame | 04a20acd669dc4f3cd6088f7149c5b5caecd660e | [
"MIT"
] | null | null | null | #pragma once
#include "FootSoldier.hpp"
class FootCommander: public FootSoldier{
public:
FootCommander(int p): Soldier(p, 20 , 150, {0,0}, "FootCommander") {}
FootCommander(): Soldier() {}
void act(pair<int,int> l, std::vector<std::vector<Soldier*>>& board) override;
void actAll(pair<int,int> l, std::vector<std::vector<Soldier*>>& board);
}; | 35.4 | 80 | 0.689266 | [
"vector"
] |
a5567caf368ccc51929c6ce1ee4e5fc8bdce8757 | 5,397 | cpp | C++ | PostProcessor/GenerateAnimation.cpp | MingAtUWA/SimpleMPM2 | 7a1d7c257c621123d85a0630e93d42ae25c70fb4 | [
"MIT"
] | null | null | null | PostProcessor/GenerateAnimation.cpp | MingAtUWA/SimpleMPM2 | 7a1d7c257c621123d85a0630e93d42ae25c70fb4 | [
"MIT"
] | null | null | null | PostProcessor/GenerateAnimation.cpp | MingAtUWA/SimpleMPM2 | 7a1d7c257c621123d85a0630e93d42ae25c70fb4 | [
"MIT"
] | null | null | null | #include "PostProcessor_pcp.h"
#include "gif.h"
#include "GenerateAnimation.h"
GenerateAnimation *GenerateAnimation::cur_generator = nullptr;
GenerateAnimation::GenerateAnimation(GLsizei win_w, GLsizei win_h) :
win_width(win_w), win_height(win_h),
time_rcds(nullptr), time_rcd_num(0) {}
GenerateAnimation::~GenerateAnimation()
{
if (time_rcds)
{
delete[] time_rcds;
time_rcds = nullptr;
time_rcd_num = 0;
}
if (cur_generator == this)
cur_generator = nullptr;
}
static void processInput(GLFWwindow *window)
{
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
}
static void resize_window(GLFWwindow *window, GLsizei width, GLsizei height)
{
GenerateAnimation &cur_gen = *GenerateAnimation::cur_generator;
cur_gen.win_width = width;
cur_gen.win_height = height;
// reset viewport size
GLsizei vp_width, vp_height, padding;
vp_height = width * cur_gen.vp_hw_ratio;
if (vp_height < height)
{
vp_width = width;
padding = (height - vp_height) / 2;
glViewport(0, padding, vp_width, vp_height);
cur_gen.md_vp_x = 0;
cur_gen.md_vp_y = padding;
cur_gen.md_vp_width = vp_width;
cur_gen.md_vp_height = vp_height;
}
else
{
vp_height = height;
vp_width = height * cur_gen.vp_wh_ratio;
padding = (width - vp_width) / 2;
glViewport(padding, 0, vp_width, vp_height);
cur_gen.md_vp_x = padding;
cur_gen.md_vp_y = 0;
cur_gen.md_vp_width = vp_width;
cur_gen.md_vp_height = vp_height;
}
}
// helper function
void reorder_buffer(unsigned char *RGBA_data, int width, int height)
{
// RGBA data are 4 bytes long
long *data = reinterpret_cast<long *>(RGBA_data);
long *line1 = data;
long *line2 = data + (height - 1) * width;
long data_tmp;
while (line1 < line2)
{
for (size_t i = 0; i < width; i++)
{
data_tmp = line1[i];
line1[i] = line2[i];
line2[i] = data_tmp;
}
line1 += width;
line2 -= width;
}
}
int GenerateAnimation::generate(double ani_time, double xl, double xu, double yl, double yu,
const char *res_file_name, const char *gif_name)
{
make_current();
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow *window = glfwCreateWindow(win_width, win_height, "model display", nullptr, nullptr);
if (!window)
{
std::cout << "Failed to create GLFW window.\n";
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glfwSetFramebufferSizeCallback(window, resize_window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
std::cout << "Failed to initialize GLAD.\n";
glfwTerminate();
return -2;
}
// init viewport
double cam_width, cam_height;
cam_width = xu - xl;
cam_height = yu - yl;
vp_hw_ratio = cam_height / cam_width;
vp_wh_ratio = cam_width / cam_height;
resize_window(window, win_width, win_height);
// init animation
init(res_file_name);
// animation_time
if (time_rcd_num == 0)
return -1; // no time record
real_time = time_rcds[time_rcd_num-1].total_time - time_rcds[0].total_time;
animation_time = ani_time;
ani_real_ratio = animation_time / real_time;
min_delay_real = 0.02 / ani_real_ratio;
// gif output
GifWriter gif_file;
unsigned char *pixels_data;
if (gif_name)
{
GifBegin(&gif_file, gif_name, win_width, win_height, 1);
pixels_data = new unsigned char[win_width * win_height * 4];
}
bool render_new_frame = true; // control whether it is time to swap and render new frame
bool reach_last_frame = false; // whether run out of frame to render
size_t draw_frame_id = 0;
double prev_time;
cur_time_rcd_id = 0;
while (!glfwWindowShouldClose(window))
{
processInput(window);
if (render_new_frame)
{
prev_time = glfwGetTime();
render_frame(xl, xu, yl, yu);
render_new_frame = false;
// output to gif file
if (!reach_last_frame)
{
std::cout << "frame " << draw_frame_id++
<< " real time " << time_rcds[cur_time_rcd_id].total_time
<< " ani time " << time_rcds[cur_time_rcd_id].total_substep_num << "\n";
reach_last_frame = !find_next_frame();
if (gif_name)
{
// read pixel from back buffer
glReadPixels(0, 0, win_width, win_height, GL_RGBA, GL_UNSIGNED_BYTE, pixels_data);
reorder_buffer(pixels_data, win_width, win_height);
GifWriteFrame(&gif_file, pixels_data, win_width, win_height, (delay_ani_100th ? delay_ani_100th : 1));
}
}
}
if (glfwGetTime() - prev_time >= delay_ani)
{
glfwSwapBuffers(window);
render_new_frame = true;
}
glfwPollEvents();
}
if (gif_name)
{
GifEnd(&gif_file);
delete[] pixels_data;
pixels_data = nullptr;
}
glfwTerminate();
return 0;
}
bool GenerateAnimation::find_next_frame(void)
{
double prev_time = time_rcds[cur_time_rcd_id].total_time;
size_t frame_id;
double diff_time;
for (frame_id = cur_time_rcd_id + 1; frame_id < time_rcd_num; ++frame_id)
{
diff_time = time_rcds[frame_id].total_time - prev_time;
if (diff_time >= min_delay_real * 0.999)
{
delay_ani = diff_time * ani_real_ratio;
delay_ani_100th = unsigned short int(delay_ani * 100);
if (delay_ani_100th == 0)
delay_ani_100th = 1;
break;
}
}
if (frame_id >= time_rcd_num)
{
delay_ani = 0.25; // update every 0.25s
delay_ani_100th = 25;
return false;
}
cur_time_rcd_id = frame_id;
return true;
}
| 24.643836 | 107 | 0.709654 | [
"render",
"model"
] |
a5568ac688c0539be585bcb3cf9461ce6d0b9f7b | 11,275 | cc | C++ | sptensor2tt.cc | lljbash/FastTT | 943ed6756f630bbf2a7d18f297b65b98c2d891b8 | [
"MIT"
] | 6 | 2021-02-27T10:07:33.000Z | 2022-02-12T22:49:26.000Z | sptensor2tt.cc | lljbash/FastTT | 943ed6756f630bbf2a7d18f297b65b98c2d891b8 | [
"MIT"
] | null | null | null | sptensor2tt.cc | lljbash/FastTT | 943ed6756f630bbf2a7d18f297b65b98c2d891b8 | [
"MIT"
] | 1 | 2021-09-14T09:22:55.000Z | 2021-09-14T09:22:55.000Z | #include "sptensor2tt.h"
#include <vector>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <limits>
#include "xerus/misc/check.h"
#include "xerus/misc/internal.h"
using namespace std;
#define order degree
namespace xerus {
int count_subvector(Tensor &a, int vpos) {
const size_t d = a.order();
TTTensor u(d);
const auto &data = a.get_sparse_data();
unordered_set<size_t> submats;
const auto &n = a.dimensions;
size_t pn = 1;
for (size_t i = vpos + 1; i < d; ++i) {
pn *= n.at(i);
}
for (const auto &[index, value] : data) {
const size_t in_pos = index / pn % n.at(vpos);
const size_t out_pos = index - in_pos * pn;
submats.insert(out_pos);
}
return submats.size();
}
TTTensor extract_subvector(Tensor &a, int vpos) {
const size_t d = a.order();
TTTensor u(d);
const auto &data = a.get_sparse_data();
unordered_map<size_t, vector<pair<size_t, value_t>>> submats;
const auto &n = a.dimensions;
size_t pn = 1;
for (size_t i = vpos + 1; i < d; ++i) {
pn *= n.at(i);
}
for (const auto &[index, value] : data) {
const size_t in_pos = index / pn % n.at(vpos);
const size_t out_pos = index - in_pos * pn;
submats[out_pos].emplace_back(in_pos, value);
}
const size_t r = submats.size();
u.set_component(0, Tensor({1, n.front(), r}));
for (size_t i = 1; i < d - 1; ++i) {
u.set_component(i, Tensor({r, n.at(i), r}));
}
u.set_component(d - 1, Tensor({r, n.back(), 1}));
size_t index = 0;
for (const auto &submat : submats) {
const size_t out_pos = submat.first;
const auto md = Tensor::position_to_multiIndex(out_pos, n);
for (size_t i = 0; i < d; ++i) {
size_t nleft = i == 0 ? 0 : index;
size_t nright = i == d - 1 ? 0 : index;
if (i != static_cast<size_t>(vpos)) {
u.component(i).operator[]({nleft, md.at(i), nright}) = 1;
}
else {
for (const auto &[index, value] : submat.second) {
u.component(i).operator[]({nleft, index, nright}) = value;
}
}
}
++index;
}
return u;
}
auto depar01(Tensor a) {
const size_t d = a.order();
REQUIRE(d == 2, "Input of depar01 must be a matrix");
const size_t nrows = a.dimensions.at(0);
const size_t ncols = a.dimensions.at(1);
vector a_col_nze(ncols, numeric_limits<size_t>::max());
a.use_sparse_representation();
const auto &data = a.get_sparse_data();
for (const auto &[index, value] : data) {
auto indices = Tensor::position_to_multiIndex(index, a.dimensions);
size_t index_row = indices.at(0);
size_t index_col = indices.at(1);
a_col_nze.at(index_col) = index_row;
}
vector hashmap(nrows, numeric_limits<size_t>::max());
vector<vector<size_t>> b_indices;
vector<vector<size_t>> t_indices;
size_t cnt = 0;
for (size_t i = 0; i < ncols; ++i) {
const size_t &index_row = a_col_nze.at(i);
if (index_row >= nrows) {
continue;
}
size_t &newid = hashmap.at(index_row);
if (newid >= ncols) {
b_indices.push_back({index_row, cnt});
newid = cnt++;
}
t_indices.push_back({newid, i});
}
vector b_size{nrows, cnt};
vector t_size{cnt, ncols};
map<size_t, value_t> b_data;
map<size_t, value_t> t_data;
for (const auto &entry : b_indices) {
size_t pos = Tensor::multiIndex_to_position(entry, b_size);
b_data.try_emplace(pos, 1);
}
for (const auto &entry : t_indices) {
size_t pos = Tensor::multiIndex_to_position(entry, t_size);
t_data.try_emplace(pos, 1);
}
auto b = Tensor(b_size, Tensor::Representation::Sparse, Tensor::Initialisation::None);
b.get_unsanitized_sparse_data() = move(b_data);
auto t = Tensor(t_size, Tensor::Representation::Sparse, Tensor::Initialisation::None);
t.get_unsanitized_sparse_data() = move(t_data);
return tuple(move(b), move(t));
}
void parrounding(TTTensor &a, size_t vpos) {
const size_t d = a.order();
for (size_t i = 0; i < vpos; ++i) {
auto &comp = a.component(i);
const auto n = comp.dimensions;
comp.reinterpret_dimensions({n.at(0) * n.at(1), n.at(2)});
auto [b, t] = depar01(move(comp));
b.reinterpret_dimensions({n.at(0), n.at(1), b.dimensions.back()});
a.set_component(i, move(b));
auto &succ = a.component(i+1);
contract(t, t, succ, 1);
a.set_component(i+1, move(t));
}
for (size_t i = d-1; i > vpos; --i) {
auto &comp = a.component(i);
const auto n = comp.dimensions;
comp.reinterpret_dimensions({n.at(0), n.at(1) * n.at(2)});
reshuffle(comp, comp, {1, 0});
auto [b, t] = depar01(move(comp));
reshuffle(b, b, {1, 0});
b.reinterpret_dimensions({b.dimensions.front(), n.at(1), n.at(2)});
a.set_component(i, move(b));
auto &pre = a.component(i-1);
contract(t, pre, false, t, true, 1);
a.set_component(i-1, move(t));
}
}
int64_t estimate_ttrounding_flops(/*int nnv*/vector<int> current_ranks, vector<size_t> dims, int vpos, int max_rank) {
if (max_rank < 0) {
max_rank = numeric_limits<int>::max();
}
const int d = dims.size();
//vector current_ranks(d+1, nnv);
//current_ranks[0] = 1;
//current_ranks[d] = 1;
vector final_ranks(current_ranks);
for (int i = 0; i < d; ++i) {
if (max_rank < final_ranks[i+1]) {
final_ranks[i+1] = max_rank;
}
}
for (auto [i, prod] = pair{0, 1LL}; i <= vpos-1; ++i) {
prod *= dims[i];
if (prod < current_ranks[i+1]) {
current_ranks[i+1] = prod;
}
}
for (auto [i, prod] = pair{d-2, 1LL}; i >= vpos; --i) {
prod *= dims[i+1];
if (prod < current_ranks[i+1]) {
current_ranks[i+1] = prod;
}
}
for (auto [i, prod] = pair{0, 1LL}; i < d-1; ++i) {
prod *= dims[i];
if (prod < final_ranks[i+1]) {
final_ranks[i+1] = prod;
}
}
for (auto [i, prod] = pair{d-2, 1LL}; i >= 0; --i) {
prod *= dims[i+1];
if (prod < final_ranks[i+1]) {
final_ranks[i+1] = prod;
}
}
//for (auto r : current_ranks) {
//cout << r << " ";
//}
//cout << endl;
//for (auto r : final_ranks) {
//cout << r << " ";
//}
//cout << endl;
auto svd_flops = [](int n, int m) {
return static_cast<int64_t>(n) * static_cast<int64_t>(m)
* static_cast<int64_t>(min(n, m));
};
int64_t flops = 0;
if (vpos != d - 1) {
flops += svd_flops(current_ranks[vpos]*dims[vpos], current_ranks[vpos+1]);
}
for (int i = vpos+1; i < d-1; ++i) {
flops += svd_flops(final_ranks[i]*dims[i], current_ranks[i+1]);
}
for (int i = d-1; i > vpos; --i) {
flops += svd_flops(final_ranks[i], dims[i]*final_ranks[i+1]) / 5; // QR flops
}
for (int i = vpos; i > 0; --i) {
flops += svd_flops(final_ranks[i+1]*dims[i], current_ranks[i]);
}
return flops;
}
void ttrounding(TTTensor &a, size_t vpos, int max_rank, double eps) {
constexpr double kAlpha = 1.5;
static_assert(kAlpha >= 1);
if (max_rank <= 0) {
max_rank = 0;
}
const size_t d = a.order();
int rnsvd = d - vpos - 1;
int lnsvd = vpos;
double peps = eps / (sqrt(lnsvd) + sqrt(rnsvd));
double reps = peps * sqrt(rnsvd);
double leps = eps - reps;
auto norm_a = a.component(vpos).frob_norm();
//cout << lnsvd << " " << rnsvd << " " << leps << " " << reps << endl;
for (size_t i = vpos; i < d-1; ++i) {
Tensor U, S, Vt;
a.component(i).use_dense_representation();
double delta = rnsvd == 1 && lnsvd == 0 ? reps : min(leps + reps, reps * kAlpha / sqrt(rnsvd));
delta = min(max(delta, 0.), 1. - numeric_limits<value_t>::epsilon());
delta = peps;
//cout << delta << endl;
double svdeps = calculate_svd(U, S, Vt, a.component(i), 2, max_rank, max_rank == 0 ? delta : 0) / norm_a;
//cout << svdeps << endl;
--rnsvd;
reps = reps * reps - svdeps * svdeps;
reps = reps >= 0 ? sqrt(reps) : -sqrt(-reps);
a.set_component(i, move(U));
auto lhs = contract(S, Vt, 1);
a.set_component(i+1, contract(lhs, a.component(i+1), 1));
//cout << lnsvd << " " << rnsvd << " " << leps << " " << reps<< endl;
}
for (size_t i = d-1; i > vpos; --i) {
Tensor Q, R;
a.component(i).use_dense_representation();
calculate_rq(R, Q, a.component(i), 1);
a.set_component(i, move(Q));
a.set_component(i-1, contract(a.component(i-1), R, 1));
}
leps += reps;
reps = 0;
//cout << lnsvd << " " << rnsvd << " " << leps << " " << reps << endl;
for (size_t i = vpos; i > 0; --i) {
Tensor U, S, Vt;
a.component(i).use_dense_representation();
double delta = rnsvd == 0 && lnsvd == 1 ? leps : min(leps + reps, leps * kAlpha / sqrt(lnsvd));
delta = min(max(delta, 0.), 1. - numeric_limits<value_t>::epsilon());
delta = peps;
//cout << delta << endl;
double svdeps = calculate_svd(U, S, Vt, a.component(i), 1, max_rank, max_rank == 0 ? delta : 0) / norm_a;
//cout << svdeps << endl;
--lnsvd;
leps = leps * leps - svdeps * svdeps;
leps = leps >= 0 ? sqrt(leps) : -sqrt(-leps);
a.set_component(i, move(Vt));
auto rhs = contract(U, S, 1);
a.set_component(i-1, contract(a.component(i-1), rhs, 1));
//cout << lnsvd << " " << rnsvd << " " << leps << " " << reps << endl;
}
}
TTTensor sptensor2tt(Tensor a, int vpos, int max_rank, double eps) {
a.use_sparse_representation();
if (int d = a.order(); vpos < 0 || vpos >= d) {
vector temp_rank(a.order()+1, 1);
for (int d : vector{0, a.order()-1}) {
auto u = extract_subvector(a, d);
parrounding(u, d);
for (size_t dd = 1; dd < a.order(); ++dd) {
if (static_cast<int>(u.rank(dd-1)) > temp_rank[dd]) {
temp_rank[dd] = u.rank(dd-1);
}
}
}
for (auto r : temp_rank) {
cout << r << " ";
}
cout << endl;
auto min_flops = numeric_limits<int64_t>::max();
for (int i = 0; i < d; ++i) {
//int nnv = count_subvector(a, i);
auto flops = estimate_ttrounding_flops(temp_rank, a.dimensions, i, max_rank);
cout << flops << endl;
if (flops < min_flops) {
min_flops = flops;
vpos = i;
}
}
cout << vpos << endl;
}
auto u = extract_subvector(a, vpos);
//for (auto r : u.ranks()) { cout << r << " "; } cout << endl;
parrounding(u, vpos);
//for (auto r : u.ranks()) { cout << r << " "; } cout << endl;
ttrounding(u, vpos, max_rank, eps);
return u;
}
}
| 34.166667 | 118 | 0.530022 | [
"vector"
] |
a55a20831cf057a1152726058589b384eebec2e3 | 894 | cpp | C++ | leetcode.com/0322 Coin Change/main.cpp | sky-bro/AC | 29bfa3f13994612887e18065fa6e854b9a29633d | [
"MIT"
] | 1 | 2020-08-20T11:02:49.000Z | 2020-08-20T11:02:49.000Z | leetcode.com/0322 Coin Change/main.cpp | sky-bro/AC | 29bfa3f13994612887e18065fa6e854b9a29633d | [
"MIT"
] | null | null | null | leetcode.com/0322 Coin Change/main.cpp | sky-bro/AC | 29bfa3f13994612887e18065fa6e854b9a29633d | [
"MIT"
] | 1 | 2022-01-01T23:23:13.000Z | 2022-01-01T23:23:13.000Z | #include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int coinChange(vector<int>& coins, int amount) {
vector<int> cnts(amount+1, -1);
cnts[0] = 0;
for (int i = 1; i <= amount; ++i) {
for (int coin: coins) {
if (coin > i) continue;
if (cnts[i-coin] != -1)
if (cnts[i] == -1) {
cnts[i] = cnts[i-coin]+1;
} else {
cnts[i] = min(cnts[i], cnts[i-coin]+1);
}
}
}
return cnts[amount];
}
};
int main(int argc, char const *argv[])
{
vector<int> coins = {1, 2, 5};
int amount = 11;
Solution s;
cout<<s.coinChange(coins, amount)<<endl; // 3
coins = {2};
amount = 3;
cout<<s.coinChange(coins, amount)<<endl; // -1
return 0;
}
| 22.923077 | 63 | 0.444072 | [
"vector"
] |
a22a354a86303c7462005dc198445272bb64610d | 15,320 | cpp | C++ | common/src/keyfile/rsa.cpp | waddlesplash/WonderBrush-v2 | df20b6a43115d02e4606c71f27d0712ac2aebb62 | [
"MIT"
] | null | null | null | common/src/keyfile/rsa.cpp | waddlesplash/WonderBrush-v2 | df20b6a43115d02e4606c71f27d0712ac2aebb62 | [
"MIT"
] | null | null | null | common/src/keyfile/rsa.cpp | waddlesplash/WonderBrush-v2 | df20b6a43115d02e4606c71f27d0712ac2aebb62 | [
"MIT"
] | null | null | null | // rsa.cpp
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <Archivable.h>
#include <ByteOrder.h>
#include <File.h>
#include <Message.h>
#include <OS.h>
#include "rsa.h"
#include "BigIntGenerator.h"
#include "BitQueue.h"
static const size_t kHeaderSize = sizeof(size_t);
static const off_t kMaxKeyFileSize = 10240;
static const char kXORCharacter = (unsigned char)0xff;
rsa_key dbgKey;
// bit_filter
static inline
unsigned long
bit_filter(int count)
{
return (~0UL >> (sizeof(unsigned long) * 8 - count));
}
static inline
void
print_queue(const BitQueue& queue)
{
printf("queue (%d): ", queue.CountBits());
queue.PrintToStream();
printf("\n");
}
// mod_pow
unsigned
mod_pow(unsigned b, unsigned e, unsigned m)
{
unsigned long long result = 1;
unsigned long long bx = b;
while (e) {
if (e & 1) {
result = result * bx;
result %= m;
}
bx *= bx;
bx %= m;
e >>= 1;
}
return (unsigned)result;
}
// rsa_generate_key
void
rsa_generate_key(rsa_key& publicKey, rsa_key& privateKey, int bits)
{
// two prime numbers p, q
bigint p = BigIntGenerator::GeneratePrime(bits / 2);
bigint q = BigIntGenerator::GeneratePrime(bits - bits / 2);
bigint n = p * q;
bigint pn = (p - 1) * (q - 1); // Euler's totient function
bigint ln = pn / gcd((p - 1), (q - 1)); // Carmichael's function
// a number d relatively prime to ln
int cookie;
bigint d = BigIntGenerator::GeneratePrimeCandidate(ln.ld() + 1, cookie);
while (gcd(d, ln) != 1)
BigIntGenerator::GetNextPrimeCandidate(d, cookie);
d %= ln;
// a number e so that (d * e) % ln = 1:
// since d and ln are rel. prime, we can abuse the gcd:
// 1 = gcd(d, ln) = u * d + v * ln
bigint e, m;
gcd(d, ln, e, m);
// e must be > 0
if (e < 0)
e = e % ln + ln;
//bigint g = gcd(d, ln, e, m);
//cout << "gcd: " << g << endl;
//cout << "e * d + m * ln: " << (e * d + m * ln) << endl;
//cout << "(e * d) % ln: " << ((e * d) % ln) << endl;
//cout << "(e * d) % ln + ln: " << ((e * d) % ln + ln) << endl;
// set the return values
publicKey.n = n;
publicKey.k = d;
privateKey.n = n;
privateKey.k = e;
}
// rsa_flattened_key_size
size_t
rsa_flattened_key_size(const rsa_key& key)
{
size_t size = 0;
unsigned long nLen = key.n.ld() + 1;
unsigned long kLen = key.k.ld() + 1;
size = 2 * sizeof(unsigned long) + (nLen + kLen + 7) / 8;
return size;
}
// rsa_flatten_key
void
rsa_flatten_key(const rsa_key& key, void* buffer)
{
BitQueue queue;
unsigned long nLen = key.n.ld() + 1;
unsigned long kLen = key.k.ld() + 1;
queue.PushBits(nLen, sizeof(unsigned long) * 8);
queue.PushBits(kLen, sizeof(unsigned long) * 8);
queue.PushBits(key.n, nLen);
queue.PushBits(key.k, kLen);
queue.PopBytes(buffer, (queue.CountBits() + 7) / 8);
}
// rsa_unflatten_key
status_t
rsa_unflatten_key(const void* buffer, size_t length, rsa_key& key)
{
status_t error = B_ERROR;
if (buffer && length > 0) {
error = B_OK;
BitQueue queue;
queue.PushBytes(buffer, length);
unsigned long nLen = queue.PopBits(sizeof(unsigned long) * 8);
unsigned long kLen = queue.PopBits(sizeof(unsigned long) * 8);
//printf("rsa_unflatten_key(): n: %lu, k: %lu\n", nLen, kLen);
queue.PopBits(key.n, nLen);
//cout << "key.n: " << key.n << endl;
queue.PopBits(key.k, kLen);
//cout << "key.k: " << key.k << endl;
}
return error;
}
// rsa_read_key
status_t
rsa_read_key(const char* filename, rsa_key& key)
{
status_t error = B_OK;
if (!filename)
error = B_ERROR;
// open the file
int fd = -1;
if (error == B_OK) {
fd = open(filename, O_RDONLY);
if (fd < 0)
error = errno;
}
// read the file
size_t flattenedSize = 0;
char* flattenedKey = NULL;
if (error == B_OK) {
off_t fileSize = 0;
struct stat st;
if (fstat(fd, &st) == 0)
fileSize = st.st_size;
else
error = errno;
if (error == B_OK) {
if (fileSize > 0 && fileSize <= kMaxKeyFileSize)
flattenedSize = (size_t)fileSize;
else
error = B_ERROR;
}
if (error == B_OK) {
flattenedKey = new char[flattenedSize];
if (read(fd, flattenedKey, flattenedSize) != (long)flattenedSize)
error = errno;
}
}
// unflatten the key
if (error == B_OK)
error = rsa_unflatten_key(flattenedKey, flattenedSize, key);
delete[] flattenedKey;
if (fd >= 0)
close(fd);
return error;
}
// rsa_write_key
status_t
rsa_write_key(const char* filename, const rsa_key& key)
{
status_t error = B_OK;
if (!filename)
error = B_ERROR;
// flatten the key
size_t flattenedSize = 0;
char* flattenedKey = NULL;
if (error == B_OK) {
flattenedSize = rsa_flattened_key_size(key);
flattenedKey = new char[flattenedSize];
rsa_flatten_key(key, flattenedKey);
}
// create the file
int fd = -1;
if (error == B_OK) {
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd < 0)
error = errno;
}
// write the flattened data
if (error == B_OK) {
if (write(fd, flattenedKey, flattenedSize) != (long)flattenedSize)
error = errno;
}
if (fd >= 0)
close(fd);
delete[] flattenedKey;
return error;
}
// write_line
static
status_t
write_line(int fd, const char* line)
{
status_t error = B_OK;
size_t toWrite = strlen(line);
ssize_t written = write(fd, line, toWrite);
if (written < 0)
error = errno;
else if (written != (ssize_t)toWrite)
error = B_ERROR;
return error;
}
// rsa_write_key_to_c
status_t
rsa_write_key_to_c(const char* filename, const rsa_key& key)
{
status_t error = B_OK;
if (!filename)
error = B_ERROR;
// flatten the key
size_t flattenedSize = 0;
char* flattenedKey = NULL;
if (error == B_OK) {
flattenedSize = rsa_flattened_key_size(key);
flattenedKey = new char[flattenedSize];
rsa_flatten_key(key, flattenedKey);
}
// create the file
int fd = -1;
if (error == B_OK) {
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd < 0)
error = errno;
}
// write the flattened data as c code
if (error == B_OK) {
char* line = new char[256];
// write variable declaration
error = write_line(fd, "const unsigned char* key = {\n");
const unsigned char* buffer = (const unsigned char*)flattenedKey;
size_t bytesRemaining = flattenedSize;
while (error == B_OK && bytesRemaining > 0) {
line[0] = '\0';
// compose a line (10 bytes at maximum)
size_t toWrite = min((unsigned long)bytesRemaining, 10UL);
char* dest = line;
sprintf(dest, "\t");
dest += strlen(dest);
for (int i = 0; i < (int)toWrite; i++) {
if (i > 0) {
sprintf(dest, ", ");
dest += strlen(dest);
}
sprintf(dest, "0x%02x", *buffer);
dest += strlen(dest);
buffer++;
}
bytesRemaining -= toWrite;
if (bytesRemaining > 0)
sprintf(dest, ",\n");
else
sprintf(dest, "\n");
error = write_line(fd, line);
}
if (error == B_OK)
error = write_line(fd, "};\n");
delete line;
}
if (fd >= 0)
close(fd);
delete[] flattenedKey;
return error;
}
// rsa_bytes_needed_for_encryption
size_t
rsa_bytes_needed_for_encryption(size_t bytesToEncrypt, const rsa_key& key)
{
// additional space for a header containing the actual number of bytes
bytesToEncrypt += kHeaderSize;
int inBlockSize = key.n.ld();
int outBlockSize = inBlockSize + 1;
int numBlocks = (bytesToEncrypt * 8 + inBlockSize - 1) / inBlockSize;
return (numBlocks * outBlockSize + 7) / 8;
}
// rsa_bytes_needed_for_decryption
//
// Returns the maximal number of bytes needed for the decryption output.
// rsa_decrypt() may return a smaller number.
size_t
rsa_bytes_needed_for_decryption(size_t bytesToDecrypt, const rsa_key& key)
{
int outBlockSize = key.n.ld();
int inBlockSize = outBlockSize + 1;
int numBlocks = (bytesToDecrypt * 8) / inBlockSize;
return (numBlocks * outBlockSize + 7) / 8 - kHeaderSize;
}
// rsa_encrypt
ssize_t
rsa_encrypt(const void* message, size_t bytesToEncrypt,
void* buffer, size_t bufferSize, const rsa_key& key)
{
//printf("rsa_encrypt()\n");
int inBlockSize = key.n.ld();
int outBlockSize = inBlockSize + 1;
// check the key -- we don't allow keys shorter than the header
if (inBlockSize < (int)kHeaderSize * 8)
return B_ERROR;
// check the buffer size
if (bufferSize < rsa_bytes_needed_for_encryption(bytesToEncrypt, key))
return B_ERROR;
const unsigned char* inBuffer = (const unsigned char*)message;
unsigned char* outBuffer = (unsigned char*)buffer;
int remainingBytes = bytesToEncrypt;
int bytesWritten = 0;
BitQueue inQueue, outQueue;
inQueue.PushBits(bytesToEncrypt, kHeaderSize * 8);
//bool firstBlock = true;
while (inQueue.CountBits() > 0 || remainingBytes > 0) {
// get material for the next block
if (inQueue.CountBits() < inBlockSize && remainingBytes > 0) {
int bytesNeeded = (inBlockSize - inQueue.CountBits() + 7) / 8;
bytesNeeded = min(bytesNeeded, remainingBytes);
inQueue.PushBytes(inBuffer, bytesNeeded);
inBuffer += bytesNeeded;
remainingBytes -= bytesNeeded;
}
// encrypt the block
//printf(" encrypt block: %d -> %d\n", inBlockSize, outBlockSize);
bigint text;
inQueue.PopBits(text, inBlockSize);
//if (firstBlock) {
//cout << "first block: " << text << endl;
//}
//bigtime_t startTime = system_time();
text.mod_pow(key.k, key.n);
//printf("encrypting block took %Ld\n", system_time() - startTime);
outQueue.PushBits(text, outBlockSize);
//if (firstBlock) {
//cout << "encrypted block: " << text << endl;
//text.mod_pow(dbgKey->k, dbgKey->n);
//cout << "decrypted block: " << text << endl;
//print_queue(outQueue);
//firstBlock = false;
//}
// write the complete bytes of the encrypted text
int bytesToWrite = outQueue.CountBits() / 8;
outQueue.PopBytes(outBuffer, bytesToWrite);
outBuffer += bytesToWrite;
bytesWritten += bytesToWrite;
//printf(" popped %d bytes: written: %d\n", bytesToWrite, bytesWritten);
}
// if an incomplete byte remains, pad it
int bytesToWrite = (outQueue.CountBits() + 7) / 8;
if (bytesToWrite > 0) {
outQueue.PopBytes(outBuffer, bytesToWrite);
outBuffer += bytesToWrite;
bytesWritten += bytesToWrite;
}
//printf("rsa_encrypt() done\n");
return bytesWritten;
}
// rsa_decrypt
ssize_t
rsa_decrypt(const void* message, size_t bytesToDecrypt,
void* buffer, size_t bufferSize, const rsa_key& key)
{
//printf("rsa_decrypt()\n");
int outBlockSize = key.n.ld();
int inBlockSize = outBlockSize + 1;
// check the key -- we don't allow keys shorter than the header
if (outBlockSize < (int)kHeaderSize * 8)
return B_ERROR;
// check the buffer size
size_t bytesForDecryption = rsa_bytes_needed_for_decryption(bytesToDecrypt, key);
if (bufferSize < bytesForDecryption)
return B_ERROR;
const unsigned char* inBuffer = (const unsigned char*)message;
unsigned char* outBuffer = (unsigned char*)buffer;
int remainingBytes = bytesToDecrypt;
int bytesWritten = 0;
size_t decryptedSize = 0;
bool firstBlock = true;
BitQueue inQueue, outQueue;
// as long as complete blocks are left...
//int blockNum = 0;
while (inQueue.CountBits() + remainingBytes * 8 >= inBlockSize) {
// get material for the next block
if (inQueue.CountBits() < inBlockSize && remainingBytes > 0) {
int bytesNeeded = (inBlockSize - inQueue.CountBits() + 7) / 8;
bytesNeeded = min(bytesNeeded, remainingBytes);
inQueue.PushBytes(inBuffer, bytesNeeded);
inBuffer += bytesNeeded;
remainingBytes -= bytesNeeded;
}
// decrypt the block
bigint text;
//printf("\n block %d:\n", blockNum++);
//printf(" encrypt block: %d -> %d\n", inBlockSize, outBlockSize);
//if (firstBlock) {
//print_queue(inQueue);
//}
inQueue.PopBits(text, inBlockSize);
//if (firstBlock) {
//cout << "first block: " << text << endl;
//}
//bigtime_t startTime = system_time();
text.mod_pow(key.k, key.n);
//printf("decrypting block took %Ld\n", system_time() - startTime);
outQueue.PushBits(text, outBlockSize);
//printf(" outQueue: ");
//print_queue(outQueue);
// the first block contains a header
if (firstBlock) {
//cout << "decrypted block: " << text << endl;
firstBlock = false;
decryptedSize = (size_t)outQueue.PopBits(kHeaderSize * 8);
if (decryptedSize > bytesForDecryption)
return B_ERROR;
}
// write the complete bytes of the encrypted text
int bytesToWrite = outQueue.CountBits() / 8;
outQueue.PopBytes(outBuffer, bytesToWrite);
//printf(" bytes written: ");
//for (int32 i = 0; i < bytesToWrite; i++)
//printf("[%02x]", outBuffer[i]);
//printf("\n");
outBuffer += bytesToWrite;
bytesWritten += bytesToWrite;
//printf(" popped %d bytes: written: %d\n", bytesToWrite, bytesWritten);
}
// if an incomplete byte remains, pad it
int bytesToWrite = (outQueue.CountBits() + 7) / 8;
if (bytesToWrite > 0) {
outQueue.PopBytes(outBuffer, bytesToWrite);
outBuffer += bytesToWrite;
bytesWritten += bytesToWrite;
}
//printf("rsa_decrypt() done\n");
return min((ssize_t)bytesWritten, (ssize_t)decryptedSize);
}
// rsa_encrypt_archivable
char*
rsa_encrypt_archivable(const BArchivable* object, const rsa_key& key,
size_t& encryptedSize)
{
status_t error = B_OK;
if (!object)
return NULL;
// archive the object
BMessage archive;
if (error == B_OK)
error = object->Archive(&archive);
// flatten the archive
char* flattenedObject = NULL;
ssize_t flattenedSize = 0;
if (error == B_OK) {
flattenedSize = archive.FlattenedSize();
if (flattenedSize < 0)
error = flattenedSize;
if (error == B_OK) {
flattenedObject = new char[flattenedSize];
error = archive.Flatten(flattenedObject, flattenedSize);
}
}
// reorder the buffer and xor it with a special character
if (error == B_OK) {
for (int i = 0; i < flattenedSize / 2; i += 2)
swap(flattenedObject[i], flattenedObject[flattenedSize - i - 1]);
for (int i = 0; i < flattenedSize; i++)
flattenedObject[i] ^= kXORCharacter;
}
// encrypt the buffer
char* encryptedObject = NULL;
encryptedSize = 0;
if (error == B_OK) {
encryptedSize = rsa_bytes_needed_for_encryption(flattenedSize, key);
encryptedObject = new char[encryptedSize];
encryptedSize = rsa_encrypt(flattenedObject, flattenedSize,
encryptedObject, encryptedSize, key);
if (encryptedSize < 0)
error = encryptedSize;
}
delete[] flattenedObject;
return encryptedObject;
}
// rsa_decrypt_archivable
BArchivable*
rsa_decrypt_archivable(const void* buffer, size_t size, const rsa_key& key)
{
status_t error = B_OK;
if (!buffer)
return NULL;;
// decrypt the buffer
ssize_t decryptedSize = 0;
char* decryptedObject = NULL;
if (error == B_OK) {
decryptedSize = rsa_bytes_needed_for_decryption(size, key);
decryptedObject = new char[decryptedSize];
decryptedSize = rsa_decrypt(buffer, size,
decryptedObject, decryptedSize, key);
if (decryptedSize < 0)
error = decryptedSize;
}
// xor the decrypted buffer and reorder it
if (error == B_OK) {
for (int i = 0; i < decryptedSize; i++)
decryptedObject[i] ^= kXORCharacter;
for (int i = 0; i < decryptedSize / 2; i += 2)
swap(decryptedObject[i], decryptedObject[decryptedSize - i - 1]);
}
// unflatten the archive
BMessage archive;
if (error == B_OK)
error = archive.Unflatten(decryptedObject);
delete[] decryptedObject;
// unarchive the object
BArchivable* object = NULL;
if (error == B_OK)
object = instantiate_object(&archive);
return object;
}
| 26.689895 | 82 | 0.674347 | [
"object"
] |
a23c1c4035bee3e4d0ec61450cb48fc10b081836 | 7,209 | hpp | C++ | INCLUDE/CSvcMgr.hpp | SammyB428/WFC | 64aee7c7953e38c8a418ba9530339e8f4faac046 | [
"BSD-2-Clause"
] | 1 | 2021-03-29T06:09:19.000Z | 2021-03-29T06:09:19.000Z | INCLUDE/CSvcMgr.hpp | SammyB428/WFC | 64aee7c7953e38c8a418ba9530339e8f4faac046 | [
"BSD-2-Clause"
] | null | null | null | INCLUDE/CSvcMgr.hpp | SammyB428/WFC | 64aee7c7953e38c8a418ba9530339e8f4faac046 | [
"BSD-2-Clause"
] | null | null | null | /*
** Author: Samuel R. Blackburn
** Internet: wfc@pobox.com
**
** Copyright, 1995-2019, Samuel R. Blackburn
**
** "You can get credit for something or get it done, but not both."
** Dr. Richard Garwin
**
** BSD License follows.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer. Redistributions
** in binary form must reproduce the above copyright notice, this list
** of conditions and the following disclaimer in the documentation and/or
** other materials provided with the distribution. Neither the name of
** the WFC nor the names of its contributors may be used to endorse or
** promote products derived from this software without specific prior
** written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
** $Workfile: csvcmgr.hpp $
** $Revision: 19 $
** $Modtime: 6/26/01 11:04a $
*/
/* SPDX-License-Identifier: BSD-2-Clause */
#if ! defined( SERVICE_MANAGER_CLASS_HEADER )
#define SERVICE_MANAGER_CLASS_HEADER
class CServiceNameAndStatusA : public _ENUM_SERVICE_STATUSA
{
public:
CServiceNameAndStatusA() noexcept;
void Copy( _In_ _ENUM_SERVICE_STATUSA const * source ) noexcept;
void Empty( void ) noexcept;
#if defined( _DEBUG ) && ! defined( WFC_NO_DUMPING )
void Dump( CDumpContext& dump_context ) const;
#endif // _DEBUG
};
class CServiceNameAndStatusW : public _ENUM_SERVICE_STATUSW
{
public:
CServiceNameAndStatusW() noexcept;
void Copy(_In_ _ENUM_SERVICE_STATUSW const * source ) noexcept;
void Empty( void ) noexcept;
#if defined( _DEBUG ) && ! defined( WFC_NO_DUMPING )
void Dump( CDumpContext& dump_context ) const;
#endif // _DEBUG
};
#if defined( UNICODE )
#define CServiceNameAndStatus CServiceNameAndStatusW
#else
#define CServiceNameAndStatus CServiceNameAndStatusA
#endif // UNICODE
class CServiceControlManager
{
private:
void m_Initialize( void ) noexcept;
protected:
SC_HANDLE m_ManagerHandle{ nullptr };
SC_LOCK m_DatabaseLockHandle{ nullptr };
std::unique_ptr<uint8_t[]> m_Buffer;
uint32_t m_BufferSize{ 0 };
uint32_t m_CurrentEntryNumber{ 0 };
uint32_t m_ErrorCode{ 0 };
uint32_t m_NumberOfEntries{ 0 };
std::wstring m_MachineName;
std::wstring m_ErrorMessage;
public:
CServiceControlManager(_In_ CServiceControlManager const&) = delete;
CServiceControlManager& operator=(_In_ CServiceControlManager const&) = delete;
static inline constexpr uint32_t const QueryStatusPermissions(void) noexcept
{
return(READ_CONTROL bitor SC_MANAGER_CONNECT bitor SC_MANAGER_ENUMERATE_SERVICE);
}
CServiceControlManager() noexcept;
virtual ~CServiceControlManager();
void Close( void ) noexcept;
_Check_return_ bool Continue( _In_z_ wchar_t const * service_name ) noexcept;
_Check_return_ bool EnableInteractiveServices( _In_ bool enable_interactive_services = true ) noexcept;
_Check_return_ bool EnumerateStatus( _In_ uint32_t state = SERVICE_ACTIVE, _In_ uint32_t type = SERVICE_WIN32 ) noexcept;
_Check_return_ bool GetConfiguration(_In_z_ wchar_t const * service_name, _Out_ CServiceConfiguration& configuration ) noexcept;
_Check_return_ bool GetDependencies(_In_z_ wchar_t const * service_name, _Out_ std::vector<std::wstring>& dependencies ) noexcept;
_Check_return_ bool GetDisplayName(_In_z_ wchar_t const * real_name, _Out_ std::wstring& friendly_name ) noexcept;
inline constexpr _Check_return_ uint32_t GetErrorCode(void) const noexcept { return(m_ErrorCode); }
inline void GetErrorMessage(__inout std::wstring& error_message) const noexcept { error_message.assign(m_ErrorMessage); }
_Check_return_ SC_HANDLE GetHandle( void ) const noexcept;
_Check_return_ bool GetKeyName(_In_z_ wchar_t const * friendly_name, _Out_ std::wstring& real_name ) noexcept;
_Check_return_ bool GetNext( _Out_ CServiceNameAndStatus& status ) noexcept;
_Check_return_ bool Install(_In_z_ wchar_t const * service_name, _In_z_ wchar_t const * friendly_name, __in_z_opt wchar_t const * name_of_executable_file = nullptr ) noexcept;
_Check_return_ bool IsDatabaseLocked( _Out_ std::wstring& who_locked_it, _Out_ CTimeSpan& how_long_it_has_been_locked ) noexcept;
_Check_return_ bool LockDatabase( void ) noexcept;
_Check_return_ bool Open( _In_ uint32_t const what_to_open = SC_MANAGER_ALL_ACCESS,
__in_z_opt wchar_t const * database_name = nullptr,
__in_z_opt wchar_t const * machine_name = nullptr ) noexcept;
_Check_return_ bool Pause(_In_z_ wchar_t const * service_name ) noexcept;
_Check_return_ bool Remove(_In_z_ wchar_t const * service_name ) noexcept;
_Check_return_ bool WaitForStop(_In_z_ wchar_t const * service_name) noexcept;
_Check_return_ bool SetConfiguration(_In_z_ wchar_t const * service_name,
_In_ uint32_t const when_to_start = SERVICE_NO_CHANGE,
_In_ uint32_t const type_of_service = SERVICE_NO_CHANGE,
_In_ uint32_t const error_control = SERVICE_NO_CHANGE,
__in_z_opt wchar_t const * name_of_executable_file = nullptr,
__in_z_opt wchar_t const * load_order_group = nullptr,
__in_z_opt wchar_t const * dependencies = nullptr,
__in_z_opt wchar_t const * start_name = nullptr,
__in_z_opt wchar_t const * password = nullptr,
__in_z_opt wchar_t const * display_name = nullptr ) noexcept;
_Check_return_ bool Start(_In_z_ wchar_t const * service_name, _In_ uint32_t const service_argc = 0, __in_ecount_z_opt( service_argc ) wchar_t const * * service_argv = nullptr ) noexcept;
_Check_return_ bool Stop(_In_z_ wchar_t const * service_name ) noexcept;
_Check_return_ bool UnlockDatabase( void ) noexcept;
};
#endif // SERVICE_MANAGER_CLASS_HEADER
| 47.427632 | 194 | 0.70842 | [
"vector"
] |
a23e15a7fc829d444e1389f11e85ec82e9aa6b90 | 6,904 | cpp | C++ | datastructure/kmp/kmp.cpp | sirdalang/cs | f039588480af975bde484f9b44d9f6df4e890b63 | [
"MIT"
] | null | null | null | datastructure/kmp/kmp.cpp | sirdalang/cs | f039588480af975bde484f9b44d9f6df4e890b63 | [
"MIT"
] | null | null | null | datastructure/kmp/kmp.cpp | sirdalang/cs | f039588480af975bde484f9b44d9f6df4e890b63 | [
"MIT"
] | null | null | null |
/**
* @brief 串的模式匹配
*
* 暴力搜索算法的两种写法。
*
* KMP算法。
*/
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
/**
* @brief 字串模式匹配的暴力搜索法
*
* 算法描述:
* 遍历@szSrc的每个位置并依次和@szToken比较,直到
* 找到完全匹配。
*
* 算法特点:双层循环
*
* 性能分析:
* 记源串长度为n,模式串长度为m。
* 时间复杂度:O(nm)
* 空间复杂度:O(1)
*/
const char *strstr_normal_v1(const char *szSrc, const char *szToken) {
bool bFound = false;
const char *szResult = nullptr;
const char *pItSrc = szSrc;
while (*pItSrc != '\0') {
const char *pItSrcTemp = pItSrc;
const char *pItTokenTemp = szToken;
while (*pItSrcTemp != '\0' && *pItTokenTemp != '\0') {
if (*pItSrcTemp == *pItTokenTemp) {
++pItSrcTemp;
++pItTokenTemp;
}
else {
break;
}
}
if (*pItTokenTemp == '\0') {
bFound = true;
szResult = pItSrc;
break;
}
++pItSrc;
}
return bFound ? szResult : nullptr;
}
/**
* @brief 子串模式匹配的暴力搜索方法v2
*
* 算法特点:指针回退。
* 算法描述:两个指针分别指向源串和模式串,如果匹配失败,则回退
* 已匹配的长度。
*/
const char *strstr_normal_v2(const char *szSrc, const char *szToken) {
int i = 0, j = 0;
if (*szToken == '\0') {
return nullptr;
}
while (szSrc[i] != '\0' && szToken[j] != '\0') {
if (szSrc[i] == szToken[j]) {
++i;
++j;
}
else {
i = i - j + 1; /* 回退 */
j = 0;
}
}
if (szToken[j] == '\0') {
return szSrc + i - j;
}
else {
return nullptr;
}
}
/**
* KMP算法作者
* D.E.Knuth, V.R.Pratt, J.H.Morris
*
* 有修改
*
求PM表:
i 0 1 2 3 4 5 6 7 8
对于模式串 1 2 1 1 2 3 1 2 1
PM 0 0 1 1 2 0 1 2 3
next -1 0 0 1 1 2 0 1 2
流程:
PM[0] = 0
i = 1, i表示下一个处理的子串
j = 0, j表示上一个处理的子串的PM值
p[j]!=p[i],而j==0,取pm[i]=j,即pm[1]=0
i = i+1 = 2
j = 0
p[j]==p[i],取pm[i]=j+1,即pm[2]=1
i = i+1 = 3
j = j+1 = 1
p[j]!=p[i],取j=pm[j-1],即j=pm[0]=0,
p[j]==p[i],取pm[i]=j+1,即pm[3]=1
i = i+1 = 4
j = 1
p[j]==p[i],取pm[i]=j+1,即pm[4]=2
i = i+1 = 5
j = 2
p[j]!=p[i],取j=pm[j-1],即j=pm[1]=0
p[j]!=p[i],而j==0,取pm[i]=j,即pm[5]=0
...
利用next表进行模式匹配
1 2 1 3 ... 目标字符串
1 2 1 1 2 3 ... 模式字符串
i 为目标字符串指针
j 为模式字符串指针
p[3]匹配失败,查next[3]=1,即
取j=1,继续进行匹配。
如果next为-1,则整体向前一步
(-1代表第一个字符就匹配失败)
*/
const char *strstr_kmp(const char *szSrc, const char *szToken) {
int nLenToken = strlen (szToken);
std::vector<int> pm(nLenToken); /* pm表 */
/* 求模式串的部分匹配(PM)表 */
pm[0] = 0;
int i = 1; /* [0,i]表示当前计算pm值的头部子串 */
int j = 0; /* j为上一个已处理字符串的PM值 */
while (i < nLenToken) {
if (szToken[j] != szToken[i]) {
if (j == 0) {
pm[i]=j;
++i;
}
else {
j = pm[j-1];
}
}
else {
pm[i] = j+1;
++i;
++j; /* j=pm[i] */
}
}
std::cout << "pm:" << std::endl;
for (auto i : pm) {
std::cout << i << " ";
}
std::cout << std::endl;
/* PM表转next表 */
std::vector<int> next(nLenToken); /* next表 */
next[0] = -1;
for (std::size_t k = 1; k < next.size(); ++k) {
next[k] = pm[k-1];
}
std::cout << "next:" << std::endl;
for (auto i : next) {
std::cout << i << " ";
}
std::cout << std::endl;
/* 利用next表进行模式匹配 */
i = 0; /* i表示szSrc指针 */
j = 0; /* j表示szToken指针 */
while (szSrc[i] != '\0' && szToken[j] != '\0') {
if (szSrc[i] == szToken[j]) {
++i;
++j;
}
else {
j = next[j];
if (j < 0) {
++i;
j = 0; /* ++j */
}
}
}
if (j == nLenToken) {
return szSrc + i - j;
}
else {
return nullptr;
}
}
/**
* 在v1基础上,避免了p[j]=p[next[j]]引起重复比较的情况
* 也即 p[j+1]=p[pm[j]] 的情况
*
对于模式串 1 1 1 1 2
PM 0 0 0 0 0
流程:
PM[0]=0
i = 1
j = 0
p[j]==p[i],尝试取pm[i]=j+1,此时p[i+1]==p[pm[i]]==p[j+1],
故尝试取pm[i]=pm[j-1],而j==0,故取pm[i]=j,即pm[i]=0
i = i+1 = 2
j = 0
p[j]==p[i],尝试取pm[i]=j+1,此时p[i+1]==p[pm[i]]==p[j+1],
故尝试取pm[i]=pm[j-1],而j==0,故取pm[i]=j,即pm[i]=0
...
*/
const char *strstr_kmp_v2(const char *szSrc, const char *szToken) {
int nLenToken = strlen (szToken);
std::vector<int> pm(nLenToken); /* pm表 */
/* 求模式串的部分匹配(PM)表 */
pm[0] = 0;
int i = 1; /* [0,i]表示当前计算pm值的头部子串 */
int j = 0; /* j为上一个已处理字符串的PM值 */
while (i < nLenToken) {
if (szToken[j] != szToken[i]) {
if (j == 0) {
pm[i]=j;
++i;
}
else {
j = pm[j-1];
}
}
else {
if (szToken[i+1] == szToken[j+1]) {
if (j == 0) {
pm[i] = 0;
}
else {
pm[i] = pm[j-1];
}
}
else {
pm[i] = j+1;
}
++i;
++j; /* j=pm[i] */
}
}
std::cout << "pm:" << std::endl;
for (auto i : pm) {
std::cout << i << " ";
}
std::cout << std::endl;
/* PM表转next表 */
std::vector<int> next(nLenToken); /* next表 */
next[0] = -1;
for (std::size_t k = 1; k < next.size(); ++k) {
next[k] = pm[k-1];
}
std::cout << "next:" << std::endl;
for (auto i : next) {
std::cout << i << " ";
}
std::cout << std::endl;
/* 利用next表进行模式匹配 */
i = 0; /* i表示szSrc指针 */
j = 0; /* j表示szToken指针 */
while (szSrc[i] != '\0' && szToken[j] != '\0') {
if (szSrc[i] == szToken[j]) {
++i;
++j;
}
else {
j = next[j];
if (j < 0) {
++i;
j = 0; /* ++j */
}
}
}
if (j == nLenToken) {
return szSrc + i - j;
}
else {
return nullptr;
}
}
int main() {
while (true) {
std::cout << "************" << std::endl;
std::string strSrc, strToken;
std::cout << "src: " << std::endl;
std::cin >> strSrc;
std::cout << "token: " << std::endl;
std::cin >> strToken;
std::cout << "src=" << strSrc << std::endl;
std::cout << "token=" << strToken << std::endl;
const char *szResult = nullptr;
// szResult = strstr_normal_v1(strSrc.c_str(), strToken.c_str());
// szResult = strstr_normal_v2(strSrc.c_str(), strToken.c_str());
// szResult = strstr_kmp(strSrc.c_str(), strToken.c_str());
szResult = strstr_kmp_v2(strSrc.c_str(), strToken.c_str());
if (szResult != nullptr) {
std::cout << "i=" << szResult - strSrc.c_str() << std::endl;
}
else {
std::cout << "not found!" << std::endl;
}
std::cout << "************\n" << std::endl;
}
} | 20.795181 | 73 | 0.415846 | [
"vector"
] |
a243ad9081c1f9e119e259051f8b0589893730ed | 1,945 | cpp | C++ | Client/src/evironment-variable-panel.cpp | q1e123/Network-resource-monitor | 3cabbeeeee628597c4c7a2362eaa3d45995f5355 | [
"MIT"
] | null | null | null | Client/src/evironment-variable-panel.cpp | q1e123/Network-resource-monitor | 3cabbeeeee628597c4c7a2362eaa3d45995f5355 | [
"MIT"
] | null | null | null | Client/src/evironment-variable-panel.cpp | q1e123/Network-resource-monitor | 3cabbeeeee628597c4c7a2362eaa3d45995f5355 | [
"MIT"
] | null | null | null | #include "environment-variable-panel.h"
#include <vector>
#include <algorithm>
#include <string>
#include "colors.h"
#include "fonts.h"
#include "gui-element-id.h"
#include "my-process.h"
#include "utils.h"
Environment_Variable_Panel::Environment_Variable_Panel(){}
Environment_Variable_Panel::Environment_Variable_Panel(wxNotebookPage *system_page, System *system){
this->system = system;
panel = new wxScrolledWindow(system_page, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL, "Process List");
box_sizer = new wxBoxSizer(wxHORIZONTAL);
value_box_sizer = new wxBoxSizer(wxVERTICAL);
environment_variable_box_sizer = new wxBoxSizer(wxVERTICAL);
environment_variable_text = new wxStaticText(panel, wxID_ANY, "---");
environment_variable_text->SetFont(Fonts::normal);
environment_variable_text->SetForegroundColour(Colors::white);
value_text = new wxStaticText(panel, wxID_ANY, "---");
value_text->SetFont(Fonts::normal);
value_text->SetForegroundColour(Colors::white);
environment_variable_box_sizer->Add(environment_variable_text, 1, wxALL, 5);
value_box_sizer->Add(value_text, 1, wxALL, 5);
box_sizer->Add(environment_variable_box_sizer, 1, wxALL, 5);
box_sizer->Add(value_box_sizer, 1, wxALL, 5);
panel->SetSizer(box_sizer);
panel->FitInside();
panel->SetScrollRate(5,5);
}
Environment_Variable_Panel::~Environment_Variable_Panel(){}
wxScrolledWindow* Environment_Variable_Panel::get_all(){
return panel;
}
void Environment_Variable_Panel::update(){
std::vector<System_User> user_list = system->get_user_list();
std::map<std::string, std::string> environment_variables = system->get_environment_variables();
std::string key, value;
key = value = "";
for (auto item : environment_variables) {
key += item.first + "\n";
value += item.second + "\n";
}
environment_variable_text->SetLabel(key);
value_text->SetLabel(value);
panel->FitInside();
} | 32.416667 | 117 | 0.747044 | [
"vector"
] |
a2513255ff33023e484ea759e7ab4b738467457f | 1,960 | hpp | C++ | include/Module/Unaryop/Unaryop.hpp | FredrikBlomgren/aff3ct | fa616bd923b2dcf03a4cf119cceca51cf810d483 | [
"MIT"
] | 315 | 2016-06-21T13:32:14.000Z | 2022-03-28T09:33:59.000Z | include/Module/Unaryop/Unaryop.hpp | a-panella/aff3ct | 61509eb756ae3725b8a67c2d26a5af5ba95186fb | [
"MIT"
] | 153 | 2017-01-17T03:51:06.000Z | 2022-03-24T15:39:26.000Z | include/Module/Unaryop/Unaryop.hpp | a-panella/aff3ct | 61509eb756ae3725b8a67c2d26a5af5ba95186fb | [
"MIT"
] | 119 | 2017-01-04T14:31:58.000Z | 2022-03-21T08:34:16.000Z | /*!
* \file
* \brief Class module::Unaryop.
*/
#ifndef UNARYOP_HPP_
#define UNARYOP_HPP_
#include <cstdint>
#include <memory>
#include <vector>
#include "Tools/Math/unaryop.h"
#include "Module/Task.hpp"
#include "Module/Socket.hpp"
#include "Module/Module.hpp"
namespace aff3ct
{
namespace module
{
namespace uop
{
enum class tsk : size_t { perform, SIZE };
namespace sck
{
enum class perform : size_t { in, out, status };
}
}
template <typename TI, typename TO, tools::proto_uop<TI,TO> UOP>
class Unaryop : public Module
{
public:
inline Task& operator[](const uop::tsk t);
inline Socket& operator[](const uop::sck::perform s);
protected:
const size_t n_elmts;
public:
Unaryop(const size_t n_elmts);
virtual ~Unaryop() = default;
virtual Unaryop<TI,TO,UOP>* clone() const;
size_t get_n_elmts() const;
template <class AI = std::allocator<TI>, class AO = std::allocator<TO>>
void perform(const std::vector<TI,AI>& in,
std::vector<TO,AO>& out,
const int frame_id = -1,
const bool managed_memory = true);
void perform(const TI *in, TO *out, const int frame_id = -1, const bool managed_memory = true);
protected:
virtual void _perform(const TI *in, TO *out, const size_t frame_id);
};
template <typename TI, typename TO = TI, tools::proto_uop<TI,TO> UOP = tools::uop_abs <TI,TO>> using Unaryop_abs = Unaryop<TI,TO,UOP>;
template <typename TI, typename TO = TI, tools::proto_uop<TI,TO> UOP = tools::uop_not <TI,TO>> using Unaryop_not = Unaryop<TI,TO,UOP>;
template <typename TI, typename TO = TI, tools::proto_uop<TI,TO> UOP = tools::uop_not_abs<TI,TO>> using Unaryop_not_abs = Unaryop<TI,TO,UOP>;
template <typename TI, typename TO = TI, tools::proto_uop<TI,TO> UOP = tools::uop_sign <TI,TO>> using Unaryop_sign = Unaryop<TI,TO,UOP>;
}
}
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#include "Module/Unaryop/Unaryop.hxx"
#endif
#endif /* UNARYOP_HPP_ */
| 26.486486 | 141 | 0.682653 | [
"vector"
] |
a252b687a10a10ec0577790b04f2f90f12608fd7 | 469 | cpp | C++ | easy/169_majority_element.cpp | pdu/leetcode_cpp | c487df7561f92562b20a31317957f47e0a20c485 | [
"Apache-2.0"
] | 4 | 2019-07-22T03:53:23.000Z | 2019-10-17T01:37:41.000Z | easy/169_majority_element.cpp | pdu/leetcode_cpp | c487df7561f92562b20a31317957f47e0a20c485 | [
"Apache-2.0"
] | null | null | null | easy/169_majority_element.cpp | pdu/leetcode_cpp | c487df7561f92562b20a31317957f47e0a20c485 | [
"Apache-2.0"
] | 2 | 2020-03-10T03:30:41.000Z | 2020-11-10T06:51:34.000Z | // moore voting algorithm
#include <vector>
using namespace std;
class Solution {
public:
int majorityElement(vector<int>& nums) {
int ret = nums[0];
int count = 1;
for (int i = 1; i < nums.size(); ++i) {
if (count == 0) {
ret = nums[i];
count = 1;
} else if (ret == nums[i])
count++;
else
count--;
}
return ret;
}
};
| 19.541667 | 47 | 0.420043 | [
"vector"
] |
a25380baf394d20559683d3311e191f6a65ae180 | 11,765 | cpp | C++ | ml/src/LinearRegression.cpp | georgephilipp/cppgstd_legacy | e130860da7700aae42b915bc36a7efa4cae06d56 | [
"MIT"
] | null | null | null | ml/src/LinearRegression.cpp | georgephilipp/cppgstd_legacy | e130860da7700aae42b915bc36a7efa4cae06d56 | [
"MIT"
] | null | null | null | ml/src/LinearRegression.cpp | georgephilipp/cppgstd_legacy | e130860da7700aae42b915bc36a7efa4cae06d56 | [
"MIT"
] | null | null | null | #include "stdafx.h"
#include "LinearRegression.h"
#include "gstd_matlab/src/MatlabMgr.h"
#include "gstd/src/Linalg.h"
#include "gstd/src/Stat.h"
#include "gstd/src/Timer.h"
#include "DpDoublesGenerators.h"
#include "RegressionGenerators.h"
#include "Data/src/Converters.h"
#include "Converters.h"
using namespace msii810161816::gstd::Linalg;
namespace msii810161816
{
namespace ml
{
LinearRegression::LinearRegression()
{
if (!mgr.instIsOpen())
mgr.instOpen();
pushedCols = 0;
pushedRows = 0;
}
LinearRegression::~LinearRegression() {}
void LinearRegression::initparameter() {} //not used
void LinearRegression::fit()
{
std::vector<double> inMatrix;
std::vector<double> outMatrix;
int d = 0;
for (int i = 0; i != maxDataPoint; i++)
{
gstd::trial<DpRegression> point = client.get(false)->get(i);
gstd::check(point.success, "cannot find data points");
if (i == 0)
d = point.result.input.size();
inMatrix.insert(inMatrix.end(), point.result.input.begin(), point.result.input.end());
outMatrix.push_back(point.result.output);
}
gstd::check(maxDataPoint >= d, "cannot run unregularized linear model on undercomplete data!");
if (d == 0)
{
gstd::vector::empty(parameter);
}
else
{
mgr.create(maxDataPoint, d, inMatrix, "X");
mgr.create(maxDataPoint, 1, outMatrix, "Y");
mgr.exec("res = X\\Y;");
std::tuple<int, int, std::vector<double> > res = mgr.get("res");
gstd::check(std::get<0>(res) == d, "incorrect output dimension");
gstd::check(std::get<1>(res) == 1, "incorrect output dimension");
parameter = std::get<2>(res);
}
if (safe)
{
std::vector<double> pred = mmult(maxDataPoint, d, 1, inMatrix, parameter);
std::vector<double> errorVector = msub(outMatrix, pred);
std::vector<double> residual = mmult(1, maxDataPoint, d, errorVector, inMatrix);
gstd::check(mequals(residual, std::vector<double>(d, 0), 1e-8, false), "gradient check failed");
}
if (doc)
{
gstd::Printer::c("Target model is (snippet): ");
gstd::Printer::vc(gstd::vector::sub(target, 0, 100, true));
gstd::Printer::c("parameter is (snippet): ");
gstd::Printer::vc(gstd::vector::sub(parameter, 0, 100, true));
}
}
void LinearRegression::fitWithOptions()
{
std::vector<double> inMatrix;
std::vector<double> outMatrix;
int d = 0;
for (int i = 0; i != maxDataPoint; i++)
{
gstd::trial<DpRegression> point = client.get(false)->get(i);
gstd::check(point.success, "cannot find data points");
if (i == 0)
d = point.result.input.size();
inMatrix.insert(inMatrix.end(), point.result.input.begin(), point.result.input.end());
outMatrix.push_back(point.result.output);
}
gstd::check(maxDataPoint >= d, "cannot run unregularized linear model on undercomplete data!");
if (d == 0)
{
gstd::vector::empty(parameter);
gstd::vector::empty(pvalues);
}
else
{
mgr.create(maxDataPoint, d, inMatrix, "X");
mgr.create(maxDataPoint, 1, outMatrix, "Y");
mgr.exec("res = LinearModel.fit(X, Y, 'intercept', false);");
mgr.exec("res = table2array(res.Coefficients);");
int ressize1, ressize2;
std::vector<double> res;
std::tie(ressize1, ressize2, res) = mgr.get("res");
gstd::check(ressize1 == d, "incorrect output dimension");
gstd::check(ressize2 == 4, "incorrect output dimension");
parameter = gstd::Linalg::submatrix(d, 4, res, 0, 0, -1, 1);
pvalues = gstd::Linalg::submatrix(d, 4, res, 0, 3, -1, 1);
}
if (safe)
{
std::vector<double> pred = mmult(maxDataPoint, d, 1, inMatrix, parameter);
std::vector<double> errorVector = msub(outMatrix, pred);
std::vector<double> residual = mmult(1, maxDataPoint, d, errorVector, inMatrix);
gstd::check(mequals(residual, std::vector<double>(d, 0), 1e-8, false), "gradient check failed");
}
if (doc)
{
gstd::Printer::c("Target model is (snippet): ");
gstd::Printer::vc(gstd::vector::sub(target, 0, 100, true));
gstd::Printer::c("parameter is (snippet): ");
gstd::Printer::vc(gstd::vector::sub(parameter, 0, 100, true));
}
}
void LinearRegression::push()
{
std::vector<double> inMatrix;
std::vector<double> outMatrix;
int d = 0;
for (int i = 0; i != maxDataPoint; i++)
{
gstd::trial<DpRegression> point = client.get(false)->get(i);
gstd::check(point.success, "cannot find data points");
if (i == 0)
d = point.result.input.size();
inMatrix.insert(inMatrix.end(), point.result.input.begin(), point.result.input.end());
outMatrix.push_back(point.result.output);
}
if (d > 0)
{
mgr.create(maxDataPoint, d, inMatrix, "X");
mgr.create(maxDataPoint, 1, outMatrix, "Y");
}
pushedRows = maxDataPoint;
pushedCols = d;
}
void LinearRegression::fitSubset(std::vector<int> rowSubSet, std::vector<int> colSubSet)
{
int numRows = rowSubSet.size();
int numCols = colSubSet.size();
if (numCols == 0)
{
gstd::vector::empty(parameter);
return;
}
gstd::check(numRows >= numCols, "cannot fit undercomplete l2 model");
for (int i = 0; i < numRows; i++)
gstd::check(rowSubSet[i] < pushedRows, "cannot run on rows that were not pushed");
for (int i = 0; i < numCols; i++)
gstd::check(colSubSet[i] < pushedCols, "cannot run on cols that were not pushed");
mgr.create(1, numRows, gstd::vector::itod(rowSubSet), "rowInds");
mgr.create(1, numCols, gstd::vector::itod(colSubSet), "colInds");
mgr.exec("rowInds = rowInds + 1;colInds = colInds + 1;subX = X(rowInds,colInds);subY = Y(rowInds);res = subX\\subY;");
std::tuple<int, int, std::vector<double> > res = mgr.get("res");
gstd::check(std::get<0>(res) == numCols, "incorrect output dimension");
gstd::check(std::get<1>(res) == 1, "incorrect output dimension");
parameter = std::get<2>(res);
if (safe)
{
std::vector<double> fullInMatrix, fullOutMatrix, inMatrix, outMatrix;
int inRows, inCols, outRows, outCols;
std::tie(inRows, inCols, fullInMatrix) = mgr.get("X");
std::tie(outRows, outCols, fullOutMatrix) = mgr.get("Y");
gstd::check(inRows == pushedRows, "safety check for fitsubset failed");
gstd::check(outRows == pushedRows, "safety check for fitsubset failed");
gstd::check(inCols == pushedCols, "safety check for fitsubset failed");
gstd::check(outCols == 1, "safety check for fitsubset failed");
for (int i = 0; i < numRows; i++)
{
for (int j = 0; j < numCols; j++)
{
inMatrix.push_back(fullInMatrix[rowSubSet[i] * pushedCols + colSubSet[j]]);
}
outMatrix.push_back(fullOutMatrix[rowSubSet[i]]);
}
std::vector<double> pred = mmult(numRows, numCols, 1, inMatrix, parameter);
std::vector<double> errorVector = msub(outMatrix, pred);
std::vector<double> residual = mmult(1, numRows, numCols, errorVector, inMatrix);
gstd::check(mequals(residual, std::vector<double>(numCols, 0), 1e-8, false), "gradient check failed");
}
if (doc)
{
gstd::Printer::c("Target model is (snippet): ");
gstd::Printer::vc(gstd::vector::sub(target, 0, 100, true));
gstd::Printer::c("parameter is (snippet): ");
gstd::Printer::vc(gstd::vector::sub(parameter, 0, 100, true));
}
}
double LinearRegression::apply(data::DpDoubles input)
{
gstd::check(parameter.size() == input.content.size(), "input of incorrect size");
double res = 0;
int size = parameter.size();
for (int i = 0; i < size; i++)
res += input.content[i] * parameter[i];
return res;
}
std::pair<double, double> LinearRegression::test(DpRegression input)
{
data::DpDoubles point;
point.content = input.input;
double res = apply(point);
double diff = res - input.output;
double error = 0.5*diff*diff;
return std::pair<double, double>(res, error);
}
//Base package
void LinearRegression::setInputs()
{
//make choices
int d = 20;
int N = 10000;
double noisestd = 1;
target.resize(d);
//generate data
GaussianGenerator<data::DataHeader>* gen = new GaussianGenerator<data::DataHeader>;
gen->setInputsBlockwise(4, 5, 1, 0.5, 0);
//create model
LinearLassoGenerator<data::DataHeader>* las = new LinearLassoGenerator<data::DataHeader>;
for (int i = 0; i < d; i++)
{
double draw = gstd::stat::randnorm(4);
target[i] = draw;
las->targetModel[i] = draw;
}
las->noiseStd = noisestd;
las->storedata = true;
las->inServer.set(gen, true);
//finish
client.set(las, true);
maxDataPoint = N;
}
bool LinearRegression::test()
{
LinearRegression obj;
obj.setInputs();
obj.safe = true;
try
{
obj.fit();
}
catch (std::exception e)
{
obj.reportFailure("safety checks for 'fit'");
return false;
}
if (!mequals(obj.parameter, obj.target, 0.1, false))
{
obj.reportFailure("'fit'");
return false;
}
try
{
obj.fitWithOptions();
}
catch (std::exception e)
{
obj.reportFailure("safety checks for 'fit'");
return false;
}
if (!mequals(obj.parameter, obj.target, 0.1, false) || obj.pvalues.size() != obj.parameter.size())
{
obj.reportFailure("'fitWithOptions'");
return false;
}
int d = obj.parameter.size();
for (int i = 0; i < d; i++)
{
if (obj.pvalues[i] < 0 || obj.pvalues[i] >= 1)
{
obj.reportFailure("'fitWithOptions'");
return false;
}
}
std::vector<int> rows = { 103, 42, 52, 36, 45 };
std::vector<int> cols = { 3, 7 };
try
{
gstd::Printer::c("expecting error message ...");
obj.fitSubset(rows, cols);
obj.reportFailure("prelim to 'fitSubset'");
return false;
}
catch (std::exception e){}
obj.push();
try
{
gstd::Printer::c("expecting error message ...");
obj.fitSubset(rows, { 40 });
obj.reportFailure("prelim to 'fitSubset'");
return false;
}
catch (std::exception e){}
try
{
obj.fitSubset(rows, cols);
}
catch (std::exception e)
{
obj.reportFailure("safety checks in 'fitSubset'");
return false;
}
std::vector<double> res = obj.parameter;
data::IndexMapper<DpRegression, data::DataHeader> mapper;
mapper.indexmap = rows;
DpRegressionComponentMapper<data::DataHeader> cMapper;
cMapper.componentMap = cols;
gstd::Pointer<data::Server<DpRegression, data::DataHeader> > point;
point.set(obj.client.get(true), true);
obj.client.set(&cMapper, false);
mapper.inServer.set(point.get(false),false);
cMapper.inServer.set(&mapper,false);
obj.maxDataPoint = rows.size();
obj.fit();
std::vector<double> target = obj.parameter;
if (!gstd::Linalg::mequals(res, target, 1e-6, false))
{
obj.reportFailure("'fitSubset'");
return false;
}
obj.parameter = { 1, 2, 3, 4 };
data::DpDoubles p1;
p1.content = { 2, 3, 4, 5 };
DpRegression p2;
p2.input = p1.content;
p2.output = 43;
double applyres = obj.apply(p1);
std::pair<double, double> testres = obj.test(p2);
if (!gstd::Double::equals(applyres, 40) || !gstd::Double::equals(testres.first, 40) || !gstd::Double::equals(testres.second, 4.5))
{
obj.reportFailure("'apply/test'");
return false;
}
return true;
}
gstd::TypeName LinearRegression::getTypeName()
{
return gstd::TypeNameGetter<LinearRegression>::get();
}
std::string LinearRegression::toString()
{
std::stringstream res;
res << "This is a ml::LinearRegression" << std::endl;
res << ModelTyped<DpRegression, data::DataHeader>::toString();
return res.str();
}
}
}
| 30.322165 | 142 | 0.622524 | [
"vector",
"model"
] |
a2578fa12d56587ced0973ca38c583281a3efb38 | 4,110 | cpp | C++ | s32v234_sdk/libs/io/gdi/vlab_vpd/src/vpd_func.cpp | intesight/Panorama4AIWAYS | 46e1988e54a5155be3b3b47c486b3f722be00b5c | [
"WTFPL"
] | null | null | null | s32v234_sdk/libs/io/gdi/vlab_vpd/src/vpd_func.cpp | intesight/Panorama4AIWAYS | 46e1988e54a5155be3b3b47c486b3f722be00b5c | [
"WTFPL"
] | null | null | null | s32v234_sdk/libs/io/gdi/vlab_vpd/src/vpd_func.cpp | intesight/Panorama4AIWAYS | 46e1988e54a5155be3b3b47c486b3f722be00b5c | [
"WTFPL"
] | 2 | 2021-01-21T02:06:16.000Z | 2021-01-28T10:47:37.000Z | /*****************************************************************************
*
* Freescale Confidential Proprietary
*
* Copyright (c) 2014 Freescale Semiconductor;
* All Rights Reserved
*
*****************************************************************************
*
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED 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 FREESCALE OR ITS 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 gdi_srv.cpp
* \brief VLAB Virtual probe display enablement functions
* \author Tomas Babinec
* \version 0.1
* \date 02-July-2014
****************************************************************************/
#include <INTEGRITY.h>
#include "oal.h"
#include "vpd_driver.h" // has to be before vpd.h (because of vpd_regs_t)
#include "vpd.h"
static MemoryRegion gsPhysicalVpdRegsRegion = NULLMemoryRegion;
static MemoryRegion gsPhysicalVpdDataRegion = NULLMemoryRegion;
// maps VPD registers
vpd_regs_t * VPD_RegsMap(void)
{
Error lError, lErrorMap;
MemoryRegion virtMemReg;
Address virtAddr = 0;
Value virtLength = 0;
Address physFirst = 0;
Address physLast = 0;
vpd_regs_t *pRet = NULL;
lError = RequestResource((Object *)&gsPhysicalVpdRegsRegion, VPD_REGS_RESOURCE_NAME, "!systempassword");
if (Success == lError)
{
// Get physical addresses of the physical memory region
GetMemoryRegionAddresses(gsPhysicalVpdRegsRegion, &physFirst, &physLast);
// map directly to the physical memory region
lErrorMap = MapMemoryWithAttributes(__ghs_VirtualMemoryRegionPool, gsPhysicalVpdRegsRegion, &virtMemReg, &virtAddr, &virtLength, 0, MEMORY_READ|MEMORY_WRITE|MEMORY_VOLATILE );
if (Success == lErrorMap)
{
printf("VPD register mapping succeeded. Region size %x.\n", virtLength);
pRet = (vpd_regs_t*)virtAddr;
} // if MapMemory succeeded
else
{
printf("VPD register mapping failed (%d)\n", lErrorMap);
} // else from if AllocateAnyMemoryRegion succeeded
} // if Resource request succeeded
else
{
printf("VPD registers resource request failed (%d)\n", lError);
} // else from if Resource request succeeded
return pRet;
} // VPD_RegsMap()
// maps VPD registers
uint8_t * VPD_DataMap(void)
{
Error lError, lErrorMap;
MemoryRegion virtMemReg;
Address virtAddr = 0;
Value virtLength = 0;
Address physFirst = 0;
Address physLast = 0;
uint8_t *pRet = NULL;
lError = RequestResource((Object *)&gsPhysicalVpdDataRegion, VPD_DATA_RESOURCE_NAME, "!systempassword");
if (Success == lError)
{
// Get physical addresses of the physical memory region
GetMemoryRegionAddresses(gsPhysicalVpdDataRegion, &physFirst, &physLast);
// map directly to the physical memory region
lErrorMap = MapMemoryWithAttributes(__ghs_VirtualMemoryRegionPool, gsPhysicalVpdDataRegion, &virtMemReg, &virtAddr, &virtLength, 0, MEMORY_READ|MEMORY_WRITE|MEMORY_VOLATILE );
if (Success == lErrorMap)
{
printf("VPD data mapping succeeded. Region size %x.\n", virtLength);
pRet = (uint8_t*)virtAddr;
} // if MapMemory succeeded
else
{
printf("VPD data mapping failed (%d)\n", lErrorMap);
} // else from if AllocateAnyMemoryRegion succeeded
} // if Resource request succeeded
else
{
printf("VPD data resource request failed (%d)\n", lError);
} // else from if Resource request succeeded
return pRet;
} // VPD_RegsMap()
| 35.431034 | 181 | 0.669343 | [
"object"
] |
a25fb4654cbbbbaf913505ba56609c7a58b9dac4 | 7,188 | cpp | C++ | escriptcore/src/AbstractContinuousDomain.cpp | markendr/esys-escript.github.io | 0023eab09cd71f830ab098cb3a468e6139191e8d | [
"Apache-2.0"
] | null | null | null | escriptcore/src/AbstractContinuousDomain.cpp | markendr/esys-escript.github.io | 0023eab09cd71f830ab098cb3a468e6139191e8d | [
"Apache-2.0"
] | null | null | null | escriptcore/src/AbstractContinuousDomain.cpp | markendr/esys-escript.github.io | 0023eab09cd71f830ab098cb3a468e6139191e8d | [
"Apache-2.0"
] | null | null | null |
/*****************************************************************************
*
* Copyright (c) 2003-2020 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
* Development from 2019 by School of Earth and Environmental Sciences
**
*****************************************************************************/
#include "AbstractContinuousDomain.h"
#include "Data.h"
using namespace boost::python;
namespace escript {
AbstractContinuousDomain::AbstractContinuousDomain()
{
}
AbstractContinuousDomain::~AbstractContinuousDomain()
{
}
bool AbstractContinuousDomain::isValidFunctionSpaceType(int functionSpaceType) const
{
throwStandardException("AbstractContinuousDomain::isValidFunctionSpaceType");
return false;
}
std::string AbstractContinuousDomain::getDescription() const
{
throwStandardException("AbstractContinuousDomain::getDescription");
return "";
}
int AbstractContinuousDomain::getContinuousFunctionCode() const
{
throwStandardException("AbstractContinuousDomain::getContinuousFunctionCode");
return 0;
}
int AbstractContinuousDomain::getReducedContinuousFunctionCode() const
{
throwStandardException("AbstractContinuousDomain::getReducedContinuousFunctionCode");
return 0;
}
int AbstractContinuousDomain::getFunctionCode() const
{
throwStandardException("AbstractContinuousDomain::getFunctionCode");
return 0;
}
int AbstractContinuousDomain::getReducedFunctionCode() const
{
throwStandardException("AbstractContinuousDomain::getReducedFunctionCode");
return 0;
}
int AbstractContinuousDomain::getFunctionOnBoundaryCode() const
{
throwStandardException("AbstractContinuousDomain::getFunctionOnBoundaryCode");
return 0;
}
int AbstractContinuousDomain::getReducedFunctionOnBoundaryCode() const
{
throwStandardException("AbstractContinuousDomain::getReducedFunctionOnBoundaryCode");
return 0;
}
int AbstractContinuousDomain::getFunctionOnContactZeroCode() const
{
throwStandardException("AbstractContinuousDomain::getFunctionOnContactZeroCode");
return 0;
}
int AbstractContinuousDomain::getReducedFunctionOnContactZeroCode() const
{
throwStandardException("AbstractContinuousDomain::getReducedFunctionOnContactZeroCode");
return 0;
}
int AbstractContinuousDomain::getFunctionOnContactOneCode() const
{
throwStandardException("AbstractContinuousDomain::getFunctionOnContactOneCode");
return 0;
}
int AbstractContinuousDomain::getReducedFunctionOnContactOneCode() const
{
throwStandardException("AbstractContinuousDomain::getReducedFunctionOnContactOneCode");
return 0;
}
int AbstractContinuousDomain::getSolutionCode() const
{
throwStandardException("AbstractContinuousDomain::getSolutionCode");
return 0;
}
int AbstractContinuousDomain::getReducedSolutionCode() const
{
throwStandardException("AbstractContinuousDomain::getReducedSolutionCode");
return 0;
}
int AbstractContinuousDomain::getDiracDeltaFunctionsCode() const
{
throwStandardException("AbstractContinuousDomain::getDiracDeltaFunctionsCode");
return 0;
}
void AbstractContinuousDomain::setToIntegrals(std::vector<DataTypes::real_t>& integrals,
const escript::Data& arg) const
{
throwStandardException("AbstractContinuousDomain::setToIntegrals<real_t>");
return;
}
void AbstractContinuousDomain::setToIntegrals(std::vector<DataTypes::cplx_t>& integrals,
const escript::Data& arg) const
{
throwStandardException("AbstractContinuousDomain::setToIntegrals<cplx_t>");
return;
}
int AbstractContinuousDomain::getSystemMatrixTypeId(const boost::python::object& options) const
{
return 0;
}
int AbstractContinuousDomain::getTransportTypeId(int solver, int precondioner, int package, bool symmetry) const
{
return 0;
}
void AbstractContinuousDomain::addPDEToSystem(
AbstractSystemMatrix& mat, escript::Data& rhs,
const escript::Data& A, const escript::Data& B, const escript::Data& C,
const escript::Data& D, const escript::Data& X, const escript::Data& Y,
const escript::Data& d, const escript::Data& y,
const escript::Data& d_contact, const escript::Data& y_contact, const escript::Data& d_dirac, const escript::Data& y_dirac) const
{
throwStandardException("AbstractContinuousDomain::addPDEToSystem");
return;
}
void AbstractContinuousDomain::addPDEToRHS(escript::Data& rhs,
const escript::Data& X, const escript::Data& Y,
const escript::Data& y, const escript::Data& y_contact, const escript::Data& y_dirac) const
{
throwStandardException("AbstractContinuousDomain::addPDEToRHS");
return;
}
void AbstractContinuousDomain::addPDEToTransportProblem(
AbstractTransportProblem& tp, escript::Data& source,
const escript::Data& M,
const escript::Data& A, const escript::Data& B, const escript::Data& C,const escript::Data& D,
const escript::Data& X,const escript::Data& Y,
const escript::Data& d, const escript::Data& y,
const escript::Data& d_contact,const escript::Data& y_contact, const escript::Data& d_dirac,const escript::Data& y_dirac) const
{
throwStandardException("AbstractContinuousDomain::addPDEToTransportProblem");
return;
}
ASM_ptr AbstractContinuousDomain::newSystemMatrix(
const int row_blocksize,
const escript::FunctionSpace& row_functionspace,
const int column_blocksize,
const escript::FunctionSpace& column_functionspace,
const int type) const
{
throwStandardException("AbstractContinuousDomain::newSystemMatrix");
return ASM_ptr();
}
ATP_ptr AbstractContinuousDomain::newTransportProblem(
const int blocksize,
const escript::FunctionSpace& functionspace,
const int type) const
{
throwStandardException("AbstractContinuousDomain::newTransportProblem");
return ATP_ptr();
}
DataTypes::dim_t AbstractContinuousDomain::getNumDataPointsGlobal() const
{
throwStandardException("AbstractContinuousDomain::getNumDataPointsGlobal");
return 1;
}
std::pair<int,DataTypes::dim_t> AbstractContinuousDomain::getDataShape(int functionSpaceCode) const
{
throwStandardException("AbstractContinuousDomain::getDataShape");
return std::pair<int,DataTypes::dim_t>(0,0);
}
void AbstractContinuousDomain::setNewX(const escript::Data& arg)
{
throwStandardException("AbstractContinuousDomain::setNewX");
return;
}
void AbstractContinuousDomain::Print_Mesh_Info(const bool full) const
{
throwStandardException("AbstractContinuousDomain::Print_Mesh_Info");
return;
}
} // end of namespace
| 31.946667 | 150 | 0.727184 | [
"object",
"vector"
] |
a2647960054988b9fb0ca1f458c08442b4e2df49 | 1,664 | hpp | C++ | src/gui/sound-effects-set.hpp | tilnewman/heroespath-src | a7784e44d8b5724f305ef8b8671fed54e2e5fd69 | [
"BSL-1.0",
"Beerware"
] | 2 | 2019-02-28T00:28:08.000Z | 2019-10-20T14:39:48.000Z | src/gui/sound-effects-set.hpp | tilnewman/heroespath-src | a7784e44d8b5724f305ef8b8671fed54e2e5fd69 | [
"BSL-1.0",
"Beerware"
] | null | null | null | src/gui/sound-effects-set.hpp | tilnewman/heroespath-src | a7784e44d8b5724f305ef8b8671fed54e2e5fd69 | [
"BSL-1.0",
"Beerware"
] | null | null | null | // ----------------------------------------------------------------------------
// "THE BEER-WARE LICENSE" (Revision 42):
// <ztn@zurreal.com> wrote this file. As long as you retain this notice you
// can do whatever you want with this stuff. If we meet some day, and you think
// this stuff is worth it, you can buy me a beer in return. Ziesche Til Newman
// ----------------------------------------------------------------------------
#ifndef HEROESPATH_GUI_SOUNDEFFECTSSET_HPP_INCLUDED
#define HEROESPATH_GUI_SOUNDEFFECTSSET_HPP_INCLUDED
//
// sound-effects-set.hpp
// Simple wrapper of sound effects
//
#include "gui/sound-effects-enum.hpp"
#include <memory>
#include <vector>
namespace heroespath
{
namespace gui
{
// Wraps a set of sound effects for easy playing of a random selection
class SfxSet
{
public:
explicit SfxSet(const SfxEnumVec_t & ENUM_VEC = SfxEnumVec_t());
explicit SfxSet(const sound_effect::Enum);
SfxSet(const sound_effect::Enum FIRST_ENUM, const sound_effect::Enum LAST_ENUM);
// throws runtime_error if given is not in the set
void Play(const sound_effect::Enum) const;
// throws range_error if out of bounds
void PlayAt(const std::size_t) const;
void PlayRandom() const;
std::size_t Size() const { return sfxEnums_.size(); }
bool IsValid() const { return !sfxEnums_.empty(); }
sound_effect::Enum SelectRandom() const;
private:
SfxEnumVec_t sfxEnums_;
};
using SfxSetVec_t = std::vector<SfxSet>;
} // namespace gui
} // namespace heroespath
#endif // HEROESPATH_GUI_SOUNDEFFECTSSET_HPP_INCLUDED
| 29.192982 | 88 | 0.63101 | [
"vector"
] |
a266449210d874dcc85f4c6ca264b44e807a44cf | 3,663 | cpp | C++ | src/qt/src/3rdparty/webkit/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp | ant0ine/phantomjs | 8114d44a28134b765ab26b7e13ce31594fa81253 | [
"BSD-3-Clause"
] | 46 | 2015-01-08T14:32:34.000Z | 2022-02-05T16:48:26.000Z | src/qt/src/3rdparty/webkit/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp | ant0ine/phantomjs | 8114d44a28134b765ab26b7e13ce31594fa81253 | [
"BSD-3-Clause"
] | 7 | 2015-01-20T14:28:12.000Z | 2017-01-18T17:21:44.000Z | src/qt/src/3rdparty/webkit/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp | ant0ine/phantomjs | 8114d44a28134b765ab26b7e13ce31594fa81253 | [
"BSD-3-Clause"
] | 14 | 2015-10-27T06:17:48.000Z | 2020-03-03T06:15:50.000Z | /*
* Copyright (c) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "ScriptCallStackFactory.h"
#include "JSDOMBinding.h"
#include "ScriptArguments.h"
#include "ScriptCallFrame.h"
#include "ScriptCallStack.h"
#include "ScriptValue.h"
#include <interpreter/CallFrame.h>
#include <interpreter/Interpreter.h>
#include <runtime/ArgList.h>
#include <runtime/JSFunction.h>
#include <runtime/JSGlobalData.h>
#include <runtime/JSValue.h>
#include <runtime/UString.h>
using namespace JSC;
namespace WebCore {
PassRefPtr<ScriptCallStack> createScriptCallStack(size_t, bool)
{
return 0;
}
PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize)
{
Vector<ScriptCallFrame> frames;
CallFrame* callFrame = exec;
while (true) {
ASSERT(callFrame);
int signedLineNumber;
intptr_t sourceID;
UString urlString;
JSValue function;
exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function);
UString functionName;
if (function)
functionName = asFunction(function)->name(exec);
else {
// Caller is unknown, but if frames is empty we should still add the frame, because
// something called us, and gave us arguments.
if (!frames.isEmpty())
break;
}
unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0;
frames.append(ScriptCallFrame(ustringToString(functionName), ustringToString(urlString), lineNumber));
if (!function || frames.size() == maxStackSize)
break;
callFrame = callFrame->callerFrame();
}
return ScriptCallStack::create(frames);
}
PassRefPtr<ScriptArguments> createScriptArguments(JSC::ExecState* exec, unsigned skipArgumentCount)
{
Vector<ScriptValue> arguments;
size_t argumentCount = exec->argumentCount();
for (size_t i = skipArgumentCount; i < argumentCount; ++i)
arguments.append(ScriptValue(exec->globalData(), exec->argument(i)));
return ScriptArguments::create(exec, arguments);
}
} // namespace WebCore
| 38.15625 | 110 | 0.723997 | [
"vector"
] |
a26695ba673210e20cd83ccbccc683bf173f6b0b | 862 | cpp | C++ | search/MaxSum/MaxSubarraySum.cpp | avi-pal/al-go-rithms | 5167a20f1db7b366ff19f2962c1746a02e4f5067 | [
"CC0-1.0"
] | 1,253 | 2017-06-06T07:19:25.000Z | 2022-03-30T17:07:58.000Z | search/MaxSum/MaxSubarraySum.cpp | avi-pal/al-go-rithms | 5167a20f1db7b366ff19f2962c1746a02e4f5067 | [
"CC0-1.0"
] | 554 | 2017-09-29T18:56:01.000Z | 2022-02-21T15:48:13.000Z | search/MaxSum/MaxSubarraySum.cpp | avi-pal/al-go-rithms | 5167a20f1db7b366ff19f2962c1746a02e4f5067 | [
"CC0-1.0"
] | 2,226 | 2017-09-29T19:59:59.000Z | 2022-03-25T08:59:55.000Z | #include <bits/stdc++.h>
using namespace std;
long maxSum(vector<long> a, long m)
{
long sum = 0, max = LONG_MIN, result = LONG_MAX;
set<long> s;
for (int i = 0; i < a.size(); i++)
{
sum = (sum + a[i]) % m;
a[i] = sum;
max = std::max(max, sum);
}
for (auto x : a)
{
auto p = s.insert(x);
if (++p.first != s.end())
{
result = min(*p.first - x, result);
}
}
return std::max(max, m - result);
}
int main()
{
int t;
int test_case;
for (scanf("%lu", &test_case); test_case--;)
{
vector<long> g1;
long n;
long m;
long a;
cin >> n >> m;
for (int i = 0; i < n; i++)
{
cin >> a;
g1.push_back(a);
}
cout << maxSum(g1, m) << endl;
}
return 0;
} | 18.340426 | 52 | 0.412993 | [
"vector"
] |
a268f7519b4fb7c2db194b5c70abc20a09abd3dd | 3,702 | hpp | C++ | blast/src/connect/services/netschedule_api_getjob.hpp | mycolab/ncbi-blast | e59746cec78044d2bf6d65de644717c42f80b098 | [
"Apache-2.0"
] | null | null | null | blast/src/connect/services/netschedule_api_getjob.hpp | mycolab/ncbi-blast | e59746cec78044d2bf6d65de644717c42f80b098 | [
"Apache-2.0"
] | null | null | null | blast/src/connect/services/netschedule_api_getjob.hpp | mycolab/ncbi-blast | e59746cec78044d2bf6d65de644717c42f80b098 | [
"Apache-2.0"
] | null | null | null | #ifndef CONN_SERVICES___NETSCHEDULE_API_GETJOB__HPP
#define CONN_SERVICES___NETSCHEDULE_API_GETJOB__HPP
/* $Id: netschedule_api_getjob.hpp 607687 2020-05-06 16:16:59Z sadyrovr $
* ===========================================================================
*
* 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.
*
* ===========================================================================
*
* Authors: Rafael Sadyrov
*
* File Description:
* NetSchedule API get/read job implementation.
*
*/
#include <connect/services/netschedule_api.hpp>
#include <vector>
#include <list>
BEGIN_NCBI_SCOPE
// A namespace-like class
struct CNetScheduleGetJob
{
// Vector of priority-ordered pairs of affinities and
// corresponding priority-ordered comma-separated affinity lists.
// E.g., for "a, b, c" it would be:
// { "a", "a" },
// { "b", "a, b" },
// { "c", "a, b, c" }
typedef vector<pair<string, string> > TAffinityLadder;
enum EState {
eWorking,
eRestarted,
eStopped
};
enum EResult {
eJob,
eAgain,
eInterrupt,
eNoJobs
};
struct SEntry
{
SSocketAddress server_address;
CDeadline deadline;
bool all_affinities_checked;
bool more_jobs;
SEntry(const SSocketAddress& a, bool j = true) :
server_address(a),
deadline(0, 0),
all_affinities_checked(true),
more_jobs(j)
{
}
bool operator==(const SEntry& rhs) const
{
return server_address == rhs.server_address;
}
};
};
template <class TImpl>
class CNetScheduleGetJobImpl : public CNetScheduleGetJob
{
public:
CNetScheduleGetJobImpl(TImpl& impl) :
m_Impl(impl),
m_DiscoveryAction(SSocketAddress(0, 0), false)
{
m_ImmediateActions.push_back(m_DiscoveryAction);
}
CNetScheduleGetJob::EResult GetJob(
const CDeadline& deadline,
CNetScheduleJob& job,
CNetScheduleAPI::EJobStatus* job_status,
bool any_affinity);
private:
template <class TJobHolder>
EResult GetJobImmediately(TJobHolder& holder);
template <class TJobHolder>
EResult GetJobImpl(const CDeadline& deadline, TJobHolder& holder);
void Restart();
void MoveToImmediateActions(SNetServerImpl* server_impl);
void NextDiscoveryIteration();
void ReturnNotFullyCheckedServers();
TImpl& m_Impl;
list<SEntry> m_ImmediateActions, m_ScheduledActions;
SEntry m_DiscoveryAction;
};
END_NCBI_SCOPE
#endif /* CONN_SERVICES___NETSCHEDULE_API_GETJOB__HPP */
| 28.476923 | 78 | 0.643976 | [
"vector"
] |
a26a3a1a855a590c6386307d99ff8ebeffe627c8 | 2,443 | cpp | C++ | examples/particles/main.cpp | Grayson112233/sdlgl | 68c0398fa1dc5ebed77f2528856f7cd6d6d9cdda | [
"MIT"
] | 1 | 2019-12-25T19:35:00.000Z | 2019-12-25T19:35:00.000Z | examples/particles/main.cpp | graysonpike/sdlgl | 68c0398fa1dc5ebed77f2528856f7cd6d6d9cdda | [
"MIT"
] | null | null | null | examples/particles/main.cpp | graysonpike/sdlgl | 68c0398fa1dc5ebed77f2528856f7cd6d6d9cdda | [
"MIT"
] | 1 | 2019-12-25T19:35:01.000Z | 2019-12-25T19:35:01.000Z | #include <iostream>
#include <sdlgl/game/context.h>
#include <sdlgl/graphics/graphics.h>
#include <sdlgl/graphics/effects/linear_emitter.h>
#include <sdlgl/game/clock.h>
#include <sdlgl/ui/fps_display.h>
#include <sdlgl/ui/entity_count.h>
class ParticleExample {
std::vector<SDL_Color> fire_colors;
std::vector<SDL_Color> explosion_colors;
void game_loop(Context context, Scene *scene) {
if (context.inputs->is_key_down_event(SDL_SCANCODE_SPACE)) {
scene->add_entity(new LinearParticleEmitter(scene, 213, 240, -100, 100, -100, 100, explosion_colors, 50, 3, 0.3f, 0.1f, false));
}
context.inputs->update();
context.clock->tick();
context.graphics->clear_screen((SDL_Color){255, 255, 255, 255});
scene->update(context.clock->get_delta());
scene->render();
context.audio->update(context.clock->get_delta());
if (context.inputs->get_quit()) {
*context.loop = false;
}
context.graphics->present_renderer(context.clock->get_delta());
}
public:
int start() {
Context context(new Graphics(640, 480), new Audio(), new Inputs(), new Clock());
Scene *scene = new Scene(context.graphics, context.audio, context.inputs);
context.graphics->get_resources()->load_resources("resources.json");
explosion_colors.push_back({50, 50, 50});
explosion_colors.push_back({100, 100, 100});
explosion_colors.push_back({150, 150, 150});
explosion_colors.push_back({255, 87, 69});
explosion_colors.push_back({255, 168, 69});
explosion_colors.push_back({255, 209, 69});
fire_colors.push_back({255, 87, 69});
fire_colors.push_back({255, 168, 69});
fire_colors.push_back({255, 209, 69});
LinearParticleEmitter *fire = new LinearParticleEmitter(scene, 426, 240, -20, 20, -40, -10, fire_colors, 100, 3, 1.5f);
scene->add_entity(fire);
scene->add_entity(new FPS_Display(
scene, "base_text", (SDL_Color){0, 0, 0, 255}));
scene->add_entity(new EntityCount(
scene, "base_text", (SDL_Color){0, 0, 0, 255}));
context.graphics->set_debug_visuals(true);
while (*context.loop) {
game_loop(context, scene);
}
return 0;
}
};
int main() {
ParticleExample program = ParticleExample();
return program.start();
} | 30.5375 | 140 | 0.62587 | [
"render",
"vector"
] |
a26baf3fca7117fb8c0fb4993621773d4b605327 | 4,538 | cpp | C++ | Uber_Duper_Simulation_Haxe/bin/windows/cpp/obj/src/haxe/ds/ObjectMap.cpp | as3boyan/Uber-Duper-Simulation | a3942831a1acf08479f06fd8cfe8896ec00ac32c | [
"MIT"
] | null | null | null | Uber_Duper_Simulation_Haxe/bin/windows/cpp/obj/src/haxe/ds/ObjectMap.cpp | as3boyan/Uber-Duper-Simulation | a3942831a1acf08479f06fd8cfe8896ec00ac32c | [
"MIT"
] | null | null | null | Uber_Duper_Simulation_Haxe/bin/windows/cpp/obj/src/haxe/ds/ObjectMap.cpp | as3boyan/Uber-Duper-Simulation | a3942831a1acf08479f06fd8cfe8896ec00ac32c | [
"MIT"
] | null | null | null | #include <hxcpp.h>
#ifndef INCLUDED_IMap
#include <IMap.h>
#endif
#ifndef INCLUDED_haxe_ds_IntMap
#include <haxe/ds/IntMap.h>
#endif
#ifndef INCLUDED_haxe_ds_ObjectMap
#include <haxe/ds/ObjectMap.h>
#endif
namespace haxe{
namespace ds{
Void ObjectMap_obj::__construct()
{
HX_STACK_FRAME("haxe.ds.ObjectMap","new",0x27af5498,"haxe.ds.ObjectMap.new","D:\\Denis\\PortableSoft\\HaxeToolkit\\haxe\\std/cpp/_std/haxe/ds/ObjectMap.hx",29,0x5bc14085)
HX_STACK_THIS(this)
{
HX_STACK_LINE(30)
::haxe::ds::IntMap _g = ::haxe::ds::IntMap_obj::__new(); HX_STACK_VAR(_g,"_g");
HX_STACK_LINE(30)
this->__Internal = _g;
HX_STACK_LINE(31)
::haxe::ds::IntMap _g1 = ::haxe::ds::IntMap_obj::__new(); HX_STACK_VAR(_g1,"_g1");
HX_STACK_LINE(31)
this->__KeyRefs = _g1;
}
;
return null();
}
//ObjectMap_obj::~ObjectMap_obj() { }
Dynamic ObjectMap_obj::__CreateEmpty() { return new ObjectMap_obj; }
hx::ObjectPtr< ObjectMap_obj > ObjectMap_obj::__new()
{ hx::ObjectPtr< ObjectMap_obj > result = new ObjectMap_obj();
result->__construct();
return result;}
Dynamic ObjectMap_obj::__Create(hx::DynamicArray inArgs)
{ hx::ObjectPtr< ObjectMap_obj > result = new ObjectMap_obj();
result->__construct();
return result;}
hx::Object *ObjectMap_obj::__ToInterface(const hx::type_info &inType) {
if (inType==typeid( ::IMap_obj)) return operator ::IMap_obj *();
return super::__ToInterface(inType);
}
Void ObjectMap_obj::set( Dynamic key,Dynamic value){
{
HX_STACK_FRAME("haxe.ds.ObjectMap","set",0x27b31fda,"haxe.ds.ObjectMap.set","D:\\Denis\\PortableSoft\\HaxeToolkit\\haxe\\std/cpp/_std/haxe/ds/ObjectMap.hx",34,0x5bc14085)
HX_STACK_THIS(this)
HX_STACK_ARG(key,"key")
HX_STACK_ARG(value,"value")
HX_STACK_LINE(35)
int id = ::__hxcpp_obj_id(key); HX_STACK_VAR(id,"id");
HX_STACK_LINE(36)
this->__Internal->set(id,value);
HX_STACK_LINE(37)
this->__KeyRefs->set(id,key);
}
return null();
}
HX_DEFINE_DYNAMIC_FUNC2(ObjectMap_obj,set,(void))
ObjectMap_obj::ObjectMap_obj()
{
}
void ObjectMap_obj::__Mark(HX_MARK_PARAMS)
{
HX_MARK_BEGIN_CLASS(ObjectMap);
HX_MARK_MEMBER_NAME(__Internal,"__Internal");
HX_MARK_MEMBER_NAME(__KeyRefs,"__KeyRefs");
HX_MARK_END_CLASS();
}
void ObjectMap_obj::__Visit(HX_VISIT_PARAMS)
{
HX_VISIT_MEMBER_NAME(__Internal,"__Internal");
HX_VISIT_MEMBER_NAME(__KeyRefs,"__KeyRefs");
}
Dynamic ObjectMap_obj::__Field(const ::String &inName,bool inCallProp)
{
switch(inName.length) {
case 3:
if (HX_FIELD_EQ(inName,"set") ) { return set_dyn(); }
break;
case 9:
if (HX_FIELD_EQ(inName,"__KeyRefs") ) { return __KeyRefs; }
break;
case 10:
if (HX_FIELD_EQ(inName,"__Internal") ) { return __Internal; }
}
return super::__Field(inName,inCallProp);
}
Dynamic ObjectMap_obj::__SetField(const ::String &inName,const Dynamic &inValue,bool inCallProp)
{
switch(inName.length) {
case 9:
if (HX_FIELD_EQ(inName,"__KeyRefs") ) { __KeyRefs=inValue.Cast< ::haxe::ds::IntMap >(); return inValue; }
break;
case 10:
if (HX_FIELD_EQ(inName,"__Internal") ) { __Internal=inValue.Cast< ::haxe::ds::IntMap >(); return inValue; }
}
return super::__SetField(inName,inValue,inCallProp);
}
void ObjectMap_obj::__GetFields(Array< ::String> &outFields)
{
outFields->push(HX_CSTRING("__Internal"));
outFields->push(HX_CSTRING("__KeyRefs"));
super::__GetFields(outFields);
};
static ::String sStaticFields[] = {
String(null()) };
#if HXCPP_SCRIPTABLE
static hx::StorageInfo sMemberStorageInfo[] = {
{hx::fsObject /*::haxe::ds::IntMap*/ ,(int)offsetof(ObjectMap_obj,__Internal),HX_CSTRING("__Internal")},
{hx::fsObject /*::haxe::ds::IntMap*/ ,(int)offsetof(ObjectMap_obj,__KeyRefs),HX_CSTRING("__KeyRefs")},
{ hx::fsUnknown, 0, null()}
};
#endif
static ::String sMemberFields[] = {
HX_CSTRING("__Internal"),
HX_CSTRING("__KeyRefs"),
HX_CSTRING("set"),
String(null()) };
static void sMarkStatics(HX_MARK_PARAMS) {
HX_MARK_MEMBER_NAME(ObjectMap_obj::__mClass,"__mClass");
};
#ifdef HXCPP_VISIT_ALLOCS
static void sVisitStatics(HX_VISIT_PARAMS) {
HX_VISIT_MEMBER_NAME(ObjectMap_obj::__mClass,"__mClass");
};
#endif
Class ObjectMap_obj::__mClass;
void ObjectMap_obj::__register()
{
hx::Static(__mClass) = hx::RegisterClass(HX_CSTRING("haxe.ds.ObjectMap"), hx::TCanCast< ObjectMap_obj> ,sStaticFields,sMemberFields,
&__CreateEmpty, &__Create,
&super::__SGetClass(), 0, sMarkStatics
#ifdef HXCPP_VISIT_ALLOCS
, sVisitStatics
#endif
#ifdef HXCPP_SCRIPTABLE
, sMemberStorageInfo
#endif
);
}
void ObjectMap_obj::__boot()
{
}
} // end namespace haxe
} // end namespace ds
| 26.231214 | 172 | 0.734024 | [
"object"
] |
a27ad0c74d8b17408cad8a846cc4c1ddd9eff93d | 9,488 | cc | C++ | SeekbarWindow.Events.cc | zhuman/foo_wave_seekbar | e53d99a5d7fe451a36299a4c2e58210ad21ebfd5 | [
"BSL-1.0"
] | null | null | null | SeekbarWindow.Events.cc | zhuman/foo_wave_seekbar | e53d99a5d7fe451a36299a4c2e58210ad21ebfd5 | [
"BSL-1.0"
] | null | null | null | SeekbarWindow.Events.cc | zhuman/foo_wave_seekbar | e53d99a5d7fe451a36299a4c2e58210ad21ebfd5 | [
"BSL-1.0"
] | null | null | null | // Copyright Lars Viklund 2008 - 2011.
// 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)
#include "PchSeekbar.h"
#include "SeekbarWindow.h"
#include "SeekTooltip.h"
#include "Clipboard.h"
#include "FrontendLoader.h"
#include "util/Profiling.h"
// {EBEABA3F-7A8E-4A54-A902-3DCF716E6A97}
static const GUID guid_seekbar_branch =
{ 0xebeaba3f, 0x7a8e, 0x4a54, { 0xa9, 0x2, 0x3d, 0xcf, 0x71, 0x6e, 0x6a, 0x97 } };
// {E913D7C7-676A-4A4F-A0F4-3DA33622D3D8}
static const GUID guid_seekbar_screenshot_branch =
{ 0xe913d7c7, 0x676a, 0x4a4f, { 0xa0, 0xf4, 0x3d, 0xa3, 0x36, 0x22, 0xd3, 0xd8 } };
// {FA3261D7-671B-4BE4-AA18-75B8EFA7E4D6}
static const GUID guid_seekbar_screenshot_width =
{ 0xfa3261d7, 0x671b, 0x4be4, { 0xaa, 0x18, 0x75, 0xb8, 0xef, 0xa7, 0xe4, 0xd6 } };
// {B3534AC9-609A-4A6E-8B6A-7522D7E9E419}
static const GUID guid_seekbar_screenshot_height =
{ 0xb3534ac9, 0x609a, 0x4a6e, { 0x8b, 0x6a, 0x75, 0x22, 0xd7, 0xe9, 0xe4, 0x19 } };
// {0936311D-C065-4C72-806C-1F68403B385D}
static const GUID guid_seekbar_screenshot_filename_format =
{ 0x936311d, 0xc065, 0x4c72, { 0x80, 0x6c, 0x1f, 0x68, 0x40, 0x3b, 0x38, 0x5d } };
// {BE7CFD4F-C880-4DD1-801C-81740D0A2CEF}
static const GUID guid_scroll_to_seek =
{ 0xbe7cfd4f, 0xc880, 0x4dd1, { 0x80, 0x1c, 0x81, 0x74, 0xd, 0xa, 0x2c, 0xef } };
static advconfig_branch_factory g_seekbar_screenshot_branch("Screenshots", guid_seekbar_screenshot_branch, guid_seekbar_branch, 0.0);
static advconfig_integer_factory g_seekbar_screenshot_width ("Horizontal size (pixels)", guid_seekbar_screenshot_width, guid_seekbar_screenshot_branch, 0.1, 1024, 16, 8192);
static advconfig_integer_factory g_seekbar_screenshot_height("Vertical size (pixels)", guid_seekbar_screenshot_height, guid_seekbar_screenshot_branch, 0.2, 1024, 16, 8192);
static advconfig_string_factory g_seekbar_screenshot_filename_format("File format template (either absolute path+filename or just filename)", guid_seekbar_screenshot_filename_format, guid_seekbar_screenshot_branch, 0.3, "%artist% - %tracknumber%. %title%.png");
static advconfig_checkbox_factory g_seekbar_scroll_to_seek("Scroll mouse wheel to seek", guid_scroll_to_seek, guid_seekbar_branch, 0.0, true);
static bool is_outside(CPoint point, CRect r, int N, bool horizontal)
{
if (!horizontal)
{
std::swap(point.x, point.y);
std::swap(r.right, r.bottom);
std::swap(r.left, r.top);
}
return point.y < -2 * N || point.y > r.bottom - r.top + 2 * N ||
point.x < -N || point.x > r.right - r.left + N;
}
struct menu_item_info
{
menu_item_info(UINT f_mask, UINT f_type, UINT f_state, LPTSTR dw_type_data, UINT w_id, HMENU h_submenu = 0, HBITMAP hbmp_checked = 0, HBITMAP hbmp_unchecked = 0, ULONG_PTR dw_item_data = 0, HBITMAP hbmp_item = 0)
{
MENUITEMINFO mi =
{
sizeof(mi), f_mask | MIIM_TYPE | MIIM_STATE | MIIM_ID, f_type, f_state, w_id, h_submenu, hbmp_checked, hbmp_unchecked, dw_item_data, dw_type_data, _tcslen(dw_type_data), hbmp_item
};
this->mi = mi;
}
mutable MENUITEMINFO mi;
operator LPMENUITEMINFO () const
{
return &mi;
}
};
namespace wave
{
void seekbar_window::on_wm_paint(HDC dc)
{
GetClientRect(client_rect);
if (!(client_rect.right > 1 && client_rect.bottom > 1))
{
ValidateRect(0);
return;
}
if (!fe->frontend && !initializing_graphics)
{
initialize_frontend();
}
if (fe->frontend)
{
fe->frontend->clear();
fe->frontend->draw();
fe->frontend->present();
}
ValidateRect(0);
}
void seekbar_window::on_wm_size(UINT wparam, CSize size)
{
if (size.cx < 1 || size.cy < 1)
return;
set_orientation(size.cx >= size.cy
? config::orientation_horizontal
: config::orientation_vertical);
lock_guard<recursive_mutex> lk(fe->mutex);
fe->callback->set_size(wave::size(size.cx, size.cy));
if (fe->frontend)
fe->frontend->on_state_changed((visual_frontend::state)(visual_frontend::state_size | visual_frontend::state_orientation));
}
void seekbar_window::on_wm_timer(UINT_PTR wparam)
{
if (wparam == REPAINT_TIMER_ID && core_api::are_services_available())
{
static_api_ptr_t<playback_control> pc;
double t = pc->playback_get_position();
set_playback_time(t);
}
}
LRESULT seekbar_window::on_wm_create(LPCREATESTRUCT)
{
util::ScopedEvent se("Windowing", "seekbar creation");
fe->callback.reset(new frontend_callback_impl);
fe->conf.reset(new frontend_config_impl(settings));
fe->callback->set_waveform(placeholder_waveform);
wait_for_frontend_module_load();
decltype(deferred_init) v;
v.swap(deferred_init);
for (auto f : v) {
f();
}
apply_settings();
static_api_ptr_t<player> p;
p->register_waveform_listener(this);
return 0;
}
void seekbar_window::on_wm_destroy()
{
static_api_ptr_t<player> p;
p->deregister_waveform_listener(this);
if (repaint_timer_id)
KillTimer(repaint_timer_id);
repaint_timer_id = 0;
lock_guard<recursive_mutex> lk(fe->mutex);
fe->clear();
}
LRESULT seekbar_window::on_wm_erasebkgnd(HDC dc)
{
SetDCBrushColor(dc, color_to_xbgr(fe->callback->get_color(config::color_background)));
auto sz = fe->callback->get_size();
CRect r(0, 0, sz.cx, sz.cy);
FillRect(dc, r, GetStockBrush(DC_BRUSH));
return 1;
}
void seekbar_window::on_wm_lbuttondown(UINT wparam, CPoint point)
{
drag_state = (wparam & MK_CONTROL) ? MouseDragSelection : MouseDragSeeking;
if (!tooltip)
{
tooltip.reset(new seek_tooltip(*this));
seek_callbacks.push_back(tooltip);
}
lock_guard<recursive_mutex> lk(fe->mutex);
if (drag_state == MouseDragSeeking)
{
fe->callback->set_seeking(true);
for each(auto cb in seek_callbacks)
if (auto p = cb.lock())
p->on_seek_begin();
set_seek_position(point);
if (fe->frontend)
{
fe->frontend->on_state_changed(visual_frontend::state_position);
}
}
else
{
drag_data.to = drag_data.from = compute_position(point);
}
SetCapture();
}
void seekbar_window::on_wm_lbuttonup(UINT wparam, CPoint point)
{
lock_guard<recursive_mutex> lk(fe->mutex);
ReleaseCapture();
if (drag_state == MouseDragSeeking)
{
bool completed = fe->callback->is_seeking();
if (completed)
{
fe->callback->set_seeking(false);
set_seek_position(point);
if (fe->frontend)
fe->frontend->on_state_changed(visual_frontend::state_position);
static_api_ptr_t<playback_control> pc;
pc->playback_seek(fe->callback->get_seek_position());
}
for each(auto cb in seek_callbacks)
if (auto p = cb.lock())
p->on_seek_end(!completed);
}
else if (drag_state == MouseDragSelection)
{
auto source = fe->displayed_song;
if (source.is_valid() && drag_data.to >= 0)
{
drag_data.to = compute_position(point);
auto from = std::min(drag_data.from, drag_data.to);
auto to = std::max(drag_data.from, drag_data.to);
if (clipboard::render_audio(source, from, to)) {
console::formatter() << "seekbar: rendered waveform from " <<
from << " through " << to << " to the clipboard of track " <<
source->get_location();
}
else {
console::formatter() << "seekbar: failed to render waveform to clipboard";
}
}
}
drag_state = MouseDragNone;
}
void seekbar_window::on_wm_mousemove(UINT wparam, CPoint point)
{
if (drag_state != MouseDragNone)
{
if (last_seek_point == point)
return;
last_seek_point = point;
lock_guard<recursive_mutex> lk(fe->mutex);
CRect r;
GetWindowRect(r);
int const N = 40;
bool horizontal = fe->callback->get_orientation() == config::orientation_horizontal;
bool outside = is_outside(point, r, N, horizontal);
if (drag_state == MouseDragSeeking)
{
fe->callback->set_seeking(!outside);
set_seek_position(point);
if (fe->frontend)
{
fe->frontend->on_state_changed(visual_frontend::state_position);
}
}
else if (drag_state == MouseDragSelection)
{
drag_data.to = outside
? -1.0f
: compute_position(point);
}
}
}
LRESULT seekbar_window::on_wm_mousewheel(UINT, short z_delta, CPoint)
{
std::pair<int64_t, double> const skip_table[] = {
{ 50, 1 },
{ 100, 2 },
{ 250, 5 },
{ 500, 10 },
{ 1500, 30 },
{ 3000, 1*60 },
{ 6000, 2*60 },
{ 15000, 5*60 },
{ 30000, 10*60 },
{ 90000, 30*60 }
};
if (!g_seekbar_scroll_to_seek)
return 0;
static_api_ptr_t<playback_control> pc;
auto pos = pc->playback_get_position();
auto length = pc->playback_get_length();
double skip_size = 1*60*60;
for (auto p : skip_table) {
if ((int64_t)length < p.first) {
skip_size = p.second;
break;
}
}
pos += skip_size * z_delta / 120.0f;
pc->playback_seek(pos);
return 0;
}
void seekbar_window::on_wm_rbuttonup(UINT wparam, CPoint point)
{
if (forward_rightclick())
{
SetMsgHandled(FALSE);
return;
}
WTL::CMenu m;
m.CreatePopupMenu();
m.InsertMenu(-1, MF_BYPOSITION | MF_STRING, 3, L"Configure");
ClientToScreen(&point);
BOOL ans = m.TrackPopupMenu(TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y, *this, 0);
config::frontend old_kind = settings.active_frontend_kind;
switch(ans)
{
case 3:
if (config_dialog)
config_dialog->BringWindowToTop();
else
{
config_dialog.reset(new configuration_dialog(*this));
config_dialog->Create(*this);
}
break;
default:
return;
}
}
} | 28.154303 | 261 | 0.693718 | [
"render"
] |
a27c1a0b725bc75e66e067aff200647375d46b10 | 1,862 | cpp | C++ | practice/NickANdArray.cpp | xenowits/cp | 963b3c7df65b5328d5ce5ef894a46691afefb98c | [
"MIT"
] | null | null | null | practice/NickANdArray.cpp | xenowits/cp | 963b3c7df65b5328d5ce5ef894a46691afefb98c | [
"MIT"
] | null | null | null | practice/NickANdArray.cpp | xenowits/cp | 963b3c7df65b5328d5ce5ef894a46691afefb98c | [
"MIT"
] | null | null | null | #include<bits/stdc++.h>
using namespace std;
#define fori(i,a,b) for (int i = a; i <= b ; ++i)
#define ford(i,a,b) for(int i = a;i >= b ; --i)
#define mk make_pair
#define mod 1000000007
#define pb push_back
#define ll long long
#define MAXN 100001
#define rnd mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().cnt())
#define pi pair<long long int,long long int>
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin >> n;
vector<ll> v(n+1);vector<pi> change_vector, zero_vector;
ll pos = 0, neg = 0, zer = 0;
fori(i,1,n)
{
cin >> v[i];
if (v[i] == 0)
{
pos += 1;
zero_vector.pb(mk(v[i],i));
zer += 1;
}
else if (v[i] < 0)
neg += 1;
else
{
change_vector.pb(mk(v[i],i));
pos += 1;
}
}
if (zer == n)
{
fori(i,1,n)
{
}
}
if (!change_vector.empty())
sort(change_vector.begin(), change_vector.end(), greater<pi>());
vector<ll> ans_v = v;
//basically we r changing the positive array
for (auto x : zero_vector)
{
ans_v[x.second] = -1;
pos -= 1;
neg += 1;
}
if (neg%2 == 0)
{
if (pos%2 == 0)
{
for (auto x : change_vector)
ans_v[x.second] = -x.first-1;
}
ll cnt = 0;
if (pos%2 == 1)
{
for (auto x : change_vector)
{
if (cnt == pos-1)
break;
ans_v[x.second] = -x.first-1;
cnt += 1;
}
}
}
if (neg%2 == 1)
{
if (pos%2 == 1)
{
for (auto x : change_vector)
ans_v[x.second] = -x.first-1;
}
ll cnt = 0;
if (pos%2 == 0)
{
for (auto x : change_vector)
{
if (cnt == pos-1)
break;
ans_v[x.second] = -x.first-1;
cnt += 1;
}
}
}
fori(i,1,n)
cout << ans_v[i] << " ";
cout << endl;
return 0;
}
| 18.808081 | 89 | 0.491944 | [
"vector"
] |
a289c550d85d3fc6bd2cda8009b3b4e32fdce4e7 | 10,485 | inl | C++ | engine/include/storm/engine/render/Transform.inl | Arthapz/StormKit | 7c8dead874734d04b97776287b25bf2ebe9be617 | [
"MIT"
] | 17 | 2019-02-12T14:40:06.000Z | 2021-12-21T12:54:17.000Z | engine/include/storm/engine/render/Transform.inl | Arthapz/StormKit | 7c8dead874734d04b97776287b25bf2ebe9be617 | [
"MIT"
] | null | null | null | engine/include/storm/engine/render/Transform.inl | Arthapz/StormKit | 7c8dead874734d04b97776287b25bf2ebe9be617 | [
"MIT"
] | 2 | 2019-02-21T10:07:42.000Z | 2020-05-08T19:49:10.000Z | // Copyright (C) 2021 Arthur LAURENT <arthur.laurent4@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level of this distribution
namespace storm::engine {
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::position() const noexcept -> const core::Vector3f & {
return m_position;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setPosition(const core::Vector2f &position) noexcept -> void {
setXPosition(position.x);
setYPosition(position.y);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setPosition(const core::Vector3f &position) noexcept -> void {
setXPosition(position.x);
setYPosition(position.y);
setZPosition(position.z);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setPosition(float x, float y, float z) noexcept -> void {
setXPosition(x);
setYPosition(y);
setZPosition(z);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setXPosition(float x) noexcept -> void {
m_position.x = x;
m_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setYPosition(float y) noexcept -> void {
m_position.y = y;
m_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setZPosition(float z) noexcept -> void {
m_position.z = z;
m_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::move(const core::Vector2f &position) noexcept -> void {
moveX(position.x);
moveY(position.y);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::move(const core::Vector3f &position) noexcept -> void {
moveX(position.x);
moveY(position.y);
moveZ(position.z);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::move(float x, float y, float z) noexcept -> void {
moveX(x);
moveY(y);
moveZ(z);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::moveX(float x) noexcept -> void {
m_position.x += x;
m_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::moveY(float y) noexcept -> void {
m_position.y += y;
m_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::moveZ(float z) noexcept -> void {
m_position.z += z;
m_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::scale() const noexcept -> const core::Vector3f & { return m_scale; }
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setScale(const core::Vector2f &scale) noexcept -> void {
setXScale(scale.x);
setYScale(scale.y);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setScale(const core::Vector3f &scale) noexcept -> void {
setXScale(scale.x);
setYScale(scale.y);
setZScale(scale.z);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setScale(float x, float y, float z) noexcept -> void {
setXScale(x);
setYScale(y);
setZScale(z);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setXScale(float x) noexcept -> void {
m_scale.x = x;
m_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setYScale(float y) noexcept -> void {
m_scale.y = y;
m_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setZScale(float z) noexcept -> void {
m_scale.z = z;
m_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::scale(const core::Vector3f &scale) noexcept -> void {
scaleX(scale.x);
scaleY(scale.y);
scaleZ(scale.z);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::scale(const core::Vector2f &scale) noexcept -> void {
scaleX(scale.x);
scaleY(scale.y);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::scale(float x_scale, float y_scale, float z_scale) noexcept -> void {
scaleX(x_scale);
scaleY(y_scale);
scaleZ(z_scale);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::scaleX(float scale) noexcept -> void {
m_scale.x += scale;
m_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::scaleY(float scale) noexcept -> void {
m_scale.y += scale;
m_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::scaleZ(float scale) noexcept -> void {
m_scale.z += scale;
m_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::orientation() const noexcept -> const core::Quaternion & {
if (m_orientation_dirty) {
recomputeOrientation();
m_orientation_dirty = false;
}
return m_orientation;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::orientationEuler() const noexcept -> const core::Vector3f & {
return m_orientation_euler;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setOrientation(const core::Vector3f &orientation) noexcept -> void {
setPitch(orientation.x);
setYaw(orientation.y);
setRoll(orientation.z);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setOrientation(const core::Vector2f &orientation) noexcept -> void {
setPitch(orientation.x);
setYaw(orientation.y);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setOrientation(float pitch, float yaw, float roll) noexcept -> void {
setPitch(pitch);
setYaw(yaw);
setRoll(roll);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setYaw(float yaw) noexcept -> void {
m_orientation_euler.y = yaw;
m_dirty = true;
m_orientation_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setPitch(float pitch) noexcept -> void {
m_orientation_euler.x = pitch;
m_dirty = true;
m_orientation_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setRoll(float roll) noexcept -> void {
m_orientation_euler.z = roll;
m_dirty = true;
m_orientation_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::rotate(const core::Vector3f &rotation) noexcept -> void {
rotatePitch(rotation.x);
rotateYaw(rotation.y);
rotateRoll(rotation.z);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::rotate(const core::Vector2f &rotation) noexcept -> void {
rotatePitch(rotation.x);
rotateYaw(rotation.y);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::rotate(float pitch, float yaw, float roll) noexcept -> void {
rotatePitch(pitch);
rotateYaw(yaw);
rotateRoll(roll);
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::rotateYaw(float yaw) noexcept -> void {
m_orientation_euler.y += yaw;
m_dirty = true;
m_orientation_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::rotatePitch(float pitch) noexcept -> void {
m_orientation_euler.x += pitch;
m_dirty = true;
m_orientation_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::rotateRoll(float roll) noexcept -> void {
m_orientation_euler.z += roll;
m_dirty = true;
m_orientation_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::setMatrix(const core::Matrix &matrix) noexcept -> void {
extract(matrix);
m_dirty = true;
m_orientation_dirty = true;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::data() const noexcept -> const Data & {
if (m_dirty) {
recomputeMatrices();
m_dirty = false;
}
return m_data;
}
/////////////////////////////////////
/////////////////////////////////////
inline auto Transform::dirty() const noexcept -> bool { return m_dirty; }
} // namespace storm::engine
| 30.479651 | 96 | 0.391989 | [
"transform"
] |
a28c63064af6d76ed26658e6488bf50d90d01964 | 5,693 | cpp | C++ | scene/animation/root_motion_view.cpp | BornStellarMakesEternalLasting/godot | 9f82368d40f1948de708804645374ea02ca6e7db | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | 3 | 2018-05-12T13:01:29.000Z | 2019-12-26T20:43:24.000Z | scene/animation/root_motion_view.cpp | Nufflee/godot | 8fbce27ea8d699f99c234aad1e1ac29c7abfb5bb | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | null | null | null | scene/animation/root_motion_view.cpp | Nufflee/godot | 8fbce27ea8d699f99c234aad1e1ac29c7abfb5bb | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | 2 | 2018-09-14T13:58:57.000Z | 2018-12-12T19:38:33.000Z | #include "root_motion_view.h"
#include "scene/animation/animation_tree.h"
#include "scene/resources/material.h"
void RootMotionView::set_animation_path(const NodePath &p_path) {
path = p_path;
first = true;
}
NodePath RootMotionView::get_animation_path() const {
return path;
}
void RootMotionView::set_color(const Color &p_color) {
color = p_color;
first = true;
}
Color RootMotionView::get_color() const {
return color;
}
void RootMotionView::set_cell_size(float p_size) {
cell_size = p_size;
first = true;
}
float RootMotionView::get_cell_size() const {
return cell_size;
}
void RootMotionView::set_radius(float p_radius) {
radius = p_radius;
first = true;
}
float RootMotionView::get_radius() const {
return radius;
}
void RootMotionView::set_zero_y(bool p_zero_y) {
zero_y = p_zero_y;
}
bool RootMotionView::get_zero_y() const {
return zero_y;
}
void RootMotionView::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
VS::get_singleton()->immediate_set_material(immediate, SpatialMaterial::get_material_rid_for_2d(false, true, false, false, false));
first = true;
}
if (p_what == NOTIFICATION_INTERNAL_PROCESS || p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) {
Transform transform;
if (has_node(path)) {
Node *node = get_node(path);
AnimationTree *tree = Object::cast_to<AnimationTree>(node);
if (tree && tree->is_active() && tree->get_root_motion_track() != NodePath()) {
if (is_processing_internal() && tree->get_process_mode() == AnimationTree::ANIMATION_PROCESS_PHYSICS) {
set_process_internal(false);
set_physics_process_internal(true);
}
if (is_physics_processing_internal() && tree->get_process_mode() == AnimationTree::ANIMATION_PROCESS_IDLE) {
set_process_internal(true);
set_physics_process_internal(false);
}
transform = tree->get_root_motion_transform();
}
}
if (!first && transform == Transform()) {
return;
}
first = false;
transform.orthonormalize(); //dont want scale, too imprecise
transform.affine_invert();
accumulated = transform * accumulated;
accumulated.origin.x = Math::fposmod(accumulated.origin.x, cell_size);
if (zero_y) {
accumulated.origin.y = 0;
}
accumulated.origin.z = Math::fposmod(accumulated.origin.z, cell_size);
VS::get_singleton()->immediate_clear(immediate);
int cells_in_radius = int((radius / cell_size) + 1.0);
VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_LINES);
for (int i = -cells_in_radius; i < cells_in_radius; i++) {
for (int j = -cells_in_radius; j < cells_in_radius; j++) {
Vector3 from(i * cell_size, 0, j * cell_size);
Vector3 from_i((i + 1) * cell_size, 0, j * cell_size);
Vector3 from_j(i * cell_size, 0, (j + 1) * cell_size);
from = accumulated.xform(from);
from_i = accumulated.xform(from_i);
from_j = accumulated.xform(from_j);
Color c = color, c_i = color, c_j = color;
c.a *= MAX(0, 1.0 - from.length() / radius);
c_i.a *= MAX(0, 1.0 - from_i.length() / radius);
c_j.a *= MAX(0, 1.0 - from_j.length() / radius);
VS::get_singleton()->immediate_color(immediate, c);
VS::get_singleton()->immediate_vertex(immediate, from);
VS::get_singleton()->immediate_color(immediate, c_i);
VS::get_singleton()->immediate_vertex(immediate, from_i);
VS::get_singleton()->immediate_color(immediate, c);
VS::get_singleton()->immediate_vertex(immediate, from);
VS::get_singleton()->immediate_color(immediate, c_j);
VS::get_singleton()->immediate_vertex(immediate, from_j);
}
}
VS::get_singleton()->immediate_end(immediate);
}
}
AABB RootMotionView::get_aabb() const {
return AABB(Vector3(-radius, 0, -radius), Vector3(radius * 2, 0.001, radius * 2));
}
PoolVector<Face3> RootMotionView::get_faces(uint32_t p_usage_flags) const {
return PoolVector<Face3>();
}
void RootMotionView::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_animation_path", "path"), &RootMotionView::set_animation_path);
ClassDB::bind_method(D_METHOD("get_animation_path"), &RootMotionView::get_animation_path);
ClassDB::bind_method(D_METHOD("set_color", "color"), &RootMotionView::set_color);
ClassDB::bind_method(D_METHOD("get_color"), &RootMotionView::get_color);
ClassDB::bind_method(D_METHOD("set_cell_size", "size"), &RootMotionView::set_cell_size);
ClassDB::bind_method(D_METHOD("get_cell_size"), &RootMotionView::get_cell_size);
ClassDB::bind_method(D_METHOD("set_radius", "size"), &RootMotionView::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &RootMotionView::get_radius);
ClassDB::bind_method(D_METHOD("set_zero_y", "enable"), &RootMotionView::set_zero_y);
ClassDB::bind_method(D_METHOD("get_zero_y"), &RootMotionView::get_zero_y);
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "animation_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "AnimationTree"), "set_animation_path", "get_animation_path");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "cell_size", PROPERTY_HINT_RANGE, "0.1,16,0.01,or_greater"), "set_cell_size", "get_cell_size");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.1,16,0.01,or_greater"), "set_radius", "get_radius");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "zero_y"), "set_zero_y", "get_zero_y");
}
RootMotionView::RootMotionView() {
zero_y = true;
radius = 10;
cell_size = 1;
set_process_internal(true);
immediate = VisualServer::get_singleton()->immediate_create();
set_base(immediate);
color = Color(0.5, 0.5, 1.0);
}
RootMotionView::~RootMotionView() {
set_base(RID());
VisualServer::get_singleton()->free(immediate);
}
| 31.804469 | 164 | 0.724223 | [
"object",
"transform"
] |
a2910402855a11ed68478b8b4e07317c1fddd7ef | 49,886 | cpp | C++ | src/FeatureMap.cpp | keio-bioinformatics/mxfold | cf1e13cf4334349a63b5676c49ae7d6a002ae6e3 | [
"MIT"
] | 4 | 2019-02-14T00:45:08.000Z | 2021-11-06T21:02:26.000Z | src/FeatureMap.cpp | keio-bioinformatics/mxfold | cf1e13cf4334349a63b5676c49ae7d6a002ae6e3 | [
"MIT"
] | 2 | 2019-03-14T02:12:08.000Z | 2019-03-28T05:59:27.000Z | src/FeatureMap.cpp | keio-bioinformatics/mxfold | cf1e13cf4334349a63b5676c49ae7d6a002ae6e3 | [
"MIT"
] | 2 | 2018-05-15T07:55:18.000Z | 2021-02-10T17:48:55.000Z | #ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
#include "Config.hpp"
#include "FeatureMap.hpp"
#include "LogSpace.hpp"
#include <cassert>
#include <sstream>
// constants
const std::string s_base_pair("base_pair_");
const std::string s_base_pair_dist_at_least("base_pair_dist_at_least_%d");
const std::string s_terminal_mismatch("terminal_mismatch_");
const std::string s_terminal_mismatch_hairpin("terminal_mismatch_hairpin_");
const std::string s_terminal_mismatch_internal("terminal_mismatch_internal_");
const std::string s_terminal_mismatch_internal_1n("terminal_mismatch_internal_1n_");
const std::string s_terminal_mismatch_internal_23("terminal_mismatch_internal_23_");
const std::string s_terminal_mismatch_multi("terminal_mismatch_multi_");
const std::string s_terminal_mismatch_external("terminal_mismatch_external_");
const std::string s_hairpin_length_at_least("hairpin_length_at_least_%d");
const std::string s_hairpin_nucleotides("hairpin_nucleotides_");
const std::string s_helix_length_at_least("helix_length_at_least_%d");
const std::string s_isolated_base_pair("isolated_base_pair");
const std::string s_internal_explicit("internal_explicit_%d_%d");
const std::string s_bulge_length_at_least("bulge_length_at_least_%d");
const std::string s_internal_length_at_least("internal_length_at_least_%d");
const std::string s_internal_symmetric_length_at_least("internal_symmetric_length_at_least_%d");
const std::string s_internal_asymmetry_at_least("internal_asymmetry_at_least_%d");
const std::string s_internal_nucleotides("internal_nucleotides_");
const std::string s_helix_stacking("helix_stacking_");
const std::string s_helix_closing("helix_closing_");
const std::string s_multi_base("multi_base");
const std::string s_multi_unpaired("multi_unpaired");
const std::string s_multi_paired("multi_paired");
const std::string s_dangle_left("dangle_left_");
const std::string s_dangle_right("dangle_right_");
const std::string s_external_unpaired("external_unpaired");
const std::string s_external_paired("external_paired");
#ifdef PARAMS_VIENNA_COMPAT
// for vienna compatibility
const std::string s_hairpin_length("hairpin_length_%d");
const std::string s_bulge_length("bulge_length_%d");
const std::string s_internal_length("internal_length_%d");
const std::string s_internal_nucleotides_int11("internal_loop_11_");
const std::string s_internal_nucleotides_int21("internal_loop_21_");
const std::string s_internal_nucleotides_int12("internal_loop_12_");
const std::string s_internal_nucleotides_int22("internal_loop_22_");
const std::string s_ninio("ninio");
const std::string s_ninio_max("ninio_max");
const std::string s_terminalAU("terminalAU");
const std::string s_triloop("triloop_");
const std::string s_tetraloop("tetraloop_");
const std::string s_hexaloop("hexaloop_");
#endif
FeatureMap::
FeatureMap(const char* def_bases,
const std::vector<std::string>& def_bps)
: def_bases_(def_bases), NBASES(def_bases_.size()),
def_bps_(def_bps), NBPS(def_bps_.size()),
hash_(), keys_()
#ifdef USE_CACHE
#if PARAMS_BASE_PAIR
, cache_base_pair_(NBPS, -1)
#endif
#if PARAMS_BASE_PAIR_DIST
, cache_base_pair_dist_at_least_(D_MAX_BP_DIST_THRESHOLDS, -1)
#endif
#if PARAMS_TERMINAL_MISMATCH
, cache_terminal_mismatch_(NBPS, VVI(NBASES, VI(NBASES, -1)))
#endif
#if PARAMS_TERMINAL_MISMATCH_HAIRPIN
, cache_terminal_mismatch_hairpin_(NBPS, VVI(NBASES, VI(NBASES, -1)))
#endif
#if PARAMS_TERMINAL_MISMATCH_INTERNAL
, cache_terminal_mismatch_internal_(NBPS, VVI(NBASES, VI(NBASES, -1)))
#endif
#if PARAMS_TERMINAL_MISMATCH_INTERNAL_1N
, cache_terminal_mismatch_internal_1n_(NBPS, VVI(NBASES, VI(NBASES, -1)))
#endif
#if PARAMS_TERMINAL_MISMATCH_INTERNAL_23
, cache_terminal_mismatch_internal_23_(NBPS, VVI(NBASES, VI(NBASES, -1)))
#endif
#if PARAMS_TERMINAL_MISMATCH_MULTI
, cache_terminal_mismatch_multi_(NBPS, VVI(NBASES, VI(NBASES, -1)))
#endif
#if PARAMS_TERMINAL_MISMATCH_EXTERNAL
, cache_terminal_mismatch_external_(NBPS, VVI(NBASES, VI(NBASES, -1)))
#endif
#if PARAMS_HAIRPIN_LENGTH
, cache_hairpin_length_at_least_(D_MAX_HAIRPIN_LENGTH, -1)
#endif
#if PARAMS_HELIX_LENGTH
, cache_helix_length_at_least_(D_MAX_HELIX_LENGTH, -1)
#endif
#if PARAMS_ISOLATED_BASE_PAIR
, cache_isolated_base_pair_(-1)
#endif
#if PARAMS_INTERNAL_EXPLICIT
, cache_internal_explicit_(D_MAX_INTERNAL_EXPLICIT_LENGTH+1, VI(D_MAX_INTERNAL_EXPLICIT_LENGTH+1, -1))
#endif
#if PARAMS_BULGE_LENGTH
, cache_bulge_length_at_least_(D_MAX_BULGE_LENGTH, -1)
#endif
#if PARAMS_INTERNAL_LENGTH
, cache_internal_length_at_least_(D_MAX_INTERNAL_LENGTH, -1)
#endif
#if PARAMS_INTERNAL_SYMMETRY
, cache_internal_symmetric_length_at_least_(D_MAX_INTERNAL_SYMMETRIC_LENGTH, -1)
#endif
#if PARAMS_INTERNAL_ASYMMETRY
, cache_internal_asymmetry_at_least_(D_MAX_INTERNAL_ASYMMETRY, -1)
#endif
#if PARAMS_HELIX_STACKING
, cache_helix_stacking_(NBPS, VI(NBPS, -1))
#endif
#if PARAMS_HELIX_CLOSING
, cache_helix_closing_(NBPS, -1)
#endif
#if PARAMS_MULTI_LENGTH
, cache_multi_base_(-1)
, cache_multi_unpaired_(-1)
, cache_multi_paired_(-1)
#endif
#if PARAMS_DANGLE
, cache_dangle_left_(NBPS, VI(NBASES, -1))
, cache_dangle_right_(NBPS, VI(NBASES, -1))
#endif
#if PARAMS_EXTERNAL_LENGTH
, cache_external_unpaired_(-1)
, cache_external_paired_(-1)
#endif
#endif
{
std::fill(std::begin(is_base_), std::end(is_base_), -1);
for (size_t i=0; i!=def_bases_.size(); ++i)
is_base_[def_bases[i]] = i;
for (auto& e : is_complementary_)
std::fill(std::begin(e), std::end(e), -1);
for (size_t i=0; i!=def_bps_.size(); ++i)
is_complementary_[def_bps_[i][0]][def_bps_[i][1]] = i;
initialize_cache();
}
void
FeatureMap::
initialize_cache()
{
#ifdef USE_CACHE
#if PARAMS_BASE_PAIR
initialize_cache_base_pair();
#endif
#if PARAMS_BASE_PAIR_DIST
initialize_cache_base_pair_dist_at_least();
#endif
#if PARAMS_TERMINAL_MISMATCH
initialize_cache_terminal_mismatch();
#endif
#if PARAMS_TERMINAL_MISMATCH_HAIRPIN
initialize_cache_terminal_mismatch_hairpin();
#endif
#if PARAMS_TERMINAL_MISMATCH_INTERNAL
initialize_cache_terminal_mismatch_internal();
#endif
#if PARAMS_TERMINAL_MISMATCH_INTERNAL_1N
initialize_cache_terminal_mismatch_internal_1n();
#endif
#if PARAMS_TERMINAL_MISMATCH_INTERNAL_23
initialize_cache_terminal_mismatch_internal_23();
#endif
#if PARAMS_TERMINAL_MISMATCH_MULTI
initialize_cache_terminal_mismatch_multi();
#endif
#if PARAMS_TERMINAL_MISMATCH_EXTERNAL
initialize_cache_terminal_mismatch_external();
#endif
#if PARAMS_HAIRPIN_LENGTH
initialize_cache_hairpin_length_at_least();
#endif
#if PARAMS_HELIX_LENGTH
initialize_cache_helix_length_at_least();
#endif
#if PARAMS_ISOLATED_BASE_PAIR
initialize_cache_isolated_base_pair();
#endif
#if PARAMS_INTERNAL_EXPLICIT
initialize_cache_internal_explicit();
#endif
#if PARAMS_BULGE_LENGTH
initialize_cache_bulge_length_at_least();
#endif
#if PARAMS_INTERNAL_LENGTH
initialize_cache_internal_length_at_least();
#endif
#if PARAMS_INTERNAL_SYMMETRY
initialize_cache_internal_symmetric_length_at_least();
#endif
#if PARAMS_INTERNAL_ASYMMETRY
initialize_cache_internal_asymmetry_at_least();
#endif
#if PARAMS_HELIX_STACKING
initialize_cache_helix_stacking();
#endif
#if PARAMS_HELIX_CLOSING
initialize_cache_helix_closing();
#endif
#if PARAMS_MULTI_LENGTH
initialize_cache_multi_base();
initialize_cache_multi_unpaired();
initialize_cache_multi_paired();
#endif
#if PARAMS_DANGLE
initialize_cache_dangle_left();
initialize_cache_dangle_right();
#endif
#if PARAMS_EXTERNAL_LENGTH
initialize_cache_external_unpaired();
initialize_cache_external_paired();
#endif
#endif
}
size_t
FeatureMap::
find_key(const std::string& key) const
{
auto itr = hash_.find(key);
return itr != hash_.end() ? itr->second : -1u;
}
size_t
FeatureMap::
insert_key(const std::string& key)
{
auto r = hash_.emplace(key, keys_.size());
if (!r.second) return r.first->second;
auto k = key;
// symmetric features
if (key.find(s_internal_nucleotides) == 0)
{
size_t pos=key.find("_", s_internal_nucleotides.size());
std::string nuc1 = key.substr(s_internal_nucleotides.size(), pos-s_internal_nucleotides.size());
std::string nuc2 = key.substr(pos+1);
std::reverse(nuc1.begin(), nuc1.end());
std::reverse(nuc2.begin(), nuc2.end());
std::string key2 = s_internal_nucleotides + nuc2 + '_' + nuc1;
hash_[key2] = keys_.size();
if (k>key2) k = key2;
}
else if (key.find(s_base_pair) == 0 && key.size() == s_base_pair.size()+2)
{
const char nuc1 = key[s_base_pair.size()+0];
const char nuc2 = key[s_base_pair.size()+1];
std::string key2 = s_base_pair + nuc2 + nuc1;
hash_[key2] = keys_.size();
if (k>key2) k = key2;
}
else if (key.find(s_helix_stacking) == 0)
{
const char nuc1 = key[s_helix_stacking.size()+0];
const char nuc2 = key[s_helix_stacking.size()+1];
const char nuc3 = key[s_helix_stacking.size()+2];
const char nuc4 = key[s_helix_stacking.size()+3];
std::string key2 = s_helix_stacking + nuc4 + nuc3 + nuc2 + nuc1;
hash_[key2] = keys_.size();
if (k>key2) k = key2;
}
else if (key.find(s_internal_explicit) == 0)
{
size_t pos=key.find("_", s_internal_explicit.size());
std::string l1 = key.substr(s_internal_explicit.size(), pos-s_internal_explicit.size());
std::string l2 = key.substr(pos+1);
std::string key2 = s_internal_explicit + l2 + '_' + l1;
hash_[key2] = keys_.size();
if (k>key2) k = key2;
}
#ifdef PARAMS_VIENNA_COMPAT
else if (key.find(s_internal_nucleotides_int11) == 0)
{
const char nuc1 = key[s_internal_nucleotides_int11.size()+0];
const char nuc2 = key[s_internal_nucleotides_int11.size()+1];
const char nuc3 = key[s_internal_nucleotides_int11.size()+2];
const char nuc4 = key[s_internal_nucleotides_int11.size()+3];
const char nuc5 = key[s_internal_nucleotides_int11.size()+5];
const char nuc6 = key[s_internal_nucleotides_int11.size()+7];
std::string key2 = s_internal_nucleotides_int11 + nuc4 + nuc3 + nuc2 + nuc1 + '_' + nuc6 + '_' + nuc5;
hash_[key2] = keys_.size();
if (k>key2) k = key2;
}
else if (key.find(s_internal_nucleotides_int21) == 0)
{
const char nuc1 = key[s_internal_nucleotides_int21.size()+0];
const char nuc2 = key[s_internal_nucleotides_int21.size()+1];
const char nuc3 = key[s_internal_nucleotides_int21.size()+2];
const char nuc4 = key[s_internal_nucleotides_int21.size()+3];
const char nuc5 = key[s_internal_nucleotides_int21.size()+5];
const char nuc6 = key[s_internal_nucleotides_int21.size()+6];
const char nuc7 = key[s_internal_nucleotides_int21.size()+8];
std::string key2 = s_internal_nucleotides_int12 + nuc4 + nuc3 + nuc2 + nuc1 + '_' + nuc7 + '_' + nuc6 + nuc5;
hash_[key2] = keys_.size();
if (k>key2) k = key2;
}
else if (key.find(s_internal_nucleotides_int12) == 0)
{
const char nuc1 = key[s_internal_nucleotides_int12.size()+0];
const char nuc2 = key[s_internal_nucleotides_int12.size()+1];
const char nuc3 = key[s_internal_nucleotides_int12.size()+2];
const char nuc4 = key[s_internal_nucleotides_int12.size()+3];
const char nuc5 = key[s_internal_nucleotides_int12.size()+5];
const char nuc6 = key[s_internal_nucleotides_int12.size()+7];
const char nuc7 = key[s_internal_nucleotides_int12.size()+8];
std::string key2 = s_internal_nucleotides_int21 + nuc4 + nuc3 + nuc2 + nuc1 + '_' + nuc7 + nuc6 + '_' + nuc5;
hash_[key2] = keys_.size();
if (k>key2) k = key2;
}
else if (key.find(s_internal_nucleotides_int22) == 0)
{
const char nuc1 = key[s_internal_nucleotides_int22.size()+0];
const char nuc2 = key[s_internal_nucleotides_int22.size()+1];
const char nuc3 = key[s_internal_nucleotides_int22.size()+2];
const char nuc4 = key[s_internal_nucleotides_int22.size()+3];
const char nuc5 = key[s_internal_nucleotides_int22.size()+5];
const char nuc6 = key[s_internal_nucleotides_int22.size()+6];
const char nuc7 = key[s_internal_nucleotides_int22.size()+8];
const char nuc8 = key[s_internal_nucleotides_int22.size()+9];
std::string key2 = s_internal_nucleotides_int22 + nuc4 + nuc3 + nuc2 + nuc1 + '_' + nuc8 + nuc7 + '_' + nuc6 + nuc5;
hash_[key2] = keys_.size();
if (k>key2) k = key2;
}
#endif
keys_.push_back(k.c_str());
return keys_.size()-1;
}
size_t
FeatureMap::
insert_keyval(const std::string& key, std::vector<param_value_type>& vals, param_value_type v)
{
size_t i = insert_key(key);
if (i>=vals.size()) vals.resize(i+1, param_value_type(0.0));
vals[i] = v;
return i;
}
std::vector<param_value_type>
FeatureMap::
load_from_hash(const std::unordered_map<std::string, param_value_type>& h)
{
std::vector<param_value_type> vals;
hash_.clear();
keys_.clear();
initialize_cache() ;
for (auto e: h)
insert_keyval(e.first, vals, e.second);
return vals;
}
std::vector<param_value_type>
FeatureMap::
read_from_file(const std::string& filename)
{
std::vector<param_value_type> vals;
hash_.clear();
keys_.clear();
initialize_cache();
std::ifstream is(filename.c_str());
if (!is) throw std::runtime_error(std::string(strerror(errno)) + ": " + filename);
std::string k;
param_value_type v;
if (!std::isdigit(is.peek()))
{
while (is >> k >> v)
if (v!=0.0)
insert_keyval(k, vals, v);
}
else
{
// for reading AdaGradRDA outputs
float eta, lambda, eps, t, s1, s2;
is >> eta >> lambda >> eps >> t;
while (is >> k >> v >> s1 >> s2)
if (v!=0.0)
insert_keyval(k, vals, v);
}
return vals;
}
std::string
ignore_comment(const std::string& l)
{
size_t cp1 = l.find("/*");
if (cp1 == std::string::npos) return l;
size_t cp2 = l.find("*/");
if (cp2 == std::string::npos)
throw std::runtime_error("unclosed comment");
return l.substr(0, cp1)+l.substr(cp2+2);
}
std::vector<param_value_type>
get_array1(const std::string& l)
{
std::vector<param_value_type> ret;
std::istringstream is(ignore_comment(l));
std::string s;
while (is >> s)
{
if (s=="DEF")
ret.push_back(0.);
else if (s=="INF")
ret.push_back(NEG_INF);
else if (s=="NST")
ret.push_back(50/100.);
else
ret.push_back(-atoi(s.c_str())/100.);
}
return ret;
}
std::vector<param_value_type>
get_array(std::istream& is, size_t sz)
{
std::vector<param_value_type> v;
v.reserve(sz);
std::string l;
while (v.size() < sz && std::getline(is, l))
{
auto w = get_array1(l);
v.insert(v.end(), w.begin(), w.end());
}
return v;
}
std::pair<std::string, param_value_type>
get_loops(std::istream& is)
{
std::string line;
if (std::getline(is, line))
{
char loop[100];
int v, w;
if (sscanf(line.c_str(), "%s %d %d", loop, &v, &w)==3)
return std::make_pair(std::string(loop), -v/100.);
}
return std::pair<std::string, param_value_type>();
}
#ifdef PARAMS_VIENNA_COMPAT
std::vector<param_value_type>
FeatureMap::
import_from_vienna_parameters(const std::string& filename)
{
std::vector<param_value_type> vals;
hash_.clear();
keys_.clear();
std::ifstream is(filename.c_str());
if (!is) throw std::runtime_error(std::string(strerror(errno)) + ": " + filename);
std::string line;
std::getline(is, line);
if (line.compare(0, 30, "## RNAfold parameter file v2.0") != 0)
throw std::runtime_error(std::string("Invalid file format: ") + filename);
while (std::getline(is, line))
{
size_t pos = line.find("# ");
if (pos == 0) {
std::string ident = line.substr(pos+2);
if (ident == "stack")
{
auto v = get_array(is, (NBPS+1)*(NBPS+1));
for (size_t i=0, p=0; i!=NBPS+1; ++i)
for (size_t j=0; j!=NBPS+1; ++j, ++p)
if (i<NBPS && j<NBPS)
insert_keyval(s_helix_stacking+def_bps_[i]+def_bps_[j], vals, v[p]);
}
else if (ident == "mismatch_hairpin")
{
auto v = get_array(is, (NBPS+1)*(NBASES+1)*(NBASES+1));
for (size_t i=0, p=0; i!=NBPS+1; ++i)
for (size_t j=0; j!=NBASES+1; ++j)
for (size_t k=0; k!=NBASES+1; ++k, ++p)
if (i<NBPS && j!=0 && k!=0)
insert_keyval(s_terminal_mismatch_hairpin+def_bps_[i]+def_bases_[j-1]+def_bases_[k-1], vals, v[p]);
}
else if (ident == "mismatch_interior")
{
auto v = get_array(is, (NBPS+1)*(NBASES+1)*(NBASES+1));
for (size_t i=0, p=0; i!=NBPS+1; ++i)
for (size_t j=0; j!=NBASES+1; ++j)
for (size_t k=0; k!=NBASES+1; ++k, ++p)
if (i<NBPS && j!=0 && k!=0)
insert_keyval(s_terminal_mismatch_internal+def_bps_[i]+def_bases_[j-1]+def_bases_[k-1], vals, v[p]);
}
else if (ident == "mismatch_interior_1n")
{
auto v = get_array(is, (NBPS+1)*(NBASES+1)*(NBASES+1));
for (size_t i=0, p=0; i!=NBPS+1; ++i)
for (size_t j=0; j!=NBASES+1; ++j)
for (size_t k=0; k!=NBASES+1; ++k, ++p)
if (i<NBPS && j!=0 && k!=0)
insert_keyval(s_terminal_mismatch_internal_1n+def_bps_[i]+def_bases_[j-1]+def_bases_[k-1], vals, v[p]);
}
else if (ident == "mismatch_interior_23")
{
auto v = get_array(is, (NBPS+1)*(NBASES+1)*(NBASES+1));
for (size_t i=0, p=0; i!=NBPS+1; ++i)
for (size_t j=0; j!=NBASES+1; ++j)
for (size_t k=0; k!=NBASES+1; ++k, ++p)
if (i<NBPS && j!=0 && k!=0)
insert_keyval(s_terminal_mismatch_internal_23+def_bps_[i]+def_bases_[j-1]+def_bases_[k-1], vals, v[p]);
}
else if (ident == "mismatch_multi")
{
auto v = get_array(is, (NBPS+1)*(NBASES+1)*(NBASES+1));
for (size_t i=0, p=0; i!=NBPS+1; ++i)
for (size_t j=0; j!=NBASES+1; ++j)
for (size_t k=0; k!=NBASES+1; ++k, ++p)
if (i<NBPS && j!=0 && k!=0)
insert_keyval(s_terminal_mismatch_multi+def_bps_[i]+def_bases_[j-1]+def_bases_[k-1], vals, v[p]);
}
else if (ident == "mismatch_exterior")
{
auto v = get_array(is, (NBPS+1)*(NBASES+1)*(NBASES+1));
for (size_t i=0, p=0; i!=NBPS+1; ++i)
for (size_t j=0; j!=NBASES+1; ++j)
for (size_t k=0; k!=NBASES+1; ++k, ++p)
if (i<NBPS && j!=0 && k!=0)
insert_keyval(s_terminal_mismatch_external+def_bps_[i]+def_bases_[j-1]+def_bases_[k-1], vals, v[p]);
}
else if (ident == "dangle5")
{
auto v = get_array(is, (NBPS+1)*(NBASES+1));
for (size_t i=0, p=0; i!=NBPS+1; ++i)
for (size_t j=0; j!=NBASES+1; ++j, ++p)
if (i<NBPS && j!=0)
insert_keyval(s_dangle_left+def_bps_[i]+def_bases_[j-1], vals, v[p]);
}
else if (ident == "dangle3")
{
auto v = get_array(is, (NBPS+1)*(NBASES+1));
for (size_t i=0, p=0; i!=NBPS+1; ++i)
for (size_t j=0; j!=NBASES+1; ++j, ++p)
if (i<NBPS && j!=0)
insert_keyval(s_dangle_right+def_bps_[i]+def_bases_[j-1], vals, v[p]);
}
else if (ident == "int11")
{
auto v = get_array(is, (NBPS+1)*(NBPS+1)*(NBASES+1)*(NBASES+1));
for (size_t i=0, p=0; i!=NBPS+1; ++i)
for (size_t j=0; j!=NBPS+1; ++j)
for (size_t k=0; k!=NBASES+1; ++k)
for (size_t l=0; l!=NBASES+1; ++l, ++p)
if (i<NBPS && j<NBPS && k!=0 && l!=0)
insert_keyval(s_internal_nucleotides_int11+def_bps_[i]+def_bps_[j]+'_'+def_bases_[k-1]+'_'+def_bases_[l-1], vals, v[p]);
}
else if (ident == "int21")
{
auto v = get_array(is, (NBPS+1)*(NBPS+1)*(NBASES+1)*(NBASES+1)*(NBASES+1));
for (size_t i=0, p=0; i!=NBPS+1; ++i)
for (size_t j=0; j!=NBPS+1; ++j)
for (size_t k=0; k!=NBASES+1; ++k)
for (size_t l=0; l!=NBASES+1; ++l)
for (size_t m=0; m!=NBASES+1; ++m, ++p)
if (i<NBPS && j<NBPS && k!=0 && l!=0 && m!=0)
insert_keyval(s_internal_nucleotides_int21+def_bps_[i]+def_bps_[j]+'_'+def_bases_[k-1]+def_bases_[l-1]+'_'+def_bases_[m-1], vals, v[p]);
}
else if (ident == "int22")
{
auto v = get_array(is, NBPS*NBPS*NBASES*NBASES*NBASES*NBASES);
for (size_t i=0, p=0; i!=NBPS; ++i)
for (size_t j=0; j!=NBPS; ++j)
for (size_t k=0; k!=NBASES; ++k)
for (size_t l=0; l!=NBASES; ++l)
for (size_t m=0; m!=NBASES; ++m)
for (size_t n=0; n!=NBASES; ++n, ++p)
insert_keyval(s_internal_nucleotides_int22+def_bps_[i]+def_bps_[j]+'_'+def_bases_[k]+def_bases_[l]+'_'+def_bases_[m]+def_bases_[n], vals, v[p]);
}
else if (ident == "hairpin")
{
auto v = get_array(is, 31);
for (size_t i=0; i!=v.size(); ++i)
//insert_keyval(SPrintF(s_hairpin_length_at_least.c_str(), i), vals, i>0 && v[i-1]>=NEG_INF/2 ? v[i]-v[i-1] : v[i]);
insert_keyval(SPrintF(s_hairpin_length.c_str(), i), vals, v[i]);
}
else if (ident == "bulge")
{
auto v = get_array(is, 31);
for (size_t i=0; i!=v.size(); ++i)
//insert_keyval(SPrintF(s_bulge_length_at_least.c_str(), i), vals, i>0 && v[i-1]>=NEG_INF/2 ? v[i]-v[i-1] : v[i]);
insert_keyval(SPrintF(s_bulge_length.c_str(), i), vals, v[i]);
}
else if (ident == "interior")
{
auto v = get_array(is, 31);
for (size_t i=0; i!=v.size(); ++i)
//insert_keyval(SPrintF(s_internal_length_at_least.c_str(), i), vals, i>0 && v[i-1]>=NEG_INF/2 ? v[i]-v[i-1] : v[i]);
insert_keyval(SPrintF(s_internal_length.c_str(), i), vals, v[i]);
}
else if (ident == "NINIO")
{
auto v = get_array(is, 3);
insert_keyval(s_ninio, vals, v[0]);
insert_keyval(s_ninio_max, vals, v[2]);
}
else if (ident == "ML_params")
{
auto v = get_array(is, 6);
insert_keyval(s_multi_unpaired, vals, v[0]);
insert_keyval(s_multi_base, vals, v[2]);
insert_keyval(s_multi_paired, vals, v[4]);
}
else if (ident == "Misc")
{
auto v = get_array(is, 6);
insert_keyval(s_terminalAU, vals, v[2]);
}
else if (ident == "Triloops")
{
while (1)
{
auto v = get_loops(is);
if (v.first.empty()) break;
insert_keyval(s_triloop+v.first, vals, v.second);
}
}
else if (ident == "Tetraloops")
{
while (1)
{
auto v = get_loops(is);
if (v.first.empty()) break;
insert_keyval(s_tetraloop+v.first, vals, v.second);
}
}
else if (ident =="Hexaloops")
{
while (1)
{
auto v = get_loops(is);
if (v.first.empty()) break;
insert_keyval(s_hexaloop+v.first, vals, v.second);
}
}
}
}
initialize_cache();
return vals;
}
#endif
void
FeatureMap::
write_to_file(const std::string& filename, const std::vector<param_value_type>& vals) const
{
std::ofstream os(filename.c_str());
if (!os) throw std::runtime_error(std::string(strerror(errno)) + ": " + filename);
std::vector<size_t> idx(keys_.size());
std::iota(idx.begin(), idx.end(), 0);
std::sort(idx.begin(), idx.end(),
[&](size_t i, size_t j) { return keys_[i] < keys_[j]; });
for (auto i: idx)
if (std::abs(vals[i])>1e-20)
os << keys_[i] << " " << vals[i] << std::endl;
}
#if PARAMS_BASE_PAIR
void
FeatureMap::
initialize_cache_base_pair()
{
#ifdef USE_CACHE
for (auto bp : def_bps_)
cache_base_pair_[is_complementary_[bp[0]][bp[1]]] = insert_key(s_base_pair+bp[0]+bp[1]);
#endif
}
size_t
FeatureMap::
find_base_pair(NUCL i, NUCL j) const
{
#ifdef USE_CACHE
auto ij=is_complementary_[i][j];
if (ij>=0)
return cache_base_pair_[ij];
#endif
return find_key(s_base_pair+i+j);
}
size_t
FeatureMap::
insert_base_pair(NUCL i, NUCL j)
{
#ifdef USE_CACHE
auto ij=is_complementary_[i][j];
if (ij>=0)
return cache_base_pair_[ij];
#endif
return insert_key(s_base_pair+i+j);
}
#endif
#if PARAMS_BASE_PAIR_DIST
void
FeatureMap::
initialize_cache_base_pair_dist_at_least()
{
#ifdef USE_CACHE
for (size_t i=0; i!=cache_base_pair_dist_at_least_.size(); ++i)
cache_base_pair_dist_at_least_[i] = insert_key(SPrintF(s_base_pair_dist_at_least.c_str(), i));
#endif
}
size_t
FeatureMap::
find_base_pair_dist_at_least(uint l) const
{
#ifdef USE_CACHE
if (l<cache_base_pair_dist_at_least_.size())
return cache_base_pair_dist_at_least_[l];
#endif
return find_key(SPrintF(s_base_pair_dist_at_least.c_str(), l));
}
size_t
FeatureMap::
insert_base_pair_dist_at_least(uint l)
{
#ifdef USE_CACHE
if (l<cache_base_pair_dist_at_least_.size())
return cache_base_pair_dist_at_least_[l];
#endif
return insert_key(SPrintF(s_base_pair_dist_at_least.c_str(), l));
}
#endif
#if PARAMS_TERMINAL_MISMATCH
void
FeatureMap::
initialize_cache_terminal_mismatch()
{
#ifdef USE_CACHE
for (auto bp : def_bps_)
{
auto ij1 = is_complementary_[bp[0]][bp[1]];
for (auto i2: def_bases_)
{
auto ii2 = is_base_[i2];
for (auto j2: def_bases_)
{
auto jj2 = is_base_[j2];
cache_terminal_mismatch_[ij1][ii2][jj2] = insert_key(s_terminal_mismatch+bp+i2+j2);
}
}
}
#endif
}
size_t
FeatureMap::
find_terminal_mismatch(NUCL i1, NUCL j1, NUCL i2, NUCL j2) const
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_[ij1][ii2][jj2];
#endif
return find_key(s_terminal_mismatch+i1+j1+i2+j2);
}
size_t
FeatureMap::
insert_terminal_mismatch(NUCL i1, NUCL j1, NUCL i2, NUCL j2)
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_[ij1][ii2][jj2];
#endif
return insert_key(s_terminal_mismatch+i1+j1+i2+j2);
}
#endif
#if PARAMS_TERMINAL_MISMATCH_HAIRPIN
void
FeatureMap::
initialize_cache_terminal_mismatch_hairpin()
{
#ifdef USE_CACHE
for (auto bp : def_bps_)
{
auto ij1 = is_complementary_[bp[0]][bp[1]];
for (auto i2: def_bases_)
{
auto ii2 = is_base_[i2];
for (auto j2: def_bases_)
{
auto jj2 = is_base_[j2];
cache_terminal_mismatch_hairpin_[ij1][ii2][jj2] = insert_key(s_terminal_mismatch_hairpin+bp+i2+j2);
}
}
}
#endif
}
size_t
FeatureMap::
find_terminal_mismatch_hairpin(NUCL i1, NUCL j1, NUCL i2, NUCL j2) const
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_hairpin_[ij1][ii2][jj2];
#endif
return find_key(s_terminal_mismatch_hairpin+i1+j1+i2+j2);
}
size_t
FeatureMap::
insert_terminal_mismatch_hairpin(NUCL i1, NUCL j1, NUCL i2, NUCL j2)
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_hairpin_[ij1][ii2][jj2];
#endif
return insert_key(s_terminal_mismatch_hairpin+i1+j1+i2+j2);
}
#endif
#if PARAMS_TERMINAL_MISMATCH_INTERNAL
void
FeatureMap::
initialize_cache_terminal_mismatch_internal()
{
#ifdef USE_CACHE
for (auto bp : def_bps_)
{
auto ij1 = is_complementary_[bp[0]][bp[1]];
for (auto i2: def_bases_)
{
auto ii2 = is_base_[i2];
for (auto j2: def_bases_)
{
auto jj2 = is_base_[j2];
cache_terminal_mismatch_internal_[ij1][ii2][jj2] = insert_key(s_terminal_mismatch_internal+bp+i2+j2);
}
}
}
#endif
}
size_t
FeatureMap::
find_terminal_mismatch_internal(NUCL i1, NUCL j1, NUCL i2, NUCL j2) const
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_internal_[ij1][ii2][jj2];
#endif
return find_key(s_terminal_mismatch_internal+i1+j1+i2+j2);
}
size_t
FeatureMap::
insert_terminal_mismatch_internal(NUCL i1, NUCL j1, NUCL i2, NUCL j2)
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_internal_[ij1][ii2][jj2];
#endif
return insert_key(s_terminal_mismatch_internal+i1+j1+i2+j2);
}
#endif
#if PARAMS_TERMINAL_MISMATCH_INTERNAL_1N
void
FeatureMap::
initialize_cache_terminal_mismatch_internal_1n()
{
#ifdef USE_CACHE
for (auto bp : def_bps_)
{
auto ij1 = is_complementary_[bp[0]][bp[1]];
for (auto i2: def_bases_)
{
auto ii2 = is_base_[i2];
for (auto j2: def_bases_)
{
auto jj2 = is_base_[j2];
cache_terminal_mismatch_internal_1n_[ij1][ii2][jj2] = insert_key(s_terminal_mismatch_internal_1n+bp+i2+j2);
}
}
}
#endif
}
size_t
FeatureMap::
find_terminal_mismatch_internal_1n(NUCL i1, NUCL j1, NUCL i2, NUCL j2) const
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_internal_1n_[ij1][ii2][jj2];
#endif
return find_key(s_terminal_mismatch_internal_1n+i1+j1+i2+j2);
}
size_t
FeatureMap::
insert_terminal_mismatch_internal_1n(NUCL i1, NUCL j1, NUCL i2, NUCL j2)
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_internal_1n_[ij1][ii2][jj2];
#endif
return insert_key(s_terminal_mismatch_internal_1n+i1+j1+i2+j2);
}
#endif
#if PARAMS_TERMINAL_MISMATCH_INTERNAL_23
void
FeatureMap::
initialize_cache_terminal_mismatch_internal_23()
{
#ifdef USE_CACHE
for (auto bp : def_bps_)
{
auto ij1 = is_complementary_[bp[0]][bp[1]];
for (auto i2: def_bases_)
{
auto ii2 = is_base_[i2];
for (auto j2: def_bases_)
{
auto jj2 = is_base_[j2];
cache_terminal_mismatch_internal_23_[ij1][ii2][jj2] = insert_key(s_terminal_mismatch_internal_23+bp+i2+j2);
}
}
}
#endif
}
size_t
FeatureMap::
find_terminal_mismatch_internal_23(NUCL i1, NUCL j1, NUCL i2, NUCL j2) const
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_internal_23_[ij1][ii2][jj2];
#endif
return find_key(s_terminal_mismatch_internal_23+i1+j1+i2+j2);
}
size_t
FeatureMap::
insert_terminal_mismatch_internal_23(NUCL i1, NUCL j1, NUCL i2, NUCL j2)
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_internal_23_[ij1][ii2][jj2];
#endif
return insert_key(s_terminal_mismatch_internal_23+i1+j1+i2+j2);
}
#endif
#if PARAMS_TERMINAL_MISMATCH_MULTI
void
FeatureMap::
initialize_cache_terminal_mismatch_multi()
{
#ifdef USE_CACHE
for (auto bp : def_bps_)
{
auto ij1 = is_complementary_[bp[0]][bp[1]];
for (auto i2: def_bases_)
{
auto ii2 = is_base_[i2];
for (auto j2: def_bases_)
{
auto jj2 = is_base_[j2];
cache_terminal_mismatch_multi_[ij1][ii2][jj2] = insert_key(s_terminal_mismatch_multi+bp+i2+j2);
}
}
}
#endif
}
size_t
FeatureMap::
find_terminal_mismatch_multi(NUCL i1, NUCL j1, NUCL i2, NUCL j2) const
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_multi_[ij1][ii2][jj2];
#endif
return find_key(s_terminal_mismatch_multi+i1+j1+i2+j2);
}
size_t
FeatureMap::
insert_terminal_mismatch_multi(NUCL i1, NUCL j1, NUCL i2, NUCL j2)
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_multi_[ij1][ii2][jj2];
#endif
return insert_key(s_terminal_mismatch_multi+i1+j1+i2+j2);
}
#endif
#if PARAMS_TERMINAL_MISMATCH_EXTERNAL
void
FeatureMap::
initialize_cache_terminal_mismatch_external()
{
#ifdef USE_CACHE
for (auto bp : def_bps_)
{
auto ij1 = is_complementary_[bp[0]][bp[1]];
for (auto i2: def_bases_)
{
auto ii2 = is_base_[i2];
for (auto j2: def_bases_)
{
auto jj2 = is_base_[j2];
cache_terminal_mismatch_external_[ij1][ii2][jj2] = insert_key(s_terminal_mismatch_external+bp+i2+j2);
}
}
}
#endif
}
size_t
FeatureMap::
find_terminal_mismatch_external(NUCL i1, NUCL j1, NUCL i2, NUCL j2) const
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_external_[ij1][ii2][jj2];
#endif
return find_key(s_terminal_mismatch_external+i1+j1+i2+j2);
}
size_t
FeatureMap::
insert_terminal_mismatch_external(NUCL i1, NUCL j1, NUCL i2, NUCL j2)
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ii2 = is_base_[i2], jj2 = is_base_[j2];
if (ij1>=0 && ii2>=0 && jj2>=0)
return cache_terminal_mismatch_external_[ij1][ii2][jj2];
#endif
return insert_key(s_terminal_mismatch_external+i1+j1+i2+j2);
}
#endif
#if PARAMS_HAIRPIN_LENGTH
void
FeatureMap::
initialize_cache_hairpin_length_at_least()
{
#ifdef USE_CACHE
for (size_t i=0; i!=cache_hairpin_length_at_least_.size(); ++i)
cache_hairpin_length_at_least_[i] = insert_key(SPrintF(s_hairpin_length_at_least.c_str(), i));
#endif
}
size_t
FeatureMap::
find_hairpin_length_at_least(uint l) const
{
#ifdef USE_CACHE
if (l<cache_hairpin_length_at_least_.size())
return cache_hairpin_length_at_least_[l];
#endif
return find_key(SPrintF(s_hairpin_length_at_least.c_str(), l));
}
size_t
FeatureMap::
insert_hairpin_length_at_least(uint l)
{
#ifdef USE_CACHE
if (l<cache_hairpin_length_at_least_.size())
return cache_hairpin_length_at_least_[l];
#endif
return insert_key(SPrintF(s_hairpin_length_at_least.c_str(), l));
}
#endif
#if PARAMS_HAIRPIN_NUCLEOTIDES || PARAMS_HAIRPIN_3_NUCLEOTIDES || PARAMS_HAIRPIN_4_NUCLEOTIDES
size_t
FeatureMap::
find_hairpin_nucleotides(const std::vector<NUCL>& s, uint i, uint l) const
{
std::string h(l, ' ');
std::copy(&s[i], &s[i]+l, h.begin());
return find_key(s_hairpin_nucleotides + h);
}
size_t
FeatureMap::
insert_hairpin_nucleotides(const std::vector<NUCL>& s, uint i, uint l)
{
std::string h(l, ' ');
std::copy(&s[i], &s[i]+l, h.begin());
return insert_key(s_hairpin_nucleotides + h);
}
#endif
#if PARAMS_HELIX_LENGTH
void
FeatureMap::
initialize_cache_helix_length_at_least()
{
#ifdef USE_CACHE
for (size_t i=0; i!=cache_helix_length_at_least_.size(); ++i)
cache_helix_length_at_least_[i] = insert_key(SPrintF(s_helix_length_at_least.c_str(), i));
#endif
}
size_t
FeatureMap::
find_helix_length_at_least(uint l) const
{
#ifdef USE_CACHE
if (l<cache_helix_length_at_least_.size())
return cache_helix_length_at_least_[l];
#endif
return find_key(SPrintF(s_helix_length_at_least.c_str(), l));
}
size_t
FeatureMap::
insert_helix_length_at_least(uint l)
{
#ifdef USE_CACHE
if (l<cache_helix_length_at_least_.size())
return cache_helix_length_at_least_[l];
#endif
return insert_key(SPrintF(s_helix_length_at_least.c_str(), l));
}
#endif
#if PARAMS_ISOLATED_BASE_PAIR
void
FeatureMap::
initialize_cache_isolated_base_pair()
{
#ifdef USE_CACHE
cache_isolated_base_pair_ = insert_key(s_isolated_base_pair);
#endif
}
size_t
FeatureMap::
find_isolated_base_pair() const
{
#ifdef USE_CACHE
return cache_isolated_base_pair_;
#else
return find_key(s_isolated_base_pair);
#endif
}
size_t
FeatureMap::
insert_isolated_base_pair()
{
#ifdef USE_CACHE
return cache_isolated_base_pair_;
#else
return insert_key(s_isolated_base_pair);
#endif
}
#endif
#if PARAMS_INTERNAL_EXPLICIT
void
FeatureMap::
initialize_cache_internal_explicit()
{
#ifdef USE_CACHE
for (size_t i=0; i!=cache_internal_explicit_.size(); ++i)
for (size_t j=0; j!=cache_internal_explicit_[i].size(); ++j)
cache_internal_explicit_[i][j] = insert_key(SPrintF(s_internal_explicit.c_str(), i, j));
#endif
}
size_t
FeatureMap::
find_internal_explicit(uint i, uint j) const
{
#ifdef USE_CACHE
if (i<cache_internal_explicit_.size() && j<cache_internal_explicit_[i].size())
return cache_internal_explicit_[i][j];
#endif
return find_key(SPrintF(s_internal_explicit.c_str(), i, j));
}
size_t
FeatureMap::
insert_internal_explicit(uint i, uint j)
{
#ifdef USE_CACHE
if (i<cache_internal_explicit_.size() && j<cache_internal_explicit_[i].size())
return cache_internal_explicit_[i][j];
#endif
return insert_key(SPrintF(s_internal_explicit.c_str(), i, j));
}
#endif
#if PARAMS_BULGE_LENGTH
void
FeatureMap::
initialize_cache_bulge_length_at_least()
{
#ifdef USE_CACHE
for (size_t i=0; i!=cache_bulge_length_at_least_.size(); ++i)
cache_bulge_length_at_least_[i] = insert_key(SPrintF(s_bulge_length_at_least.c_str(), i));
#endif
}
size_t
FeatureMap::
find_bulge_length_at_least(uint l) const
{
#ifdef USE_CACHE
if (l<cache_bulge_length_at_least_.size())
return cache_bulge_length_at_least_[l];
#endif
return find_key(SPrintF(s_bulge_length_at_least.c_str(), l));
}
size_t
FeatureMap::
insert_bulge_length_at_least(uint l)
{
#ifdef USE_CACHE
if (l<cache_bulge_length_at_least_.size())
return cache_bulge_length_at_least_[l];
#endif
return insert_key(SPrintF(s_bulge_length_at_least.c_str(), l));
}
#endif
#if PARAMS_INTERNAL_LENGTH
void
FeatureMap::
initialize_cache_internal_length_at_least()
{
#ifdef USE_CACHE
for (size_t i=0; i!=cache_internal_length_at_least_.size(); ++i)
cache_internal_length_at_least_[i] = insert_key(SPrintF(s_internal_length_at_least.c_str(), i));
#endif
}
size_t
FeatureMap::
find_internal_length_at_least(uint l) const
{
#ifdef USE_CACHE
if (l<cache_internal_length_at_least_.size())
return cache_internal_length_at_least_[l];
#endif
return find_key(SPrintF(s_internal_length_at_least.c_str(), l));
}
size_t
FeatureMap::
insert_internal_length_at_least(uint l)
{
#ifdef USE_CACHE
if (l<cache_internal_length_at_least_.size())
return cache_internal_length_at_least_[l];
#endif
return insert_key(SPrintF(s_internal_length_at_least.c_str(), l));
}
#endif
#if PARAMS_INTERNAL_SYMMETRY
void
FeatureMap::
initialize_cache_internal_symmetric_length_at_least()
{
#ifdef USE_CACHE
for (size_t i=0; i!=cache_internal_symmetric_length_at_least_.size(); ++i)
cache_internal_symmetric_length_at_least_[i] = insert_key(SPrintF(s_internal_symmetric_length_at_least.c_str(), i));
#endif
}
size_t
FeatureMap::
find_internal_symmetric_length_at_least(uint l) const
{
#ifdef USE_CACHE
if (l<cache_internal_symmetric_length_at_least_.size())
return cache_internal_symmetric_length_at_least_[l];
#endif
return find_key(SPrintF(s_internal_symmetric_length_at_least.c_str(), l));
}
size_t
FeatureMap::
insert_internal_symmetric_length_at_least(uint l)
{
#ifdef USE_CACHE
if (l<cache_internal_symmetric_length_at_least_.size())
return cache_internal_symmetric_length_at_least_[l];
#endif
return insert_key(SPrintF(s_internal_symmetric_length_at_least.c_str(), l));
}
#endif
#if PARAMS_INTERNAL_ASYMMETRY
void
FeatureMap::
initialize_cache_internal_asymmetry_at_least()
{
#ifdef USE_CACHE
for (size_t i=0; i!=cache_internal_asymmetry_at_least_.size(); ++i)
cache_internal_asymmetry_at_least_[i] = insert_key(SPrintF(s_internal_asymmetry_at_least.c_str(), i));
#endif
}
size_t
FeatureMap::
find_internal_asymmetry_at_least(uint l) const
{
#ifdef USE_CACHE
if (l<cache_internal_asymmetry_at_least_.size())
return cache_internal_asymmetry_at_least_[l];
#endif
return find_key(SPrintF(s_internal_asymmetry_at_least.c_str(), l));
}
size_t
FeatureMap::
insert_internal_asymmetry_at_least(uint l)
{
#ifdef USE_CACHE
if (l<cache_internal_asymmetry_at_least_.size())
return cache_internal_asymmetry_at_least_[l];
#endif
return insert_key(SPrintF(s_internal_asymmetry_at_least.c_str(), l));
}
#endif
#if PARAMS_INTERNAL_NUCLEOTIDES || PARAMS_BULGE_0x1_NUCLEOTIDES || PARAMS_BULGE_0x2_NUCLEOTIDES || PARAMS_BULGE_0x3_NUCLEOTIDES || PARAMS_INTERNAL_1x1_NUCLEOTIDES || PARAMS_INTERNAL_1x2_NUCLEOTIDES || PARAMS_INTERNAL_2x2_NUCLEOTIDES
size_t
FeatureMap::
find_internal_nucleotides(const std::vector<NUCL>& s, uint i, uint l, uint j, uint m) const
{
std::string nuc(l+m+1, ' ');
auto x = std::copy(&s[i], &s[i+l], nuc.begin());
*(x++) = '_';
std::reverse_copy(&s[j-m+1], &s[j+1], x);
return find_key(s_internal_nucleotides + nuc);
}
size_t
FeatureMap::
insert_internal_nucleotides(const std::vector<NUCL>& s, uint i, uint l, uint j, uint m)
{
std::string nuc(l+m+1, ' ');
auto x = std::copy(&s[i], &s[i+l], nuc.begin());
*(x++) = '_';
std::reverse_copy(&s[j-m+1], &s[j+1], x);
return insert_key(s_internal_nucleotides + nuc);
}
#endif
#if PARAMS_HELIX_STACKING
void
FeatureMap::
initialize_cache_helix_stacking()
{
#ifdef USE_CACHE
for (auto bp1: def_bps_)
{
auto ij1 = is_complementary_[bp1[0]][bp1[1]];
for (auto bp2: def_bps_)
{
auto ij2 = is_complementary_[bp2[0]][bp2[1]];
cache_helix_stacking_[ij1][ij2] = insert_key(s_helix_stacking+bp1+bp2);
}
}
#endif
}
size_t
FeatureMap::
find_helix_stacking(NUCL i1, NUCL j1, NUCL i2, NUCL j2) const
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ij2 = is_complementary_[i2][j2];
if (ij1>=0 && ij2>=0)
return cache_helix_stacking_[ij1][ij2];
#endif
return find_key(s_helix_stacking+i1+j1+i2+j2);
}
size_t
FeatureMap::
insert_helix_stacking(NUCL i1, NUCL j1, NUCL i2, NUCL j2)
{
#ifdef USE_CACHE
auto ij1 = is_complementary_[i1][j1];
auto ij2 = is_complementary_[i2][j2];
if (ij1>=0 && ij2>=0)
return cache_helix_stacking_[ij1][ij2];
#endif
return insert_key(s_helix_stacking+i1+j1+i2+j2);
}
#endif
#if PARAMS_HELIX_CLOSING
void
FeatureMap::
initialize_cache_helix_closing()
{
#ifdef USE_CACHE
for (auto bp: def_bps_)
{
auto ij = is_complementary_[bp[0]][bp[1]];
cache_helix_closing_[ij] = insert_key(s_helix_closing+bp);
}
#endif
}
size_t
FeatureMap::
find_helix_closing(NUCL i, NUCL j) const
{
#ifdef USE_CACHE
auto ij=is_complementary_[i][j];
if (ij>=0)
return cache_helix_closing_[ij];
#endif
return find_key(s_helix_closing+i+j);
}
size_t
FeatureMap::
insert_helix_closing(NUCL i, NUCL j)
{
#ifdef USE_CACHE
auto ij=is_complementary_[i][j];
if (ij>=0)
return cache_helix_closing_[ij];
#endif
return insert_key(s_helix_closing+i+j);
}
#endif
#if PARAMS_MULTI_LENGTH
void
FeatureMap::
initialize_cache_multi_base()
{
#ifdef USE_CACHE
cache_multi_base_ = insert_key(s_multi_base);
#endif
}
size_t
FeatureMap::
find_multi_base() const
{
#ifdef USE_CACHE
return cache_multi_base_;
#else
return find_key(s_multi_base);
#endif
}
size_t
FeatureMap::
insert_multi_base()
{
#ifdef USE_CACHE
return cache_multi_base_;
#else
return insert_key(s_multi_base);
#endif
}
void
FeatureMap::
initialize_cache_multi_unpaired()
{
#ifdef USE_CACHE
cache_multi_unpaired_ = insert_key(s_multi_unpaired);
#endif
}
size_t
FeatureMap::
find_multi_unpaired() const
{
#ifdef USE_CACHE
return cache_multi_unpaired_;
#else
return find_key(s_multi_unpaired);
#endif
}
size_t
FeatureMap::
insert_multi_unpaired()
{
#ifdef USE_CACHE
return cache_multi_unpaired_;
#else
return insert_key(s_multi_unpaired);
#endif
}
void
FeatureMap::
initialize_cache_multi_paired()
{
#ifdef USE_CACHE
cache_multi_paired_ = insert_key(s_multi_paired);
#endif
}
size_t
FeatureMap::
find_multi_paired() const
{
#ifdef USE_CACHE
return cache_multi_paired_;
#else
return find_key(s_multi_paired);
#endif
}
size_t
FeatureMap::
insert_multi_paired()
{
#ifdef USE_CACHE
return cache_multi_paired_;
#else
return insert_key(s_multi_paired);
#endif
}
#endif
#if PARAMS_DANGLE
void
FeatureMap::
initialize_cache_dangle_left()
{
#ifdef USE_CACHE
for (auto bp: def_bps_)
{
auto ij = is_complementary_[bp[0]][bp[1]];
for (auto i2: def_bases_)
{
auto ii2 = is_base_[i2];
cache_dangle_left_[ij][ii2] = insert_key(s_dangle_left+bp+i2);
}
}
#endif
}
size_t
FeatureMap::
find_dangle_left(NUCL i1, NUCL j1, NUCL i2) const
{
#ifdef USE_CACHE
auto ij1=is_complementary_[i1][j1];
auto ii2=is_base_[i2];
if (ij1>=0 && ii2>=0)
return cache_dangle_left_[ij1][ii2];
#endif
return find_key(s_dangle_left+i1+j1+i2);
}
size_t
FeatureMap::
insert_dangle_left(NUCL i1, NUCL j1, NUCL i2)
{
#ifdef USE_CACHE
auto ij1=is_complementary_[i1][j1];
auto ii2=is_base_[i2];
if (ij1>=0 && ii2>=0)
return cache_dangle_left_[ij1][ii2];
#endif
return insert_key(s_dangle_left+i1+j1+i2);
}
void
FeatureMap::
initialize_cache_dangle_right()
{
#ifdef USE_CACHE
for (auto bp: def_bps_)
{
auto ij = is_complementary_[bp[0]][bp[1]];
for (auto j2: def_bases_)
{
auto jj2 = is_base_[j2];
cache_dangle_right_[ij][jj2] = insert_key(s_dangle_right+bp+j2);
}
}
#endif
}
size_t
FeatureMap::
find_dangle_right(NUCL i1, NUCL j1, NUCL j2) const
{
#ifdef USE_CACHE
auto ij1=is_complementary_[i1][j1];
auto jj2=is_base_[j2];
if (ij1>=0 && jj2>=0)
return cache_dangle_right_[ij1][jj2];
#endif
return find_key(s_dangle_right+i1+j1+j2);
}
size_t
FeatureMap::
insert_dangle_right(NUCL i1, NUCL j1, NUCL j2)
{
#ifdef USE_CACHE
auto ij1=is_complementary_[i1][j1];
auto jj2=is_base_[j2];
if (ij1>=0 && jj2>=0)
return cache_dangle_right_[ij1][jj2];
#endif
return insert_key(s_dangle_right+i1+j1+j2);
}
#endif
#if PARAMS_EXTERNAL_LENGTH
void
FeatureMap::
initialize_cache_external_unpaired()
{
#ifdef USE_CACHE
cache_external_unpaired_ = insert_key(s_external_unpaired);
#endif
}
size_t
FeatureMap::
find_external_unpaired() const
{
#ifdef USE_CACHE
return cache_external_unpaired_;
#else
return find_key(s_external_unpaired);
#endif
}
size_t
FeatureMap::
insert_external_unpaired()
{
#ifdef USE_CACHE
return cache_external_unpaired_;
#else
return insert_key(s_external_unpaired);
#endif
}
void
FeatureMap::
initialize_cache_external_paired()
{
#ifdef USE_CACHE
cache_external_paired_ = insert_key(s_external_paired);
#endif
}
size_t
FeatureMap::
find_external_paired() const
{
#ifdef USE_CACHE
return cache_external_paired_;
#else
return find_key(s_external_paired);
#endif
}
size_t
FeatureMap::
insert_external_paired()
{
#ifdef USE_CACHE
return cache_external_paired_;
#else
return insert_key(s_external_paired);
#endif
}
#endif
#if PARAMS_VIENNA_COMPAT
size_t
FeatureMap::
find_internal_loop_11(const std::vector<NUCL>& s1, const std::vector<NUCL>& s2) const
{
assert(s1.size()==3);
assert(s2.size()==3);
#if 0
auto bp1 = is_complementary_[s1.front()][s2.back()];
auto bp2 = is_complementary_[s1.back()][s2.front()];
auto i1 = is_base_[s1[1]];
auto j1 = is_base_[s2[1]];
if (bp1>=0 && bp2>=0 && i1>=0 && j1>=0)
return cache_internal_loop_11_[bp1][bp2][i1][j1];
#endif
return find_key(s_internal_nucleotides_int11+s1.front()+s2.back()+s1.back()+s2.front()+'_'+s1[1]+'_'+s2[1]);
}
size_t
FeatureMap::
find_internal_loop_21(const std::vector<NUCL>& s1, const std::vector<NUCL>& s2) const
{
assert(s1.size()==4);
assert(s2.size()==3);
#if 0
auto bp1 = is_complementary_[s1.front()][s2.back()];
auto bp2 = is_complementary_[s1.back()][s2.front()];
auto i1 = is_base_[s1[1]];
auto i2 = is_base_[s1[2]];
auto j1 = is_base_[s2[1]];
if (bp1>=0 && bp2>=0 && i1>=0 && i2>=0 && j1>=0)
return cache_internal_loop_21_[bp1][bp2][i1][i2][j1];
#endif
return find_key(s_internal_nucleotides_int21+s1.front()+s2.back()+s1.back()+s2.front()+'_'+s1[1]+s1[2]+'_'+s2[1]);
}
size_t
FeatureMap::
find_internal_loop_12(const std::vector<NUCL>& s1, const std::vector<NUCL>& s2) const
{
assert(s1.size()==3);
assert(s2.size()==4);
#if 0
auto bp1 = is_complementary_[s1.front()][s2.back()];
auto bp2 = is_complementary_[s1.back()][s2.front()];
auto i1 = is_base_[s1[1]];
auto j1 = is_base_[s2[1]];
auto j2 = is_base_[s2[2]];
if (bp1>=0 && bp2>=0 && i1>=0 && j1>=0 && j2>=0 )
return cache_internal_loop_12_[bp1][bp2][i1][j1][j2];
#endif
return find_key(s_internal_nucleotides_int12+s1.front()+s2.back()+s1.back()+s2.front()+'_'+s1[1]+'_'+s2[1]+s2[2]);
}
size_t
FeatureMap::
find_internal_loop_22(const std::vector<NUCL>& s1, const std::vector<NUCL>& s2) const
{
assert(s1.size()==4);
assert(s2.size()==4);
#if 0
auto bp1 = is_complementary_[s1.front()][s2.back()];
auto bp2 = is_complementary_[s1.back()][s2.front()];
auto i1 = is_base_[s1[1]];
auto i2 = is_base_[s1[2]];
auto j1 = is_base_[s2[1]];
auto j2 = is_base_[s2[2]];
if (bp1>=0 && bp2>=0 && i1>=0 && i2>=0 && j1>=0 && j2>=0 )
return cache_internal_loop_22_[bp1][bp2][i1][i2][j1][j2];
#endif
return find_key(s_internal_nucleotides_int22+s1.front()+s2.back()+s1.back()+s2.front()+'_'+s1[1]+s1[2]+'_'+s2[1]+s2[2]);
}
#ifdef PARAMS_VIENNA_COMPAT
#if 0
void
FeatureMap::
initialize_cache_ninio()
{
#ifdef USE_CACHE
cache_ninio_ = insert_key(s_ninio);
#endif
}
#endif
size_t
FeatureMap::
find_ninio() const
{
#if 0
return cache_ninio_;
#else
return find_key(s_ninio);
#endif
}
#if 0
void
FeatureMap::
initialize_cache_ninio_max()
{
#ifdef USE_CACHE
cache_ninio_max_ = insert_key(s_ninio_max);
#endif
}
#endif
size_t
FeatureMap::
find_ninio_max() const
{
#if 0
return cache_ninio_max_;
#else
return find_key(s_ninio_max);
#endif
}
#if 0
void
FeatureMap::
initialize_cache_terminalAU()
{
#ifdef USE_CACHE
cache_terminalAU_ = insert_key(s_terminalAU);
#endif
}
#endif
size_t
FeatureMap::
find_terminalAU() const
{
#if 0
return cache_terminalAU_;
#else
return find_key(s_terminalAU);
#endif
}
#endif
#endif
| 26.478769 | 232 | 0.694103 | [
"vector"
] |
a2981428e414ab91d3715a5e74a5d5fb015365ba | 1,079 | cpp | C++ | paradigms/binary_search/33_search-in-rotated-sorted-array.cpp | b1tank/leetcode | 0b71eb7a4f52291ff072b1280d6b76e68f7adfee | [
"MIT"
] | null | null | null | paradigms/binary_search/33_search-in-rotated-sorted-array.cpp | b1tank/leetcode | 0b71eb7a4f52291ff072b1280d6b76e68f7adfee | [
"MIT"
] | null | null | null | paradigms/binary_search/33_search-in-rotated-sorted-array.cpp | b1tank/leetcode | 0b71eb7a4f52291ff072b1280d6b76e68f7adfee | [
"MIT"
] | null | null | null | // Author: b1tank
// Email: b1tank@outlook.com
//=================================
/*
33_search-in-rotated-sorted-array LeetCode
Solution:
- empty array check
*/
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class Solution {
public:
int search(vector<int>& nums, int target) {
int s = nums.size();
int l = 0;
int r = s - 1;
while (l < r) {
int mid = l + (r - l) / 2;
if (nums[mid] == target) {
return mid;
} else if (nums[mid] > nums[r]) {
if (target >= nums[l] && target < nums[mid]) {
r = mid;
} else {
l = mid + 1;
}
} else if (nums[mid] < nums[r]) {
if (target > nums[mid] && target <= nums[r]) {
l = mid + 1;
} else {
r = mid;
}
}
}
return s > 0 && nums[l] == target ? l : -1;
}
}; | 24.522727 | 63 | 0.370714 | [
"vector"
] |
a298e28b57df43b33c328bd1531b9aa101c6f2d8 | 16,129 | ipp | C++ | include/fvm/implementation/component/MassKernels.ipp | thorbenlouw/CUP-CFD | d06f7673a1ed12bef24de4f1b828ef864fa45958 | [
"MIT"
] | 3 | 2021-06-24T10:20:12.000Z | 2021-07-18T14:43:19.000Z | include/fvm/implementation/component/MassKernels.ipp | thorbenlouw/CUP-CFD | d06f7673a1ed12bef24de4f1b828ef864fa45958 | [
"MIT"
] | 2 | 2021-07-22T15:31:03.000Z | 2021-07-28T14:27:28.000Z | include/fvm/implementation/component/MassKernels.ipp | thorbenlouw/CUP-CFD | d06f7673a1ed12bef24de4f1b828ef864fa45958 | [
"MIT"
] | 1 | 2021-07-22T15:24:24.000Z | 2021-07-22T15:24:24.000Z | /*
* @file
* @author University of Warwick
* @version 1.0
*
* @section LICENSE
* These kernels were ported/derived to C++ from Dolfyn:
* Copyright 2003-2009 Henk Krus, Cyclone Fluid Dynamics BV
* 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.dolfyn.net/license.html
*
* 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.
*
*
* @section DESCRIPTION
*
* Contains header level definitions for the Finite Volume Mass Operations
*/
#ifndef CUPCFD_FVM_MASS_IPP_H
#define CUPCFD_FVM_MASS_IPP_H
namespace cupcfd
{
namespace fvm
{
template <class M, class I, class T, class L>
cupcfd::error::eCodes FluxMassDolfynFaceLoop(cupcfd::geometry::mesh::UnstructuredMeshInterface<M,I,T,L>& mesh,
cupcfd::geometry::euclidean::EuclideanVector<T,3> * dudx, I nDudx,
cupcfd::geometry::euclidean::EuclideanVector<T,3> * dvdx, I nDvdx,
cupcfd::geometry::euclidean::EuclideanVector<T,3> * dwdx, I nDwdx,
cupcfd::geometry::euclidean::EuclideanVector<T,3> * dpdx, I nDpdx,
T * denCell, I nDenCell,
T * denBoundary, I nDenBoundary,
T * uCell, I nUCell,
T * vCell, I nVCell,
T * wCell, I nWCell,
T * massFlux, I nMassFlux,
T * p, I nP,
T * ar, I nAr,
T * su, I nSu,
T * rface, I nRFace,
T small,
I * icinl,
I * icout,
I * icsym,
I * icwal,
bool solveTurbEnergy,
bool solveTurbDiss,
bool solveVisc,
bool solveEnthalpy,
T * teCell, I nTeCell,
T * teBoundary, I nTeBoundary,
T * edCell, I nEdCell,
T * edBoundary, I nEdBoundary,
T * viseffCell, I nViseffCell,
T * viseffBoundary, I nViseffBoundary,
T * tCell, I nTCell,
T * tBoundary, I nTBoundary) {
I ip, in, ib, ir;
T facn, facp;
T denf;
cupcfd::geometry::euclidean::EuclideanVector<T,3> dudxac;
cupcfd::geometry::euclidean::EuclideanVector<T,3> dvdxac;
cupcfd::geometry::euclidean::EuclideanVector<T,3> dwdxac;
cupcfd::geometry::euclidean::EuclideanPoint<T,3> xface;
cupcfd::geometry::euclidean::EuclideanVector<T,3> delta;
cupcfd::geometry::euclidean::EuclideanVector<T,3> xnorm;
cupcfd::geometry::euclidean::EuclideanVector<T,3> xpn;
cupcfd::geometry::euclidean::EuclideanVector<T,3> xpn2;
cupcfd::geometry::mesh::RType it;
cupcfd::geometry::euclidean::EuclideanPoint<T,3> xac;
cupcfd::geometry::euclidean::EuclideanVector<T,3> uIn;
cupcfd::geometry::euclidean::EuclideanPoint<T,3> xpac;
cupcfd::geometry::euclidean::EuclideanPoint<T,3> xnac;
cupcfd::geometry::euclidean::EuclideanVector<T,3> delp;
cupcfd::geometry::euclidean::EuclideanVector<T,3> deln;
cupcfd::geometry::euclidean::EuclideanVector<T,3> norm;
T uFace, vFace, wFace;
T pip, pin;
T apv1, apv2, apv, fact, factv;
T dpx, dpy, dpz;
T dens;
for(int i = 0; i < mesh.properties.lFaces; i++) {
ip = mesh.getFaceCell1ID(i);
in = mesh.getFaceCell2ID(i);
bool isBoundary = mesh.getFaceIsBoundary(i);
#ifdef DEBUG
if (i >= nMassFlux) {
return cupcfd::error::E_INVALID_INDEX;
}
#endif
if(!isBoundary) {
#ifdef DEBUG
if (in >= nDudx || ip >= nDudx) {
return cupcfd::error::E_INVALID_INDEX;
}
if (in >= nDvdx || ip >= nDvdx) {
return cupcfd::error::E_INVALID_INDEX;
}
if (in >= nDwdx || ip >= nDwdx) {
return cupcfd::error::E_INVALID_INDEX;
}
if (in >= nDpdx || ip >= nDpdx) {
return cupcfd::error::E_INVALID_INDEX;
}
if (in >= nDenCell || ip >= nDenCell) {
return cupcfd::error::E_INVALID_INDEX;
}
if (in >= nUCell || ip >= nUCell) {
return cupcfd::error::E_INVALID_INDEX;
}
if (in >= nVCell || ip >= nVCell) {
return cupcfd::error::E_INVALID_INDEX;
}
if (in >= nWCell || ip >= nWCell) {
return cupcfd::error::E_INVALID_INDEX;
}
if (in >= nP || ip >= nP) {
return cupcfd::error::E_INVALID_INDEX;
}
if (in >= nAr || ip >= nAr) {
return cupcfd::error::E_INVALID_INDEX;
}
#endif
facn = mesh.getFaceLambda(i);
facp = 1.0 - facn;
dudxac = dudx[in] * facn + dudx[ip] * facp;
dvdxac = dvdx[in] * facn + dvdx[ip] * facp;
dwdxac = dwdx[in] * facn + dwdx[ip] * facp;
denf = denCell[in] * facn + denCell[ip] * facp;
xac = mesh.getCellCenter(in) * facn + mesh.getCellCenter(ip) * facp;
xface = mesh.getFaceCenter(i);
delta = xface - xac;
uFace = uCell[in]*facn + uCell[ip]*facp + dudxac.dotProduct(delta);
vFace = vCell[in]*facn + vCell[ip]*facp + dvdxac.dotProduct(delta);
wFace = wCell[in]*facn + wCell[ip]*facp + dwdxac.dotProduct(delta);
massFlux[i] = denf * (uFace * mesh.getFaceNorm(i).cmp[0] +
vFace * mesh.getFaceNorm(i).cmp[1] +
wFace * mesh.getFaceNorm(i).cmp[2]);
xnorm = mesh.getFaceNorm(i);
xnorm.normalise();
xpac = mesh.getFaceXpac(i);
xnac = mesh.getFaceXnac(i);
delp = xpac - mesh.getCellCenter(ip);
pip = p[ip] + dpdx[ip].dotProduct(delp);
deln = xpac - mesh.getCellCenter(in);
pin = p[in] + dpdx[ip].dotProduct(deln);
xpn = xnac - xpac;
xpn2 = mesh.getCellCenter(in) - mesh.getCellCenter(ip);
apv1 = denCell[ip] * ar[ip];
apv2 = denCell[in] * ar[in];
apv = apv2 * facn + apv1 * facp;
factv = mesh.getCellVolume(in) * facn + mesh.getCellVolume(ip) * facp;
apv *= mesh.getFaceArea(i) * factv/xpn2.dotProduct(xnorm);
dpx = (dpdx[in].cmp[0] * facn + dpdx[ip].cmp[0] * facp) * xpn.cmp[0];
dpy = (dpdx[in].cmp[1] * facn + dpdx[ip].cmp[1] * facp) * xpn.cmp[1];
dpz = (dpdx[in].cmp[2] * facn + dpdx[ip].cmp[2] * facp) * xpn.cmp[2];
fact = apv;
#ifdef DEBUG
if ( ((i*2)+1) >= nRFace) {
return cupcfd::error::E_INVALID_INDEX;
}
#endif
rface[(i*2)] = -fact;
rface[(i*2)+1] = -fact;
massFlux[i] = massFlux[i] - fact * ((pin-pip) - dpx - dpy - dpz);
}
else {
ip = mesh.getFaceCell1ID(i);
ib = mesh.getFaceBoundaryID(i);
ir = mesh.getBoundaryRegionID(ib);
it = mesh.getRegionType(ir);
#ifdef DEBUG
if (ip >= nSu) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ip >= nUCell) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ip >= nVCell) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ip >= nWCell) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ip >= nDenCell) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ib >= nDenBoundary) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ib >= nTeBoundary) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ib >= nTeCell) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ib >= nEdBoundary) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ib >= nViseffBoundary) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ib >= nTBoundary) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ip >= nEdCell) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ip >= nViseffCell) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ip >= nTCell) {
return cupcfd::error::E_INVALID_INDEX;
}
#endif
if(it == cupcfd::geometry::mesh::RTYPE_INLET) {
*icinl = *icinl + 1;
xac = mesh.getFaceCenter(i);
// Ignoring User Option
uIn = mesh.getRegionUVW(ir);
dens = mesh.getRegionDen(ir);
norm = mesh.getFaceNorm(i);
massFlux[i] = dens * uIn.dotProduct(norm);
su[ip] = su[ip] - massFlux[i];
}
else if(it == cupcfd::geometry::mesh::RTYPE_OUTLET) {
*icout = *icout + 1;
delta = mesh.getFaceCenter(i) - mesh.getCellCenter(ip);
uFace = uCell[ip];
vFace = vCell[ip];
wFace = wCell[ip];
denf = denCell[ip];
denBoundary[ib] = denf;
norm = mesh.getFaceNorm(i);
massFlux[i] = denf * (uFace * norm.cmp[0] +
vFace * norm.cmp[1] +
wFace * norm.cmp[2]);
if(massFlux[i] < 0.0) {
massFlux[i] = small;
if(solveTurbEnergy) {
teBoundary[ib] = teCell[ip];
}
if(solveTurbDiss) {
edBoundary[ib] = edCell[ip];
}
if(solveVisc) {
viseffBoundary[ib] = viseffCell[ip];
}
if(solveEnthalpy) {
tBoundary[ib] = tCell[ip];
}
// Skip SolveScalars
}
}
else if(it == cupcfd::geometry::mesh::RTYPE_SYMP) {
*icsym = *icsym + 1;
massFlux[i] = 0.0;
}
else if(it == cupcfd::geometry::mesh::RTYPE_WALL) {
*icwal = *icwal + 1;
massFlux[i] = 0.0;
}
}
}
return cupcfd::error::E_SUCCESS;
}
template <class M, class I, class T, class L>
cupcfd::error::eCodes FluxMassDolfynBoundaryLoop1(cupcfd::geometry::mesh::UnstructuredMeshInterface<M,I,T,L>& mesh,
T * massFlux, I nMassFlux,
T * flowin) {
cupcfd::geometry::mesh::RType it;
I ib, ir, i;
*flowin = 0.0;
for(ib = 0; ib < mesh.properties.lBoundaries; ib++) {
ir = mesh.getBoundaryRegionID(ib);
it = mesh.getRegionType(ir);
if(it == cupcfd::geometry::mesh::RTYPE_INLET) {
i = mesh.getBoundaryFaceID(ib);
#ifdef DEBUG
if (i >= nMassFlux) {
return cupcfd::error::E_INVALID_INDEX;
}
#endif
*flowin = *flowin + massFlux[i];
}
}
return cupcfd::error::E_SUCCESS;
}
template <class M, class I, class T, class L>
cupcfd::error::eCodes FluxMassDolfynBoundaryLoop2(cupcfd::geometry::mesh::UnstructuredMeshInterface<M,I,T,L>& mesh,
T * massFlux, I nMassFlux,
T * flowRegion, I nFlowRegion,
T * flowout) {
cupcfd::geometry::mesh::RType it;
I ib, ir, i;
*flowout = 0.0;
for(ib = 0; ib < mesh.properties.lBoundaries; ib++) {
ir = mesh.getBoundaryRegionID(ib);
it = mesh.getRegionType(ir);
if(it == cupcfd::geometry::mesh::RTYPE_OUTLET) {
i = mesh.getBoundaryFaceID(ib);
#ifdef DEBUG
if (i >= nMassFlux) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ir >= nFlowRegion) {
return cupcfd::error::E_INVALID_INDEX;
}
#endif
*flowout = *flowout + massFlux[i];
flowRegion[ir] = flowRegion[ir] + massFlux[i];
}
}
return cupcfd::error::E_SUCCESS;
}
template <class M, class I, class T, class L>
cupcfd::error::eCodes FluxMassDolfynBoundaryLoop3(cupcfd::geometry::mesh::UnstructuredMeshInterface<M,I,T,L>& mesh,
T flowin, T * ratearea) {
cupcfd::geometry::mesh::RType it;
T areaout;
I ib, ir, i;
areaout = 0.0;
for(ib = 0; ib < mesh.properties.lBoundaries; ib++) {
ir = mesh.getBoundaryRegionID(ib);
it = mesh.getRegionType(ir);
if(it == cupcfd::geometry::mesh::RTYPE_OUTLET) {
i = mesh.getBoundaryFaceID(ib);
areaout = areaout + mesh.getFaceArea(i);
}
}
*ratearea = -flowin/areaout;
return cupcfd::error::E_SUCCESS;
}
template <class M, class I, class T, class L>
cupcfd::error::eCodes FluxMassDolfynBoundaryLoop4(cupcfd::geometry::mesh::UnstructuredMeshInterface<M,I,T,L>& mesh,
T * massFlux, I nMassFlux,
T * uBoundary, I nUBoundary,
T * vBoundary, I nVboundary,
T * wBoundary, I nWBoundary,
T * denBoundary, I nDenBoundary,
T ratearea,
T * flowout) {
cupcfd::geometry::mesh::RType it;
cupcfd::geometry::euclidean::EuclideanVector<T,3> xnorm;
I ib,ir, i;
T split;
T faceFlux;
*flowout = 0.0;
for(ib = 0; ib < mesh.properties.lBoundaries; ib++) {
ir = mesh.getBoundaryRegionID(ib);
it = mesh.getRegionType(ir);
if(it == cupcfd::geometry::mesh::RTYPE_OUTLET) {
i = mesh.getBoundaryFaceID(ib);
#ifdef DEBUG
if (i >= nMassFlux) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ib >= nUBoundary) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ib >= nVboundary) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ib >= nWBoundary) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ib >= nDenBoundary) {
return cupcfd::error::E_INVALID_INDEX;
}
#endif
split = mesh.getRegionSplvl(ir);
massFlux[i] = ratearea * mesh.getFaceArea(i) * split;
faceFlux = massFlux[i]/denBoundary[ib]/mesh.getFaceArea(i);
xnorm = mesh.getFaceNorm(i);
xnorm.normalise();
uBoundary[ib] = faceFlux * xnorm.cmp[0];
vBoundary[ib] = faceFlux * xnorm.cmp[1];
wBoundary[ib] = faceFlux * xnorm.cmp[2];
*flowout = *flowout + massFlux[i];
}
}
return cupcfd::error::E_SUCCESS;
}
template <class M, class I, class T, class L>
cupcfd::error::eCodes FluxMassDolfynBoundaryLoop5(cupcfd::geometry::mesh::UnstructuredMeshInterface<M,I,T,L>& mesh,
T * massFlux, I nMassFlux,
T * su, I nSu,
T * uBoundary, I nUBoundary,
T * vBoundary, I nVBoundary,
T * wBoundary, I nWBoundary,
T fact, bool solveU, bool solveV, bool solveW,
T * flowFact, I nFlowFact,
T * flowout2) {
cupcfd::geometry::mesh::RType it;
I ib, ir;
for(ib = 0; ib < mesh.properties.lBoundaries; ib++) {
ir = mesh.getBoundaryRegionID(ib);
it = mesh.getRegionType(ir);
if(it == cupcfd::geometry::mesh::RTYPE_OUTLET) {
I i = mesh.getBoundaryFaceID(ib);
#ifdef DEBUG
if (i >= nMassFlux) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ir >= nFlowFact) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ib >= nUBoundary) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ib >= nVBoundary) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ib >= nWBoundary) {
return cupcfd::error::E_INVALID_INDEX;
}
#endif
massFlux[i] = massFlux[i] * flowFact[ir];
*flowout2 = *flowout2 + massFlux[i];
if(solveU) {
uBoundary[ib] = uBoundary[ib] * fact;
}
if(solveV) {
vBoundary[ib] = vBoundary[ib] * fact;
}
if(solveW) {
wBoundary[ib] = wBoundary[ib] * fact;
}
int ip = mesh.getFaceCell1ID(i);
#ifdef DEBUG
if (ip >= nSu) {
return cupcfd::error::E_INVALID_INDEX;
}
#endif
su[ip] = su[ip] - massFlux[i];
}
}
return cupcfd::error::E_SUCCESS;
}
template <class M, class I, class T, class L>
cupcfd::error::eCodes FluxMassDolfynRegionLoop(cupcfd::geometry::mesh::UnstructuredMeshInterface<M,I,T,L>& mesh,
T * flowFact, I nFlowFact,
T * flowRegion, I nFlowRegion,
T flowIn) {
cupcfd::geometry::mesh::RType it;
T split;
I nRegions = mesh.properties.lRegions;
for(I ir = 0; ir < nRegions; ir++) {
it = mesh.getRegionType(ir);
#ifdef DEBUG
if (ir >= nFlowFact) {
return cupcfd::error::E_INVALID_INDEX;
}
if (ir >= nFlowRegion) {
return cupcfd::error::E_INVALID_INDEX;
}
#endif
if(it == cupcfd::geometry::mesh::RTYPE_OUTLET) {
split = mesh.getRegionSplvl(ir);
flowFact[ir] = -(split * flowIn) / flowRegion[ir];
}
else {
flowFact[ir] = 0.0;
}
}
return cupcfd::error::E_SUCCESS;
}
}
}
#endif
| 28.853309 | 117 | 0.579577 | [
"mesh",
"geometry"
] |
9470b69812f3397a0190ed4a44b0c9d6db27eb63 | 3,209 | cpp | C++ | LivingPeople.cpp | ashwinrs/Shine | 026489d8a8124dc88c33c7220b04ec41c3161878 | [
"MIT"
] | null | null | null | LivingPeople.cpp | ashwinrs/Shine | 026489d8a8124dc88c33c7220b04ec41c3161878 | [
"MIT"
] | null | null | null | LivingPeople.cpp | ashwinrs/Shine | 026489d8a8124dc88c33c7220b04ec41c3161878 | [
"MIT"
] | null | null | null | /*
Problem Type - Two array if else method
Problem from - Cracking the coding interview. Moderate 16.10
Living People: Given an array of people with birth year and death year, find the max number of year the people were alive.
algorithm: sort the birth year and death year. Add 1 when a birth happens, subtract 1 when a death happens.
Run time = O(P log P) where P is the array of people
Command to run - g++ -std=c++11 LivingPeople.cpp
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class People{
public:
unsigned int birth_year;
unsigned int death_year;
People(unsigned int birth_year, unsigned int death_year){
this->birth_year = birth_year;
this->death_year = death_year;
}
};
bool less_than_birth_year(const People& people1, const People& people2){
return (people1.birth_year < people2.birth_year);
}
bool less_than_death_year (const People& people1, const People& people2){
return (people1.death_year < people2.death_year);
}
class Solution{
vector<unsigned int> getArray(vector<People> people, bool isBirth){
vector<unsigned int> result;
result.reserve(people.size());
if(isBirth){
//use transform with lambda function
transform(people.begin(), people.end(), back_inserter(result),[](const People& p) { return p.birth_year; });
}else{
//use transform with lambda function
transform(people.begin(), people.end(), back_inserter(result),[](const People& p) { return p.death_year; });
}
return result;
}
public:
int getYearWithMaxPeopleAlive(vector<People> people){
sort(people.begin(), people.end(), less_than_birth_year);
vector<unsigned int> sorted_by_birth = getArray(people, true);
sort(people.begin(), people.end(), less_than_death_year);
vector<unsigned int> sorted_by_death = getArray(people,false);
int max_people_alive = 0;
int max_people_alive_year = 0;
int running_max_people_alive = 0;
int birth_year_index = 0;
int death_year_index = 0;
//write the crux here
while( birth_year_index < sorted_by_birth.size()){
if(sorted_by_birth[birth_year_index] <= sorted_by_death[death_year_index]){
running_max_people_alive++;
if(running_max_people_alive > max_people_alive){
max_people_alive = running_max_people_alive;
max_people_alive_year = sorted_by_birth[birth_year_index];
}
birth_year_index++;
}else{
running_max_people_alive--;
death_year_index++;
}
}
return max_people_alive_year;
}
};
int main(){
vector<People> peoples;
peoples.push_back(People(9,76));
peoples.push_back(People(23,66));
peoples.push_back(People(13,93));
Solution s;
cout << "Year with max people alive "<< s.getYearWithMaxPeopleAlive(peoples) << endl;
}
| 32.744898 | 124 | 0.621377 | [
"vector",
"transform"
] |
9471ec4120b174f4a44fa40232cd9babfab498ed | 1,331 | hpp | C++ | examples/engine/engine/boot.hpp | Kysela/libaroma-1 | 0d97d91d10993698d581c7baa6d3d30a71bdcb62 | [
"Apache-2.0"
] | null | null | null | examples/engine/engine/boot.hpp | Kysela/libaroma-1 | 0d97d91d10993698d581c7baa6d3d30a71bdcb62 | [
"Apache-2.0"
] | null | null | null | examples/engine/engine/boot.hpp | Kysela/libaroma-1 | 0d97d91d10993698d581c7baa6d3d30a71bdcb62 | [
"Apache-2.0"
] | null | null | null | /*
Pterodon Recovery - bootup manager
Copyright (C) <2019> ATGDroid <bythedroid@gmail.com>
This file is part of Pterodon Recovery Project
Pterodon Recovery is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Pterodon Recovery 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 Pterodon Recovery. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PTERODON_BOOT_HPP
#define PTERODON_BOOT_HPP
#include "aroma.h"
#include <string>
#include <vector>
namespace Pterodon {
namespace Gui {
class BootManager {
public:
static void Initialize(void);
//static void ShowSplash(void);
static void ShowConsole(void);
static void ShowSplash(const std::string& splash_image_name);
}; // class BootManager
} // namespace Gui
} // namespace Pterodon
#endif // PTERODON_BOOT_HPP
| 30.25 | 79 | 0.703231 | [
"vector"
] |
94787882bd15f07286b2071af771e126d7b050d6 | 639 | cpp | C++ | out/aaa_missing.cpp | FardaleM/metalang | 171557c540f3e2c051ec39ea150afb740c1f615f | [
"BSD-2-Clause"
] | 22 | 2017-04-24T10:00:45.000Z | 2021-04-01T10:11:05.000Z | out/aaa_missing.cpp | FardaleM/metalang | 171557c540f3e2c051ec39ea150afb740c1f615f | [
"BSD-2-Clause"
] | 12 | 2017-03-26T18:34:21.000Z | 2019-03-21T19:13:03.000Z | out/aaa_missing.cpp | FardaleM/metalang | 171557c540f3e2c051ec39ea150afb740c1f615f | [
"BSD-2-Clause"
] | 7 | 2017-10-14T13:33:33.000Z | 2021-03-18T15:18:50.000Z | #include <iostream>
#include <vector>
/*
Ce test a été généré par Metalang.
*/
int result(int len, std::vector<int>& tab) {
std::vector<bool> tab2( len, false );
for (int i1 = 0; i1 < len; i1++)
{
std::cout << tab[i1] << " ";
tab2[tab[i1]] = true;
}
std::cout << "\n";
for (int i2 = 0; i2 < len; i2++)
if (!tab2[i2])
return i2;
return -1;
}
int main() {
int len;
std::cin >> len;
std::cout << len << "\n";
std::vector<int> tab( len );
for (int a = 0; a < len; a++)
{
std::cin >> tab[a];
}
std::cout << result(len, tab) << "\n";
}
| 19.363636 | 44 | 0.456964 | [
"vector"
] |
947b1d903d4822471929aa31d5852bca6a008e80 | 5,161 | cpp | C++ | Engine/source/VITC/console/vitcBitStreamObject.cpp | fr1tz/terminal-overload | 85f0689a40022e5eb7e54dcb6ddfb5ddd82a0a60 | [
"CC-BY-4.0"
] | 46 | 2015-01-05T17:34:43.000Z | 2022-01-04T04:03:09.000Z | Engine/source/VITC/console/vitcBitStreamObject.cpp | fr1tz/terminal-overload | 85f0689a40022e5eb7e54dcb6ddfb5ddd82a0a60 | [
"CC-BY-4.0"
] | 10 | 2015-01-20T23:14:46.000Z | 2019-04-05T22:04:15.000Z | Engine/source/VITC/console/vitcBitStreamObject.cpp | fr1tz/terminal-overload | 85f0689a40022e5eb7e54dcb6ddfb5ddd82a0a60 | [
"CC-BY-4.0"
] | 9 | 2015-08-08T18:46:06.000Z | 2021-02-01T13:53:20.000Z | // Copyright information can be found in the file named COPYING
// located in the root directory of this distribution.
#include "VITC/console/vitcBitStreamObject.h"
#include "platform/platform.h"
#include "console/consoleTypes.h"
#include "console/engineAPI.h"
#include "core/base64.h"
#include "math/mMathFn.h"
IMPLEMENT_CONOBJECT(vitcBitStreamObject);
vitcBitStreamObject::vitcBitStreamObject()
{
mStream = NULL;
mBuffer = NULL;
mBufferSize = 0;
}
vitcBitStreamObject::~vitcBitStreamObject()
{
if(mBuffer)
dFree(mBuffer);
}
void vitcBitStreamObject::initBuffer(size_t size)
{
if (mBuffer)
dFree(mBuffer);
mBufferSize = size;
mBuffer = (U8*)dMalloc(mBufferSize);
if (mStream)
delete mStream;
mStream = new BitStream(mBuffer, mBufferSize);
}
void vitcBitStreamObject::initBufferFromBase64(const char* string)
{
if(mBuffer)
dFree(mBuffer);
mBufferSize = dStrlen(string);
mBuffer = (U8*)dMalloc(mBufferSize);
size_t streamLength = base64_decode(string, mBuffer);
#if 0
for (U32 i = 0; i < streamLength; i++)
Con::printf("%i: %i", i, mBuffer[i]);
#endif
if(mStream)
delete mStream;
mStream = new BitStream(mBuffer, streamLength);
}
//-----------------------------------------------------------------------------
// Misc methods
DefineEngineMethod(vitcBitStreamObject, initBuffer, void, (S32 size), ,
"TODO")
{
object->initBuffer(size);
}
DefineEngineMethod(vitcBitStreamObject, initBufferFromBase64, void, (const char* string), ,
"TODO" )
{
object->initBufferFromBase64(string);
}
DefineEngineMethod(vitcBitStreamObject, getStreamSize, S32, (), , "TODO\n")
{
if (!object->getBitStream())
return -1;
return object->getBitStream()->getStreamSize();
}
DefineEngineMethod(vitcBitStreamObject, getBase64, const char*, (), , "TODO\n")
{
if (!object->getBitStream())
return "";
BitStream* bitstream = object->getBitStream();
String base64data = base64_encode(bitstream->getBuffer(), bitstream->getPosition());
char* ret = Con::getReturnBuffer(base64data);
return ret;
}
//-----------------------------------------------------------------------------
// Reading methods
DefineEngineMethod(vitcBitStreamObject, read, const char*, (S32 numBytes), , "TODO\n")
{
if (!object->getBitStream())
return "";
char* ret = Con::getReturnBuffer(numBytes + 1);
object->getBitStream()->_read(numBytes, ret);
ret[numBytes] = '\0';
return ret;
}
DefineEngineMethod(vitcBitStreamObject, readFlag, bool, (), , "TODO\n")
{
if (!object->getBitStream())
return -1;
return object->getBitStream()->readFlag();
}
DefineEngineMethod(vitcBitStreamObject, readU8, S32, (), , "TODO\n" )
{
if(!object->getBitStream())
return -1;
U8 ret;
object->getBitStream()->read(&ret);
return ret;
}
DefineEngineMethod(vitcBitStreamObject, readU16, S32, (), , "TODO\n" )
{
if(!object->getBitStream())
return -1;
U16 ret;
object->getBitStream()->read(&ret);
return ret;
}
DefineEngineMethod(vitcBitStreamObject, readU32, S32, (), , "TODO\n" )
{
if(!object->getBitStream())
return -1;
U32 ret;
object->getBitStream()->read(&ret);
return ret;
}
DefineEngineMethod(vitcBitStreamObject, readS8, S32, (), , "TODO\n" )
{
if(!object->getBitStream())
return -1;
S8 ret;
object->getBitStream()->read(&ret);
return ret;
}
DefineEngineMethod(vitcBitStreamObject, readS16, S32, (), , "TODO\n" )
{
if(!object->getBitStream())
return -1;
S16 ret;
object->getBitStream()->read(&ret);
return ret;
}
DefineEngineMethod(vitcBitStreamObject, readS32, S32, (), , "TODO\n" )
{
if(!object->getBitStream())
return -1;
S32 ret;
object->getBitStream()->read(&ret);
return ret;
}
//-----------------------------------------------------------------------------
// Writing methods
DefineEngineMethod(vitcBitStreamObject, write, bool, (const char* string), , "TODO\n")
{
if(!object->getBitStream())
return false;
return object->getBitStream()->_write(dStrlen(string), string);
}
DefineEngineMethod(vitcBitStreamObject, writeFlag, bool, (bool flag), , "TODO\n")
{
if(!object->getBitStream())
return false;
return object->getBitStream()->writeFlag(flag);
}
DefineEngineMethod(vitcBitStreamObject, writeU8, bool, (S32 val), , "TODO\n")
{
if(!object->getBitStream())
return false;
return object->getBitStream()->write((U8)val);
}
DefineEngineMethod(vitcBitStreamObject, writeU16, bool, (S32 val), , "TODO\n")
{
if(!object->getBitStream())
return false;
return object->getBitStream()->write((U16)val);
}
DefineEngineMethod(vitcBitStreamObject, writeU32, bool, (S32 val), , "TODO\n")
{
if(!object->getBitStream())
return false;
return object->getBitStream()->write((U32)val);
}
DefineEngineMethod(vitcBitStreamObject, writeS8, bool, (S32 val), , "TODO\n")
{
if(!object->getBitStream())
return false;
return object->getBitStream()->write((S8)val);
}
DefineEngineMethod(vitcBitStreamObject, writeS16, bool, (S32 val), , "TODO\n")
{
if(!object->getBitStream())
return false;
return object->getBitStream()->write((S16)val);
}
DefineEngineMethod(vitcBitStreamObject, writeS32, bool, (S32 val), , "TODO\n")
{
if(!object->getBitStream())
return false;
return object->getBitStream()->write((S32)val);
}
| 23.247748 | 91 | 0.674869 | [
"object"
] |
947d435838820fa4347586bd4ad44261fa5a4772 | 3,100 | cc | C++ | code/addons/attic/physics/capsuleshape.cc | gscept/nebula-trifid | e7c0a0acb05eedad9ed37a72c1bdf2d658511b42 | [
"BSD-2-Clause"
] | 67 | 2015-03-30T19:56:16.000Z | 2022-03-11T13:52:17.000Z | code/addons/attic/physics/capsuleshape.cc | gscept/nebula-trifid | e7c0a0acb05eedad9ed37a72c1bdf2d658511b42 | [
"BSD-2-Clause"
] | 5 | 2015-04-15T17:17:33.000Z | 2016-02-11T00:40:17.000Z | code/addons/attic/physics/capsuleshape.cc | gscept/nebula-trifid | e7c0a0acb05eedad9ed37a72c1bdf2d658511b42 | [
"BSD-2-Clause"
] | 34 | 2015-03-30T15:08:00.000Z | 2021-09-23T05:55:10.000Z | //------------------------------------------------------------------------------
// physics/capsuleshape.cc
// (C) 2005 RadonLabs GmbH
//------------------------------------------------------------------------------
#include "stdneb.h"
#include "physics/capsuleshape.h"
#include "debugrender/debugshaperenderer.h"
#include "math/vector.h"
namespace Physics
{
__ImplementClass(Physics::CapsuleShape, 'PCSH', Physics::Shape);
using namespace Math;
using namespace Debug;
//------------------------------------------------------------------------------
/**
*/
CapsuleShape::CapsuleShape() :
Shape(Capsule),
radius(1.0f),
length(1.0f)
{
// empty
}
//------------------------------------------------------------------------------
/**
*/
CapsuleShape::~CapsuleShape()
{
// empty
}
//------------------------------------------------------------------------------
/**
Create a capsule object, add it to ODE's collide space, and initialize
the mass member.
*/
bool
CapsuleShape::Attach(dSpaceID spaceId)
{
if (Shape::Attach(spaceId))
{
dGeomID capsule = dCreateCCylinder(0, this->radius, this->length);
this->AttachGeom(capsule, spaceId);
dMassSetCappedCylinder(&(this->odeMass), Physics::MaterialTable::GetDensity(this->materialType),
3, this->radius, this->length);
this->TransformMass();
return true;
}
return false;
}
//------------------------------------------------------------------------------
/**
Render a debug visualization of the capsule shape.
*/
void
CapsuleShape::RenderDebug(const Math::matrix44& parentTransform)
{
if (this->IsAttached())
{
DebugShapeRenderer* shapeRenderer = DebugShapeRenderer::Instance();
Math::vector capScale(this->radius, this->radius, this->radius);
Math::float4 color = this->GetDebugVisualizationColor();
Math::matrix44 cap0Transform = Math::matrix44::identity();
cap0Transform.scale(capScale);
cap0Transform.translate(Math::vector(0.0f, 0.0f, this->length * 0.5f));
cap0Transform = matrix44::multiply(cap0Transform , this->GetTransform());
cap0Transform = matrix44::multiply(cap0Transform , parentTransform);
shapeRenderer->DrawSphere(cap0Transform, color);
Math::matrix44 cap1Transform = Math::matrix44::identity();
cap1Transform.scale(capScale);
cap1Transform.translate(Math::vector(0.0f, 0.0f, -this->length * 0.5f));
cap1Transform = matrix44::multiply(cap1Transform , this->GetTransform());
cap1Transform = matrix44::multiply(cap1Transform , parentTransform);
shapeRenderer->DrawSphere(cap1Transform, color);
Math::matrix44 cylTransform = Math::matrix44::identity();
cylTransform.scale(Math::vector(this->radius, this->radius, this->length));
cylTransform = matrix44::multiply(cylTransform, this->GetTransform());
cylTransform = matrix44::multiply(cylTransform, parentTransform);
shapeRenderer->DrawCylinder(cylTransform, color);
}
}
}; // namespace Physics | 34.065934 | 104 | 0.56871 | [
"render",
"object",
"shape",
"vector"
] |
947e396dc750e7b3f8afa6787d0b222f49dcbe5c | 82,813 | cpp | C++ | csrc/define.cpp | ycaseau/CLAIRE3.5 | 57e3a719de7265e54f474003a422f8d509d19037 | [
"Unlicense"
] | null | null | null | csrc/define.cpp | ycaseau/CLAIRE3.5 | 57e3a719de7265e54f474003a422f8d509d19037 | [
"Unlicense"
] | null | null | null | csrc/define.cpp | ycaseau/CLAIRE3.5 | 57e3a719de7265e54f474003a422f8d509d19037 | [
"Unlicense"
] | null | null | null | /***** CLAIRE Compilation of file /Users/ycaseau/claire/v3.5/src/meta/define.cl
[version 3.5.01 / safety 5] Sun Jul 24 08:43:43 2016 *****/
#include <claire.h>
#include <Kernel.h>
#include <Core.h>
#include <Language.h>
//+-------------------------------------------------------------+
//| CLAIRE |
//| define.cl |
//| Copyright (C) 1994 - 2013 Yves Caseau. All Rights Reserved |
//| cf. copyright info in file object.cl: about() |
//+-------------------------------------------------------------+
// --------------------------------------------------------------
// this file contains all definition & instanciation instructions
//---------------------------------------------------------------
// **************************************************************************
// * Contents: *
// * Part 1: Definition instructions (Defobj, Defclass, Defmethod ...) *
// * Part 2: the instantiation macros *
// * Part 3: the useful stuff *
// * Part 4: the other macros *
// **************************************************************************
// *********************************************************************
// * Part 1: Definition *
// *********************************************************************
// this is the basic class instantiation
//
/* The c++ function for: self_print(self:Definition) [NEW_ALLOC] */
OID self_print_Definition_Language(Definition *self)
{ GC_BIND;
print_any(_oid_(self->arg));
princ_string(CSTRING("("));
printbox_bag2(GC_OBJECT(list,self->args));
{ OID Result = 0;
princ_string(CSTRING(")"));
GC_UNBIND; return (Result);}
}
// ------------- named object definition ------------------------------
//
/* The c++ function for: self_print(self:Defobj) [NEW_ALLOC+SLOT_UPDATE] */
void self_print_Defobj_Language(Defobj *self)
{ GC_RESERVE(3); // v3.0.55 optim !
if (self->arg == Core._global_variable)
{ OID r = _oid_(Kernel._any);
OID v = CNULL;
{ OID gc_local;
ITERATE(x);
bag *x_support;
x_support = GC_OBJECT(list,self->args);
for (START(x_support); NEXT(x);)
{ GC_LOOP;
if ((*(OBJECT(Call,x)->args))[1] == _oid_(Kernel.value))
GC__OID(v = (*(OBJECT(Call,x)->args))[2], 3);
else if ((*(OBJECT(Call,x)->args))[1] == _oid_(Kernel.range))
GC__OID(r = (*(OBJECT(Call,x)->args))[2], 2);
GC_UNLOOP;}
}
if (boolean_I_any(r) == CTRUE)
{ princ_symbol(self->ident);
princ_string(CSTRING(":"));
print_any(r);
princ_string(CSTRING(" := "));
printexp_any(v,CFALSE);
princ_string(CSTRING(""));
}
else { princ_symbol(self->ident);
princ_string(CSTRING(" :: "));
printexp_any(v,CFALSE);
princ_string(CSTRING(""));
}
}
else { princ_symbol(self->ident);
princ_string(CSTRING(" :: "));
print_any(_oid_(self->arg));
princ_string(CSTRING("("));
printbox_bag2(GC_OBJECT(list,self->args));
princ_string(CSTRING(")"));
}
GC_UNBIND;}
// ------------- class definition ------------------------------------
//
/* The c++ function for: self_print(self:Defclass) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
void self_print_Defclass_Language(Defclass *self)
{ GC_BIND;
princ_symbol(self->ident);
if (self->params->length != 0)
{ princ_string(CSTRING("["));
princ_bag(GC_OBJECT(list,self->params));
princ_string(CSTRING("]"));
}
princ_string(CSTRING(" <: "));
print_any(_oid_(self->arg));
princ_string(CSTRING("("));
{ Cint _Zl = Core.pretty->index;
list * l = GC_OBJECT(list,self->args);
Cint n = l->length;
Cint i = 1;
Cint g0066 = n;
{ OID gc_local;
while ((i <= g0066))
{ GC_LOOP;
if (i == 1)
set_level_void();
else lbreak_void();
if (INHERIT(OWNER((*(l))[i]),Language._Vardef))
(*Language.ppvariable)((*(l))[i]);
else { (*Language.ppvariable)(GC_OID((*(OBJECT(bag,(*Core.args)((*(l))[i]))))[1]));
princ_string(CSTRING(" = "));
print_any(GC_OID((*(OBJECT(bag,(*Core.args)((*(l))[i]))))[2]));
princ_string(CSTRING(""));
}
if (i < n)
princ_string(CSTRING(","));
++i;
GC_UNLOOP;}
}
}
princ_string(CSTRING(")"));
GC_UNBIND;}
// -------------- method definition ----------------------------------
//
/* The c++ function for: self_print(self:Defmethod) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
void self_print_Defmethod_Language(Defmethod *self)
{ GC_BIND;
print_any(_oid_(self->arg->selector));
princ_string(CSTRING("("));
if (((self->arg->args == (NULL)) ? CTRUE : CFALSE) != CTRUE)
ppvariable_list(GC_OBJECT(list,self->arg->args));
princ_string(CSTRING(") : "));
printexp_any(GC_OID(self->set_arg),CFALSE);
lbreak_void();
(Core.pretty->index = (Core.pretty->index+4));
princ_string(CSTRING(" "));
princ_string(((boolean_I_any(self->inline_ask) == CTRUE) ?
CSTRING("=>") :
CSTRING("->") ));
princ_string(CSTRING(" "));
printexp_any(GC_OID(self->body),CFALSE);
princ_string(CSTRING(" "));
(Core.pretty->index = (Core.pretty->index-4));
GC_UNBIND;}
// -------------- array definition -----------------------------------
/* The c++ function for: self_print(self:Defarray) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
void self_print_Defarray_Language(Defarray *self)
{ GC_BIND;
print_any(GC_OID((*(self->arg->args))[1]));
princ_string(CSTRING("["));
ppvariable_list(GC_OBJECT(list,cdr_list(GC_OBJECT(list,self->arg->args))));
princ_string(CSTRING("] : "));
print_any(GC_OID(self->set_arg));
lbreak_void();
(Core.pretty->index = (Core.pretty->index+4));
princ_string(CSTRING(" := "));
printexp_any(GC_OID(self->body),CFALSE);
princ_string(CSTRING(" "));
(Core.pretty->index = (Core.pretty->index-4));
GC_UNBIND;}
// -------------- rule definition ------------------------------------
/* The c++ function for: self_print(self:Defrule) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
void self_print_Defrule_Language(Defrule *self)
{ GC_BIND;
princ_symbol(self->ident);
princ_string(CSTRING("("));
ppvariable_list(GC_OBJECT(list,self->args));
princ_string(CSTRING(") :: rule("));
lbreak_integer(4);
princ_string(CSTRING(" "));
print_any(GC_OID(self->arg));
princ_string(CSTRING(" "));
lbreak_integer(4);
princ_string(CSTRING("=> "));
print_any(GC_OID(self->body));
princ_string(CSTRING(")"));
(Core.pretty->index = (Core.pretty->index-4));
GC_UNBIND;}
/* The c++ function for: self_print(self:Defvar) [NEW_ALLOC+SLOT_UPDATE] */
void self_print_Defvar_Language(Defvar *self)
{ GC_BIND;
ppvariable_Variable(GC_OBJECT(Variable,self->ident));
princ_string(CSTRING(" := "));
printexp_any(GC_OID(self->arg),CFALSE);
princ_string(CSTRING(""));
GC_UNBIND;}
// *********************************************************************
// * Part 2: the general instantiation macro *
// *********************************************************************
// creation of a new object
//
/* The c++ function for: self_eval(self:Definition) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
OID self_eval_Definition(Definition *self)
{ GC_BIND;
{ OID Result = 0;
{ ClaireClass * _Zc = self->arg;
ClaireObject * _Zo;
{ { if (_Zc->open <= 0)
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[105] cannot instantiate ~S")),
_oid_(list::alloc(1,_oid_(_Zc))))));
_Zo = new_object_class(_Zc);
}
GC_OBJECT(ClaireObject,_Zo);}
if (_Zc->open != ClEnv->ephemeral)
(_Zc->instances = _Zc->instances->addFast(_oid_(_Zo)));
Result = complete_object(_Zo,GC_OBJECT(list,self->args));
}
GC_UNBIND; return (Result);}
}
// the instantiation body is a sequence of words from which the initialization
// of the object must be built.
//
/* The c++ function for: complete(self:object,%l:list) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
OID complete_object(ClaireObject *self,list *_Zl)
{ GC_RESERVE(6); // v3.0.55 optim !
{ OID gc_local;
ITERATE(x);
for (START(_Zl); NEXT(x);)
{ GC_LOOP;
{ property * p = make_a_property_any(GC_OID((*(OBJECT(Call,x)->args))[1]));
OID y = GC_OID(eval_any(GC_OID((*(OBJECT(Call,x)->args))[2])));
ClaireObject * s = GC_OBJECT(ClaireObject,_at_property1(p,self->isa));
if (Kernel._slot == s->isa)
{ if (belong_to(y,_oid_(CLREAD(restriction,s,range))) != CTRUE)
range_is_wrong_slot(((slot *) s),y);
else update_property(p,
self,
CLREAD(slot,s,index),
CLREAD(slot,s,srange),
y);
}
else close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[106] the object ~S does not understand ~S")),
_oid_(list::alloc(2,_oid_(self),_oid_(p))))));
}
GC_UNLOOP;}
}
{ OID Result = 0;
Result = _oid_(complete_I_object(self));
GC_UNBIND; return (Result);}
}
// creation of a new named object
//
/* The c++ function for: self_eval(self:Defobj) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
OID self_eval_Defobj(Defobj *self)
{ GC_BIND;
{ OID Result = 0;
{ ClaireClass * _Zc = self->arg;
if (_Zc->open <= 0)
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[105] cannot instantiate ~S")),
_oid_(list::alloc(1,_oid_(_Zc))))));
if (INHERIT(_Zc,Kernel._thing))
{ thing * _Zo = new_thing_class(_Zc,self->ident);
if (INHERIT(_Zo->isa,Kernel._property))
{ if (CLREAD(property,_Zo,restrictions)->length > 0)
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[188] the property ~S is already defined")),
_oid_(list::alloc(1,_oid_(_Zo))))));
}
Result = complete_object(_Zo,GC_OBJECT(list,self->args));
}
else { ClaireObject * ob = GC_OBJECT(ClaireObject,new_object_class(_Zc));
if (_Zc->open != ClEnv->ephemeral)
_Zc->instances->addFast(_oid_(ob));
Result = put_symbol(self->ident,complete_object(ob,GC_OBJECT(list,self->args)));
}
}
GC_UNBIND; return (Result);}
}
// creation of a new named object
/* The c++ function for: self_eval(self:Defclass) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
OID self_eval_Defclass(Defclass *self)
{ if ((INHERIT(owner_any(get_symbol(self->ident)),Kernel._class)) &&
((OBJECT(ClaireClass,get_symbol(self->ident))->open != -2) ||
(self->arg != OBJECT(ClaireClass,get_symbol(self->ident))->superclass)))
{ { OID Result = 0;
{ OID V_CL0072;close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[107] class re-definition is not valid: ~S")),
_oid_(list::alloc(1,_oid_(self))))));
Result=_void_(V_CL0072);}
return (Result);}
}
else{ if ((self->arg->open == 1) ||
(self->arg->open == -1))
{ { OID Result = 0;
{ OID V_CL0073;close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[109] the parent class ~S of ~S is closed")),
_oid_(list::alloc(2,_oid_(self->arg),_oid_(self))))));
Result=_void_(V_CL0073);}
return (Result);}
}
else{ GC_RESERVE(8); // v3.0.55 optim !
{ OID Result = 0;
{ ClaireClass * _Zo = class_I_symbol(self->ident,self->arg);
{ OID gc_local;
ITERATE(x);
bag *x_support;
x_support = GC_OBJECT(list,self->args);
for (START(x_support); NEXT(x);)
{ GC_LOOP;
{ OID v = CNULL;
if (INHERIT(OWNER(x),Language._Call))
{ GC__OID(v = eval_any(GC_OID((*(OBJECT(Call,x)->args))[2])), 4);
GC__OID(x = (*(OBJECT(Call,x)->args))[1], 3);
}
{ ClaireType * rt = GC_OBJECT(ClaireType,extract_type_any(GC_OID((*Kernel.range)(x))));
property * p = make_a_property_any(_oid_(OBJECT(Variable,x)->pname));
slot * ps = OBJECT(slot,last_list(_Zo->slots));
Cint ix = ps->index;
if ((v != CNULL) &&
(belong_to(v,_oid_(rt)) != CTRUE))
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[108] default(~S) = ~S does not belong to ~S")),
_oid_(list::alloc(3,x,
v,
_oid_(rt))))));
{ ClaireBoolean * g0074I;
{ ClaireBoolean *v_and;
{ v_and = ((p->open <= 0) ? CTRUE : CFALSE);
if (v_and == CFALSE) g0074I =CFALSE;
else { { OID g0075UU;
{ OID gc_local;
ITERATE(sx);
g0075UU= Kernel.cfalse;
for (START(self->arg->slots); NEXT(sx);)
if (OBJECT(restriction,sx)->selector == p)
{ g0075UU = Kernel.ctrue;
break;}
}
v_and = boolean_I_any(g0075UU);
}
if (v_and == CFALSE) g0074I =CFALSE;
else g0074I = CTRUE;}
}
}
if (g0074I == CTRUE) close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[181] cannot overide a slot for a closed property ~S")),
_oid_(list::alloc(1,_oid_(p))))));
}
if (ps->range == Kernel._float)
++ix;
add_slot_class(_Zo,
p,
rt,
v,
(ix+1));
}
}
GC_UNLOOP;}
}
close_class(_Zo);
if (self->forward_ask == CTRUE)
(_Zo->open = -2);
else if (_Zo->open == -2)
(_Zo->open = 2);
if (_inf_equal_type(_Zo,Kernel._cl_import) == CTRUE)
(_Zo->open = -1);
(_Zo->params = self->params);
{ OID gc_local;
ITERATE(p);
bag *p_support;
p_support = GC_OBJECT(list,self->params);
for (START(p_support); NEXT(p);)
(OBJECT(property,p)->open = 0);
}
attach_comment_any(_oid_(_Zo));
Result = _oid_(_Zo);
}
GC_UNBIND; return (Result);}
}
}
}
// method definition
// v0.01
/* The c++ function for: self_eval(self:Defmethod) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE+SAFE_RESULT] */
OID self_eval_Defmethod(Defmethod *self)
{ GC_BIND;
if (inherit_ask_class(self->arg->isa,Language._Call) != CTRUE)
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[110] wrong signature definition ~S")),
_oid_(list::alloc(1,GC_OID(_oid_(self->arg)))))));
{ OID Result = 0;
{ property * p = make_a_property_any(_oid_(self->arg->selector));
list * l = GC_OBJECT(list,self->arg->args);
list * lv;
if ((l->length == 1) &&
((*(l))[1] == _oid_(ClEnv)))
{ OID v_bag;
GC_ANY(lv= list::empty(Kernel.emptySet));
{ { Variable * _CL_obj = ((Variable *) GC_OBJECT(Variable,new_object_class(Language._Variable)));
(_CL_obj->pname = symbol_I_string2(CSTRING("XfakeParameter")));
(_CL_obj->range = Kernel._void);
add_I_property(Kernel.instances,Language._Variable,11,_oid_(_CL_obj));
v_bag = _oid_(_CL_obj);
}
GC_OID(v_bag);}
((list *) lv)->addFast(v_bag);}
else lv = l;
list * lp = GC_OBJECT(list,extract_signature_list(lv));
list * lrange = GC_OBJECT(list,extract_range_any(GC_OID(self->set_arg),lv,GC_OBJECT(list,OBJECT(list,Language.LDEF->value))));
list * lbody = GC_OBJECT(list,extract_status_any(GC_OID(self->body)));
method * m = add_method_property(p,
lp,
OBJECT(ClaireType,(*(lrange))[1]),
(*(lbody))[1],
(*(lbody))[2]);
if ((p->open > 0) &&
((p->open <= 1) &&
(p->dispatcher == 0)))
{ OID rtest;
{ { OID r_some = CNULL;
{ ITERATE(r);
for (START(p->restrictions); NEXT(r);)
if (r != _oid_(m))
{ if (length_bag(_exp_list(OBJECT(restriction,r)->domain,m->domain)) != 0)
{ r_some= r;
break;}
}
}
rtest = r_some;
}
GC_OID(rtest);}
if (rtest != CNULL)
{ restriction * r = OBJECT(restriction,rtest);
tformat_string(CSTRING("--- WARNING ! [186] conflict between ~S and ~S is dangerous since ~S is closed\n"),1,list::alloc(3,_oid_(m),
_oid_(r),
_oid_(p)));
}
else ;}
(Language.LDEF->value= _oid_(list::empty(Kernel._any)));
if ((*(lbody))[3] != _oid_(Kernel.body))
(m->formula = lambda_I_list(lv,(*(lbody))[3]));
if (lrange->length > 1)
(m->typing = (*(lrange))[2]);
update_property(Kernel.inline_ask,
m,
13,
Kernel._object,
GC_OID(self->inline_ask));
attach_comment_any(_oid_(m));
if ((p == Kernel.close) &&
(_inf_equal_type(m->range,domain_I_restriction(m)) != CTRUE))
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[184] the close method ~S has a wrong range")),
_oid_(list::alloc(1,_oid_(m))))));
Result = _oid_(m);
}
GC_UNBIND; return (Result);}
}
// v3.2.24
// attach a cute comment if needed ... to a defclass or a defmethod
/* The c++ function for: attach_comment(x:any) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
void attach_comment_any(OID x)
{ if (((OBJECT(ClaireBoolean,Language.NeedComment->value)) == CTRUE) &&
(Language.LastComment->value != CNULL))
{ write_property(Kernel.comment,OBJECT(ClaireObject,x),GC_OID(Language.LastComment->value));
}
else{ GC_BIND;
;GC_UNBIND;}
}
// returns the list of types AND modifies LDEF
/* The c++ function for: iClaire/extract_signature(l:list) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
list * extract_signature_list(list *l)
{ GC_BIND;
(Language.LDEF->value= _oid_(list::empty(Kernel._any)));
{ list *Result ;
{ Cint n = 0;
{ bag *v_list; OID v_val;
OID v,CLcount;
v_list = l;
Result = v_list->clone();
for (CLcount= 1; CLcount <= v_list->length; CLcount++)
{ v = (*(v_list))[CLcount];
if (inherit_ask_class(OBJECT(ClaireObject,v)->isa,Language._Variable) != CTRUE)
{ OID V_CL0076;close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[111] wrong typed argument ~S")),
_oid_(list::alloc(1,v)))));
v_val=_void_(V_CL0076);}
else { OID p = GC_OID(extract_pattern_any(GC_OID(_oid_(OBJECT(Variable,v)->range)),list::alloc(1,n)));
++n;
if (p == CNULL)
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[111] wrong typed argument ~S (~S)")),
_oid_(list::alloc(2,v,GC_OID(_oid_(OBJECT(Variable,v)->range)))))));
(OBJECT(Variable,v)->range = type_I_any(p));
v_val = p;
}
(*((list *) Result))[CLcount] = v_val;}
}
}
GC_UNBIND; return (Result);}
}
// takes an <exp> that must belong to <type> and returns the CLAIRE type
// if LDEF is non-empty, it is used as a list of type variable and patterns
// may be returned. In addition, if the path list is non empty, new type
// variables may be defined. a syntax error will produce the unknown value
//
/* The c++ function for: iClaire/extract_pattern(x:any,path:list) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
OID extract_pattern_any(OID x,list *path)
{ GC_BIND;
{ OID Result = 0;
if (INHERIT(OWNER(x),Kernel._class))
Result = x;
else if (Kernel._set == OWNER(x))
{ OID z;
{ if (OBJECT(bag,x)->length == 1)
z = extract_pattern_any((*(OBJECT(bag,x)))[1],Kernel.nil);
else z = Kernel.cfalse;
GC_OID(z);}
if (INHERIT(OWNER(z),Core._Reference))
{ Reference * w = GC_OBJECT(Reference,((Reference *) copy_object(OBJECT(ClaireObject,z))));
(w->arg = CTRUE);
Result = _oid_(w);
}
else Result = x;
}
else if (INHERIT(OWNER(x),Language._Tuple))
{ list * ltp;
{ { bag *v_list; OID v_val;
OID z,CLcount;
v_list = GC_OBJECT(list,OBJECT(Construct,x)->args);
ltp = v_list->clone();
for (CLcount= 1; CLcount <= v_list->length; CLcount++)
{ z = (*(v_list))[CLcount];
v_val = extract_pattern_any(z,path);
(*((list *) ltp))[CLcount] = v_val;}
}
GC_OBJECT(list,ltp);}
{ ClaireBoolean * g0077I;
{ OID g0078UU;
{ OID gc_local;
ITERATE(y);
g0078UU= Kernel.cfalse;
for (START(ltp); NEXT(y);)
if (y == CNULL)
{ g0078UU = Kernel.ctrue;
break;}
}
g0077I = boolean_I_any(g0078UU);
}
if (g0077I == CTRUE) Result = CNULL;
else Result = _oid_(tuple_I_list(ltp));
}
}
else if (INHERIT(OWNER(x),Core._global_variable))
Result = extract_pattern_any(GC_OID(OBJECT(global_variable,x)->value),path);
else if (INHERIT(OWNER(x),Language._Call))
{ property * p = OBJECT(Call,x)->selector;
if (p == Core.U)
{ OID x1 = GC_OID(extract_pattern_any(GC_OID((*(OBJECT(Call,x)->args))[1]),Kernel.nil));
OID x2 = GC_OID(extract_pattern_any(GC_OID((*(OBJECT(Call,x)->args))[2]),Kernel.nil));
if ((x1 == CNULL) ||
(x2 == CNULL))
Result = CNULL;
else Result = _oid_(U_type(OBJECT(ClaireType,x1),OBJECT(ClaireType,x2)));
}
else if (p == Kernel._exp)
Result = (*Kernel._exp)(GC_OID(extract_pattern_any(GC_OID((*(OBJECT(Call,x)->args))[1]),Kernel.nil)),
GC_OID(extract_pattern_any(GC_OID((*(OBJECT(Call,x)->args))[2]),Kernel.nil)));
else if (p == Kernel._dot_dot)
{ OID v1 = GC_OID(extract_item_any(GC_OID((*(OBJECT(Call,x)->args))[1]),Core.nil->value));
OID v2 = GC_OID(extract_item_any(GC_OID((*(OBJECT(Call,x)->args))[2]),Core.nil->value));
if ((INHERIT(OWNER(v1),Kernel._integer)) &&
(INHERIT(OWNER(v2),Kernel._integer)))
Result = _oid_(_dot_dot_integer(v1,v2));
else Result = CNULL;
}
else if (p == Kernel.nth)
Result = extract_pattern_nth_list(GC_OBJECT(list,OBJECT(Call,x)->args),path);
else if (p == Kernel._star)
{ OID z = GC_OID(extract_pattern_any(GC_OID((*(OBJECT(Call,x)->args))[1]),path));
if (z != CNULL)
Result = _oid_(U_type(OBJECT(ClaireType,z),set::alloc(Kernel.emptySet,1,CNULL)));
else Result = CNULL;
}
else Result = CNULL;
}
else if (INHERIT(OWNER(x),Kernel._type))
Result = x;
else if (INHERIT(OWNER(x),Kernel._unbound_symbol))
{ symbol * s = extract_symbol_any(x);
OID v;
{ { OID z_some = CNULL;
{ OID gc_local;
ITERATE(z);
bag *z_support;
z_support = GC_OBJECT(bag,enumerate_any(GC_OID(Language.LDEF->value)));
for (START(z_support); NEXT(z);)
{ GC_LOOP;
if (OBJECT(Variable,z)->pname == s)
{ z_some= z;
break;}
GC_UNLOOP;}
}
v = z_some;
}
GC_OID(v);}
if (v != CNULL)
Result = (*Kernel.range)(v);
else if ((INHERIT(path->isa,Kernel._list)) && (path->length > 1))
{ Reference * y;
{ { Reference * _CL_obj = ((Reference *) GC_OBJECT(Reference,new_object_class(Core._Reference)));
(_CL_obj->index = (*(path))[1]);
(_CL_obj->args = cdr_list(path));
add_I_property(Kernel.instances,Core._Reference,11,_oid_(_CL_obj));
y = _CL_obj;
}
GC_OBJECT(Reference,y);}
Variable * v;
{ { Variable * _CL_obj = ((Variable *) GC_OBJECT(Variable,new_object_class(Language._Variable)));
(_CL_obj->pname = s);
(_CL_obj->range = y);
add_I_property(Kernel.instances,Language._Variable,11,_oid_(_CL_obj));
v = _CL_obj;
}
GC_OBJECT(Variable,v);}
(Language.LDEF->value= (*Kernel.add)(GC_OID(Language.LDEF->value),
_oid_(v)));
Result = _oid_(Kernel._void);
}
else Result = CNULL;
}
else Result = CNULL;
GC_UNBIND; return (Result);}
}
// takes an <exp> that must belong to <type> and returns the CLAIRE type
//
/* The c++ function for: iClaire/extract_type(x:any) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
ClaireType * extract_type_any(OID x)
{ GC_BIND;
{ ClaireType *Result ;
{ ClaireObject *V_CC ;
{ (Language.LDEF->value= _oid_(list::empty(Kernel._any)));
{ OID r = GC_OID(extract_pattern_any(x,Kernel.nil));
if (r == CNULL)
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[112] wrong type expression ~S")),
_oid_(list::alloc(1,x)))));
else V_CC = OBJECT(ClaireType,r);
}
}
Result= (ClaireType *) V_CC;}
GC_UNBIND; return (Result);}
}
// an item is an integer, a float, a symbol, a string or a type
//
/* The c++ function for: extract_item(x:any,y:any) [NEW_ALLOC] */
OID extract_item_any(OID x,OID y)
{ if (((((INHERIT(OWNER(x),Kernel._integer)) ||
(Kernel._float == OWNER(x))) ||
(INHERIT(OWNER(x),Kernel._symbol))) ||
(Kernel._string == OWNER(x))) ||
(INHERIT(OWNER(x),Kernel._type)))
{ { OID Result = 0;
Result = x;
return (Result);}
}
else{ GC_BIND;
{ OID Result = 0;
if (INHERIT(OWNER(x),Core._global_variable))
Result = extract_item_any(GC_OID((*Kernel.value)(x)),y);
else Result = CNULL;
GC_UNBIND; return (Result);}
}
}
// version for X[...] which is the most complex case - note the extensibility
// patch.
/* The c++ function for: extract_pattern_nth(l:list,path:list) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
OID extract_pattern_nth_list(list *l,list *path)
{ GC_BIND;
{ OID Result = 0;
{ Cint m = l->length;
OID x = (*(l))[1];
if (m == 1)
{ OID y = GC_OID(extract_pattern_any((*(l))[1],Kernel.nil));
if (y == CNULL)
Result = CNULL;
else { Param * _CL_obj = ((Param *) GC_OBJECT(Param,new_object_class(Core._Param)));
(_CL_obj->arg = Kernel._array);
(_CL_obj->params = list::alloc(1,_oid_(Kernel.of)));
(_CL_obj->args = list::alloc(1,_oid_(set::alloc(1,y))));
Result = _oid_(_CL_obj);
}
}
else if (m == 2)
{ if (((x == _oid_(Core._subtype)) ||
((x == _oid_(Kernel._set)) ||
(x == _oid_(Kernel._list)))) ||
(inherit_ask_class(OWNER(x),Kernel._class) != CTRUE))
{ OID y = GC_OID(extract_pattern_any((*(l))[2],Kernel.nil));
{ ClaireHandler c_handle = ClaireHandler();
if ERROR_IN
{ if (y != CNULL)
Result = (*Kernel.nth)((*(l))[1],
y);
else Result = CNULL;
ClEnv->cHandle--;}
else if (belong_to(_oid_(ClEnv->exception_I),_oid_(Kernel._any)) == CTRUE)
{ c_handle.catchIt();Result = CNULL;
}
else PREVIOUS_HANDLER;}
}
else Result = CNULL;
}
else { OID l1 = (*(l))[2];
OID l2 = GC_OID((*Core.args)((*(l))[3]));
list * l3 = list::empty(Kernel._any);
{ Cint n = 1;
Cint g0079 = (*Kernel.length)(l1);
{ OID gc_local;
while ((n <= g0079))
{ GC_LOOP;
{ OID y = (*(OBJECT(bag,l2)))[n];
{ OID g0080UU;
{ if (INHERIT(OWNER(y),Language._Set))
{ OID v = GC_OID(extract_pattern_any(GC_OID((*(OBJECT(Construct,y)->args))[1]),GC_OBJECT(list,((list *) copy_bag(path)))->addFast(GC_OID((*Kernel.nth)(l1,
n)))));
if (v == _oid_(Kernel._void))
g0080UU = _oid_(Kernel._any);
else if (INHERIT(OWNER(v),Core._Reference))
{ Reference * z = GC_OBJECT(Reference,((Reference *) copy_object(OBJECT(ClaireObject,v))));
(z->arg = CTRUE);
g0080UU = _oid_(z);
}
else { set * V_CL0081;{ OID v_bag;
GC_ANY(V_CL0081= set::empty(Kernel.emptySet));
{ if (v != CNULL)
v_bag = v;
else v_bag = eval_any(GC_OID((*(OBJECT(Construct,y)->args))[1]));
GC_OID(v_bag);}
((set *) V_CL0081)->addFast(v_bag);}
g0080UU=_oid_(V_CL0081);}
}
else { list * g0082UU;
{ ClaireObject *V_CC ;
if (path->length != 0)
V_CC = path->addFast(GC_OID((*Kernel.nth)(l1,
n)));
else V_CC = CFALSE;
g0082UU= (list *) V_CC;}
g0080UU = extract_pattern_any(y,g0082UU);
}
GC_OID(g0080UU);}
l3 = l3->addFast(g0080UU);
}
}
++n;
GC_UNLOOP;}
}
}
if (l3->memq(CNULL) == CTRUE)
Result = CNULL;
else { Param * _CL_obj = ((Param *) GC_OBJECT(Param,new_object_class(Core._Param)));
update_property(Kernel.arg,
_CL_obj,
2,
Kernel._object,
x);
update_property(Kernel.params,
_CL_obj,
3,
Kernel._object,
l1);
(_CL_obj->args = l3);
Result = _oid_(_CL_obj);
}
}
}
GC_UNBIND; return (Result);}
}
// we perform some pre-processing on x[l] at reading time to make evaluation easier
/* The c++ function for: iClaire/extract_class_call(self:class,l:list) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
ClaireObject * extract_class_call_class(ClaireClass *self,list *l)
{ GC_RESERVE(1); // HOHO v3.0.55 optim !
{ ClaireObject *Result ;
{ ClaireObject *V_CC ;
{ ClaireBoolean * g0084I;
{ ClaireBoolean *v_and;
{ v_and = ((self == Core._subtype) ? CTRUE : ((self == Kernel._set) ? CTRUE : ((self == Kernel._list) ? CTRUE : CFALSE)));
if (v_and == CFALSE) g0084I =CFALSE;
else { v_and = ((l->length == 1) ? CTRUE : CFALSE);
if (v_and == CFALSE) g0084I =CFALSE;
else { { OID y = (*(l))[1];
OID z = GC_OID(extract_pattern_any(y,Kernel.nil));
if (INHERIT(OWNER(y),Core._global_variable))
y= GC_OID((*Kernel.value)((*(l))[1]));
v_and = ((INHERIT(OWNER(z),Kernel._type)) ? CTRUE : ((self == Core._subtype) ? CTRUE : (((INHERIT(OWNER(y),Language._Call)) ? ((OBJECT(Call,y)->selector != Kernel._equal) ||
(OBJECT(Call,y)->args->length != 2)) : ((INHERIT(OWNER(y),Language._Tuple)) && (CTRUE == CTRUE))) ? CTRUE : CFALSE)));
}
if (v_and == CFALSE) g0084I =CFALSE;
else g0084I = CTRUE;}
}
}
}
if (g0084I == CTRUE) { Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Kernel.nth);
(_CL_obj->args = cons_any(_oid_(self),l));
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
V_CC = _CL_obj;
}
else if (self == Core._lambda)
{ if ((l->length == 2) &&
((INHERIT(OWNER((*(l))[1]),Language._Do)) ||
(INHERIT(OWNER((*(l))[1]),Language._Variable))))
{ list * lv;
{ if (INHERIT(OWNER((*(l))[1]),Language._Do))
{ list * v_out = list::empty(Kernel.emptySet);
{ OID gc_local;
ITERATE(v);
bag *v_support;
v_support = GC_OBJECT(list,OBJECT(bag,(*Core.args)((*(l))[1])));
for (START(v_support); NEXT(v);)
if (INHERIT(OWNER(v),Language._Variable))
v_out->addFast(v);
}
lv = GC_OBJECT(list,v_out);
}
else lv = list::alloc(1,(*(l))[1]);
GC_OBJECT(list,lv);}
extract_signature_list(lv);
V_CC = lambda_I_list(lv,(*(l))[2]);
}
else close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[113] Wrong lambda definition lambda[~S]")),
_oid_(list::alloc(1,_oid_(l))))));
}
else { list * l1 = GC_OBJECT(list,list::empty(Kernel._any));
list * l2 = GC_OBJECT(list,list::empty(Kernel._any));
Cint m = l->length;
{ Cint n = 1;
Cint g0083 = m;
{ OID gc_local;
while ((n <= g0083))
{ GC_LOOP;
{ OID y = (*(l))[n];
OID p = CNULL;
OID v = CNULL;
if (INHERIT(OWNER(y),Language._Call))
{ if (((OBJECT(Call,y)->selector == Kernel._equal) ? ((OBJECT(Call,y)->args->length == 2) ? CTRUE: CFALSE): CFALSE) != CTRUE)
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[114] Wrong parametrization ~S")),
_oid_(list::alloc(1,y)))));
p= _oid_(make_a_property_any(GC_OID((*(OBJECT(Call,y)->args))[1])));
{ { Set * _CL_obj = ((Set *) GC_OBJECT(Set,new_object_class(Language._Set)));
(_CL_obj->args = list::alloc(1,GC_OID((*(OBJECT(Call,y)->args))[2])));
add_I_property(Kernel.instances,Language._Set,11,_oid_(_CL_obj));
v = _oid_(_CL_obj);
}
GC__OID(v, 11);}
}
else if (INHERIT(OWNER(y),Language._Vardef))
{ p= _oid_(make_a_property_any(_oid_(OBJECT(Variable,y)->pname)));
GC__OID(v = _oid_(OBJECT(Variable,y)->range), 11);
}
else { p= _oid_(make_a_property_any(y));
v= _oid_(Kernel.emptySet);
}
l1= l1->addFast(p);
l2= l2->addFast(v);
}
++n;
GC_UNLOOP;}
}
}
{ Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Kernel.nth);
{ Call * g0085 = _CL_obj;
list * g0086;
{ list * g0087UU;
{ { OID v_bag;
GC_ANY(g0087UU= list::empty(Kernel.emptySet));
((list *) g0087UU)->addFast(_oid_(l1));
{ { List * _CL_obj = ((List *) GC_OBJECT(List,new_object_class(Language._List)));
(_CL_obj->args = l2);
add_I_property(Kernel.instances,Language._List,11,_oid_(_CL_obj));
v_bag = _oid_(_CL_obj);
}
GC_OID(v_bag);}
((list *) g0087UU)->addFast(v_bag);}
GC_OBJECT(list,g0087UU);}
g0086 = cons_any(_oid_(self),g0087UU);
}
(g0085->args = g0086);}
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
V_CC = _CL_obj;
}
}
}
Result= (ClaireObject *) V_CC;}
GC_UNBIND; return (Result);}
}
// extract the range (type and/or second-order function)
// lvar is the list of arguments that will serve as second-o. args
// ldef is the list of extra type variables that are defined in the sig.
/* The c++ function for: iClaire/extract_range(x:any,lvar:list,ldef:list) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
list * extract_range_any(OID x,list *lvar,list *ldef)
{ GC_RESERVE(13); // v3.0.55 optim !
{ list *Result ;
{ ClaireBoolean * g0089I;
{ OID g0090UU;
if (INHERIT(OWNER(x),Language._Call))
g0090UU = _oid_(((OBJECT(Call,x)->selector == Kernel.nth) ? (((*(OBJECT(Call,x)->args))[1] == _oid_(Kernel._type)) ? CTRUE: CFALSE): CFALSE));
else g0090UU = Kernel.cfalse;
g0089I = not_any(g0090UU);
}
if (g0089I == CTRUE) Result = list::alloc(2,GC_OID(_oid_(extract_type_any(x))),_oid_(Kernel.emptySet));
else { { OID gc_local;
ITERATE(v);
for (START(ldef); NEXT(v);)
{ GC_LOOP;
{ Reference * r = GC_OBJECT(Reference,OBJECT(Reference,(*Kernel.range)(v)));
list * path = GC_OBJECT(list,r->args);
Cint n = path->length;
OID y = (*(lvar))[(r->index+1)];
{ Cint i = 1;
Cint g0088 = path->length;
{ OID gc_local;
while ((i <= g0088))
{ GC_LOOP;
{ { Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Core._at);
(_CL_obj->args = list::alloc(2,y,(*(path))[i]));
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
y = _oid_(_CL_obj);
}
GC__OID(y, 9);}
++i;
GC_UNLOOP;}
}
}
{ { OID g0091UU;
{ Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Core.member);
(_CL_obj->args = list::alloc(1,y));
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
g0091UU = _oid_(_CL_obj);
}
x = substitution_any(x,OBJECT(Variable,v),g0091UU);
}
GC__OID(x, 1);}
}
GC_UNLOOP;}
}
{ list * lv2 = GC_OBJECT(list,list::empty(Kernel._any));
{ OID gc_local;
ITERATE(v);
for (START(lvar); NEXT(v);)
{ GC_LOOP;
{ Variable * v2;
{ { Variable * _CL_obj = ((Variable *) GC_OBJECT(Variable,new_object_class(Language._Variable)));
(_CL_obj->pname = OBJECT(Variable,v)->pname);
(_CL_obj->range = Kernel._type);
add_I_property(Kernel.instances,Language._Variable,11,_oid_(_CL_obj));
v2 = _CL_obj;
}
GC_OBJECT(Variable,v2);}
lv2= lv2->addFast(_oid_(v2));
GC__OID(x = substitution_any(x,OBJECT(Variable,v),_oid_(v2)), 1);
}
GC_UNLOOP;}
}
{ lambda * lb = GC_OBJECT(lambda,lambda_I_list(lv2,GC_OID((*(OBJECT(bag,(*Core.args)(x))))[2])));
OID ur = CNULL;
{ ClaireHandler c_handle = ClaireHandler();
if ERROR_IN
{ { { list * g0092UU;
{ { bag *v_list; OID v_val;
OID v,CLcount;
v_list = lvar;
g0092UU = v_list->clone();
for (CLcount= 1; CLcount <= v_list->length; CLcount++)
{ v = (*(v_list))[CLcount];
v_val = (*Kernel.range)(v);
(*((list *) g0092UU))[CLcount] = v_val;}
}
GC_OBJECT(list,g0092UU);}
ur = apply_lambda(lb,g0092UU);
}
GC_OID(ur);}
ClEnv->cHandle--;}
else if (belong_to(_oid_(ClEnv->exception_I),_oid_(Kernel._any)) == CTRUE)
{ c_handle.catchIt();{ princ_string(CSTRING("The type expression "));
print_any(x);
princ_string(CSTRING(" is not valid ... \n"));
princ_string(CSTRING("context: lambda = "));
print_any(_oid_(lb));
princ_string(CSTRING(", lvars = "));
{ OID g0093UU;
{ { list * V_CL0094;{ bag *v_list; OID v_val;
OID v,CLcount;
v_list = lvar;
V_CL0094 = v_list->clone();
for (CLcount= 1; CLcount <= v_list->length; CLcount++)
{ v = (*(v_list))[CLcount];
v_val = (*Kernel.range)(v);
(*((list *) V_CL0094))[CLcount] = v_val;}
}
g0093UU=_oid_(V_CL0094);}
GC_OID(g0093UU);}
print_any(g0093UU);
}
princ_string(CSTRING("\n"));
close_exception(ClEnv->exception_I);
}
}
else PREVIOUS_HANDLER;}
if (inherit_ask_class(OWNER(ur),Kernel._type) != CTRUE)
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[115] the (resulting) range ~S is not a type")),
_oid_(list::alloc(1,ur)))));
Result = list::alloc(2,ur,_oid_(lb));
}
}
}
}
GC_UNBIND; return (Result);}
}
// define the different components of status(m), which is a bit vector
// a new allocation may be done by running the method
// a list is updated whose content is not gcsafe
// an slot is updated whose content is not gcsafe
// the method returns one of its args
// the result (not gcsafe) does not need protection
// the args (not gcsafe) does not need protection
// a string is modified hence constant strings are forbiden v3.3.46
// create a bitvector from a list of flags
/* The c++ function for: bit_vector(l:listargs) [0] */
Cint bit_vector_listargs2(listargs *l)
{ { Cint Result = 0;
{ Cint d = 0;
{ ITERATE(x);
for (START(l); NEXT(x);)
d= (d+exp2_integer(x));
}
Result = d;
}
return (Result);}
}
// parse the body and return (status, functional, body)
// the input is body | (function!(f) | function!(f,s)) < | body> opt
//
/* The c++ function for: iClaire/extract_status(x:any) [NEW_ALLOC] */
list * extract_status_any(OID x)
{ GC_BIND;
{ list *Result ;
{ OID s = CNULL;
OID f;
if ((INHERIT(OWNER(x),Language._Call)) && (OBJECT(Call,x)->selector == Language.function_I))
f = x;
else f = CNULL;
if (INHERIT(OWNER(x),Language._And))
{ OID y = (*(OBJECT(And,x)->args))[1];
if ((INHERIT(OWNER(y),Language._Call)) && (OBJECT(Call,y)->selector == Language.function_I))
{ f= y;
x= (*(OBJECT(And,x)->args))[2];
}
}
else if (INHERIT(OWNER(x),Language._Call))
{ if (OBJECT(Call,x)->selector == Language.function_I)
x= _oid_(Kernel.body);
}
else ;if (f != CNULL)
{ x= _oid_(Kernel.body);
if (length_bag(OBJECT(bag,(*Core.args)(f))) > 1)
{ Cint V_CL0095;{ set * g0096UU;
{ set * u_bag = set::empty(Kernel.emptySet);
{ OID gc_local;
ITERATE(u);
bag *u_support;
u_support = GC_OBJECT(list,cdr_list(GC_OBJECT(list,OBJECT(list,(*Core.args)(f)))));
for (START(u_support); NEXT(u);)
{ GC_LOOP;
{ OID g0097UU;
{ if (INHERIT(OWNER(u),Kernel._integer))
g0097UU = u;
else if (INHERIT(OWNER(u),Core._global_variable))
g0097UU = OBJECT(global_variable,u)->value;
else { OID V_CL0098;close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[116] ~S not allowed in function!")),
_oid_(list::alloc(1,u)))));
g0097UU=_void_(V_CL0098);}
GC_OID(g0097UU);}
u_bag->addFast(g0097UU);
}
GC_UNLOOP;}
}
g0096UU = GC_OBJECT(set,u_bag);
}
V_CL0095 = integer_I_set(g0096UU);
}
s=V_CL0095;}
else s= 0;
f= _oid_(make_function_string(string_I_symbol(extract_symbol_any((*(OBJECT(bag,(*Core.args)(f))))[1]))));
}
Result = list::alloc(3,s,
f,
x);
}
GC_UNBIND; return (Result);}
}
// cleans a pattern into a type
//
/* The c++ function for: iClaire/type!(x:any) [NEW_ALLOC] */
ClaireType * type_I_any(OID x)
{ GC_BIND;
{ ClaireType *Result ;
if (INHERIT(OWNER(x),Kernel._list))
{ bag *v_list; OID v_val;
OID y,CLcount;
v_list = OBJECT(bag,x);
Result = v_list->clone();
for (CLcount= 1; CLcount <= v_list->length; CLcount++)
{ y = (*(v_list))[CLcount];
v_val = _oid_(type_I_any(y));
(*((list *) Result))[CLcount] = v_val;}
}
else if (INHERIT(OWNER(x),Core._Param))
{ Param * _CL_obj = ((Param *) GC_OBJECT(Param,new_object_class(Core._Param)));
(_CL_obj->arg = OBJECT(Param,x)->arg);
(_CL_obj->params = OBJECT(Param,x)->params);
{ Param * g0099 = _CL_obj;
list * g0100;
{ bag *v_list; OID v_val;
OID y,CLcount;
v_list = GC_OBJECT(list,OBJECT(Param,x)->args);
g0100 = v_list->clone();
for (CLcount= 1; CLcount <= v_list->length; CLcount++)
{ y = (*(v_list))[CLcount];
v_val = _oid_(type_I_any(y));
(*((list *) g0100))[CLcount] = v_val;}
}
(g0099->args = g0100);}
Result = _CL_obj;
}
else if (INHERIT(OWNER(x),Core._Reference))
Result = Kernel._any;
else Result = OBJECT(ClaireType,x);
GC_UNBIND; return (Result);}
}
// creates a table
// to do in later versions: use an array if direct indexed access
// in the meanwhile, arrays of float should be used with care (indexed arrays)
//
/* The c++ function for: self_eval(self:Defarray) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE+SAFE_RESULT] */
OID self_eval_Defarray(Defarray *self)
{ GC_BIND;
{ OID Result = 0;
{ list * a = GC_OBJECT(list,self->arg->args);
table * ar = ((table *) new_thing_class(Kernel._table,extract_symbol_any((*(a))[1])));
Variable * v = OBJECT(Variable,(*(a))[2]);
ClaireType * s = GC_OBJECT(ClaireType,extract_type_any(GC_OID(_oid_(v->range))));
OID e;
{ { list * l = GC_OBJECT(list,cdr_list(a));
OID b = GC_OID(lexical_build_any(GC_OID(self->body),l,0));
{ ClaireBoolean * g0101I;
{ OID g0102UU;
{ OID gc_local;
ITERATE(va);
g0102UU= Kernel.cfalse;
for (START(l); NEXT(va);)
if (occurrence_any(b,OBJECT(Variable,va)) > 0)
{ g0102UU = Kernel.ctrue;
break;}
}
g0101I = boolean_I_any(g0102UU);
}
if (g0101I == CTRUE) e = _oid_(lambda_I_list(l,b));
else e = self->body;
}
}
GC_OID(e);}
OID d;
{ if (INHERIT(OWNER(e),Core._lambda))
d = CNULL;
else d = eval_any(GC_OID(self->body));
GC_OID(d);}
update_property(Kernel.range,
ar,
5,
Kernel._object,
GC_OID(extract_pattern_any(GC_OID(self->set_arg),Kernel.nil)));
if (ar->range == (NULL))
close_exception(((range_error *) (*Core._range_error)(_oid_(Kernel._table),
GC_OID(self->set_arg),
_oid_(Kernel._type))));
if ((d != CNULL) &&
(belong_to(d,_oid_(ar->range)) != CTRUE))
close_exception(((range_error *) (*Core._range_error)(_oid_(ar),
d,
_oid_(ar->range))));
(v->range = s);
attach_comment_any(_oid_(ar));
if (INHERIT(class_I_type(ar->range),Kernel._set))
(ar->multivalued_ask = CTRUE);
else if ((INHERIT(class_I_type(ar->range),Kernel._list)) &&
(inherit_ask_class(ar->range->isa,Language._Tuple) != CTRUE))
(ar->multivalued_ask = Kernel._list);
if (a->length == 2)
{ (ar->domain = s);
if (INHERIT(s->isa,Core._Interval))
{ (ar->params = (CLREAD(Interval,s,arg1)-1));
(ar->graph = make_copy_list_integer(size_Interval(((Interval *) s)),d));
}
else { (ar->params = _oid_(Kernel._any));
(ar->graph = make_list_integer(29,CNULL));
}
if (INHERIT(OWNER(e),Core._lambda))
{ OID gc_local;
ITERATE(y);
bag *y_support;
y_support = GC_OBJECT(bag,enumerate_any(_oid_(ar->domain)));
for (START(y_support); NEXT(y);)
{ GC_LOOP;
nth_equal_table1(ar,y,GC_OID(funcall_lambda1(OBJECT(lambda,e),y)));
GC_UNLOOP;}
}
else (ar->DEFAULT = d);
}
else { ClaireType * s2 = GC_OBJECT(ClaireType,extract_type_any(GC_OID(_oid_(OBJECT(Variable,(*(a))[3])->range))));
(ar->domain = tuple_I_list(GC_OBJECT(list,list::alloc(2,_oid_(s),_oid_(s2)))));
(OBJECT(Variable,(*(a))[3])->range = s2);
if ((INHERIT(s->isa,Core._Interval)) &&
(INHERIT(s2->isa,Core._Interval)))
{ (ar->params = _oid_(list::alloc(2,Core.size->fcall(((Cint) s2)),(((CLREAD(Interval,s,arg1)*(Core.size->fcall(((Cint) s2))))+CLREAD(Interval,s2,arg1))-1))));
(ar->graph = make_copy_list_integer(((Core.size->fcall(((Cint) s)))*(Core.size->fcall(((Cint) s2)))),d));
}
else { (ar->params = _oid_(Kernel._any));
(ar->graph = make_list_integer(29,CNULL));
}
if (INHERIT(OWNER(e),Core._lambda))
{ OID gc_local;
ITERATE(y1);
bag *y1_support;
y1_support = GC_OBJECT(bag,enumerate_any(_oid_(s)));
for (START(y1_support); NEXT(y1);)
{ GC_LOOP;
{ OID gc_local;
ITERATE(y2);
bag *y2_support;
y2_support = GC_OBJECT(bag,enumerate_any(_oid_(s2)));
for (START(y2_support); NEXT(y2);)
{ GC_LOOP;
nth_equal_table2(ar,y1,y2,GC_OID((*Kernel.funcall)(e,
y1,
y2)));
GC_UNLOOP;}
}
GC_UNLOOP;}
}
else (ar->DEFAULT = d);
}
Result = _oid_(ar);
}
GC_UNBIND; return (Result);}
}
// ------------------ NEW in v3.2 : definition of rules -----------------------
//
// a demon is a lambda with a name and a priority
/* The c++ function for: self_print(self:demon) [0] */
void self_print_demon(Language_demon *self)
{ princ_symbol(self->pname);
}
/* The c++ function for: funcall(self:demon,x:any,y:any) [NEW_ALLOC] */
OID funcall_demon1(Language_demon *self,OID x,OID y)
{ GC_BIND;
{ OID Result = 0;
Result = (*Kernel.funcall)(GC_OID(_oid_(self->formula)),
x,
y);
GC_UNBIND; return (Result);}
}
/* The c++ function for: funcall(self:demon,x:any,y:any,z:any) [NEW_ALLOC] */
OID funcall_demon2(Language_demon *self,OID x,OID y,OID z)
{ GC_BIND;
{ OID Result = 0;
Result = (*Kernel.funcall)(GC_OID(_oid_(self->formula)),
x,
y,
z);
GC_UNBIND; return (Result);}
}
// in the interpreted mode we store the list of demons using a table
// list of relevant demons
// the last rule/axiom that was defined on each relation
// this is used to find when the relation may be compiled
// list of involved relations
// compile(ru) => may compile(r)
// evaluate a rule definition: create a new demon and, if needed, the if_write
// function
/* The c++ function for: self_eval(self:Defrule) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
OID self_eval_Defrule(Defrule *self)
{ GC_BIND;
{ OID Result = 0;
if ((*(self->args))[1] != _oid_(ClEnv))
Result = (*Language.eval_rule)(_oid_(self));
else { OID _Zcondition = GC_OID(self->arg);
OID ru = GC_OID(get_symbol(self->ident));
(OBJECT(ClaireObject,ru)->isa = Language._rule_object);
add_I_property(Kernel.instances,Language._rule_object,11,ru);
{ tuple * g0104 = make_filter_any(_Zcondition);
OID R = (*(g0104))[1];
OID lvar = GC_OID((*(g0104))[2]);
Language_demon * d = make_demon_relation(OBJECT(ClaireRelation,R),
OBJECT(symbol,(*Kernel.name)(ru)),
OBJECT(list,lvar),
_Zcondition,
GC_OID(lexical_build_any(GC_OID(self->body),OBJECT(list,lvar),0)));
if (INHERIT(OWNER(OBJECT(ClaireRelation,R)->if_write),Kernel._function))
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("cannot define a new rule on ~S which is closed")),
_oid_(list::alloc(1,R)))));
add_table(Language.demons,R,_oid_(d));
nth_put_table(Language.last_rule,R,ru);
if (length_bag(OBJECT(bag,nth_table1(Language.demons,R))) == 1)
eval_if_write_relation(OBJECT(ClaireRelation,R));
if ((INHERIT(OBJECT(ClaireObject,R)->isa,Kernel._property)) && (OBJECT(property,R)->restrictions->length == 0))
eventMethod_property(OBJECT(property,R));
Result = ru;
}
}
GC_UNBIND; return (Result);}
}
// an eventMethod is a property whose unique (?) restriction is a method
/* The c++ function for: eventMethod?(r:relation) [0] */
ClaireBoolean * eventMethod_ask_relation2(ClaireRelation *r)
{ { ClaireBoolean *Result ;
if (INHERIT(r->isa,Kernel._property))
{ OID g0106UU;
{ ITERATE(x);
g0106UU= Kernel.cfalse;
for (START(CLREAD(property,r,restrictions)); NEXT(x);)
if (not_any(_oid_(equal(_oid_(Kernel._slot),_oid_(OBJECT(ClaireObject,x)->isa)))) != CTRUE)
{ g0106UU = Kernel.ctrue;
break;}
}
Result = not_any(g0106UU);
}
else Result = CFALSE;
return (Result);}
}
// check that condition is either a filter or the conjunction of a filter and a
// condition
// a filter is R(x) := y | R(x) := (y <- z) | R(x) :add y | P(x,y)
// R(x) is x.r or A[x]
// the list of variable is of length 3 if R is mono-valued
/* The c++ function for: make_filter(g0107:any) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
tuple * make_filter_any_(OID g0107)
{ return make_filter_any(g0107)->copyIfNeeded();}
/* The c++ function for: make_filter(cond:any) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
tuple * make_filter_any(OID cond)
{ GC_BIND;
{ tuple *Result ;
{ ClaireObject *V_CC ;
{ OID c;
{ if (INHERIT(OWNER(cond),Language._And))
c = (*(OBJECT(And,cond)->args))[1];
else c = cond;
GC_OID(c);}
if ((INHERIT(OWNER(c),Language._Call)) && (((OBJECT(Call,c)->selector == Core.write) ||
(OBJECT(Call,c)->selector == Kernel.nth_equal)) &&
(INHERIT(OWNER((*(OBJECT(Call,c)->args))[1]),Kernel._relation))))
{ ClaireRelation * R = OBJECT(ClaireRelation,(*(OBJECT(bag,(*Core.args)(c))))[1]);
Variable * x;
{ { Variable * _CL_obj = ((Variable *) GC_OBJECT(Variable,new_object_class(Language._Variable)));
(_CL_obj->pname = extract_symbol_any((*(OBJECT(bag,(*Core.args)(c))))[2]));
(_CL_obj->range = R->domain);
add_I_property(Kernel.instances,Language._Variable,11,_oid_(_CL_obj));
x = _CL_obj;
}
GC_OBJECT(Variable,x);}
OID y1 = GC_OID((*(OBJECT(bag,(*Core.args)(c))))[3]);
if (multi_ask_any(_oid_(R)) == CTRUE)
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[188] wrong event filter ~S for multi-valued relation")),
_oid_(list::alloc(2,c,_oid_(R))))));
if ((INHERIT(OWNER(y1),Language._Call)) && (OBJECT(Call,y1)->selector == Language._inf_dash))
{ OID v_bag;
GC_ANY(V_CC= tuple::empty());
((tuple *) V_CC)->addFast(_oid_(R));
{ list * V_CL0108;{ OID v_bag;
GC_ANY(V_CL0108= list::empty(Kernel.emptySet));
((list *) V_CL0108)->addFast(_oid_(x));
{ { Variable * _CL_obj = ((Variable *) GC_OBJECT(Variable,new_object_class(Language._Variable)));
(_CL_obj->pname = extract_symbol_any((*(OBJECT(bag,(*Core.args)(y1))))[1]));
(_CL_obj->range = R->range);
add_I_property(Kernel.instances,Language._Variable,11,_oid_(_CL_obj));
v_bag = _oid_(_CL_obj);
}
GC_OID(v_bag);}
((list *) V_CL0108)->addFast(v_bag);
{ { Variable * _CL_obj = ((Variable *) GC_OBJECT(Variable,new_object_class(Language._Variable)));
(_CL_obj->pname = extract_symbol_any((*(OBJECT(bag,(*Core.args)(y1))))[2]));
(_CL_obj->range = R->range);
add_I_property(Kernel.instances,Language._Variable,11,_oid_(_CL_obj));
v_bag = _oid_(_CL_obj);
}
GC_OID(v_bag);}
((list *) V_CL0108)->addFast(v_bag);}
v_bag=_oid_(V_CL0108);}
((tuple *) V_CC)->addFast(v_bag);}
else { OID v_bag;
GC_ANY(V_CC= tuple::empty());
((tuple *) V_CC)->addFast(_oid_(R));
{ list * V_CL0109;{ OID v_bag;
GC_ANY(V_CL0109= list::empty(Kernel.emptySet));
((list *) V_CL0109)->addFast(_oid_(x));
{ { Variable * _CL_obj = ((Variable *) GC_OBJECT(Variable,new_object_class(Language._Variable)));
(_CL_obj->pname = extract_symbol_any(y1));
(_CL_obj->range = safeRange_relation(R));
add_I_property(Kernel.instances,Language._Variable,11,_oid_(_CL_obj));
v_bag = _oid_(_CL_obj);
}
GC_OID(v_bag);}
((list *) V_CL0109)->addFast(v_bag);
{ { Variable * _CL_obj = ((Variable *) GC_OBJECT(Variable,new_object_class(Language._Variable)));
(_CL_obj->pname = gensym_void());
(_CL_obj->range = safeRange_relation(R));
add_I_property(Kernel.instances,Language._Variable,11,_oid_(_CL_obj));
v_bag = _oid_(_CL_obj);
}
GC_OID(v_bag);}
((list *) V_CL0109)->addFast(v_bag);}
v_bag=_oid_(V_CL0109);}
((tuple *) V_CC)->addFast(v_bag);}
}
else if ((INHERIT(OWNER(c),Language._Call)) && ((OBJECT(Call,c)->selector == Kernel.add) &&
(INHERIT(OWNER((*(OBJECT(Call,c)->args))[1]),Kernel._relation))))
{ ClaireRelation * R = OBJECT(ClaireRelation,(*(OBJECT(bag,(*Core.args)(c))))[1]);
Variable * x;
{ { Variable * _CL_obj = ((Variable *) GC_OBJECT(Variable,new_object_class(Language._Variable)));
(_CL_obj->pname = extract_symbol_any((*(OBJECT(bag,(*Core.args)(c))))[2]));
(_CL_obj->range = R->domain);
add_I_property(Kernel.instances,Language._Variable,11,_oid_(_CL_obj));
x = _CL_obj;
}
GC_OBJECT(Variable,x);}
Variable * y;
{ { Variable * _CL_obj = ((Variable *) GC_OBJECT(Variable,new_object_class(Language._Variable)));
(_CL_obj->pname = extract_symbol_any((*(OBJECT(bag,(*Core.args)(c))))[3]));
(_CL_obj->range = R->range);
add_I_property(Kernel.instances,Language._Variable,11,_oid_(_CL_obj));
y = _CL_obj;
}
GC_OBJECT(Variable,y);}
V_CC = tuple::alloc(2,_oid_(R),_oid_(list::alloc(2,_oid_(x),_oid_(y))));
}
else if ((INHERIT(OWNER(c),Language._Call)) && (OBJECT(Call,c)->args->length == 2))
{ property * R = OBJECT(Call,c)->selector;
Variable * x;
{ { Variable * _CL_obj = ((Variable *) GC_OBJECT(Variable,new_object_class(Language._Variable)));
(_CL_obj->pname = extract_symbol_any((*(OBJECT(bag,(*Core.args)(c))))[1]));
(_CL_obj->range = R->domain);
add_I_property(Kernel.instances,Language._Variable,11,_oid_(_CL_obj));
x = _CL_obj;
}
GC_OBJECT(Variable,x);}
Variable * y;
{ { Variable * _CL_obj = ((Variable *) GC_OBJECT(Variable,new_object_class(Language._Variable)));
(_CL_obj->pname = extract_symbol_any((*(OBJECT(bag,(*Core.args)(c))))[2]));
(_CL_obj->range = R->range);
add_I_property(Kernel.instances,Language._Variable,11,_oid_(_CL_obj));
y = _CL_obj;
}
GC_OBJECT(Variable,y);}
V_CC = tuple::alloc(2,_oid_(R),_oid_(list::alloc(2,_oid_(x),_oid_(y))));
}
else close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[188] wrong event filter: ~S")),
_oid_(list::alloc(1,c)))));
}
Result= (tuple *) V_CC;}
GC_UNBIND; return (Result);}
}
// create a demon
// notice that a demon has 3 args if R is monovalued
/* The c++ function for: make_demon(R:relation,n:symbol,lvar:list[Variable],cond:any,conc:any) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
Language_demon * make_demon_relation(ClaireRelation *R,symbol *n,list *lvar,OID cond,OID conc)
{ GC_BIND;
{ Language_demon *Result ;
{ OID x = (*(lvar))[1];
OID y = (*(lvar))[2];
OID _Ztest;
{ { Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = ((multi_ask_any(_oid_(R)) == CTRUE) ?
Kernel._Z :
Kernel._equal ));
(_CL_obj->args = list::alloc(2,y,GC_OID(_oid_(readCall_relation(R,x)))));
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
_Ztest = _oid_(_CL_obj);
}
GC_OID(_Ztest);}
OID _Zbody = conc;
if (Kernel.if_write->trace_I > ClEnv->verbose)
{ { Do * _CL_obj = ((Do *) GC_OBJECT(Do,new_object_class(Language._Do)));
{ Do * g0110 = _CL_obj;
list * g0111;
{ OID v_bag;
GC_ANY(g0111= list::empty(Kernel.emptySet));
{ { Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Core.format);
{ Call * g0112 = _CL_obj;
list * g0113;
{ OID v_bag;
GC_ANY(g0113= list::empty(Kernel.emptySet));
((list *) g0113)->addFast(_string_(CSTRING("--- trigger ~A(~S,~S)\n")));
{ { List * _CL_obj = ((List *) GC_OBJECT(List,new_object_class(Language._List)));
(_CL_obj->args = list::alloc(3,GC_OID(_string_(string_I_symbol(n))),
x,
y));
add_I_property(Kernel.instances,Language._List,11,_oid_(_CL_obj));
v_bag = _oid_(_CL_obj);
}
GC_OID(v_bag);}
((list *) g0113)->addFast(v_bag);}
(g0112->args = g0113);}
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
v_bag = _oid_(_CL_obj);
}
GC_OID(v_bag);}
((list *) g0111)->addFast(v_bag);
((list *) g0111)->addFast(conc);}
(g0110->args = g0111);}
add_I_property(Kernel.instances,Language._Do,11,_oid_(_CL_obj));
conc = _oid_(_CL_obj);
}
GC_OID(conc);}
{ { If * _CL_obj = ((If *) GC_OBJECT(If,new_object_class(Language._If)));
(_CL_obj->arg = conc);
add_I_property(Kernel.instances,Language._If,11,_oid_(_CL_obj));
(_CL_obj->other = Kernel.cfalse);
_Zbody = _oid_(_CL_obj);
}
GC_OID(_Zbody);}
if (eventMethod_ask_relation2(R) == CTRUE)
{ if (INHERIT(OWNER(cond),Language._And))
{ if (OBJECT(And,cond)->args->length > 2)
{ And * _CL_obj = ((And *) GC_OBJECT(And,new_object_class(Language._And)));
(_CL_obj->args = cdr_list(GC_OBJECT(list,OBJECT(And,cond)->args)));
add_I_property(Kernel.instances,Language._And,11,_oid_(_CL_obj));
_Ztest = _oid_(_CL_obj);
}
else _Ztest = (*(OBJECT(And,cond)->args))[2];
GC_OID(_Ztest);}
else _Zbody= conc;
}
else if (INHERIT(OWNER(cond),Language._And))
{ { And * _CL_obj = ((And *) GC_OBJECT(And,new_object_class(Language._And)));
(_CL_obj->args = append_list(list::alloc(1,_Ztest),GC_OBJECT(list,cdr_list(GC_OBJECT(list,OBJECT(And,cond)->args)))));
add_I_property(Kernel.instances,Language._And,11,_oid_(_CL_obj));
_Ztest = _oid_(_CL_obj);
}
GC_OID(_Ztest);}
if (INHERIT(OWNER(_Zbody),Language._If))
(OBJECT(If,_Zbody)->test = _Ztest);
{ Language_demon * _CL_obj = ((Language_demon *) GC_OBJECT(Language_demon,new_object_class(Language._demon)));
(_CL_obj->pname = n);
(_CL_obj->formula = lambda_I_list(lvar,_Zbody));
add_I_property(Kernel.instances,Language._demon,11,_oid_(_CL_obj));
Result = _CL_obj;
}
}
GC_UNBIND; return (Result);}
}
// cute litle guy
/* The c++ function for: readCall(R:relation,x:any) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
Call * readCall_relation(ClaireRelation *R,OID x)
{ GC_BIND;
{ Call *Result ;
if (INHERIT(R->isa,Kernel._table))
{ Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Kernel.get);
(_CL_obj->args = list::alloc(2,_oid_(R),x));
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
Result = _CL_obj;
}
else { Call_plus * _CL_obj = ((Call_plus *) GC_OBJECT(Call_plus,new_object_class(Language._Call_plus)));
(_CL_obj->selector = ((property *) R));
(_CL_obj->args = list::alloc(1,x));
add_I_property(Kernel.instances,Language._Call_plus,11,_oid_(_CL_obj));
Result = _CL_obj;
}
GC_UNBIND; return (Result);}
}
// a small brother
/* The c++ function for: putCall(R:relation,x:any,y:any) [NEW_ALLOC] */
Call * putCall_relation2(ClaireRelation *R,OID x,OID y)
{ GC_BIND;
{ Call *Result ;
if (multi_ask_any(_oid_(R)) == CTRUE)
{ Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Core.add_value);
(_CL_obj->args = list::alloc(3,_oid_(R),
x,
y));
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
Result = _CL_obj;
}
else { Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Kernel.put);
(_CL_obj->args = list::alloc(3,_oid_(R),
x,
y));
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
Result = _CL_obj;
}
GC_UNBIND; return (Result);}
}
// v3.3 : find the range when we read the current value
/* The c++ function for: safeRange(x:relation) [0] */
ClaireType * safeRange_relation(ClaireRelation *x)
{ { ClaireType *Result ;
if (INHERIT(x->isa,Kernel._property))
{ { ClaireBoolean * g0114I;
{ OID g0115UU;
{ ITERATE(s);
g0115UU= Kernel.cfalse;
for (START(CLREAD(property,x,restrictions)); NEXT(s);)
{ ClaireBoolean * g0116I;
{ OID g0117UU;
{ ClaireBoolean * V_CL0118;{ OID g0119UU;
if (Kernel._slot == OBJECT(ClaireObject,s)->isa)
g0119UU = _oid_(belong_to(OBJECT(slot,s)->DEFAULT,_oid_(OBJECT(restriction,s)->range)));
else g0119UU = Kernel.cfalse;
V_CL0118 = boolean_I_any(g0119UU);
}
g0117UU=_oid_(V_CL0118);}
g0116I = ((g0117UU != Kernel.ctrue) ? CTRUE : CFALSE);
}
if (g0116I == CTRUE) { g0115UU = Kernel.ctrue;
break;}
}
}
g0114I = not_any(g0115UU);
}
if (g0114I == CTRUE) Result = x->range;
else Result = Kernel._any;
}
}
else if (INHERIT(x->isa,Kernel._table))
{ if (belong_to(CLREAD(table,x,DEFAULT),_oid_(x->range)) == CTRUE)
Result = x->range;
else Result = Kernel._any;
}
else Result = Kernel._any;
return (Result);}
}
// generate an if_write "daemon", only the first time, which uses
// the list in demons[R]
// the first step is to make the update (with inverse management)
/* The c++ function for: eval_if_write(R:relation) [NEW_ALLOC+BAG_UPDATE+SLOT_UPDATE] */
void eval_if_write_relation(ClaireRelation *R)
{ GC_BIND;
{ OID l = GC_OID(nth_table1(Language.demons,_oid_(R)));
list * lvar = GC_OBJECT(list,OBJECT(Language_demon,(*(OBJECT(bag,l)))[1])->formula->vars);
Variable * dv;
{ { Variable * _CL_obj = ((Variable *) GC_OBJECT(Variable,new_object_class(Language._Variable)));
(_CL_obj->pname = gensym_void());
(_CL_obj->range = Language._demon);
add_I_property(Kernel.instances,Language._Variable,11,_oid_(_CL_obj));
dv = _CL_obj;
}
GC_OBJECT(Variable,dv);}
list * l1 = list::alloc(Kernel._any,1,GC_OID(_oid_(putCall_relation2(R,(*(lvar))[1],(*(lvar))[2]))));
list * l2;
{ OID v_bag;
GC_ANY(l2= list::empty(Kernel._any));
{ { For * _CL_obj = ((For *) GC_OBJECT(For,new_object_class(Language._For)));
(_CL_obj->var = dv);
{ Iteration * g0120 = _CL_obj;
OID g0121;
{ Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Kernel.nth);
(_CL_obj->args = list::alloc(2,_oid_(Language.demons),_oid_(R)));
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
g0121 = _oid_(_CL_obj);
}
(g0120->set_arg = g0121);}
{ Iteration * g0122 = _CL_obj;
OID g0123;
{ Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Kernel.funcall);
(_CL_obj->args = append_list(list::alloc(1,_oid_(dv)),lvar));
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
g0123 = _oid_(_CL_obj);
}
(g0122->arg = g0123);}
add_I_property(Kernel.instances,Language._For,11,_oid_(_CL_obj));
v_bag = _oid_(_CL_obj);
}
GC_OID(v_bag);}
((list *) l2)->addFast(v_bag);}
{ ITERATE(v);
for (START(lvar); NEXT(v);)
put_property2(Kernel.range,OBJECT(ClaireObject,v),_oid_(class_I_type(OBJECT(ClaireType,(*Kernel.range)(v)))));
}
if (((R->inverse == (NULL)) ? CTRUE : CFALSE) != CTRUE)
{ if (multi_ask_any(_oid_(R)) != CTRUE)
{ { OID g0124UU;
{ Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Core.update_dash);
(_CL_obj->args = list::alloc(3,_oid_(R->inverse),
(*(lvar))[3],
(*(lvar))[1]));
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
g0124UU = _oid_(_CL_obj);
}
l1 = l1->addFast(g0124UU);
}
GC_OBJECT(list,l1);}
l1= GC_OBJECT(list,l1->addFast(GC_OID(_oid_(putCall_relation2(R->inverse,(*(lvar))[2],(*(lvar))[1])))));
}
{ ClaireRelation * g0125 = R;
OID g0126;
{ lambda * V_CL0127;{ OID g0128UU;
if (eventMethod_ask_relation2(R) == CTRUE)
{ Do * _CL_obj = ((Do *) GC_OBJECT(Do,new_object_class(Language._Do)));
(_CL_obj->args = l2);
add_I_property(Kernel.instances,Language._Do,11,_oid_(_CL_obj));
g0128UU = _oid_(_CL_obj);
}
else if (multi_ask_any(_oid_(R)) == CTRUE)
{ If * _CL_obj = ((If *) GC_OBJECT(If,new_object_class(Language._If)));
{ If * g0129 = _CL_obj;
OID g0130;
{ Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Core.NOT);
{ Call * g0131 = _CL_obj;
list * g0132;
{ OID v_bag;
GC_ANY(g0132= list::empty(Kernel.emptySet));
{ { Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Kernel._Z);
(_CL_obj->args = list::alloc(2,(*(lvar))[2],GC_OID(_oid_(readCall_relation(R,(*(lvar))[1])))));
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
v_bag = _oid_(_CL_obj);
}
GC_OID(v_bag);}
((list *) g0132)->addFast(v_bag);}
(g0131->args = g0132);}
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
g0130 = _oid_(_CL_obj);
}
(g0129->test = g0130);}
{ If * g0133 = _CL_obj;
OID g0134;
{ Do * _CL_obj = ((Do *) GC_OBJECT(Do,new_object_class(Language._Do)));
(_CL_obj->args = append_list(l1,l2));
add_I_property(Kernel.instances,Language._Do,11,_oid_(_CL_obj));
g0134 = _oid_(_CL_obj);
}
(g0133->arg = g0134);}
add_I_property(Kernel.instances,Language._If,11,_oid_(_CL_obj));
(_CL_obj->other = Kernel.cfalse);
g0128UU = _oid_(_CL_obj);
}
else { Let * _CL_obj = ((Let *) GC_OBJECT(Let,new_object_class(Language._Let)));
store_object(_CL_obj,
2,
Kernel._object,
(*(lvar))[3],
CFALSE);
(_CL_obj->value = _oid_(readCall_relation(R,(*(lvar))[1])));
{ Let * g0135 = _CL_obj;
OID g0136;
{ If * _CL_obj = ((If *) GC_OBJECT(If,new_object_class(Language._If)));
{ If * g0137 = _CL_obj;
OID g0138;
{ Call * _CL_obj = ((Call *) GC_OBJECT(Call,new_object_class(Language._Call)));
(_CL_obj->selector = Core._I_equal);
(_CL_obj->args = list::alloc(2,(*(lvar))[2],(*(lvar))[3]));
add_I_property(Kernel.instances,Language._Call,11,_oid_(_CL_obj));
g0138 = _oid_(_CL_obj);
}
(g0137->test = g0138);}
{ If * g0139 = _CL_obj;
OID g0140;
{ Do * _CL_obj = ((Do *) GC_OBJECT(Do,new_object_class(Language._Do)));
(_CL_obj->args = append_list(l1,l2));
add_I_property(Kernel.instances,Language._Do,11,_oid_(_CL_obj));
g0140 = _oid_(_CL_obj);
}
(g0139->arg = g0140);}
add_I_property(Kernel.instances,Language._If,11,_oid_(_CL_obj));
(_CL_obj->other = Kernel.cfalse);
g0136 = _oid_(_CL_obj);
}
(g0135->arg = g0136);}
add_I_property(Kernel.instances,Language._Let,11,_oid_(_CL_obj));
g0128UU = _oid_(_CL_obj);
}
V_CL0127 = lambda_I_list(list::alloc(2,(*(lvar))[1],(*(lvar))[2]),g0128UU);
}
g0126=_oid_(V_CL0127);}
(g0125->if_write = g0126);}
}
GC_UNBIND;}
// create a restriction (method) that will trigger an event
/* The c++ function for: eventMethod(p:property) [NEW_ALLOC+SLOT_UPDATE] */
void eventMethod_property(property *p)
{ GC_BIND;
{ method * m = add_method_property(p,
list::alloc(2,_oid_(p->domain),_oid_(p->range)),
Kernel._void,
0,
CNULL);
store_object(m,
8,
Kernel._object,
p->if_write,
CFALSE);
(m->functional = make_function_string(append_string(GC_STRING(string_I_symbol(p->name)),CSTRING("_write"))));
}
GC_UNBIND;}
// new in v3.1: the inter face pragma ******************************
// this array is used to store the declarations
// define a property as an interface
/* The c++ function for: interface(p:property) [NEW_ALLOC+SLOT_UPDATE] */
void interface_property(property *p)
{ if (boolean_I_any(_oid_(p->restrictions)) != CTRUE)
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[185] cannot define an empty property ~S as an interface")),
_oid_(list::alloc(1,_oid_(p))))));
if ((uniform_property(p) != CTRUE) ||
(OBJECT(restriction,(*(p->restrictions))[1])->domain->memq(_oid_(Kernel._float)) == CTRUE))
close_exception(((general_error *) (*Core._general_error)(_string_(CSTRING("[185] cannot define an non-uniform property ~S as an interface")),
_oid_(list::alloc(1,_oid_(p))))));
{ ClaireClass * d = domain_I_restriction(OBJECT(restriction,(*(p->restrictions))[1]));
list * ls = list::empty(Kernel._any);
{ ITERATE(g0141);
bag *g0141_support;
g0141_support = Kernel._property->descendents;
for (START(g0141_support); NEXT(g0141);)
{ ClaireBoolean * g0142;
{ OID V_C;{ ITERATE(p2);
V_C= Kernel.cfalse;
for (START(OBJECT(ClaireClass,g0141)->instances); NEXT(p2);)
if ((OBJECT(property,p2)->dispatcher > 0) &&
(boolean_I_any((*Core.glb)(_oid_(OBJECT(ClaireRelation,p2)->domain),
_oid_(p->domain))) == CTRUE))
ls= ls->addFast(OBJECT(property,p2)->dispatcher);
}
g0142=OBJECT(ClaireBoolean,V_C);}
if (g0142 == CTRUE)
{ ;break;}
}
}
{ ITERATE(x);
for (START(p->restrictions); NEXT(x);)
d= meet_class(d,domain_I_restriction(OBJECT(restriction,x)));
}
(p->domain = d);
{ property * g0144 = p;
Cint g0145;
{ OID i_some = CNULL;
{ Cint i = 1;
Cint g0143 = (ls->length+1);
{ while ((i <= g0143))
{ if (ls->memq(i) != CTRUE)
{ i_some= i;
break;}
++i;
}
}
}
g0145 = i_some;
}
(g0144->dispatcher = g0145);}
}
}
/* The c++ function for: interface(c:class,l:listargs) [NEW_ALLOC] */
void interface_class(ClaireClass *c,listargs *l)
{ GC_BIND;
{ OID g0146UU;
{ list * V_CL0147;{ list * x_out = list::empty(Kernel._property);
{ OID gc_local;
ITERATE(x);
for (START(l); NEXT(x);)
if (INHERIT(OWNER(x),Kernel._property))
x_out->addFast(x);
}
V_CL0147 = GC_OBJECT(list,x_out);
}
g0146UU=_oid_(V_CL0147);}
put_table(Language.InterfaceList,_oid_(c),g0146UU);
}
{ property * px = Language.ClaireInterface;
{ OID gc_local;
ITERATE(p);
bag *p_support;
p_support = GC_OBJECT(list,OBJECT(bag,nth_table1(Language.InterfaceList,_oid_(c))));
for (START(p_support); NEXT(p);)
if ((*Kernel.open)(p) == 3)
(*Core.call)(_oid_(px),
p);
}
}
GC_UNBIND;}
// only implied for open properties !!!!
// ****************** Construction *********************************
// filling the evaluation form
| 41.740423 | 192 | 0.517853 | [
"object",
"vector"
] |
9483a63dfd5f94fc7cc5d5248da351e02899dd82 | 4,849 | cpp | C++ | ImageHeightTrimesh/src/ImageHeightFieldApp.cpp | eighteight/CinderEigh | d9dfc6a0ad9a9e6c5b82624971127f0335d91639 | [
"Apache-2.0"
] | null | null | null | ImageHeightTrimesh/src/ImageHeightFieldApp.cpp | eighteight/CinderEigh | d9dfc6a0ad9a9e6c5b82624971127f0335d91639 | [
"Apache-2.0"
] | null | null | null | ImageHeightTrimesh/src/ImageHeightFieldApp.cpp | eighteight/CinderEigh | d9dfc6a0ad9a9e6c5b82624971127f0335d91639 | [
"Apache-2.0"
] | null | null | null | #include "cinder/app/AppBasic.h"
#include "cinder/ArcBall.h"
#include "cinder/Rand.h"
#include "cinder/Camera.h"
#include "cinder/Surface.h"
#include "cinder/gl/Vbo.h"
#include "cinder/ImageIo.h"
using namespace ci;
using namespace ci::app;
class ImageHFApp : public AppBasic {
public:
void setup();
void resize();
void mouseDown( MouseEvent event );
void mouseDrag( MouseEvent event );
void keyDown( KeyEvent event );
void draw();
void openFile();
private:
enum ColorSwitch {
kColor, kRed, kGreen, kBlue
};
void updateData( ColorSwitch whichColor );
CameraPersp mCam;
Arcball mArcball;
uint32_t mWidth, mHeight;
Surface32f mImage;
gl::VboMesh mVboMesh;
};
void ImageHFApp::setup()
{
gl::enableAlphaBlending();
gl::enableDepthRead();
gl::enableDepthWrite();
// initialize the arcball with a semi-arbitrary rotation just to give an interesting angle
mArcball.setQuat( Quatf( Vec3f( 0.0577576f, -0.956794f, 0.284971f ), 3.68f ) );
openFile();
}
void ImageHFApp::openFile()
{
fs::path path = getOpenFilePath( "", ImageIo::getLoadExtensions() );
if( ! path.empty() ) {
mImage = loadImage( path );
mWidth = mImage.getWidth();
mHeight = mImage.getHeight();
gl::VboMesh::Layout layout;
layout.setDynamicColorsRGB();
layout.setDynamicPositions();
layout.setStaticIndices();
bool forward = false;
std::vector<uint32_t> indices;
for(int y=0;y<mHeight-1;++y) {
if(forward) {
indices.push_back( y*mWidth + 0 );
for(int x=0;x<mWidth;++x) {
indices.push_back( y*mWidth + x );
indices.push_back( (y+1)*mWidth + x );
}
}
else {
indices.push_back( y*mWidth + mWidth-1 );
for(int x=mWidth-1;x>=0;--x) {
indices.push_back( y*mWidth + x );
indices.push_back( (y+1)*mWidth + x );
}
}
forward = !forward;
}
mVboMesh = gl::VboMesh( mWidth * mHeight, indices.size(),
layout, GL_TRIANGLE_STRIP );
mVboMesh.bufferIndices( indices );
updateData( kColor );
}
}
void ImageHFApp::resize()
{
mArcball.setWindowSize( getWindowSize() );
mArcball.setCenter( Vec2f( getWindowWidth() / 2.0f, getWindowHeight() / 2.0f ) );
mArcball.setRadius( getWindowHeight() / 2.0f );
mCam.lookAt( Vec3f( 0.0f, 0.0f, -150 ), Vec3f::zero() );
mCam.setPerspective( 60.0f, getWindowAspectRatio(), 0.1f, 1000.0f );
gl::setMatrices( mCam );
}
void ImageHFApp::mouseDown( MouseEvent event )
{
mArcball.mouseDown( event.getPos() );
}
void ImageHFApp::mouseDrag( MouseEvent event )
{
mArcball.mouseDrag( event.getPos() );
}
void ImageHFApp::keyDown( KeyEvent event )
{
switch( event.getChar() ) {
case 'r':
updateData( kRed );
break;
case 'g':
updateData( kGreen );
break;
case 'b':
updateData( kBlue );
break;
case 'c':
updateData( kColor );
break;
case 'o':
openFile();
break;
}
}
void ImageHFApp::draw()
{
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
gl::pushModelView();
gl::translate( Vec3f( 0.0f, 0.0f, mHeight / 2.0f ) );
gl::rotate( mArcball.getQuat() );
if( mVboMesh )
gl::draw( mVboMesh );
gl::popModelView();
}
void ImageHFApp::updateData( ImageHFApp::ColorSwitch whichColor )
{
Surface32f::Iter pixelIter = mImage.getIter();
gl::VboMesh::VertexIter vertexIter( mVboMesh );
while( pixelIter.line() ) {
while( pixelIter.pixel() ) {
Color color( pixelIter.r(), pixelIter.g(), pixelIter.b() );
float height;
const float muteColor = 0.2f;
// calculate the height based on a weighted average of the RGB, and emphasize either the red green or blue color in each of those modes
switch( whichColor ) {
case kColor:
height = color.dot( Color( 0.3333f, 0.3333f, 0.3333f ) );
break;
case kRed:
height = color.dot( Color( 1, 0, 0 ) );
color *= Color( 1, muteColor, muteColor );
break;
case kGreen:
height = color.dot( Color( 0, 1, 0 ) );
color *= Color( muteColor, 1, muteColor );
break;
case kBlue:
height = color.dot( Color( 0, 0, 1 ) );
color *= Color( muteColor, muteColor, 1 );
break;
}
// the x and the z coordinates correspond to the pixel's x & y
float x = pixelIter.x() - mWidth / 2.0f;
float z = pixelIter.y() - mHeight / 2.0f;
vertexIter.setPosition( x, height * 30.0f, z );
vertexIter.setColorRGB( color );
++vertexIter;
}
}
}
CINDER_APP_BASIC( ImageHFApp, RendererGl );
| 25.255208 | 138 | 0.592906 | [
"vector"
] |
948685290511a7837c1b607330fde82d2c58145a | 7,992 | cc | C++ | hwy/contrib/sort/bench_sort.cc | oniliste/highway | f82b45e0b2428c5759cb3e7ea204b52ae27bb0bf | [
"Apache-2.0"
] | null | null | null | hwy/contrib/sort/bench_sort.cc | oniliste/highway | f82b45e0b2428c5759cb3e7ea204b52ae27bb0bf | [
"Apache-2.0"
] | null | null | null | hwy/contrib/sort/bench_sort.cc | oniliste/highway | f82b45e0b2428c5759cb3e7ea204b52ae27bb0bf | [
"Apache-2.0"
] | null | null | null | // Copyright 2021 Google LLC
// SPDX-License-Identifier: Apache-2.0
//
// 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.
// clang-format off
#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "hwy/contrib/sort/bench_sort.cc"
#include "hwy/foreach_target.h"
// After foreach_target
#include "hwy/contrib/sort/algo-inl.h"
#include "hwy/contrib/sort/result-inl.h"
#include "hwy/contrib/sort/vqsort.h"
#include "hwy/contrib/sort/sorting_networks-inl.h" // SharedTraits
#include "hwy/contrib/sort/traits-inl.h"
#include "hwy/contrib/sort/traits128-inl.h"
#include "hwy/tests/test_util-inl.h"
// clang-format on
#include <stdint.h>
#include <stdio.h>
#include <string.h> // memcpy
#include <vector>
HWY_BEFORE_NAMESPACE();
namespace hwy {
// Defined within HWY_ONCE, used by BenchAllSort.
extern uint32_t first_sort_target;
namespace HWY_NAMESPACE {
namespace {
using detail::TraitsLane;
using detail::OrderAscending;
using detail::OrderDescending;
using detail::SharedTraits;
#if HWY_TARGET != HWY_SCALAR
using detail::OrderAscending128;
using detail::OrderDescending128;
using detail::Traits128;
template <class Traits, typename T>
HWY_NOINLINE void BenchPartition() {
const SortTag<T> d;
detail::SharedTraits<Traits> st;
const Dist dist = Dist::kUniform8;
double sum = 0.0;
const size_t max_log2 = AdjustedLog2Reps(20);
for (size_t log2 = max_log2; log2 < max_log2 + 1; ++log2) {
const size_t num = 1ull << log2;
auto aligned = hwy::AllocateAligned<T>(num);
auto buf =
hwy::AllocateAligned<T>(hwy::SortConstants::PartitionBufNum(Lanes(d)));
std::vector<double> seconds;
const size_t num_reps = (1ull << (14 - log2 / 2)) * kReps;
for (size_t rep = 0; rep < num_reps; ++rep) {
(void)GenerateInput(dist, aligned.get(), num);
const Timestamp t0;
detail::Partition(d, st, aligned.get(), 0, num - 1, Set(d, T(128)),
buf.get());
seconds.push_back(SecondsSince(t0));
// 'Use' the result to prevent optimizing out the partition.
sum += static_cast<double>(aligned.get()[num / 2]);
}
MakeResult<T>(Algo::kVQSort, dist, st, num, 1,
SummarizeMeasurements(seconds))
.Print();
}
HWY_ASSERT(sum != 999999); // Prevent optimizing out
}
HWY_NOINLINE void BenchAllPartition() {
// Not interested in benchmark results for these targets
if (HWY_TARGET == HWY_SSSE3 || HWY_TARGET == HWY_SSE4) {
return;
}
BenchPartition<TraitsLane<OrderDescending>, float>();
BenchPartition<TraitsLane<OrderAscending>, int64_t>();
BenchPartition<Traits128<OrderDescending128>, uint64_t>();
}
template <class Traits, typename T>
HWY_NOINLINE void BenchBase(std::vector<Result>& results) {
// Not interested in benchmark results for these targets
if (HWY_TARGET == HWY_SSSE3 || HWY_TARGET == HWY_SSE4) {
return;
}
const SortTag<T> d;
detail::SharedTraits<Traits> st;
const Dist dist = Dist::kUniform32;
const size_t N = Lanes(d);
const size_t num = SortConstants::BaseCaseNum(N);
auto keys = hwy::AllocateAligned<T>(num);
auto buf = hwy::AllocateAligned<T>(num + N);
std::vector<double> seconds;
double sum = 0; // prevents elision
constexpr size_t kMul = AdjustedReps(600); // ensures long enough to measure
for (size_t rep = 0; rep < kReps; ++rep) {
InputStats<T> input_stats = GenerateInput(dist, keys.get(), num);
const Timestamp t0;
for (size_t i = 0; i < kMul; ++i) {
detail::BaseCase(d, st, keys.get(), num, buf.get());
sum += static_cast<double>(keys[0]);
}
seconds.push_back(SecondsSince(t0));
// printf("%f\n", seconds.back());
HWY_ASSERT(VerifySort(st, input_stats, keys.get(), num, "BenchBase"));
}
HWY_ASSERT(sum < 1E99);
results.push_back(MakeResult<T>(Algo::kVQSort, dist, st, num * kMul, 1,
SummarizeMeasurements(seconds)));
}
HWY_NOINLINE void BenchAllBase() {
// Not interested in benchmark results for these targets
if (HWY_TARGET == HWY_SSSE3) {
return;
}
std::vector<Result> results;
BenchBase<TraitsLane<OrderAscending>, float>(results);
BenchBase<TraitsLane<OrderDescending>, int64_t>(results);
BenchBase<Traits128<OrderAscending128>, uint64_t>(results);
for (const Result& r : results) {
r.Print();
}
}
std::vector<Algo> AlgoForBench() {
return {
#if HAVE_AVX2SORT
Algo::kSEA,
#endif
#if HAVE_PARALLEL_IPS4O
Algo::kParallelIPS4O,
#elif HAVE_IPS4O
Algo::kIPS4O,
#endif
#if HAVE_PDQSORT
Algo::kPDQ,
#endif
#if HAVE_SORT512
Algo::kSort512,
#endif
// These are 10-20x slower, but that's OK for the default size when we are
// not testing the parallel mode.
#if !HAVE_PARALLEL_IPS4O
Algo::kStd, Algo::kHeap,
Algo::kVQSort, // only ~4x slower, but not required for Table 1a
#endif
};
}
template <class Traits, typename T>
HWY_NOINLINE void BenchSort(size_t num) {
if (first_sort_target == 0) first_sort_target = HWY_TARGET;
SharedState shared;
detail::SharedTraits<Traits> st;
auto aligned = hwy::AllocateAligned<T>(num);
for (Algo algo : AlgoForBench()) {
// Other algorithms don't depend on the vector instructions, so only run
// them for the first target.
if (algo != Algo::kVQSort && HWY_TARGET != first_sort_target) continue;
for (Dist dist : AllDist()) {
std::vector<double> seconds;
for (size_t rep = 0; rep < kReps; ++rep) {
InputStats<T> input_stats = GenerateInput(dist, aligned.get(), num);
const Timestamp t0;
Run<typename Traits::Order>(algo, aligned.get(), num, shared,
/*thread=*/0);
seconds.push_back(SecondsSince(t0));
// printf("%f\n", seconds.back());
HWY_ASSERT(
VerifySort(st, input_stats, aligned.get(), num, "BenchSort"));
}
MakeResult<T>(algo, dist, st, num, 1, SummarizeMeasurements(seconds))
.Print();
} // dist
} // algo
}
HWY_NOINLINE void BenchAllSort() {
// Not interested in benchmark results for these targets
if (HWY_TARGET == HWY_SSSE3 || HWY_TARGET == HWY_SSE4) {
return;
}
constexpr size_t K = 1000;
constexpr size_t M = K * K;
(void)K;
(void)M;
for (size_t num : {
#if HAVE_PARALLEL_IPS4O
100 * M,
#else
AdjustedReps(1 * M),
#endif
}) {
BenchSort<TraitsLane<OrderAscending>, float>(num);
// BenchSort<TraitsLane<OrderDescending>, double>(num);
// BenchSort<TraitsLane<OrderAscending>, int16_t>(num);
BenchSort<TraitsLane<OrderDescending>, int32_t>(num);
BenchSort<TraitsLane<OrderAscending>, int64_t>(num);
// BenchSort<TraitsLane<OrderDescending>, uint16_t>(num);
// BenchSort<TraitsLane<OrderDescending>, uint32_t>(num);
// BenchSort<TraitsLane<OrderAscending>, uint64_t>(num);
BenchSort<Traits128<OrderAscending128>, uint64_t>(num);
}
}
#else
void BenchAllPartition() {}
void BenchAllBase() {}
void BenchAllSort() {}
#endif
} // namespace
// NOLINTNEXTLINE(google-readability-namespace-comments)
} // namespace HWY_NAMESPACE
} // namespace hwy
HWY_AFTER_NAMESPACE();
#if HWY_ONCE
namespace hwy {
uint32_t first_sort_target = 0; // none run yet
namespace {
HWY_BEFORE_TEST(BenchSort);
HWY_EXPORT_AND_TEST_P(BenchSort, BenchAllPartition);
HWY_EXPORT_AND_TEST_P(BenchSort, BenchAllBase);
HWY_EXPORT_AND_TEST_P(BenchSort, BenchAllSort);
} // namespace
} // namespace hwy
#endif // HWY_ONCE
| 29.820896 | 79 | 0.678929 | [
"vector"
] |
948bb505a7e839c547be31bb495591b74f3d57ae | 1,346 | cpp | C++ | 1718-construct-the-lexicographically-largest-valid-sequence/1718-construct-the-lexicographically-largest-valid-sequence.cpp | Ananyaas/LeetCodeDaily | e134e20ac02f26dc40881c376656d3294be0df2c | [
"MIT"
] | 2 | 2022-01-02T19:15:00.000Z | 2022-01-05T21:12:24.000Z | 1718-construct-the-lexicographically-largest-valid-sequence/1718-construct-the-lexicographically-largest-valid-sequence.cpp | Ananyaas/LeetCodeDaily | e134e20ac02f26dc40881c376656d3294be0df2c | [
"MIT"
] | null | null | null | 1718-construct-the-lexicographically-largest-valid-sequence/1718-construct-the-lexicographically-largest-valid-sequence.cpp | Ananyaas/LeetCodeDaily | e134e20ac02f26dc40881c376656d3294be0df2c | [
"MIT"
] | 1 | 2022-03-11T17:11:07.000Z | 2022-03-11T17:11:07.000Z | class Solution {
private:
bool backtrack(vector<int>&curr,vector<bool>&table,int &n,int index){
if(index==curr.size()){
return true;
} else if(curr[index]!=0){
return backtrack(curr,table,n,index+1);
} else {
for(int i=n;i>=1;i--){
if(!table[i]){
table[i]=true;
curr[index]=i;
if(i==1){
if(backtrack(curr,table,n,index+1)){
return true;
}
} else {
if(index+i<2*n-1){
if(curr[index+i]==0){
curr[index+i]=i;
if(backtrack(curr,table,n,index+1)){
return true;
}
curr[index+i]=0;
}
}
}
curr[index]=0;
table[i]=false;
}
}
return false;
}
}
public:
vector<int> constructDistancedSequence(int n) {
vector<bool>table(n+1,false);
vector<int>curr(2*n-1,0);
backtrack(curr,table,n,0);
return curr;
}
}; | 32.047619 | 73 | 0.343239 | [
"vector"
] |
948d78d2398cd1ecb4f2a3fb496c00a625e5202e | 7,308 | cpp | C++ | test/unit_test/policy/main.cpp | poseidonos/air | da7a5531abfd446941f5aa75fac8db984b664c6a | [
"MIT"
] | 3 | 2021-08-19T00:17:02.000Z | 2021-09-15T00:41:47.000Z | test/unit_test/policy/main.cpp | poseidonos/air | da7a5531abfd446941f5aa75fac8db984b664c6a | [
"MIT"
] | null | null | null | test/unit_test/policy/main.cpp | poseidonos/air | da7a5531abfd446941f5aa75fac8db984b664c6a | [
"MIT"
] | null | null | null | #include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <stdio.h>
#include <vector>
#include "mock_collection_observer.h"
#include "mock_output_observer.h"
#include "policy_cor_handler_test.h"
#include "src/config/ConfigInterface.h"
TEST_F(PolicyTest, RulerCheckRule)
{
int count = cfg::GetSentenceCount(config::ParagraphType::NODE);
// enable air
EXPECT_EQ(0, ruler->CheckRule(0, to_dtype(pi::Type2::ENABLE_AIR), 0, 0));
// set streaming interval
EXPECT_EQ(0, ruler->CheckRule(0, to_dtype(pi::Type2::SET_STREAMING_INTERVAL), 1, 0));
EXPECT_EQ(0, ruler->CheckRule(0, to_dtype(pi::Type2::SET_STREAMING_INTERVAL), 30, 0));
EXPECT_EQ(-12, ruler->CheckRule(0, to_dtype(pi::Type2::SET_STREAMING_INTERVAL), 0, 0));
EXPECT_EQ(-12, ruler->CheckRule(0, to_dtype(pi::Type2::SET_STREAMING_INTERVAL), 31, 0));
// enable node
EXPECT_EQ(0, ruler->CheckRule(0, to_dtype(pi::Type2::ENABLE_NODE), 0, count - 1));
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::ENABLE_NODE), 0, count));
EXPECT_EQ(0, ruler->CheckRule(0, to_dtype(pi::Type2::ENABLE_NODE_WITH_RANGE), 0, 0x00000001)); // 0~1
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::ENABLE_NODE_WITH_RANGE), 0, 0x0000ffff)); // 0~0xffff
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::ENABLE_NODE_WITH_RANGE), 0, 0xffff0000)); // 0xffff~0
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::ENABLE_NODE_WITH_RANGE), 0, 0x00010000)); // 1~0
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::ENABLE_NODE_WITH_GROUP), 0, 0x0000000f));
EXPECT_EQ(0, ruler->CheckRule(0, to_dtype(pi::Type2::ENABLE_NODE_ALL), 0, 0));
// init node
EXPECT_EQ(0, ruler->CheckRule(0, to_dtype(pi::Type2::INITIALIZE_NODE), count - 1, 0));
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::INITIALIZE_NODE), count, 0));
EXPECT_EQ(0, ruler->CheckRule(0, to_dtype(pi::Type2::INITIALIZE_NODE_WITH_RANGE), 0x00000001, 0)); // 0~1
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::INITIALIZE_NODE_WITH_RANGE), 0x0000ffff, 0)); // 0~0xffff
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::INITIALIZE_NODE_WITH_RANGE), 0xffff0000, 0)); // 0xffff~0
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::INITIALIZE_NODE_WITH_RANGE), 0x00010000, 0)); // 1~0
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::INITIALIZE_NODE_WITH_GROUP), 0x0000000f, 0));
EXPECT_EQ(0, ruler->CheckRule(0, to_dtype(pi::Type2::INITIALIZE_NODE_ALL), 0, 0));
// set sampling rate
EXPECT_EQ(0, ruler->CheckRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE), 1, 0));
EXPECT_EQ(0, ruler->CheckRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE), 10000, 0));
EXPECT_EQ(-13, ruler->CheckRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE), 0, 0));
EXPECT_EQ(-13, ruler->CheckRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE), 10001, 0));
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE), 1, 0x0000ffff));
EXPECT_EQ(0, ruler->CheckRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE_WITH_RANGE), 1, 0x00000001)); // 0~1
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE_WITH_RANGE), 1, 0x0000ffff)); // 0~0xffff
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE_WITH_RANGE), 1, 0xffff0000)); // 0xffff~0
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE_WITH_RANGE), 1, 0x00001000)); // 1~0
EXPECT_EQ(-11, ruler->CheckRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE_WITH_GROUP), 1, 0x0000000f));
EXPECT_EQ(-13, ruler->CheckRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE_WITH_GROUP), 0, 0x00000001));
EXPECT_EQ(0, ruler->CheckRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE_ALL), 1, 0));
// invalid command
EXPECT_EQ(-1, ruler->CheckRule(0, to_dtype(pi::Type2::COUNT), 1, 0));
}
TEST_F(PolicyTest, RulerSetRule)
{
// enable air
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::ENABLE_AIR), true, 0));
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::ENABLE_AIR), false, 0));
// set streaming interval
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::SET_STREAMING_INTERVAL), 1, 0));
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::SET_STREAMING_INTERVAL), 2, 0));
mock_node_meta->SetGroupId(1, 0);
mock_node_meta->SetGroupId(5, 0);
mock_node_meta->SetGroupId(3, 1);
mock_node_meta->SetGroupId(6, 1);
// set enable node
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::ENABLE_NODE), false, 0));
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::ENABLE_NODE_WITH_RANGE), false, 0x00000001));
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::ENABLE_NODE_WITH_GROUP), false, 0x00000000));
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::ENABLE_NODE_ALL), false, 0));
// set init node
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::INITIALIZE_NODE), 0, 0));
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::INITIALIZE_NODE_WITH_RANGE), 0, 0));
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::INITIALIZE_NODE_WITH_GROUP), 0, 0));
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::INITIALIZE_NODE_ALL), 0, 0));
// set sampling rate
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE), 2, 0));
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE_WITH_RANGE), 2, 0x00000001));
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE_WITH_GROUP), 10, 0x00000001));
EXPECT_EQ(true, ruler->SetRule(0, to_dtype(pi::Type2::SET_SAMPLING_RATE_ALL), 2, 0));
}
TEST_F(PolicyTest, RuleManagerConfig)
{
// set node meta config
air::NodeMetaData node[cfg::GetSentenceCount(config::ParagraphType::NODE)];
rule_manager->SetNodeMetaConfig(node);
EXPECT_EQ(air::ProcessorType::PERFORMANCE,
node[cfg::GetSentenceIndex(config::ParagraphType::NODE, "PERF_PSD")].processor_type);
EXPECT_EQ(air::ProcessorType::LATENCY,
node[cfg::GetSentenceIndex(config::ParagraphType::NODE, "LAT_PSD")].processor_type);
EXPECT_EQ(air::ProcessorType::QUEUE,
node[cfg::GetSentenceIndex(config::ParagraphType::NODE, "Q_EVENT")].processor_type);
// set global config
rule_manager->SetGlobalConfig();
}
TEST_F(PolicyTest, CollectionCoRHandler)
{
MockCollectionObserver* mock_collection_observer = new MockCollectionObserver{};
MockOutputObserver* mock_output_observer = new MockOutputObserver{};
policy_subject->Attach(mock_collection_observer,
to_dtype(pi::PolicySubject::TO_COLLECTION));
policy_subject->Attach(mock_output_observer,
to_dtype(pi::PolicySubject::TO_OUTPUT));
EXPECT_EQ((unsigned int)1, mock_global_meta->StreamingInterval());
EXPECT_EQ(false, mock_node_meta->Run(2));
// send msg
policy_observer->Update(0, to_dtype(pi::Type2::SET_STREAMING_INTERVAL), 2, 0, 0, 0, 0);
policy_observer->Update(0, to_dtype(pi::Type2::ENABLE_NODE), 2, 2, 0, 0, 0);
// handle msg
policy_cor_handler->HandleRequest();
EXPECT_EQ((unsigned int)2, mock_global_meta->StreamingInterval());
EXPECT_EQ(true, mock_node_meta->Run(2));
}
int
main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
| 51.104895 | 118 | 0.711275 | [
"vector"
] |
948e72ff6da71a05bcd73c6cbd063be2ec6ab141 | 3,429 | cpp | C++ | TP3_Prog_SpaceSim/ship.cpp | Arganancer/S3_TP3_Prog_SpaceSim | 43364f6613ad690f81c94f8a027ee3708fa58d3d | [
"MIT"
] | null | null | null | TP3_Prog_SpaceSim/ship.cpp | Arganancer/S3_TP3_Prog_SpaceSim | 43364f6613ad690f81c94f8a027ee3708fa58d3d | [
"MIT"
] | null | null | null | TP3_Prog_SpaceSim/ship.cpp | Arganancer/S3_TP3_Prog_SpaceSim | 43364f6613ad690f81c94f8a027ee3708fa58d3d | [
"MIT"
] | null | null | null | #include "ship.h"
#include "tools.hpp"
#include <SFML/Graphics/RectangleShape.hpp>
#include "hull.h"
ship::ship(Vector2f position, float mass) :
collidable(position, mass),
desired_weapon_angle_(0),
is_throttling_(false),
owner_(npc),
hull_max_endurance_(0),
hull_current_endurance_(0),
hull_percentage_strength_(1),
current_shield_max_endurance_(0),
current_shield_actual_endurance_(0),
current_shield_percentage_strength_(0)
{
}
void ship::set_is_colliding() const
{
hull_->set_is_colliding();
}
ship::~ship()
{
delete hull_;
}
void ship::update(float delta_t)
{
if(hull_current_endurance_ <= 0)
kill_entity();
// ROTATION
// Ships have integrated smart rotational inertia dampeners that reduce torque as
// the ship's rotation approaches its target rotation.
const auto desired_angle = tools::vec_util::angle_d(throttling_direction_);
auto difference_between_both_angles = desired_angle - rotation_angle_;
difference_between_both_angles +=
(difference_between_both_angles > 180) ? -360 :
(difference_between_both_angles < -180) ? 360 : 0;
if (fabs(difference_between_both_angles) > 1)
{
const auto adjusted_torque = 0.038f + 0.0054f * fabs(difference_between_both_angles);
if (difference_between_both_angles > 0)
torque_ = max_torque_ * adjusted_torque;
else
torque_ = -max_torque_ * adjusted_torque;
set_current_max_angular_velocity(adjusted_torque);
}
else { torque_ = 0; }
if (!is_throttling_)
{
dampen_velocity();
}
calculate_velocity(delta_t);
rotate(delta_t);
hull_->update(position_, rotation_angle_);
// TODO: Figure out where to include weapons.
//for (auto weap_it = active_weapons_.begin(); weap_it != active_weapons_.end(); ++weap_it)
//{
// weap_it->update(delta_t);
// weap_it->set_transform(entity_shapes_.front()->getTransform());
// weap_it->set_desired_direction(aiming_target_, desired_weapon_angle_);
//}
}
void ship::dampen_velocity()
{
// Dampen Force.
if(fabs(tools::vec_util::magnitude(velocity_)) > 3)
{
const auto current_direction = tools::vec_util::direction(velocity_);
force_ = -current_direction * max_force_;
}
else
{
force_ = Vector2f(0, 0);
velocity_ = Vector2f(0, 0);
}
}
void ship::dampen_angular_velocity()
{
// Dampen torque.
if (angular_velocity_ > max_torque_)
torque_ = -max_torque_;
else if (angular_velocity_ < -max_torque_)
torque_ = max_torque_;
else {
torque_ = 0;
angular_velocity_ = 0;
}
}
void ship::inflict_damage(int damage_to_hull)
{
hull_current_endurance_ -= damage_to_hull;
hull_percentage_strength_ = float(hull_current_endurance_) / float(hull_max_endurance_);
}
void ship::draw(RenderWindow& main_win)
{
//#pragma region DEBUG CODE
// auto health = RectangleShape(Vector2f(40, 5));
// health.setFillColor(Color::Red);
// health.setPosition(position_.x - 20, position_.y + 80);
// main_win.draw(health);
// health.setSize(Vector2f(40 * hull_percentage_strength_, 5));
// health.setFillColor(Color::Green);
// main_win.draw(health);
//#pragma endregion
hull_->draw(main_win);
}
vector<Vector2f> ship::get_axes()
{
// Get the normals (right angles) of each shape's edges:
return hull_->get_axes();
}
vector<ConvexShape> ship::get_shapes()
{
return hull_->get_shapes();
}
FloatRect ship::get_global_bounds() const
{
return hull_->get_global_bounds();
}
container_t::list_t<projectile*>& ship::get_projectiles() const
{
return hull_->get_projectiles();
}
| 23.648276 | 92 | 0.740449 | [
"shape",
"vector"
] |
9490490751250d2ceb9675f299488069bd2591b9 | 11,477 | cpp | C++ | examples/example_3_evaluators.cpp | SalusaSecondus/homomorphic-implementors-toolkit | b7775b77cb0ff4ff42a1b47bf958bb0e3c75fb9b | [
"Apache-2.0"
] | 38 | 2020-12-02T12:43:16.000Z | 2022-03-15T19:27:39.000Z | examples/example_3_evaluators.cpp | SalusaSecondus/homomorphic-implementors-toolkit | b7775b77cb0ff4ff42a1b47bf958bb0e3c75fb9b | [
"Apache-2.0"
] | 15 | 2020-12-03T05:04:12.000Z | 2021-08-20T21:26:27.000Z | examples/example_3_evaluators.cpp | SalusaSecondus/homomorphic-implementors-toolkit | b7775b77cb0ff4ff42a1b47bf958bb0e3c75fb9b | [
"Apache-2.0"
] | 6 | 2021-01-06T18:37:00.000Z | 2021-09-20T06:43:13.000Z | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
#include "hit/hit.h"
#include <glog/logging.h>
using namespace std;
using namespace hit;
// defined in example_1_ckks.cpp
extern vector<double> random_vector(int dim, double maxNorm);
// defined in example_2_plaintext.cpp
extern vector<double> poly_eval_plaintext(const vector<double> &xs);
extern CKKSCiphertext poly_eval_homomorphic_v1(CKKSEvaluator &eval, CKKSCiphertext &ct);
/* In the previous example, we saw how to use HIT to validate that a circuit
* works correctly on plaintexts. While that is a good start, the point of
* homomorphic circuit design is to evaluate the circuit on ciphertexts! To
* do that, we need cryptosystem parameters. HIT demystifies the process of
* selecting encryption system parameters by providing evaluators which
* compute suggested encryption parameters. HIT does help a bit in this area:
* if the requested depth and scale are not compatible with the requested number
* of slots, HIT will throw a runtime error when trying to make a CKKS instance
* indicating that a larger plaintext must be used.
*
*
* ******** Plaintext Slots ********
* It's up to the user to determine the number of plaintext slots that should
* be in each ciphertext. A smaller number of slots results in better performance,
* but, as noted in Example 1, limits the size of the ciphertext modulus, which
* in turn limits the precision of the computation and/or the depth of circuits
* which can be evaluated. Thus, to evaluate deeper circuits, evaluate with
* more precision, or to pack more plaintext slots into a single ciphertext, you
* can increase the number of plaintext slots.
*
*
* ******** Circuit Depth ********
* The first paramter we will need to determine is the maximum circuit depth
* we should support. If this depth is too low, we will not be able to evaluate
* our target function. If the maximum circuit depth is unnecessarily large, we
* risk either having to reduce the scale (and thus the precision of the result)
* or increasing the number of plaintext slots, which dramatically decreases
* performance. One way to compute circuit depth is to carefully track the levels
* of each ciphertext in the computation, as we have done in the comments in
* `poly_eval_homomorphic_v1()`. From that we can see the input has level i,
* and the output has level i-3, so the multiplicative depth of the circuit is three.
* However, this manual tracking quickly gets out of hand:
* - It's difficult to track and record these levels in the first place
* - If we made an error in the circuit, we may have to update the levels of
* ciphertexts throughout the circuit.
* - Manually tracking ciphertext levels only works for small circuits,
* it's infeasible for large circuits.
* Instead, we will use HIT's `DepthFinder` instance type to compute the depth
* of the function we want to evaluate.
*/
void example_3_driver() {
int num_slots = 8192;
// Create a CKKS instance to compute circuit depth. This instance type needs _no_ parameters.
ImplicitDepthFinder df_inst;
// Generate a plaintext with `num_slots` random coefficients, each with absolute value < `plaintext_inf_norm`
int plaintext_inf_norm = 10;
vector<double> plaintext = random_vector(num_slots, plaintext_inf_norm);
// Encrypt the plaintext. This evaluator only tracks ciphertext metadata;
// the CKKSCiphertext does not contain a real ciphertext or the plaintext.
CKKSCiphertext df_ciphertext = df_inst.encrypt(plaintext);
// Now we can evaluate our homomorphic circuit on this input, ignoring the output
// While evaluating this circuit, the DepthFinder instance emits logs indicating the level
// of the output of each gate, which can be seen when the logging level is 1 or 2.
poly_eval_homomorphic_v1(df_inst, df_ciphertext);
// Finally, we can ask the evaluator for the circuit's depth.
// Since this circuit does not use bootstrapping, the circuit depth is
// in circuit_depth.min_post_boostrap_depth
int max_depth = df_inst.get_multiplicative_depth();
LOG(INFO) << "poly_eval_homomorphic_v1 has multiplicative depth " << max_depth;
/* ******** CKKS Scale ********
* The next parameter we will need is the CKKS scale. You should use the largest scale
* possible, since it results in the most precision in the homomorphic computation.
* The scale is bounded above because the scaled plaintext can never exceed the
* ciphertext modulus, otherwise the plaintext wraps around the modulus and is lost.
* Imagine a ciphertext at level 0. SEAL recommends a 60-bit ciphertext
* modulus at this level, so in order to avoid overflow, we must satisfy inf_norm(plaintext)*scale < 2^60.
* By evaluating the circuit on a representative plaintext, we can get a good idea of the
* maximum scale.
*/
// Assume that the plaintext generated above is representative.
// The ScaleEstimator instance type requires the maximum depth of the circuits which
// will be evaluated, so we pass in the value computed with the DepthFinder instance.
ScaleEstimator se_inst(num_slots, max_depth);
// Don't reuse ciphertexts between instance types!
CKKSCiphertext se_ciphertext = se_inst.encrypt(plaintext);
// Now we can evaluate our homomorphic circuit on this input, ignoring the output.
// While evaluating this circuit, the ScaleEstimator instance emits logs for the maximum
// plaintext value, number of ciphertext modulus bits, and estimated max log scale at
// the output of each gate. This logging is enabled when the logging level is 1 or 2.
poly_eval_homomorphic_v1(se_inst, se_ciphertext);
// After evaluating the circuit on the representative input, we can ask the
// ScaleEstimator to estimate the maximum log scale we can use with ciphertexts.
double log_scale = se_inst.get_estimated_max_log_scale();
/* ******** Rotation Keys ********
* The next parameter we will need is the set of explicit rotations in the circuit
* i.e., either using rotate_left() or rotate_right(). We need to know the complete
* set of rotations so that the HomomorphicEvaluator below will generate the necessary
* rotation keys. Although our example circuit doesn't use any rotations, in general
* it can be tedious to track this manually. Thus we can use the RotationSet evaluator
* to help us compute the complete set of explicit rotations.
*/
// Create a RotationSet evaluator
RotationSet rs_inst(num_slots);
// Don't reuse ciphertexts between instance types!
CKKSCiphertext rs_ciphertext = rs_inst.encrypt(plaintext);
// Now we can evaluate our homomorphic circuit on this input, ignoring the output.
// While evaluating this circuit, the RotationSet instance tracks explit rotations.
poly_eval_homomorphic_v1(rs_inst, rs_ciphertext);
// After evaluating the circuit, we can ask the
// RotationSet for the complete set of explicit rotations in the circuit.
// For our example, this list will be empty because there are no explict rotations.
vector<int> rotation_set = rs_inst.needed_rotations();
/* ******** Ciphertext Evaluation ********
* Having used HIT to help determine the circuit depth and the maximum scale
* we can use, we can now set up an instance which actually does homomorphic
* computation.
*/
HomomorphicEval he_inst(num_slots, max_depth, static_cast<int>(floor(log_scale)), rotation_set);
// Don't reuse ciphertexts between instance types!
CKKSCiphertext he_ciphertext = he_inst.encrypt(plaintext);
// Now we can evaluate our homomorphic circuit on this input
CKKSCiphertext ct_result = poly_eval_homomorphic_v1(he_inst, he_ciphertext);
vector<double> actual_result = he_inst.decrypt(ct_result);
// Next, we will evaluate the plaintext function on the plaintext input
vector<double> expected_result = poly_eval_plaintext(plaintext);
// Compute the |expected-actual|/|expected|, where |*| denotes the 2-norm.
// If this value is small, then the expected and actual results closely agree,
// up to floating point roundoff (note that since the PlaintextEval only operates on
// plaintexts, there is no CKKS noise to introduce additional error.)
LOG(INFO) << "Relative difference between input and decrypted output: " << relative_error(expected_result, actual_result);
/* ******** Debug Evaluator ********
* Notice that this is subtley different than what we did in Example 2: here we are comparing
* the plaintext computation to the *encrypted* computation. Even if the difference between
* the two vectors was small in Example 2, they may not be here! There are several ways in
* which a circuit which works on plaintext values may fail on ciphertexts. For instance,
* the plaintext value may become too large and wrap around the ciphertext modulus,
* producing a random output on decryption. Because our function passes a test with the
* PlaintextEval instance, we know that the algorithm is mostly correct, but we've got some
* problems *only* due to the details of CKKS homomorphic encryption. This narrows down the
* search space for the error. However, we now need a way to look at the value inside plaintexts
* *as the encrypted computation proceeds*. The PlaintextEval instance can't do this for us; it
* does not do any homomorhic computation, and the HomomorphicEval instance doesn't allow us to
* see inside the ciphertexts. Instead, we should run the comptuation with the DebugEval instance.
* This runs the homomorphic comptutation in parallel with the plaintext computation, and compares
* the plaintext computation to the decrypted homomorphic computation at each gate. This allows you
* to pinpoint exactly where the homomorphic computation went off the rails. You use the DebugEval
* instance just like the HomomorphicEval instance.
*/
DebugEval dbg_inst(num_slots, max_depth, static_cast<int>(floor(log_scale)));
// Don't reuse ciphertexts between instance types!
CKKSCiphertext dbg_ciphertext = dbg_inst.encrypt(plaintext);
// Now we can evaluate our homomorphic circuit on this input, ignoring the output
poly_eval_homomorphic_v1(dbg_inst, dbg_ciphertext);
/* When you set the logging level to 1 or 2, the DebugEval instance logs the first few coefficients of the
* decrypted homomorphic computation at each gate. When the evaluator detects a divergence
* between the plaintext and homomorphic computations, it prints out additional information.
*/
/* ******** OpCount Evaluator ********
* Let's look at one final evaluator before moving on. When comparing large circuits, it is
* useful to know how many gates (and of what type) are evaluated in each circuit. The OpCount evaluator
* provides exactly this information. Let's see how to use it below.
*/
// The OpCount instance type takes the number of plaintext slots, since most of the high-level
// operations in the linear algebra API perform a different number of low-level operations depending
// on how inputs are encoded, which depends on the number of plaintext slots.
OpCount oc_inst(num_slots);
// Don't reuse ciphertexts between instance types!
CKKSCiphertext oc_ciphertext = oc_inst.encrypt(plaintext);
// Now we can evaluate our homomorphic circuit on this input, ignoring the output
poly_eval_homomorphic_v1(oc_inst, oc_ciphertext);
// We can now ask the OpCount evaluator to print (to the log) a tally of each type of gate.
// This log output is visible when the log leve is set to 1 or 2.
oc_inst.print_op_count();
}
| 54.652381 | 123 | 0.770236 | [
"vector"
] |
949512b4184b8eb3fd9ef8324c02c0b8cb758bf7 | 2,980 | cpp | C++ | common/hashing.cpp | SixSiebenUno/HashingTables | acbdf8a620c66eabc006a26b2473b5cb9239ffc7 | [
"MIT"
] | null | null | null | common/hashing.cpp | SixSiebenUno/HashingTables | acbdf8a620c66eabc006a26b2473b5cb9239ffc7 | [
"MIT"
] | null | null | null | common/hashing.cpp | SixSiebenUno/HashingTables | acbdf8a620c66eabc006a26b2473b5cb9239ffc7 | [
"MIT"
] | null | null | null | //
// \file hashing.cpp
// \author Oleksandr Tkachenko
// \email tkachenko@encrypto.cs.tu-darmstadt.de
// \organization Cryptography and Privacy Engineering Group (ENCRYPTO)
// \TU Darmstadt, Computer Science department
// \copyright The MIT License. Copyright 2019
//
// 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 "hashing.h"
#include <openssl/sha.h>
namespace ENCRYPTO {
bool HashingTable::MapElements() {
AllocateTable();
MapElementsToTable();
mapped_ = true;
return true;
}
bool HashingTable::AllocateLUTs() {
luts_.resize(num_of_hash_functions_);
for (auto& luts : luts_) {
luts.resize(num_of_luts_);
for (auto& entry : luts) {
entry.resize(num_of_tables_in_lut_);
}
}
return true;
}
bool HashingTable::GenerateLUTs() {
for (auto i = 0ull; i < num_of_hash_functions_; ++i) {
for (auto j = 0ull; j < num_of_luts_; ++j) {
for (auto k = 0ull; k < num_of_tables_in_lut_; k++) {
luts_.at(i).at(j).at(k) = generator_();
}
}
}
return true;
}
std::vector<std::uint64_t> HashingTable::HashToPosition(uint64_t element) const {
std::vector<std::uint64_t> addresses;
for (auto func_i = 0ull; func_i < num_of_hash_functions_; ++func_i) {
std::uint64_t address = element;
for (auto lut_i = 0ull; lut_i < num_of_luts_; ++lut_i) {
std::size_t lut_id = ((address >> (lut_i * elem_byte_length_ / num_of_luts_)) & 0x000000FFu);
lut_id %= num_of_tables_in_lut_;
address ^= luts_.at(func_i).at(lut_i).at(lut_id);
}
addresses.push_back(address);
}
return addresses;
}
std::uint64_t HashingTable::ElementToHash(std::uint64_t element) {
SHA_CTX ctx;
unsigned char hash[SHA_DIGEST_LENGTH];
SHA1_Init(&ctx);
SHA1_Update(&ctx, reinterpret_cast<unsigned char*>(&element), sizeof(element));
SHA1_Final(hash, &ctx);
uint64_t result = 0;
std::copy(hash, hash + sizeof(result), reinterpret_cast<unsigned char*>(&result));
return result;
}
} | 33.863636 | 99 | 0.71443 | [
"vector"
] |
94bca93c8ec1317ae786b996d695801cb266c2f7 | 1,392 | hpp | C++ | src/Sprite.hpp | Stephen-Seo/LudumDare37---One-Room---ZombieFight | a161923bcfd8441e6f682c793751b7642494401c | [
"MIT"
] | null | null | null | src/Sprite.hpp | Stephen-Seo/LudumDare37---One-Room---ZombieFight | a161923bcfd8441e6f682c793751b7642494401c | [
"MIT"
] | null | null | null | src/Sprite.hpp | Stephen-Seo/LudumDare37---One-Room---ZombieFight | a161923bcfd8441e6f682c793751b7642494401c | [
"MIT"
] | null | null | null |
#ifndef LD37_SPRITE_HPP
#define LD37_SPRITE_HPP
#include <unordered_map>
#include <vector>
#include <SFML/Graphics.hpp>
struct SpriteData
{
SpriteData() = default;
SpriteData(sf::IntRect subRect, float duration);
// copy
SpriteData(const SpriteData& other) = default;
SpriteData& operator = (const SpriteData& other) = default;
sf::IntRect subRect;
float duration;
};
class Sprite : public sf::Transformable
{
public:
typedef std::unordered_map<unsigned int, std::vector<SpriteData> > SpriteMap;
Sprite(SpriteMap* externalMap = nullptr);
Sprite(sf::Texture& texture, SpriteMap* externalMap = nullptr);
// copy
Sprite(const Sprite& other) = default;
Sprite& operator = (const Sprite& other) = default;
void setTexture(sf::Texture& texture);
void setExternalMap(SpriteMap* externalMap);
void registerMapping(unsigned int phase, SpriteData data);
void clearMapping(unsigned int phase);
void clearAllMappings();
void setPhase(unsigned int phase);
unsigned int getPhase();
void update(float dt);
void draw(sf::RenderWindow& window);
void setColor(sf::Color color = sf::Color::White);
private:
sf::Sprite sprite;
unsigned int currentPhase;
unsigned int currentIndex;
float timer;
bool spriteDirty;
SpriteMap spriteMap;
SpriteMap* externalSpriteMap;
};
#endif
| 21.75 | 81 | 0.699713 | [
"vector"
] |
94c2b75a3ac70c5c8c4d48d679e3d74ec04a538e | 543,700 | cpp | C++ | cisco-ios-xe/ydk/models/cisco_ios_xe/fragmented/Cisco_IOS_XE_native_116.cpp | CiscoDevNet/ydk-cpp | ef7d75970f2ef1154100e0f7b0a2ee823609b481 | [
"ECL-2.0",
"Apache-2.0"
] | 17 | 2016-12-02T05:45:49.000Z | 2022-02-10T19:32:54.000Z | cisco-ios-xe/ydk/models/cisco_ios_xe/fragmented/Cisco_IOS_XE_native_116.cpp | CiscoDevNet/ydk-cpp | ef7d75970f2ef1154100e0f7b0a2ee823609b481 | [
"ECL-2.0",
"Apache-2.0"
] | 2 | 2017-03-27T15:22:38.000Z | 2019-11-05T08:30:16.000Z | cisco-ios-xe/ydk/models/cisco_ios_xe/fragmented/Cisco_IOS_XE_native_116.cpp | CiscoDevNet/ydk-cpp | ef7d75970f2ef1154100e0f7b0a2ee823609b481 | [
"ECL-2.0",
"Apache-2.0"
] | 11 | 2016-12-02T05:45:52.000Z | 2019-11-07T08:28:17.000Z |
#include <sstream>
#include <iostream>
#include <ydk/entity_util.hpp>
#include "bundle_info.hpp"
#include "generated_entity_lookup.hpp"
#include "Cisco_IOS_XE_native_116.hpp"
#include "Cisco_IOS_XE_native_117.hpp"
using namespace ydk;
namespace cisco_ios_xe {
namespace Cisco_IOS_XE_native {
Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::DestPfx::DestPfx()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "dest-pfx"; yang_parent_name = "flowspec"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::DestPfx::~DestPfx()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::DestPfx::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : access_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::DestPfx::has_operation() const
{
for (auto const & leaf : access_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::DestPfx::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "dest-pfx";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::DestPfx::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto access_list_name_datas = access_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), access_list_name_datas.begin(), access_list_name_datas.end());
auto prefix_list_name_datas = prefix_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::DestPfx::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::DestPfx::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::DestPfx::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list.append(value);
}
if(value_path == "prefix-list")
{
prefix_list.append(value);
}
}
void Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::DestPfx::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::DestPfx::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::SrcPfx::SrcPfx()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "src-pfx"; yang_parent_name = "flowspec"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::SrcPfx::~SrcPfx()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::SrcPfx::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : access_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::SrcPfx::has_operation() const
{
for (auto const & leaf : access_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::SrcPfx::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "src-pfx";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::SrcPfx::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto access_list_name_datas = access_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), access_list_name_datas.begin(), access_list_name_datas.end());
auto prefix_list_name_datas = prefix_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::SrcPfx::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::SrcPfx::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::SrcPfx::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list.append(value);
}
if(value_path == "prefix-list")
{
prefix_list.append(value);
}
}
void Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::SrcPfx::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::Flowspec::SrcPfx::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Ip::NextHop::NextHop()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "next-hop"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Ip::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::NextHop::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : access_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::NextHop::has_operation() const
{
for (auto const & leaf : access_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Ip::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Ip::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto access_list_name_datas = access_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), access_list_name_datas.begin(), access_list_name_datas.end());
auto prefix_list_name_datas = prefix_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Ip::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Ip::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Ip::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list.append(value);
}
if(value_path == "prefix-list")
{
prefix_list.append(value);
}
}
void Native::RouteMap::RouteMapSeq::Match::Ip::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Ip::RedistributionSource::RedistributionSource()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "redistribution-source"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Ip::RedistributionSource::~RedistributionSource()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::RedistributionSource::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : access_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::RedistributionSource::has_operation() const
{
for (auto const & leaf : access_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Ip::RedistributionSource::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "redistribution-source";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Ip::RedistributionSource::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto access_list_name_datas = access_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), access_list_name_datas.begin(), access_list_name_datas.end());
auto prefix_list_name_datas = prefix_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Ip::RedistributionSource::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Ip::RedistributionSource::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Ip::RedistributionSource::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list.append(value);
}
if(value_path == "prefix-list")
{
prefix_list.append(value);
}
}
void Native::RouteMap::RouteMapSeq::Match::Ip::RedistributionSource::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::RedistributionSource::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Ip::RouteSource::RouteSource()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "route-source"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Ip::RouteSource::~RouteSource()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::RouteSource::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : access_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::RouteSource::has_operation() const
{
for (auto const & leaf : access_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Ip::RouteSource::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "route-source";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Ip::RouteSource::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto access_list_name_datas = access_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), access_list_name_datas.begin(), access_list_name_datas.end());
auto prefix_list_name_datas = prefix_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Ip::RouteSource::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Ip::RouteSource::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Ip::RouteSource::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list.append(value);
}
if(value_path == "prefix-list")
{
prefix_list.append(value);
}
}
void Native::RouteMap::RouteMapSeq::Match::Ip::RouteSource::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Ip::RouteSource::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::Ipv6()
:
address(std::make_shared<Native::RouteMap::RouteMapSeq::Match::Ipv6::Address>())
, flowspec(std::make_shared<Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec>())
, next_hop(std::make_shared<Native::RouteMap::RouteMapSeq::Match::Ipv6::NextHop>())
, route_source(std::make_shared<Native::RouteMap::RouteMapSeq::Match::Ipv6::RouteSource>())
{
address->parent = this;
flowspec->parent = this;
next_hop->parent = this;
route_source->parent = this;
yang_name = "ipv6"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::~Ipv6()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::has_data() const
{
if (is_presence_container) return true;
return (address != nullptr && address->has_data())
|| (flowspec != nullptr && flowspec->has_data())
|| (next_hop != nullptr && next_hop->has_data())
|| (route_source != nullptr && route_source->has_data());
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::has_operation() const
{
return is_set(yfilter)
|| (address != nullptr && address->has_operation())
|| (flowspec != nullptr && flowspec->has_operation())
|| (next_hop != nullptr && next_hop->has_operation())
|| (route_source != nullptr && route_source->has_operation());
}
std::string Native::RouteMap::RouteMapSeq::Match::Ipv6::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv6";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Ipv6::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Ipv6::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "address")
{
if(address == nullptr)
{
address = std::make_shared<Native::RouteMap::RouteMapSeq::Match::Ipv6::Address>();
}
return address;
}
if(child_yang_name == "flowspec")
{
if(flowspec == nullptr)
{
flowspec = std::make_shared<Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec>();
}
return flowspec;
}
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapSeq::Match::Ipv6::NextHop>();
}
return next_hop;
}
if(child_yang_name == "route-source")
{
if(route_source == nullptr)
{
route_source = std::make_shared<Native::RouteMap::RouteMapSeq::Match::Ipv6::RouteSource>();
}
return route_source;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Ipv6::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(address != nullptr)
{
_children["address"] = address;
}
if(flowspec != nullptr)
{
_children["flowspec"] = flowspec;
}
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
if(route_source != nullptr)
{
_children["route-source"] = route_source;
}
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "flowspec" || name == "next-hop" || name == "route-source")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::Address::Address()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "address"; yang_parent_name = "ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::Address::~Address()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::Address::has_data() const
{
if (is_presence_container) return true;
return access_list.is_set
|| prefix_list.is_set;
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::Address::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Ipv6::Address::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "address";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Ipv6::Address::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (access_list.is_set || is_set(access_list.yfilter)) leaf_name_data.push_back(access_list.get_name_leafdata());
if (prefix_list.is_set || is_set(prefix_list.yfilter)) leaf_name_data.push_back(prefix_list.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Ipv6::Address::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Ipv6::Address::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::Address::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list = value;
access_list.value_namespace = name_space;
access_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-list")
{
prefix_list = value;
prefix_list.value_namespace = name_space;
prefix_list.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::Address::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::Address::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::Flowspec()
:
dest_pfx(std::make_shared<Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::DestPfx>())
, src_pfx(std::make_shared<Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::SrcPfx>())
{
dest_pfx->parent = this;
src_pfx->parent = this;
yang_name = "flowspec"; yang_parent_name = "ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::~Flowspec()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::has_data() const
{
if (is_presence_container) return true;
return (dest_pfx != nullptr && dest_pfx->has_data())
|| (src_pfx != nullptr && src_pfx->has_data());
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::has_operation() const
{
return is_set(yfilter)
|| (dest_pfx != nullptr && dest_pfx->has_operation())
|| (src_pfx != nullptr && src_pfx->has_operation());
}
std::string Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "flowspec";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "dest-pfx")
{
if(dest_pfx == nullptr)
{
dest_pfx = std::make_shared<Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::DestPfx>();
}
return dest_pfx;
}
if(child_yang_name == "src-pfx")
{
if(src_pfx == nullptr)
{
src_pfx = std::make_shared<Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::SrcPfx>();
}
return src_pfx;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(dest_pfx != nullptr)
{
_children["dest-pfx"] = dest_pfx;
}
if(src_pfx != nullptr)
{
_children["src-pfx"] = src_pfx;
}
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dest-pfx" || name == "src-pfx")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::DestPfx::DestPfx()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "dest-pfx"; yang_parent_name = "flowspec"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::DestPfx::~DestPfx()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::DestPfx::has_data() const
{
if (is_presence_container) return true;
return access_list.is_set
|| prefix_list.is_set;
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::DestPfx::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::DestPfx::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "dest-pfx";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::DestPfx::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (access_list.is_set || is_set(access_list.yfilter)) leaf_name_data.push_back(access_list.get_name_leafdata());
if (prefix_list.is_set || is_set(prefix_list.yfilter)) leaf_name_data.push_back(prefix_list.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::DestPfx::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::DestPfx::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::DestPfx::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list = value;
access_list.value_namespace = name_space;
access_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-list")
{
prefix_list = value;
prefix_list.value_namespace = name_space;
prefix_list.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::DestPfx::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::DestPfx::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::SrcPfx::SrcPfx()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "src-pfx"; yang_parent_name = "flowspec"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::SrcPfx::~SrcPfx()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::SrcPfx::has_data() const
{
if (is_presence_container) return true;
return access_list.is_set
|| prefix_list.is_set;
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::SrcPfx::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::SrcPfx::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "src-pfx";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::SrcPfx::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (access_list.is_set || is_set(access_list.yfilter)) leaf_name_data.push_back(access_list.get_name_leafdata());
if (prefix_list.is_set || is_set(prefix_list.yfilter)) leaf_name_data.push_back(prefix_list.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::SrcPfx::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::SrcPfx::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::SrcPfx::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list = value;
access_list.value_namespace = name_space;
access_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-list")
{
prefix_list = value;
prefix_list.value_namespace = name_space;
prefix_list.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::SrcPfx::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::Flowspec::SrcPfx::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::NextHop::NextHop()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "next-hop"; yang_parent_name = "ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::NextHop::has_data() const
{
if (is_presence_container) return true;
return access_list.is_set
|| prefix_list.is_set;
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::NextHop::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Ipv6::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Ipv6::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (access_list.is_set || is_set(access_list.yfilter)) leaf_name_data.push_back(access_list.get_name_leafdata());
if (prefix_list.is_set || is_set(prefix_list.yfilter)) leaf_name_data.push_back(prefix_list.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Ipv6::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Ipv6::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list = value;
access_list.value_namespace = name_space;
access_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-list")
{
prefix_list = value;
prefix_list.value_namespace = name_space;
prefix_list.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::RouteSource::RouteSource()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "route-source"; yang_parent_name = "ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Ipv6::RouteSource::~RouteSource()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::RouteSource::has_data() const
{
if (is_presence_container) return true;
return access_list.is_set
|| prefix_list.is_set;
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::RouteSource::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Ipv6::RouteSource::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "route-source";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Ipv6::RouteSource::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (access_list.is_set || is_set(access_list.yfilter)) leaf_name_data.push_back(access_list.get_name_leafdata());
if (prefix_list.is_set || is_set(prefix_list.yfilter)) leaf_name_data.push_back(prefix_list.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Ipv6::RouteSource::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Ipv6::RouteSource::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::RouteSource::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list = value;
access_list.value_namespace = name_space;
access_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-list")
{
prefix_list = value;
prefix_list.value_namespace = name_space;
prefix_list.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapSeq::Match::Ipv6::RouteSource::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Ipv6::RouteSource::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Length::Length()
:
lengths(this, {"min_len", "max_len"})
{
yang_name = "length"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Length::~Length()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Length::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<lengths.len(); index++)
{
if(lengths[index]->has_data())
return true;
}
return false;
}
bool Native::RouteMap::RouteMapSeq::Match::Length::has_operation() const
{
for (std::size_t index=0; index<lengths.len(); index++)
{
if(lengths[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Length::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "length";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Length::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Length::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "lengths")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapSeq::Match::Length::Lengths>();
ent_->parent = this;
lengths.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Length::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : lengths.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Length::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapSeq::Match::Length::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapSeq::Match::Length::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "lengths")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Length::Lengths::Lengths()
:
min_len{YType::uint32, "min-len"},
max_len{YType::uint32, "max-len"}
{
yang_name = "lengths"; yang_parent_name = "length"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Length::Lengths::~Lengths()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Length::Lengths::has_data() const
{
if (is_presence_container) return true;
return min_len.is_set
|| max_len.is_set;
}
bool Native::RouteMap::RouteMapSeq::Match::Length::Lengths::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(min_len.yfilter)
|| ydk::is_set(max_len.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Length::Lengths::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "lengths";
ADD_KEY_TOKEN(min_len, "min-len");
ADD_KEY_TOKEN(max_len, "max-len");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Length::Lengths::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (min_len.is_set || is_set(min_len.yfilter)) leaf_name_data.push_back(min_len.get_name_leafdata());
if (max_len.is_set || is_set(max_len.yfilter)) leaf_name_data.push_back(max_len.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Length::Lengths::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Length::Lengths::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Length::Lengths::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "min-len")
{
min_len = value;
min_len.value_namespace = name_space;
min_len.value_namespace_prefix = name_space_prefix;
}
if(value_path == "max-len")
{
max_len = value;
max_len.value_namespace = name_space;
max_len.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapSeq::Match::Length::Lengths::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "min-len")
{
min_len.yfilter = yfilter;
}
if(value_path == "max-len")
{
max_len.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Length::Lengths::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "min-len" || name == "max-len")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::LocalPreference::LocalPreference()
:
values{YType::uint32, "values"}
{
yang_name = "local-preference"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::LocalPreference::~LocalPreference()
{
}
bool Native::RouteMap::RouteMapSeq::Match::LocalPreference::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : values.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapSeq::Match::LocalPreference::has_operation() const
{
for (auto const & leaf : values.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(values.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::LocalPreference::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "local-preference";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::LocalPreference::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto values_name_datas = values.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), values_name_datas.begin(), values_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::LocalPreference::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::LocalPreference::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::LocalPreference::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "values")
{
values.append(value);
}
}
void Native::RouteMap::RouteMapSeq::Match::LocalPreference::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "values")
{
values.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::LocalPreference::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "values")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::MdtGroup::MdtGroup()
:
name{YType::str, "name"}
{
yang_name = "mdt-group"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::MdtGroup::~MdtGroup()
{
}
bool Native::RouteMap::RouteMapSeq::Match::MdtGroup::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : name.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapSeq::Match::MdtGroup::has_operation() const
{
for (auto const & leaf : name.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(name.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::MdtGroup::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "mdt-group";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::MdtGroup::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto name_name_datas = name.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), name_name_datas.begin(), name_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::MdtGroup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::MdtGroup::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::MdtGroup::set_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.append(value);
}
}
void Native::RouteMap::RouteMapSeq::Match::MdtGroup::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "name")
{
name.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::MdtGroup::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "name")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Metric::Metric()
:
metric_value{YType::str, "metric-value"},
external{YType::str, "external"}
{
yang_name = "metric"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Metric::~Metric()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Metric::has_data() const
{
if (is_presence_container) return true;
return metric_value.is_set
|| external.is_set;
}
bool Native::RouteMap::RouteMapSeq::Match::Metric::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(metric_value.yfilter)
|| ydk::is_set(external.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Metric::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "metric";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Metric::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (metric_value.is_set || is_set(metric_value.yfilter)) leaf_name_data.push_back(metric_value.get_name_leafdata());
if (external.is_set || is_set(external.yfilter)) leaf_name_data.push_back(external.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Metric::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Metric::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Metric::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "metric-value")
{
metric_value = value;
metric_value.value_namespace = name_space;
metric_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "external")
{
external = value;
external.value_namespace = name_space;
external.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapSeq::Match::Metric::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "metric-value")
{
metric_value.yfilter = yfilter;
}
if(value_path == "external")
{
external.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Metric::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "metric-value" || name == "external")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::PolicyList::PolicyList()
:
policy_map_names{YType::str, "policy-map-names"}
{
yang_name = "policy-list"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::PolicyList::~PolicyList()
{
}
bool Native::RouteMap::RouteMapSeq::Match::PolicyList::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : policy_map_names.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapSeq::Match::PolicyList::has_operation() const
{
for (auto const & leaf : policy_map_names.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(policy_map_names.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::PolicyList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "policy-list";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::PolicyList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto policy_map_names_name_datas = policy_map_names.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), policy_map_names_name_datas.begin(), policy_map_names_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::PolicyList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::PolicyList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::PolicyList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "policy-map-names")
{
policy_map_names.append(value);
}
}
void Native::RouteMap::RouteMapSeq::Match::PolicyList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "policy-map-names")
{
policy_map_names.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::PolicyList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "policy-map-names")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::RouteType::RouteType()
:
internal{YType::empty, "internal"},
level_1{YType::empty, "level-1"},
level_2{YType::empty, "level-2"},
local{YType::empty, "local"}
,
external(nullptr) // presence node
, nssa_external(nullptr) // presence node
{
yang_name = "route-type"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::RouteType::~RouteType()
{
}
bool Native::RouteMap::RouteMapSeq::Match::RouteType::has_data() const
{
if (is_presence_container) return true;
return internal.is_set
|| level_1.is_set
|| level_2.is_set
|| local.is_set
|| (external != nullptr && external->has_data())
|| (nssa_external != nullptr && nssa_external->has_data());
}
bool Native::RouteMap::RouteMapSeq::Match::RouteType::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(internal.yfilter)
|| ydk::is_set(level_1.yfilter)
|| ydk::is_set(level_2.yfilter)
|| ydk::is_set(local.yfilter)
|| (external != nullptr && external->has_operation())
|| (nssa_external != nullptr && nssa_external->has_operation());
}
std::string Native::RouteMap::RouteMapSeq::Match::RouteType::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "route-type";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::RouteType::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (internal.is_set || is_set(internal.yfilter)) leaf_name_data.push_back(internal.get_name_leafdata());
if (level_1.is_set || is_set(level_1.yfilter)) leaf_name_data.push_back(level_1.get_name_leafdata());
if (level_2.is_set || is_set(level_2.yfilter)) leaf_name_data.push_back(level_2.get_name_leafdata());
if (local.is_set || is_set(local.yfilter)) leaf_name_data.push_back(local.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::RouteType::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "external")
{
if(external == nullptr)
{
external = std::make_shared<Native::RouteMap::RouteMapSeq::Match::RouteType::External>();
}
return external;
}
if(child_yang_name == "nssa-external")
{
if(nssa_external == nullptr)
{
nssa_external = std::make_shared<Native::RouteMap::RouteMapSeq::Match::RouteType::NssaExternal>();
}
return nssa_external;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::RouteType::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(external != nullptr)
{
_children["external"] = external;
}
if(nssa_external != nullptr)
{
_children["nssa-external"] = nssa_external;
}
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::RouteType::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "internal")
{
internal = value;
internal.value_namespace = name_space;
internal.value_namespace_prefix = name_space_prefix;
}
if(value_path == "level-1")
{
level_1 = value;
level_1.value_namespace = name_space;
level_1.value_namespace_prefix = name_space_prefix;
}
if(value_path == "level-2")
{
level_2 = value;
level_2.value_namespace = name_space;
level_2.value_namespace_prefix = name_space_prefix;
}
if(value_path == "local")
{
local = value;
local.value_namespace = name_space;
local.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapSeq::Match::RouteType::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "internal")
{
internal.yfilter = yfilter;
}
if(value_path == "level-1")
{
level_1.yfilter = yfilter;
}
if(value_path == "level-2")
{
level_2.yfilter = yfilter;
}
if(value_path == "local")
{
local.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::RouteType::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "external" || name == "nssa-external" || name == "internal" || name == "level-1" || name == "level-2" || name == "local")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::RouteType::External::External()
:
type_1{YType::empty, "type-1"},
type_2{YType::empty, "type-2"}
{
yang_name = "external"; yang_parent_name = "route-type"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::RouteMap::RouteMapSeq::Match::RouteType::External::~External()
{
}
bool Native::RouteMap::RouteMapSeq::Match::RouteType::External::has_data() const
{
if (is_presence_container) return true;
return type_1.is_set
|| type_2.is_set;
}
bool Native::RouteMap::RouteMapSeq::Match::RouteType::External::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(type_1.yfilter)
|| ydk::is_set(type_2.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::RouteType::External::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "external";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::RouteType::External::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (type_1.is_set || is_set(type_1.yfilter)) leaf_name_data.push_back(type_1.get_name_leafdata());
if (type_2.is_set || is_set(type_2.yfilter)) leaf_name_data.push_back(type_2.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::RouteType::External::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::RouteType::External::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::RouteType::External::set_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-1")
{
type_1 = value;
type_1.value_namespace = name_space;
type_1.value_namespace_prefix = name_space_prefix;
}
if(value_path == "type-2")
{
type_2 = value;
type_2.value_namespace = name_space;
type_2.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapSeq::Match::RouteType::External::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "type-1")
{
type_1.yfilter = yfilter;
}
if(value_path == "type-2")
{
type_2.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::RouteType::External::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "type-1" || name == "type-2")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::RouteType::NssaExternal::NssaExternal()
:
type_1{YType::empty, "type-1"},
type_2{YType::empty, "type-2"}
{
yang_name = "nssa-external"; yang_parent_name = "route-type"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::RouteMap::RouteMapSeq::Match::RouteType::NssaExternal::~NssaExternal()
{
}
bool Native::RouteMap::RouteMapSeq::Match::RouteType::NssaExternal::has_data() const
{
if (is_presence_container) return true;
return type_1.is_set
|| type_2.is_set;
}
bool Native::RouteMap::RouteMapSeq::Match::RouteType::NssaExternal::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(type_1.yfilter)
|| ydk::is_set(type_2.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::RouteType::NssaExternal::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "nssa-external";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::RouteType::NssaExternal::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (type_1.is_set || is_set(type_1.yfilter)) leaf_name_data.push_back(type_1.get_name_leafdata());
if (type_2.is_set || is_set(type_2.yfilter)) leaf_name_data.push_back(type_2.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::RouteType::NssaExternal::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::RouteType::NssaExternal::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::RouteType::NssaExternal::set_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-1")
{
type_1 = value;
type_1.value_namespace = name_space;
type_1.value_namespace_prefix = name_space_prefix;
}
if(value_path == "type-2")
{
type_2 = value;
type_2.value_namespace = name_space;
type_2.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapSeq::Match::RouteType::NssaExternal::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "type-1")
{
type_1.yfilter = yfilter;
}
if(value_path == "type-2")
{
type_2.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::RouteType::NssaExternal::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "type-1" || name == "type-2")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Rpki::Rpki()
:
invalid{YType::empty, "invalid"},
not_found{YType::empty, "not-found"},
valid{YType::empty, "valid"}
{
yang_name = "rpki"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Rpki::~Rpki()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Rpki::has_data() const
{
if (is_presence_container) return true;
return invalid.is_set
|| not_found.is_set
|| valid.is_set;
}
bool Native::RouteMap::RouteMapSeq::Match::Rpki::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(invalid.yfilter)
|| ydk::is_set(not_found.yfilter)
|| ydk::is_set(valid.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Rpki::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "rpki";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Rpki::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (invalid.is_set || is_set(invalid.yfilter)) leaf_name_data.push_back(invalid.get_name_leafdata());
if (not_found.is_set || is_set(not_found.yfilter)) leaf_name_data.push_back(not_found.get_name_leafdata());
if (valid.is_set || is_set(valid.yfilter)) leaf_name_data.push_back(valid.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Rpki::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Rpki::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Rpki::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "invalid")
{
invalid = value;
invalid.value_namespace = name_space;
invalid.value_namespace_prefix = name_space_prefix;
}
if(value_path == "not-found")
{
not_found = value;
not_found.value_namespace = name_space;
not_found.value_namespace_prefix = name_space_prefix;
}
if(value_path == "valid")
{
valid = value;
valid.value_namespace = name_space;
valid.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapSeq::Match::Rpki::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "invalid")
{
invalid.yfilter = yfilter;
}
if(value_path == "not-found")
{
not_found.yfilter = yfilter;
}
if(value_path == "valid")
{
valid.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Rpki::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "invalid" || name == "not-found" || name == "valid")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::SourceProtocol::SourceProtocol()
:
bgp{YType::str, "bgp"},
connected{YType::empty, "connected"},
eigrp{YType::str, "eigrp"},
isis{YType::empty, "isis"},
lisp{YType::empty, "lisp"},
mobile{YType::empty, "mobile"},
ospf{YType::str, "ospf"},
ospfv3{YType::str, "ospfv3"},
rip{YType::empty, "rip"},
static_{YType::empty, "static"}
{
yang_name = "source-protocol"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::RouteMap::RouteMapSeq::Match::SourceProtocol::~SourceProtocol()
{
}
bool Native::RouteMap::RouteMapSeq::Match::SourceProtocol::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : bgp.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : eigrp.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : ospf.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : ospfv3.getYLeafs())
{
if(leaf.is_set)
return true;
}
return connected.is_set
|| isis.is_set
|| lisp.is_set
|| mobile.is_set
|| rip.is_set
|| static_.is_set;
}
bool Native::RouteMap::RouteMapSeq::Match::SourceProtocol::has_operation() const
{
for (auto const & leaf : bgp.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : eigrp.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : ospf.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : ospfv3.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(bgp.yfilter)
|| ydk::is_set(connected.yfilter)
|| ydk::is_set(eigrp.yfilter)
|| ydk::is_set(isis.yfilter)
|| ydk::is_set(lisp.yfilter)
|| ydk::is_set(mobile.yfilter)
|| ydk::is_set(ospf.yfilter)
|| ydk::is_set(ospfv3.yfilter)
|| ydk::is_set(rip.yfilter)
|| ydk::is_set(static_.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::SourceProtocol::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "source-protocol";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::SourceProtocol::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (connected.is_set || is_set(connected.yfilter)) leaf_name_data.push_back(connected.get_name_leafdata());
if (isis.is_set || is_set(isis.yfilter)) leaf_name_data.push_back(isis.get_name_leafdata());
if (lisp.is_set || is_set(lisp.yfilter)) leaf_name_data.push_back(lisp.get_name_leafdata());
if (mobile.is_set || is_set(mobile.yfilter)) leaf_name_data.push_back(mobile.get_name_leafdata());
if (rip.is_set || is_set(rip.yfilter)) leaf_name_data.push_back(rip.get_name_leafdata());
if (static_.is_set || is_set(static_.yfilter)) leaf_name_data.push_back(static_.get_name_leafdata());
auto bgp_name_datas = bgp.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), bgp_name_datas.begin(), bgp_name_datas.end());
auto eigrp_name_datas = eigrp.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), eigrp_name_datas.begin(), eigrp_name_datas.end());
auto ospf_name_datas = ospf.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), ospf_name_datas.begin(), ospf_name_datas.end());
auto ospfv3_name_datas = ospfv3.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), ospfv3_name_datas.begin(), ospfv3_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::SourceProtocol::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::SourceProtocol::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::SourceProtocol::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "bgp")
{
bgp.append(value);
}
if(value_path == "connected")
{
connected = value;
connected.value_namespace = name_space;
connected.value_namespace_prefix = name_space_prefix;
}
if(value_path == "eigrp")
{
eigrp.append(value);
}
if(value_path == "isis")
{
isis = value;
isis.value_namespace = name_space;
isis.value_namespace_prefix = name_space_prefix;
}
if(value_path == "lisp")
{
lisp = value;
lisp.value_namespace = name_space;
lisp.value_namespace_prefix = name_space_prefix;
}
if(value_path == "mobile")
{
mobile = value;
mobile.value_namespace = name_space;
mobile.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ospf")
{
ospf.append(value);
}
if(value_path == "ospfv3")
{
ospfv3.append(value);
}
if(value_path == "rip")
{
rip = value;
rip.value_namespace = name_space;
rip.value_namespace_prefix = name_space_prefix;
}
if(value_path == "static")
{
static_ = value;
static_.value_namespace = name_space;
static_.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapSeq::Match::SourceProtocol::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "bgp")
{
bgp.yfilter = yfilter;
}
if(value_path == "connected")
{
connected.yfilter = yfilter;
}
if(value_path == "eigrp")
{
eigrp.yfilter = yfilter;
}
if(value_path == "isis")
{
isis.yfilter = yfilter;
}
if(value_path == "lisp")
{
lisp.yfilter = yfilter;
}
if(value_path == "mobile")
{
mobile.yfilter = yfilter;
}
if(value_path == "ospf")
{
ospf.yfilter = yfilter;
}
if(value_path == "ospfv3")
{
ospfv3.yfilter = yfilter;
}
if(value_path == "rip")
{
rip.yfilter = yfilter;
}
if(value_path == "static")
{
static_.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::SourceProtocol::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "bgp" || name == "connected" || name == "eigrp" || name == "isis" || name == "lisp" || name == "mobile" || name == "ospf" || name == "ospfv3" || name == "rip" || name == "static")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Tag::Tag()
:
tag_value{YType::uint32, "tag_value"},
ipv4_address{YType::str, "ipv4-address"}
,
list(std::make_shared<Native::RouteMap::RouteMapSeq::Match::Tag::List>())
{
list->parent = this;
yang_name = "tag"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Tag::~Tag()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Tag::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : tag_value.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : ipv4_address.getYLeafs())
{
if(leaf.is_set)
return true;
}
return (list != nullptr && list->has_data());
}
bool Native::RouteMap::RouteMapSeq::Match::Tag::has_operation() const
{
for (auto const & leaf : tag_value.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : ipv4_address.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(tag_value.yfilter)
|| ydk::is_set(ipv4_address.yfilter)
|| (list != nullptr && list->has_operation());
}
std::string Native::RouteMap::RouteMapSeq::Match::Tag::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tag";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Tag::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto tag_value_name_datas = tag_value.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), tag_value_name_datas.begin(), tag_value_name_datas.end());
auto ipv4_address_name_datas = ipv4_address.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), ipv4_address_name_datas.begin(), ipv4_address_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Tag::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "list")
{
if(list == nullptr)
{
list = std::make_shared<Native::RouteMap::RouteMapSeq::Match::Tag::List>();
}
return list;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Tag::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(list != nullptr)
{
_children["list"] = list;
}
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Tag::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "tag_value")
{
tag_value.append(value);
}
if(value_path == "ipv4-address")
{
ipv4_address.append(value);
}
}
void Native::RouteMap::RouteMapSeq::Match::Tag::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "tag_value")
{
tag_value.yfilter = yfilter;
}
if(value_path == "ipv4-address")
{
ipv4_address.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Tag::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "list" || name == "tag_value" || name == "ipv4-address")
return true;
return false;
}
Native::RouteMap::RouteMapSeq::Match::Tag::List::List()
:
tag_names{YType::str, "tag-names"}
{
yang_name = "list"; yang_parent_name = "tag"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapSeq::Match::Tag::List::~List()
{
}
bool Native::RouteMap::RouteMapSeq::Match::Tag::List::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : tag_names.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapSeq::Match::Tag::List::has_operation() const
{
for (auto const & leaf : tag_names.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(tag_names.yfilter);
}
std::string Native::RouteMap::RouteMapSeq::Match::Tag::List::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "list";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapSeq::Match::Tag::List::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto tag_names_name_datas = tag_names.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), tag_names_name_datas.begin(), tag_names_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapSeq::Match::Tag::List::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapSeq::Match::Tag::List::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapSeq::Match::Tag::List::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "tag-names")
{
tag_names.append(value);
}
}
void Native::RouteMap::RouteMapSeq::Match::Tag::List::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "tag-names")
{
tag_names.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapSeq::Match::Tag::List::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "tag-names")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::RouteMapWithoutOrderSeq()
:
seq_no{YType::uint16, "seq_no"},
operation_{YType::enumeration, "operation"},
description{YType::str, "description"}
,
set(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set>())
, match(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match>())
{
set->parent = this;
match->parent = this;
yang_name = "route-map-without-order-seq"; yang_parent_name = "route-map"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::~RouteMapWithoutOrderSeq()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::has_data() const
{
if (is_presence_container) return true;
return seq_no.is_set
|| operation_.is_set
|| description.is_set
|| (set != nullptr && set->has_data())
|| (match != nullptr && match->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(seq_no.yfilter)
|| ydk::is_set(operation_.yfilter)
|| ydk::is_set(description.yfilter)
|| (set != nullptr && set->has_operation())
|| (match != nullptr && match->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "Cisco-IOS-XE-route-map:route-map-without-order-seq";
ADD_KEY_TOKEN(seq_no, "seq_no");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (seq_no.is_set || is_set(seq_no.yfilter)) leaf_name_data.push_back(seq_no.get_name_leafdata());
if (operation_.is_set || is_set(operation_.yfilter)) leaf_name_data.push_back(operation_.get_name_leafdata());
if (description.is_set || is_set(description.yfilter)) leaf_name_data.push_back(description.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "set")
{
if(set == nullptr)
{
set = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set>();
}
return set;
}
if(child_yang_name == "match")
{
if(match == nullptr)
{
match = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match>();
}
return match;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(set != nullptr)
{
_children["set"] = set;
}
if(match != nullptr)
{
_children["match"] = match;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "seq_no")
{
seq_no = value;
seq_no.value_namespace = name_space;
seq_no.value_namespace_prefix = name_space_prefix;
}
if(value_path == "operation")
{
operation_ = value;
operation_.value_namespace = name_space;
operation_.value_namespace_prefix = name_space_prefix;
}
if(value_path == "description")
{
description = value;
description.value_namespace = name_space;
description.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "seq_no")
{
seq_no.yfilter = yfilter;
}
if(value_path == "operation")
{
operation_.yfilter = yfilter;
}
if(value_path == "description")
{
description.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "set" || name == "match" || name == "seq_no" || name == "operation" || name == "description")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Set()
:
attribute_set{YType::str, "attribute-set"},
automatic_tag{YType::empty, "automatic-tag"},
global{YType::empty, "global"},
local_preference{YType::uint32, "local-preference"},
metric_type{YType::enumeration, "metric-type"},
mpls_label{YType::empty, "mpls-label"},
weight{YType::uint32, "weight"},
traffic_index{YType::uint8, "traffic-index"},
vrf{YType::str, "vrf"}
,
aigp_metric(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::AigpMetric>())
, as_path(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath>())
, clns(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns>())
, community(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community>())
, comm_list(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::CommList>())
, dampening(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening>())
, default_(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default>())
, extcomm_list(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList>())
, extcommunity(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity>())
, interface(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface>())
, ip(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip>())
, ipv6(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6>())
, level(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Level>())
, lisp(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Lisp>())
, metric(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric>())
, nlri(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Nlri>())
, origin(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin>())
, tag(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Tag>())
{
aigp_metric->parent = this;
as_path->parent = this;
clns->parent = this;
community->parent = this;
comm_list->parent = this;
dampening->parent = this;
default_->parent = this;
extcomm_list->parent = this;
extcommunity->parent = this;
interface->parent = this;
ip->parent = this;
ipv6->parent = this;
level->parent = this;
lisp->parent = this;
metric->parent = this;
nlri->parent = this;
origin->parent = this;
tag->parent = this;
yang_name = "set"; yang_parent_name = "route-map-without-order-seq"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::~Set()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::has_data() const
{
if (is_presence_container) return true;
return attribute_set.is_set
|| automatic_tag.is_set
|| global.is_set
|| local_preference.is_set
|| metric_type.is_set
|| mpls_label.is_set
|| weight.is_set
|| traffic_index.is_set
|| vrf.is_set
|| (aigp_metric != nullptr && aigp_metric->has_data())
|| (as_path != nullptr && as_path->has_data())
|| (clns != nullptr && clns->has_data())
|| (community != nullptr && community->has_data())
|| (comm_list != nullptr && comm_list->has_data())
|| (dampening != nullptr && dampening->has_data())
|| (default_ != nullptr && default_->has_data())
|| (extcomm_list != nullptr && extcomm_list->has_data())
|| (extcommunity != nullptr && extcommunity->has_data())
|| (interface != nullptr && interface->has_data())
|| (ip != nullptr && ip->has_data())
|| (ipv6 != nullptr && ipv6->has_data())
|| (level != nullptr && level->has_data())
|| (lisp != nullptr && lisp->has_data())
|| (metric != nullptr && metric->has_data())
|| (nlri != nullptr && nlri->has_data())
|| (origin != nullptr && origin->has_data())
|| (tag != nullptr && tag->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(attribute_set.yfilter)
|| ydk::is_set(automatic_tag.yfilter)
|| ydk::is_set(global.yfilter)
|| ydk::is_set(local_preference.yfilter)
|| ydk::is_set(metric_type.yfilter)
|| ydk::is_set(mpls_label.yfilter)
|| ydk::is_set(weight.yfilter)
|| ydk::is_set(traffic_index.yfilter)
|| ydk::is_set(vrf.yfilter)
|| (aigp_metric != nullptr && aigp_metric->has_operation())
|| (as_path != nullptr && as_path->has_operation())
|| (clns != nullptr && clns->has_operation())
|| (community != nullptr && community->has_operation())
|| (comm_list != nullptr && comm_list->has_operation())
|| (dampening != nullptr && dampening->has_operation())
|| (default_ != nullptr && default_->has_operation())
|| (extcomm_list != nullptr && extcomm_list->has_operation())
|| (extcommunity != nullptr && extcommunity->has_operation())
|| (interface != nullptr && interface->has_operation())
|| (ip != nullptr && ip->has_operation())
|| (ipv6 != nullptr && ipv6->has_operation())
|| (level != nullptr && level->has_operation())
|| (lisp != nullptr && lisp->has_operation())
|| (metric != nullptr && metric->has_operation())
|| (nlri != nullptr && nlri->has_operation())
|| (origin != nullptr && origin->has_operation())
|| (tag != nullptr && tag->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "set";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (attribute_set.is_set || is_set(attribute_set.yfilter)) leaf_name_data.push_back(attribute_set.get_name_leafdata());
if (automatic_tag.is_set || is_set(automatic_tag.yfilter)) leaf_name_data.push_back(automatic_tag.get_name_leafdata());
if (global.is_set || is_set(global.yfilter)) leaf_name_data.push_back(global.get_name_leafdata());
if (local_preference.is_set || is_set(local_preference.yfilter)) leaf_name_data.push_back(local_preference.get_name_leafdata());
if (metric_type.is_set || is_set(metric_type.yfilter)) leaf_name_data.push_back(metric_type.get_name_leafdata());
if (mpls_label.is_set || is_set(mpls_label.yfilter)) leaf_name_data.push_back(mpls_label.get_name_leafdata());
if (weight.is_set || is_set(weight.yfilter)) leaf_name_data.push_back(weight.get_name_leafdata());
if (traffic_index.is_set || is_set(traffic_index.yfilter)) leaf_name_data.push_back(traffic_index.get_name_leafdata());
if (vrf.is_set || is_set(vrf.yfilter)) leaf_name_data.push_back(vrf.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "aigp-metric")
{
if(aigp_metric == nullptr)
{
aigp_metric = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::AigpMetric>();
}
return aigp_metric;
}
if(child_yang_name == "as-path")
{
if(as_path == nullptr)
{
as_path = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath>();
}
return as_path;
}
if(child_yang_name == "clns")
{
if(clns == nullptr)
{
clns = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns>();
}
return clns;
}
if(child_yang_name == "community")
{
if(community == nullptr)
{
community = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community>();
}
return community;
}
if(child_yang_name == "comm-list")
{
if(comm_list == nullptr)
{
comm_list = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::CommList>();
}
return comm_list;
}
if(child_yang_name == "dampening")
{
if(dampening == nullptr)
{
dampening = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening>();
}
return dampening;
}
if(child_yang_name == "default")
{
if(default_ == nullptr)
{
default_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default>();
}
return default_;
}
if(child_yang_name == "extcomm-list")
{
if(extcomm_list == nullptr)
{
extcomm_list = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList>();
}
return extcomm_list;
}
if(child_yang_name == "extcommunity")
{
if(extcommunity == nullptr)
{
extcommunity = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity>();
}
return extcommunity;
}
if(child_yang_name == "interface")
{
if(interface == nullptr)
{
interface = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface>();
}
return interface;
}
if(child_yang_name == "ip")
{
if(ip == nullptr)
{
ip = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip>();
}
return ip;
}
if(child_yang_name == "ipv6")
{
if(ipv6 == nullptr)
{
ipv6 = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6>();
}
return ipv6;
}
if(child_yang_name == "level")
{
if(level == nullptr)
{
level = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Level>();
}
return level;
}
if(child_yang_name == "lisp")
{
if(lisp == nullptr)
{
lisp = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Lisp>();
}
return lisp;
}
if(child_yang_name == "metric")
{
if(metric == nullptr)
{
metric = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric>();
}
return metric;
}
if(child_yang_name == "nlri")
{
if(nlri == nullptr)
{
nlri = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Nlri>();
}
return nlri;
}
if(child_yang_name == "origin")
{
if(origin == nullptr)
{
origin = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin>();
}
return origin;
}
if(child_yang_name == "tag")
{
if(tag == nullptr)
{
tag = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Tag>();
}
return tag;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(aigp_metric != nullptr)
{
_children["aigp-metric"] = aigp_metric;
}
if(as_path != nullptr)
{
_children["as-path"] = as_path;
}
if(clns != nullptr)
{
_children["clns"] = clns;
}
if(community != nullptr)
{
_children["community"] = community;
}
if(comm_list != nullptr)
{
_children["comm-list"] = comm_list;
}
if(dampening != nullptr)
{
_children["dampening"] = dampening;
}
if(default_ != nullptr)
{
_children["default"] = default_;
}
if(extcomm_list != nullptr)
{
_children["extcomm-list"] = extcomm_list;
}
if(extcommunity != nullptr)
{
_children["extcommunity"] = extcommunity;
}
if(interface != nullptr)
{
_children["interface"] = interface;
}
if(ip != nullptr)
{
_children["ip"] = ip;
}
if(ipv6 != nullptr)
{
_children["ipv6"] = ipv6;
}
if(level != nullptr)
{
_children["level"] = level;
}
if(lisp != nullptr)
{
_children["lisp"] = lisp;
}
if(metric != nullptr)
{
_children["metric"] = metric;
}
if(nlri != nullptr)
{
_children["nlri"] = nlri;
}
if(origin != nullptr)
{
_children["origin"] = origin;
}
if(tag != nullptr)
{
_children["tag"] = tag;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::set_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-set")
{
attribute_set = value;
attribute_set.value_namespace = name_space;
attribute_set.value_namespace_prefix = name_space_prefix;
}
if(value_path == "automatic-tag")
{
automatic_tag = value;
automatic_tag.value_namespace = name_space;
automatic_tag.value_namespace_prefix = name_space_prefix;
}
if(value_path == "global")
{
global = value;
global.value_namespace = name_space;
global.value_namespace_prefix = name_space_prefix;
}
if(value_path == "local-preference")
{
local_preference = value;
local_preference.value_namespace = name_space;
local_preference.value_namespace_prefix = name_space_prefix;
}
if(value_path == "metric-type")
{
metric_type = value;
metric_type.value_namespace = name_space;
metric_type.value_namespace_prefix = name_space_prefix;
}
if(value_path == "mpls-label")
{
mpls_label = value;
mpls_label.value_namespace = name_space;
mpls_label.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 == "traffic-index")
{
traffic_index = value;
traffic_index.value_namespace = name_space;
traffic_index.value_namespace_prefix = name_space_prefix;
}
if(value_path == "vrf")
{
vrf = value;
vrf.value_namespace = name_space;
vrf.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "attribute-set")
{
attribute_set.yfilter = yfilter;
}
if(value_path == "automatic-tag")
{
automatic_tag.yfilter = yfilter;
}
if(value_path == "global")
{
global.yfilter = yfilter;
}
if(value_path == "local-preference")
{
local_preference.yfilter = yfilter;
}
if(value_path == "metric-type")
{
metric_type.yfilter = yfilter;
}
if(value_path == "mpls-label")
{
mpls_label.yfilter = yfilter;
}
if(value_path == "weight")
{
weight.yfilter = yfilter;
}
if(value_path == "traffic-index")
{
traffic_index.yfilter = yfilter;
}
if(value_path == "vrf")
{
vrf.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "aigp-metric" || name == "as-path" || name == "clns" || name == "community" || name == "comm-list" || name == "dampening" || name == "default" || name == "extcomm-list" || name == "extcommunity" || name == "interface" || name == "ip" || name == "ipv6" || name == "level" || name == "lisp" || name == "metric" || name == "nlri" || name == "origin" || name == "tag" || name == "attribute-set" || name == "automatic-tag" || name == "global" || name == "local-preference" || name == "metric-type" || name == "mpls-label" || name == "weight" || name == "traffic-index" || name == "vrf")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::AigpMetric::AigpMetric()
:
value_{YType::uint32, "value"},
igp_metric{YType::empty, "igp-metric"}
{
yang_name = "aigp-metric"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::AigpMetric::~AigpMetric()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AigpMetric::has_data() const
{
if (is_presence_container) return true;
return value_.is_set
|| igp_metric.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AigpMetric::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(value_.yfilter)
|| ydk::is_set(igp_metric.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::AigpMetric::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "aigp-metric";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::AigpMetric::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (value_.is_set || is_set(value_.yfilter)) leaf_name_data.push_back(value_.get_name_leafdata());
if (igp_metric.is_set || is_set(igp_metric.yfilter)) leaf_name_data.push_back(igp_metric.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::AigpMetric::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::AigpMetric::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::AigpMetric::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "value")
{
value_ = value;
value_.value_namespace = name_space;
value_.value_namespace_prefix = name_space_prefix;
}
if(value_path == "igp-metric")
{
igp_metric = value;
igp_metric.value_namespace = name_space;
igp_metric.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::AigpMetric::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "value")
{
value_.yfilter = yfilter;
}
if(value_path == "igp-metric")
{
igp_metric.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AigpMetric::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "value" || name == "igp-metric")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::AsPath()
:
prepend(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend>())
, tag(nullptr) // presence node
{
prepend->parent = this;
yang_name = "as-path"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::~AsPath()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::has_data() const
{
if (is_presence_container) return true;
return (prepend != nullptr && prepend->has_data())
|| (tag != nullptr && tag->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::has_operation() const
{
return is_set(yfilter)
|| (prepend != nullptr && prepend->has_operation())
|| (tag != nullptr && tag->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "as-path";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "prepend")
{
if(prepend == nullptr)
{
prepend = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend>();
}
return prepend;
}
if(child_yang_name == "tag")
{
if(tag == nullptr)
{
tag = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Tag>();
}
return tag;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(prepend != nullptr)
{
_children["prepend"] = prepend;
}
if(tag != nullptr)
{
_children["tag"] = tag;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "prepend" || name == "tag")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::Prepend()
:
as_container(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::AsContainer>())
, last_as_cont(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::LastAsCont>())
{
as_container->parent = this;
last_as_cont->parent = this;
yang_name = "prepend"; yang_parent_name = "as-path"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::~Prepend()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::has_data() const
{
if (is_presence_container) return true;
return (as_container != nullptr && as_container->has_data())
|| (last_as_cont != nullptr && last_as_cont->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::has_operation() const
{
return is_set(yfilter)
|| (as_container != nullptr && as_container->has_operation())
|| (last_as_cont != nullptr && last_as_cont->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "prepend";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "as-container")
{
if(as_container == nullptr)
{
as_container = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::AsContainer>();
}
return as_container;
}
if(child_yang_name == "last-as-cont")
{
if(last_as_cont == nullptr)
{
last_as_cont = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::LastAsCont>();
}
return last_as_cont;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(as_container != nullptr)
{
_children["as-container"] = as_container;
}
if(last_as_cont != nullptr)
{
_children["last-as-cont"] = last_as_cont;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "as-container" || name == "last-as-cont")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::AsContainer::AsContainer()
:
as_number{YType::str, "as-number"}
{
yang_name = "as-container"; yang_parent_name = "prepend"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::AsContainer::~AsContainer()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::AsContainer::has_data() const
{
if (is_presence_container) return true;
return as_number.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::AsContainer::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(as_number.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::AsContainer::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "as-container";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::AsContainer::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (as_number.is_set || is_set(as_number.yfilter)) leaf_name_data.push_back(as_number.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::AsContainer::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::AsContainer::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::AsContainer::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "as-number")
{
as_number = value;
as_number.value_namespace = name_space;
as_number.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::AsContainer::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "as-number")
{
as_number.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::AsContainer::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "as-number")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::LastAsCont::LastAsCont()
:
last_as{YType::uint16, "last-as"}
{
yang_name = "last-as-cont"; yang_parent_name = "prepend"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::LastAsCont::~LastAsCont()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::LastAsCont::has_data() const
{
if (is_presence_container) return true;
return last_as.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::LastAsCont::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(last_as.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::LastAsCont::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "last-as-cont";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::LastAsCont::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (last_as.is_set || is_set(last_as.yfilter)) leaf_name_data.push_back(last_as.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::LastAsCont::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::LastAsCont::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::LastAsCont::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "last-as")
{
last_as = value;
last_as.value_namespace = name_space;
last_as.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::LastAsCont::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "last-as")
{
last_as.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Prepend::LastAsCont::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "last-as")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Tag::Tag()
{
yang_name = "tag"; yang_parent_name = "as-path"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Tag::~Tag()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Tag::has_data() const
{
if (is_presence_container) return true;
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Tag::has_operation() const
{
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Tag::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tag";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Tag::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Tag::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Tag::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Tag::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Tag::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::AsPath::Tag::has_leaf_or_child_of_name(const std::string & name) const
{
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::Clns()
:
next_hop(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::NextHop>())
{
next_hop->parent = this;
yang_name = "clns"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::~Clns()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::has_data() const
{
if (is_presence_container) return true;
return (next_hop != nullptr && next_hop->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::has_operation() const
{
return is_set(yfilter)
|| (next_hop != nullptr && next_hop->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "clns";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::NextHop>();
}
return next_hop;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "next-hop")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::NextHop::NextHop()
:
address{YType::str, "address"}
{
yang_name = "next-hop"; yang_parent_name = "clns"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::NextHop::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : address.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::NextHop::has_operation() const
{
for (auto const & leaf : address.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(address.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto address_name_datas = address.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), address_name_datas.begin(), address_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Clns::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::Community()
:
none{YType::empty, "none"}
,
community_well_known(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::CommunityWellKnown>())
{
community_well_known->parent = this;
yang_name = "community"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::~Community()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::has_data() const
{
if (is_presence_container) return true;
return none.is_set
|| (community_well_known != nullptr && community_well_known->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(none.yfilter)
|| (community_well_known != nullptr && community_well_known->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "community";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (none.is_set || is_set(none.yfilter)) leaf_name_data.push_back(none.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "community-well-known")
{
if(community_well_known == nullptr)
{
community_well_known = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::CommunityWellKnown>();
}
return community_well_known;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(community_well_known != nullptr)
{
_children["community-well-known"] = community_well_known;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "none")
{
none = value;
none.value_namespace = name_space;
none.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "none")
{
none.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "community-well-known" || name == "none")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::CommunityWellKnown::CommunityWellKnown()
:
community_list{YType::str, "community-list"}
{
yang_name = "community-well-known"; yang_parent_name = "community"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::CommunityWellKnown::~CommunityWellKnown()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::CommunityWellKnown::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : community_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::CommunityWellKnown::has_operation() const
{
for (auto const & leaf : community_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(community_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::CommunityWellKnown::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "community-well-known";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::CommunityWellKnown::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto community_list_name_datas = community_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), community_list_name_datas.begin(), community_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::CommunityWellKnown::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::CommunityWellKnown::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::CommunityWellKnown::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "community-list")
{
community_list.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::CommunityWellKnown::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "community-list")
{
community_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Community::CommunityWellKnown::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "community-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::CommList::CommList()
:
comm_list_standard{YType::uint16, "comm-list-standard"},
comm_list_expanded{YType::uint16, "comm-list-expanded"},
comm_list_name{YType::str, "comm-list-name"},
delete_{YType::empty, "delete"}
{
yang_name = "comm-list"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::CommList::~CommList()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::CommList::has_data() const
{
if (is_presence_container) return true;
return comm_list_standard.is_set
|| comm_list_expanded.is_set
|| comm_list_name.is_set
|| delete_.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::CommList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(comm_list_standard.yfilter)
|| ydk::is_set(comm_list_expanded.yfilter)
|| ydk::is_set(comm_list_name.yfilter)
|| ydk::is_set(delete_.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::CommList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "comm-list";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::CommList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (comm_list_standard.is_set || is_set(comm_list_standard.yfilter)) leaf_name_data.push_back(comm_list_standard.get_name_leafdata());
if (comm_list_expanded.is_set || is_set(comm_list_expanded.yfilter)) leaf_name_data.push_back(comm_list_expanded.get_name_leafdata());
if (comm_list_name.is_set || is_set(comm_list_name.yfilter)) leaf_name_data.push_back(comm_list_name.get_name_leafdata());
if (delete_.is_set || is_set(delete_.yfilter)) leaf_name_data.push_back(delete_.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::CommList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::CommList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::CommList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "comm-list-standard")
{
comm_list_standard = value;
comm_list_standard.value_namespace = name_space;
comm_list_standard.value_namespace_prefix = name_space_prefix;
}
if(value_path == "comm-list-expanded")
{
comm_list_expanded = value;
comm_list_expanded.value_namespace = name_space;
comm_list_expanded.value_namespace_prefix = name_space_prefix;
}
if(value_path == "comm-list-name")
{
comm_list_name = value;
comm_list_name.value_namespace = name_space;
comm_list_name.value_namespace_prefix = name_space_prefix;
}
if(value_path == "delete")
{
delete_ = value;
delete_.value_namespace = name_space;
delete_.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::CommList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "comm-list-standard")
{
comm_list_standard.yfilter = yfilter;
}
if(value_path == "comm-list-expanded")
{
comm_list_expanded.yfilter = yfilter;
}
if(value_path == "comm-list-name")
{
comm_list_name.yfilter = yfilter;
}
if(value_path == "delete")
{
delete_.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::CommList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "comm-list-standard" || name == "comm-list-expanded" || name == "comm-list-name" || name == "delete")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::Dampening()
:
dampening_list(this, {"half_life_penalty", "restart_penalty", "suppress_penalty", "max_suppress_penalty"})
{
yang_name = "dampening"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::~Dampening()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<dampening_list.len(); index++)
{
if(dampening_list[index]->has_data())
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::has_operation() const
{
for (std::size_t index=0; index<dampening_list.len(); index++)
{
if(dampening_list[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "dampening";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "dampening-list")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::DampeningList>();
ent_->parent = this;
dampening_list.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : dampening_list.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dampening-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::DampeningList::DampeningList()
:
half_life_penalty{YType::uint8, "half-life-penalty"},
restart_penalty{YType::uint16, "restart-penalty"},
suppress_penalty{YType::uint16, "suppress-penalty"},
max_suppress_penalty{YType::uint8, "max-suppress-penalty"}
{
yang_name = "dampening-list"; yang_parent_name = "dampening"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::DampeningList::~DampeningList()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::DampeningList::has_data() const
{
if (is_presence_container) return true;
return half_life_penalty.is_set
|| restart_penalty.is_set
|| suppress_penalty.is_set
|| max_suppress_penalty.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::DampeningList::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(half_life_penalty.yfilter)
|| ydk::is_set(restart_penalty.yfilter)
|| ydk::is_set(suppress_penalty.yfilter)
|| ydk::is_set(max_suppress_penalty.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::DampeningList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "dampening-list";
ADD_KEY_TOKEN(half_life_penalty, "half-life-penalty");
ADD_KEY_TOKEN(restart_penalty, "restart-penalty");
ADD_KEY_TOKEN(suppress_penalty, "suppress-penalty");
ADD_KEY_TOKEN(max_suppress_penalty, "max-suppress-penalty");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::DampeningList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (half_life_penalty.is_set || is_set(half_life_penalty.yfilter)) leaf_name_data.push_back(half_life_penalty.get_name_leafdata());
if (restart_penalty.is_set || is_set(restart_penalty.yfilter)) leaf_name_data.push_back(restart_penalty.get_name_leafdata());
if (suppress_penalty.is_set || is_set(suppress_penalty.yfilter)) leaf_name_data.push_back(suppress_penalty.get_name_leafdata());
if (max_suppress_penalty.is_set || is_set(max_suppress_penalty.yfilter)) leaf_name_data.push_back(max_suppress_penalty.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::DampeningList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::DampeningList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::DampeningList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "half-life-penalty")
{
half_life_penalty = value;
half_life_penalty.value_namespace = name_space;
half_life_penalty.value_namespace_prefix = name_space_prefix;
}
if(value_path == "restart-penalty")
{
restart_penalty = value;
restart_penalty.value_namespace = name_space;
restart_penalty.value_namespace_prefix = name_space_prefix;
}
if(value_path == "suppress-penalty")
{
suppress_penalty = value;
suppress_penalty.value_namespace = name_space;
suppress_penalty.value_namespace_prefix = name_space_prefix;
}
if(value_path == "max-suppress-penalty")
{
max_suppress_penalty = value;
max_suppress_penalty.value_namespace = name_space;
max_suppress_penalty.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::DampeningList::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "half-life-penalty")
{
half_life_penalty.yfilter = yfilter;
}
if(value_path == "restart-penalty")
{
restart_penalty.yfilter = yfilter;
}
if(value_path == "suppress-penalty")
{
suppress_penalty.yfilter = yfilter;
}
if(value_path == "max-suppress-penalty")
{
max_suppress_penalty.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Dampening::DampeningList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "half-life-penalty" || name == "restart-penalty" || name == "suppress-penalty" || name == "max-suppress-penalty")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Default()
:
interface(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface>())
{
interface->parent = this;
yang_name = "default"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::~Default()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::has_data() const
{
if (is_presence_container) return true;
return (interface != nullptr && interface->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::has_operation() const
{
return is_set(yfilter)
|| (interface != nullptr && interface->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "default";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "interface")
{
if(interface == nullptr)
{
interface = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface>();
}
return interface;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(interface != nullptr)
{
_children["interface"] = interface;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "interface")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::Interface()
:
appnav_compress{YType::uint16, "AppNav-Compress"},
appnav_uncompress{YType::uint16, "AppNav-UnCompress"},
atm{YType::str, "ATM"},
atm_acr{YType::str, "ATM-ACR"},
bdi{YType::str, "BDI"},
cem{YType::str, "CEM"},
cem_acr{YType::uint8, "CEM-ACR"},
embedded_service_engine{YType::str, "Embedded-Service-Engine"},
ethernet{YType::str, "Ethernet"},
fastethernet{YType::str, "FastEthernet"},
gigabitethernet{YType::str, "GigabitEthernet"},
fivegigabitethernet{YType::str, "FiveGigabitEthernet"},
twentyfivegige{YType::str, "TwentyFiveGigE"},
twogigabitethernet{YType::str, "TwoGigabitEthernet"},
fortygigabitethernet{YType::str, "FortyGigabitEthernet"},
hundredgige{YType::str, "HundredGigE"},
lisp{YType::str, "LISP"},
loopback{YType::uint32, "Loopback"},
multilink{YType::uint16, "Multilink"},
nve{YType::uint16, "nve"},
overlay{YType::uint16, "overlay"},
port_channel{YType::uint32, "Port-channel"},
pseudowire{YType::uint32, "pseudowire"},
sm{YType::str, "SM"},
cellular{YType::str, "Cellular"},
serial{YType::str, "Serial"},
tengigabitethernet{YType::str, "TenGigabitEthernet"},
tunnel{YType::uint32, "Tunnel"},
virtual_template{YType::uint16, "Virtual-Template"},
vlan{YType::uint16, "Vlan"},
virtualportgroup{YType::uint16, "VirtualPortGroup"},
vasileft{YType::uint16, "vasileft"},
vasiright{YType::uint16, "vasiright"}
,
atm_subinterface(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMSubinterface>())
, atm_acrsubinterface(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMACRsubinterface>())
, lisp_subinterface(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::LISPSubinterface>())
, port_channel_subinterface(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::PortChannelSubinterface>())
{
atm_subinterface->parent = this;
atm_acrsubinterface->parent = this;
lisp_subinterface->parent = this;
port_channel_subinterface->parent = this;
yang_name = "interface"; yang_parent_name = "default"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::~Interface()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::has_data() const
{
if (is_presence_container) return true;
return appnav_compress.is_set
|| appnav_uncompress.is_set
|| atm.is_set
|| atm_acr.is_set
|| bdi.is_set
|| cem.is_set
|| cem_acr.is_set
|| embedded_service_engine.is_set
|| ethernet.is_set
|| fastethernet.is_set
|| gigabitethernet.is_set
|| fivegigabitethernet.is_set
|| twentyfivegige.is_set
|| twogigabitethernet.is_set
|| fortygigabitethernet.is_set
|| hundredgige.is_set
|| lisp.is_set
|| loopback.is_set
|| multilink.is_set
|| nve.is_set
|| overlay.is_set
|| port_channel.is_set
|| pseudowire.is_set
|| sm.is_set
|| cellular.is_set
|| serial.is_set
|| tengigabitethernet.is_set
|| tunnel.is_set
|| virtual_template.is_set
|| vlan.is_set
|| virtualportgroup.is_set
|| vasileft.is_set
|| vasiright.is_set
|| (atm_subinterface != nullptr && atm_subinterface->has_data())
|| (atm_acrsubinterface != nullptr && atm_acrsubinterface->has_data())
|| (lisp_subinterface != nullptr && lisp_subinterface->has_data())
|| (port_channel_subinterface != nullptr && port_channel_subinterface->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(appnav_compress.yfilter)
|| ydk::is_set(appnav_uncompress.yfilter)
|| ydk::is_set(atm.yfilter)
|| ydk::is_set(atm_acr.yfilter)
|| ydk::is_set(bdi.yfilter)
|| ydk::is_set(cem.yfilter)
|| ydk::is_set(cem_acr.yfilter)
|| ydk::is_set(embedded_service_engine.yfilter)
|| ydk::is_set(ethernet.yfilter)
|| ydk::is_set(fastethernet.yfilter)
|| ydk::is_set(gigabitethernet.yfilter)
|| ydk::is_set(fivegigabitethernet.yfilter)
|| ydk::is_set(twentyfivegige.yfilter)
|| ydk::is_set(twogigabitethernet.yfilter)
|| ydk::is_set(fortygigabitethernet.yfilter)
|| ydk::is_set(hundredgige.yfilter)
|| ydk::is_set(lisp.yfilter)
|| ydk::is_set(loopback.yfilter)
|| ydk::is_set(multilink.yfilter)
|| ydk::is_set(nve.yfilter)
|| ydk::is_set(overlay.yfilter)
|| ydk::is_set(port_channel.yfilter)
|| ydk::is_set(pseudowire.yfilter)
|| ydk::is_set(sm.yfilter)
|| ydk::is_set(cellular.yfilter)
|| ydk::is_set(serial.yfilter)
|| ydk::is_set(tengigabitethernet.yfilter)
|| ydk::is_set(tunnel.yfilter)
|| ydk::is_set(virtual_template.yfilter)
|| ydk::is_set(vlan.yfilter)
|| ydk::is_set(virtualportgroup.yfilter)
|| ydk::is_set(vasileft.yfilter)
|| ydk::is_set(vasiright.yfilter)
|| (atm_subinterface != nullptr && atm_subinterface->has_operation())
|| (atm_acrsubinterface != nullptr && atm_acrsubinterface->has_operation())
|| (lisp_subinterface != nullptr && lisp_subinterface->has_operation())
|| (port_channel_subinterface != nullptr && port_channel_subinterface->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "interface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (appnav_compress.is_set || is_set(appnav_compress.yfilter)) leaf_name_data.push_back(appnav_compress.get_name_leafdata());
if (appnav_uncompress.is_set || is_set(appnav_uncompress.yfilter)) leaf_name_data.push_back(appnav_uncompress.get_name_leafdata());
if (atm.is_set || is_set(atm.yfilter)) leaf_name_data.push_back(atm.get_name_leafdata());
if (atm_acr.is_set || is_set(atm_acr.yfilter)) leaf_name_data.push_back(atm_acr.get_name_leafdata());
if (bdi.is_set || is_set(bdi.yfilter)) leaf_name_data.push_back(bdi.get_name_leafdata());
if (cem.is_set || is_set(cem.yfilter)) leaf_name_data.push_back(cem.get_name_leafdata());
if (cem_acr.is_set || is_set(cem_acr.yfilter)) leaf_name_data.push_back(cem_acr.get_name_leafdata());
if (embedded_service_engine.is_set || is_set(embedded_service_engine.yfilter)) leaf_name_data.push_back(embedded_service_engine.get_name_leafdata());
if (ethernet.is_set || is_set(ethernet.yfilter)) leaf_name_data.push_back(ethernet.get_name_leafdata());
if (fastethernet.is_set || is_set(fastethernet.yfilter)) leaf_name_data.push_back(fastethernet.get_name_leafdata());
if (gigabitethernet.is_set || is_set(gigabitethernet.yfilter)) leaf_name_data.push_back(gigabitethernet.get_name_leafdata());
if (fivegigabitethernet.is_set || is_set(fivegigabitethernet.yfilter)) leaf_name_data.push_back(fivegigabitethernet.get_name_leafdata());
if (twentyfivegige.is_set || is_set(twentyfivegige.yfilter)) leaf_name_data.push_back(twentyfivegige.get_name_leafdata());
if (twogigabitethernet.is_set || is_set(twogigabitethernet.yfilter)) leaf_name_data.push_back(twogigabitethernet.get_name_leafdata());
if (fortygigabitethernet.is_set || is_set(fortygigabitethernet.yfilter)) leaf_name_data.push_back(fortygigabitethernet.get_name_leafdata());
if (hundredgige.is_set || is_set(hundredgige.yfilter)) leaf_name_data.push_back(hundredgige.get_name_leafdata());
if (lisp.is_set || is_set(lisp.yfilter)) leaf_name_data.push_back(lisp.get_name_leafdata());
if (loopback.is_set || is_set(loopback.yfilter)) leaf_name_data.push_back(loopback.get_name_leafdata());
if (multilink.is_set || is_set(multilink.yfilter)) leaf_name_data.push_back(multilink.get_name_leafdata());
if (nve.is_set || is_set(nve.yfilter)) leaf_name_data.push_back(nve.get_name_leafdata());
if (overlay.is_set || is_set(overlay.yfilter)) leaf_name_data.push_back(overlay.get_name_leafdata());
if (port_channel.is_set || is_set(port_channel.yfilter)) leaf_name_data.push_back(port_channel.get_name_leafdata());
if (pseudowire.is_set || is_set(pseudowire.yfilter)) leaf_name_data.push_back(pseudowire.get_name_leafdata());
if (sm.is_set || is_set(sm.yfilter)) leaf_name_data.push_back(sm.get_name_leafdata());
if (cellular.is_set || is_set(cellular.yfilter)) leaf_name_data.push_back(cellular.get_name_leafdata());
if (serial.is_set || is_set(serial.yfilter)) leaf_name_data.push_back(serial.get_name_leafdata());
if (tengigabitethernet.is_set || is_set(tengigabitethernet.yfilter)) leaf_name_data.push_back(tengigabitethernet.get_name_leafdata());
if (tunnel.is_set || is_set(tunnel.yfilter)) leaf_name_data.push_back(tunnel.get_name_leafdata());
if (virtual_template.is_set || is_set(virtual_template.yfilter)) leaf_name_data.push_back(virtual_template.get_name_leafdata());
if (vlan.is_set || is_set(vlan.yfilter)) leaf_name_data.push_back(vlan.get_name_leafdata());
if (virtualportgroup.is_set || is_set(virtualportgroup.yfilter)) leaf_name_data.push_back(virtualportgroup.get_name_leafdata());
if (vasileft.is_set || is_set(vasileft.yfilter)) leaf_name_data.push_back(vasileft.get_name_leafdata());
if (vasiright.is_set || is_set(vasiright.yfilter)) leaf_name_data.push_back(vasiright.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ATM-subinterface")
{
if(atm_subinterface == nullptr)
{
atm_subinterface = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMSubinterface>();
}
return atm_subinterface;
}
if(child_yang_name == "ATM-ACRsubinterface")
{
if(atm_acrsubinterface == nullptr)
{
atm_acrsubinterface = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMACRsubinterface>();
}
return atm_acrsubinterface;
}
if(child_yang_name == "LISP-subinterface")
{
if(lisp_subinterface == nullptr)
{
lisp_subinterface = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::LISPSubinterface>();
}
return lisp_subinterface;
}
if(child_yang_name == "Port-channel-subinterface")
{
if(port_channel_subinterface == nullptr)
{
port_channel_subinterface = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::PortChannelSubinterface>();
}
return port_channel_subinterface;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(atm_subinterface != nullptr)
{
_children["ATM-subinterface"] = atm_subinterface;
}
if(atm_acrsubinterface != nullptr)
{
_children["ATM-ACRsubinterface"] = atm_acrsubinterface;
}
if(lisp_subinterface != nullptr)
{
_children["LISP-subinterface"] = lisp_subinterface;
}
if(port_channel_subinterface != nullptr)
{
_children["Port-channel-subinterface"] = port_channel_subinterface;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "AppNav-Compress")
{
appnav_compress = value;
appnav_compress.value_namespace = name_space;
appnav_compress.value_namespace_prefix = name_space_prefix;
}
if(value_path == "AppNav-UnCompress")
{
appnav_uncompress = value;
appnav_uncompress.value_namespace = name_space;
appnav_uncompress.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ATM")
{
atm = value;
atm.value_namespace = name_space;
atm.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ATM-ACR")
{
atm_acr = value;
atm_acr.value_namespace = name_space;
atm_acr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "BDI")
{
bdi = value;
bdi.value_namespace = name_space;
bdi.value_namespace_prefix = name_space_prefix;
}
if(value_path == "CEM")
{
cem = value;
cem.value_namespace = name_space;
cem.value_namespace_prefix = name_space_prefix;
}
if(value_path == "CEM-ACR")
{
cem_acr = value;
cem_acr.value_namespace = name_space;
cem_acr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Embedded-Service-Engine")
{
embedded_service_engine = value;
embedded_service_engine.value_namespace = name_space;
embedded_service_engine.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Ethernet")
{
ethernet = value;
ethernet.value_namespace = name_space;
ethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FastEthernet")
{
fastethernet = value;
fastethernet.value_namespace = name_space;
fastethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "GigabitEthernet")
{
gigabitethernet = value;
gigabitethernet.value_namespace = name_space;
gigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FiveGigabitEthernet")
{
fivegigabitethernet = value;
fivegigabitethernet.value_namespace = name_space;
fivegigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TwentyFiveGigE")
{
twentyfivegige = value;
twentyfivegige.value_namespace = name_space;
twentyfivegige.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TwoGigabitEthernet")
{
twogigabitethernet = value;
twogigabitethernet.value_namespace = name_space;
twogigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FortyGigabitEthernet")
{
fortygigabitethernet = value;
fortygigabitethernet.value_namespace = name_space;
fortygigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "HundredGigE")
{
hundredgige = value;
hundredgige.value_namespace = name_space;
hundredgige.value_namespace_prefix = name_space_prefix;
}
if(value_path == "LISP")
{
lisp = value;
lisp.value_namespace = name_space;
lisp.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Loopback")
{
loopback = value;
loopback.value_namespace = name_space;
loopback.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Multilink")
{
multilink = value;
multilink.value_namespace = name_space;
multilink.value_namespace_prefix = name_space_prefix;
}
if(value_path == "nve")
{
nve = value;
nve.value_namespace = name_space;
nve.value_namespace_prefix = name_space_prefix;
}
if(value_path == "overlay")
{
overlay = value;
overlay.value_namespace = name_space;
overlay.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Port-channel")
{
port_channel = value;
port_channel.value_namespace = name_space;
port_channel.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pseudowire")
{
pseudowire = value;
pseudowire.value_namespace = name_space;
pseudowire.value_namespace_prefix = name_space_prefix;
}
if(value_path == "SM")
{
sm = value;
sm.value_namespace = name_space;
sm.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Cellular")
{
cellular = value;
cellular.value_namespace = name_space;
cellular.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Serial")
{
serial = value;
serial.value_namespace = name_space;
serial.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TenGigabitEthernet")
{
tengigabitethernet = value;
tengigabitethernet.value_namespace = name_space;
tengigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Tunnel")
{
tunnel = value;
tunnel.value_namespace = name_space;
tunnel.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Virtual-Template")
{
virtual_template = value;
virtual_template.value_namespace = name_space;
virtual_template.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Vlan")
{
vlan = value;
vlan.value_namespace = name_space;
vlan.value_namespace_prefix = name_space_prefix;
}
if(value_path == "VirtualPortGroup")
{
virtualportgroup = value;
virtualportgroup.value_namespace = name_space;
virtualportgroup.value_namespace_prefix = name_space_prefix;
}
if(value_path == "vasileft")
{
vasileft = value;
vasileft.value_namespace = name_space;
vasileft.value_namespace_prefix = name_space_prefix;
}
if(value_path == "vasiright")
{
vasiright = value;
vasiright.value_namespace = name_space;
vasiright.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "AppNav-Compress")
{
appnav_compress.yfilter = yfilter;
}
if(value_path == "AppNav-UnCompress")
{
appnav_uncompress.yfilter = yfilter;
}
if(value_path == "ATM")
{
atm.yfilter = yfilter;
}
if(value_path == "ATM-ACR")
{
atm_acr.yfilter = yfilter;
}
if(value_path == "BDI")
{
bdi.yfilter = yfilter;
}
if(value_path == "CEM")
{
cem.yfilter = yfilter;
}
if(value_path == "CEM-ACR")
{
cem_acr.yfilter = yfilter;
}
if(value_path == "Embedded-Service-Engine")
{
embedded_service_engine.yfilter = yfilter;
}
if(value_path == "Ethernet")
{
ethernet.yfilter = yfilter;
}
if(value_path == "FastEthernet")
{
fastethernet.yfilter = yfilter;
}
if(value_path == "GigabitEthernet")
{
gigabitethernet.yfilter = yfilter;
}
if(value_path == "FiveGigabitEthernet")
{
fivegigabitethernet.yfilter = yfilter;
}
if(value_path == "TwentyFiveGigE")
{
twentyfivegige.yfilter = yfilter;
}
if(value_path == "TwoGigabitEthernet")
{
twogigabitethernet.yfilter = yfilter;
}
if(value_path == "FortyGigabitEthernet")
{
fortygigabitethernet.yfilter = yfilter;
}
if(value_path == "HundredGigE")
{
hundredgige.yfilter = yfilter;
}
if(value_path == "LISP")
{
lisp.yfilter = yfilter;
}
if(value_path == "Loopback")
{
loopback.yfilter = yfilter;
}
if(value_path == "Multilink")
{
multilink.yfilter = yfilter;
}
if(value_path == "nve")
{
nve.yfilter = yfilter;
}
if(value_path == "overlay")
{
overlay.yfilter = yfilter;
}
if(value_path == "Port-channel")
{
port_channel.yfilter = yfilter;
}
if(value_path == "pseudowire")
{
pseudowire.yfilter = yfilter;
}
if(value_path == "SM")
{
sm.yfilter = yfilter;
}
if(value_path == "Cellular")
{
cellular.yfilter = yfilter;
}
if(value_path == "Serial")
{
serial.yfilter = yfilter;
}
if(value_path == "TenGigabitEthernet")
{
tengigabitethernet.yfilter = yfilter;
}
if(value_path == "Tunnel")
{
tunnel.yfilter = yfilter;
}
if(value_path == "Virtual-Template")
{
virtual_template.yfilter = yfilter;
}
if(value_path == "Vlan")
{
vlan.yfilter = yfilter;
}
if(value_path == "VirtualPortGroup")
{
virtualportgroup.yfilter = yfilter;
}
if(value_path == "vasileft")
{
vasileft.yfilter = yfilter;
}
if(value_path == "vasiright")
{
vasiright.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM-subinterface" || name == "ATM-ACRsubinterface" || name == "LISP-subinterface" || name == "Port-channel-subinterface" || name == "AppNav-Compress" || name == "AppNav-UnCompress" || name == "ATM" || name == "ATM-ACR" || name == "BDI" || name == "CEM" || name == "CEM-ACR" || name == "Embedded-Service-Engine" || name == "Ethernet" || name == "FastEthernet" || name == "GigabitEthernet" || name == "FiveGigabitEthernet" || name == "TwentyFiveGigE" || name == "TwoGigabitEthernet" || name == "FortyGigabitEthernet" || name == "HundredGigE" || name == "LISP" || name == "Loopback" || name == "Multilink" || name == "nve" || name == "overlay" || name == "Port-channel" || name == "pseudowire" || name == "SM" || name == "Cellular" || name == "Serial" || name == "TenGigabitEthernet" || name == "Tunnel" || name == "Virtual-Template" || name == "Vlan" || name == "VirtualPortGroup" || name == "vasileft" || name == "vasiright")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMSubinterface::ATMSubinterface()
:
atm{YType::str, "ATM"}
{
yang_name = "ATM-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMSubinterface::~ATMSubinterface()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMSubinterface::has_data() const
{
if (is_presence_container) return true;
return atm.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(atm.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ATM-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (atm.is_set || is_set(atm.yfilter)) leaf_name_data.push_back(atm.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ATM")
{
atm = value;
atm.value_namespace = name_space;
atm.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ATM")
{
atm.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMACRsubinterface::ATMACRsubinterface()
:
atm_acr{YType::str, "ATM-ACR"}
{
yang_name = "ATM-ACRsubinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMACRsubinterface::~ATMACRsubinterface()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMACRsubinterface::has_data() const
{
if (is_presence_container) return true;
return atm_acr.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMACRsubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(atm_acr.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMACRsubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ATM-ACRsubinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMACRsubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (atm_acr.is_set || is_set(atm_acr.yfilter)) leaf_name_data.push_back(atm_acr.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMACRsubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMACRsubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMACRsubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ATM-ACR")
{
atm_acr = value;
atm_acr.value_namespace = name_space;
atm_acr.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMACRsubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ATM-ACR")
{
atm_acr.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::ATMACRsubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM-ACR")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::LISPSubinterface::LISPSubinterface()
:
lisp{YType::str, "LISP"}
{
yang_name = "LISP-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::LISPSubinterface::~LISPSubinterface()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::LISPSubinterface::has_data() const
{
if (is_presence_container) return true;
return lisp.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::LISPSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lisp.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::LISPSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "LISP-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::LISPSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lisp.is_set || is_set(lisp.yfilter)) leaf_name_data.push_back(lisp.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::LISPSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::LISPSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::LISPSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "LISP")
{
lisp = value;
lisp.value_namespace = name_space;
lisp.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::LISPSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "LISP")
{
lisp.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::LISPSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "LISP")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::PortChannelSubinterface::PortChannelSubinterface()
:
port_channel{YType::str, "Port-channel"}
{
yang_name = "Port-channel-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::PortChannelSubinterface::~PortChannelSubinterface()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::PortChannelSubinterface::has_data() const
{
if (is_presence_container) return true;
return port_channel.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::PortChannelSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(port_channel.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::PortChannelSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "Port-channel-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::PortChannelSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (port_channel.is_set || is_set(port_channel.yfilter)) leaf_name_data.push_back(port_channel.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::PortChannelSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::PortChannelSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::PortChannelSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "Port-channel")
{
port_channel = value;
port_channel.value_namespace = name_space;
port_channel.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::PortChannelSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "Port-channel")
{
port_channel.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Default::Interface::PortChannelSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "Port-channel")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExtcommList()
:
ext_range(this, {"comm_list_num"})
, excomm_list_name(this, {"name"})
{
yang_name = "extcomm-list"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::~ExtcommList()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<ext_range.len(); index++)
{
if(ext_range[index]->has_data())
return true;
}
for (std::size_t index=0; index<excomm_list_name.len(); index++)
{
if(excomm_list_name[index]->has_data())
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::has_operation() const
{
for (std::size_t index=0; index<ext_range.len(); index++)
{
if(ext_range[index]->has_operation())
return true;
}
for (std::size_t index=0; index<excomm_list_name.len(); index++)
{
if(excomm_list_name[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "extcomm-list";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ext-range")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExtRange>();
ent_->parent = this;
ext_range.append(ent_);
return ent_;
}
if(child_yang_name == "excomm-list-name")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExcommListName>();
ent_->parent = this;
excomm_list_name.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : ext_range.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
count_ = 0;
for (auto ent_ : excomm_list_name.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ext-range" || name == "excomm-list-name")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExtRange::ExtRange()
:
comm_list_num{YType::uint16, "comm-list-num"},
delete_{YType::empty, "delete"}
{
yang_name = "ext-range"; yang_parent_name = "extcomm-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExtRange::~ExtRange()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExtRange::has_data() const
{
if (is_presence_container) return true;
return comm_list_num.is_set
|| delete_.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExtRange::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(comm_list_num.yfilter)
|| ydk::is_set(delete_.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExtRange::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ext-range";
ADD_KEY_TOKEN(comm_list_num, "comm-list-num");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExtRange::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (comm_list_num.is_set || is_set(comm_list_num.yfilter)) leaf_name_data.push_back(comm_list_num.get_name_leafdata());
if (delete_.is_set || is_set(delete_.yfilter)) leaf_name_data.push_back(delete_.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExtRange::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExtRange::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExtRange::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "comm-list-num")
{
comm_list_num = value;
comm_list_num.value_namespace = name_space;
comm_list_num.value_namespace_prefix = name_space_prefix;
}
if(value_path == "delete")
{
delete_ = value;
delete_.value_namespace = name_space;
delete_.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExtRange::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "comm-list-num")
{
comm_list_num.yfilter = yfilter;
}
if(value_path == "delete")
{
delete_.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExtRange::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "comm-list-num" || name == "delete")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExcommListName::ExcommListName()
:
name{YType::str, "name"},
delete_{YType::empty, "delete"}
{
yang_name = "excomm-list-name"; yang_parent_name = "extcomm-list"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExcommListName::~ExcommListName()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExcommListName::has_data() const
{
if (is_presence_container) return true;
return name.is_set
|| delete_.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExcommListName::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(name.yfilter)
|| ydk::is_set(delete_.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExcommListName::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "excomm-list-name";
ADD_KEY_TOKEN(name, "name");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExcommListName::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 (delete_.is_set || is_set(delete_.yfilter)) leaf_name_data.push_back(delete_.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExcommListName::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExcommListName::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExcommListName::set_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 == "delete")
{
delete_ = value;
delete_.value_namespace = name_space;
delete_.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExcommListName::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "name")
{
name.yfilter = yfilter;
}
if(value_path == "delete")
{
delete_.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::ExtcommList::ExcommListName::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "name" || name == "delete")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Extcommunity()
:
cost(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost>())
, rt(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt>())
, soo(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Soo>())
, vpn_distinguisher(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher>())
{
cost->parent = this;
rt->parent = this;
soo->parent = this;
vpn_distinguisher->parent = this;
yang_name = "extcommunity"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::~Extcommunity()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::has_data() const
{
if (is_presence_container) return true;
return (cost != nullptr && cost->has_data())
|| (rt != nullptr && rt->has_data())
|| (soo != nullptr && soo->has_data())
|| (vpn_distinguisher != nullptr && vpn_distinguisher->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::has_operation() const
{
return is_set(yfilter)
|| (cost != nullptr && cost->has_operation())
|| (rt != nullptr && rt->has_operation())
|| (soo != nullptr && soo->has_operation())
|| (vpn_distinguisher != nullptr && vpn_distinguisher->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "extcommunity";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "cost")
{
if(cost == nullptr)
{
cost = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost>();
}
return cost;
}
if(child_yang_name == "rt")
{
if(rt == nullptr)
{
rt = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt>();
}
return rt;
}
if(child_yang_name == "soo")
{
if(soo == nullptr)
{
soo = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Soo>();
}
return soo;
}
if(child_yang_name == "vpn-distinguisher")
{
if(vpn_distinguisher == nullptr)
{
vpn_distinguisher = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher>();
}
return vpn_distinguisher;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(cost != nullptr)
{
_children["cost"] = cost;
}
if(rt != nullptr)
{
_children["rt"] = rt;
}
if(soo != nullptr)
{
_children["soo"] = soo;
}
if(vpn_distinguisher != nullptr)
{
_children["vpn-distinguisher"] = vpn_distinguisher;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "cost" || name == "rt" || name == "soo" || name == "vpn-distinguisher")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Cost()
:
community_id(this, {"community_id", "cost_value"})
, igp(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp>())
, pre_bestpath(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath>())
{
igp->parent = this;
pre_bestpath->parent = this;
yang_name = "cost"; yang_parent_name = "extcommunity"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::~Cost()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<community_id.len(); index++)
{
if(community_id[index]->has_data())
return true;
}
return (igp != nullptr && igp->has_data())
|| (pre_bestpath != nullptr && pre_bestpath->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::has_operation() const
{
for (std::size_t index=0; index<community_id.len(); index++)
{
if(community_id[index]->has_operation())
return true;
}
return is_set(yfilter)
|| (igp != nullptr && igp->has_operation())
|| (pre_bestpath != nullptr && pre_bestpath->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "cost";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "community-id")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::CommunityId>();
ent_->parent = this;
community_id.append(ent_);
return ent_;
}
if(child_yang_name == "igp")
{
if(igp == nullptr)
{
igp = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp>();
}
return igp;
}
if(child_yang_name == "pre-bestpath")
{
if(pre_bestpath == nullptr)
{
pre_bestpath = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath>();
}
return pre_bestpath;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : community_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_;
}
if(igp != nullptr)
{
_children["igp"] = igp;
}
if(pre_bestpath != nullptr)
{
_children["pre-bestpath"] = pre_bestpath;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "community-id" || name == "igp" || name == "pre-bestpath")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::CommunityId::CommunityId()
:
community_id{YType::uint8, "community-id"},
cost_value{YType::uint32, "cost-value"}
{
yang_name = "community-id"; yang_parent_name = "cost"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::CommunityId::~CommunityId()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::CommunityId::has_data() const
{
if (is_presence_container) return true;
return community_id.is_set
|| cost_value.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::CommunityId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(community_id.yfilter)
|| ydk::is_set(cost_value.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::CommunityId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "community-id";
ADD_KEY_TOKEN(community_id, "community-id");
ADD_KEY_TOKEN(cost_value, "cost-value");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::CommunityId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (community_id.is_set || is_set(community_id.yfilter)) leaf_name_data.push_back(community_id.get_name_leafdata());
if (cost_value.is_set || is_set(cost_value.yfilter)) leaf_name_data.push_back(cost_value.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::CommunityId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::CommunityId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::CommunityId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "community-id")
{
community_id = value;
community_id.value_namespace = name_space;
community_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "cost-value")
{
cost_value = value;
cost_value.value_namespace = name_space;
cost_value.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::CommunityId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "community-id")
{
community_id.yfilter = yfilter;
}
if(value_path == "cost-value")
{
cost_value.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::CommunityId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "community-id" || name == "cost-value")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::Igp()
:
community_id(this, {"community_id", "cost_value"})
{
yang_name = "igp"; yang_parent_name = "cost"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::~Igp()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<community_id.len(); index++)
{
if(community_id[index]->has_data())
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::has_operation() const
{
for (std::size_t index=0; index<community_id.len(); index++)
{
if(community_id[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "igp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "community-id")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::CommunityId>();
ent_->parent = this;
community_id.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : community_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 Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "community-id")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::CommunityId::CommunityId()
:
community_id{YType::uint8, "community-id"},
cost_value{YType::uint32, "cost-value"}
{
yang_name = "community-id"; yang_parent_name = "igp"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::CommunityId::~CommunityId()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::CommunityId::has_data() const
{
if (is_presence_container) return true;
return community_id.is_set
|| cost_value.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::CommunityId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(community_id.yfilter)
|| ydk::is_set(cost_value.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::CommunityId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "community-id";
ADD_KEY_TOKEN(community_id, "community-id");
ADD_KEY_TOKEN(cost_value, "cost-value");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::CommunityId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (community_id.is_set || is_set(community_id.yfilter)) leaf_name_data.push_back(community_id.get_name_leafdata());
if (cost_value.is_set || is_set(cost_value.yfilter)) leaf_name_data.push_back(cost_value.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::CommunityId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::CommunityId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::CommunityId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "community-id")
{
community_id = value;
community_id.value_namespace = name_space;
community_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "cost-value")
{
cost_value = value;
cost_value.value_namespace = name_space;
cost_value.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::CommunityId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "community-id")
{
community_id.yfilter = yfilter;
}
if(value_path == "cost-value")
{
cost_value.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::Igp::CommunityId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "community-id" || name == "cost-value")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::PreBestpath()
:
community_id(this, {"community_id", "cost_value"})
{
yang_name = "pre-bestpath"; yang_parent_name = "cost"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::~PreBestpath()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<community_id.len(); index++)
{
if(community_id[index]->has_data())
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::has_operation() const
{
for (std::size_t index=0; index<community_id.len(); index++)
{
if(community_id[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "pre-bestpath";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "community-id")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::CommunityId>();
ent_->parent = this;
community_id.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : community_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 Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "community-id")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::CommunityId::CommunityId()
:
community_id{YType::uint8, "community-id"},
cost_value{YType::uint32, "cost-value"}
{
yang_name = "community-id"; yang_parent_name = "pre-bestpath"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::CommunityId::~CommunityId()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::CommunityId::has_data() const
{
if (is_presence_container) return true;
return community_id.is_set
|| cost_value.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::CommunityId::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(community_id.yfilter)
|| ydk::is_set(cost_value.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::CommunityId::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "community-id";
ADD_KEY_TOKEN(community_id, "community-id");
ADD_KEY_TOKEN(cost_value, "cost-value");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::CommunityId::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (community_id.is_set || is_set(community_id.yfilter)) leaf_name_data.push_back(community_id.get_name_leafdata());
if (cost_value.is_set || is_set(cost_value.yfilter)) leaf_name_data.push_back(cost_value.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::CommunityId::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::CommunityId::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::CommunityId::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "community-id")
{
community_id = value;
community_id.value_namespace = name_space;
community_id.value_namespace_prefix = name_space_prefix;
}
if(value_path == "cost-value")
{
cost_value = value;
cost_value.value_namespace = name_space;
cost_value.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::CommunityId::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "community-id")
{
community_id.yfilter = yfilter;
}
if(value_path == "cost-value")
{
cost_value.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Cost::PreBestpath::CommunityId::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "community-id" || name == "cost-value")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Rt()
:
asn_nn{YType::str, "asn-nn"}
,
range(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Range>())
{
range->parent = this;
yang_name = "rt"; yang_parent_name = "extcommunity"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::~Rt()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : asn_nn.getYLeafs())
{
if(leaf.is_set)
return true;
}
return (range != nullptr && range->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::has_operation() const
{
for (auto const & leaf : asn_nn.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(asn_nn.yfilter)
|| (range != nullptr && range->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "rt";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto asn_nn_name_datas = asn_nn.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), asn_nn_name_datas.begin(), asn_nn_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "range")
{
if(range == nullptr)
{
range = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Range>();
}
return range;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(range != nullptr)
{
_children["range"] = range;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "asn-nn")
{
asn_nn.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "asn-nn")
{
asn_nn.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "range" || name == "asn-nn")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Range::Range()
:
lower_limit{YType::str, "lower-limit"},
high_limit{YType::str, "high-limit"},
additive{YType::empty, "additive"}
{
yang_name = "range"; yang_parent_name = "rt"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Range::~Range()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Range::has_data() const
{
if (is_presence_container) return true;
return lower_limit.is_set
|| high_limit.is_set
|| additive.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Range::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lower_limit.yfilter)
|| ydk::is_set(high_limit.yfilter)
|| ydk::is_set(additive.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Range::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "range";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Range::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lower_limit.is_set || is_set(lower_limit.yfilter)) leaf_name_data.push_back(lower_limit.get_name_leafdata());
if (high_limit.is_set || is_set(high_limit.yfilter)) leaf_name_data.push_back(high_limit.get_name_leafdata());
if (additive.is_set || is_set(additive.yfilter)) leaf_name_data.push_back(additive.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Range::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Range::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Range::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "lower-limit")
{
lower_limit = value;
lower_limit.value_namespace = name_space;
lower_limit.value_namespace_prefix = name_space_prefix;
}
if(value_path == "high-limit")
{
high_limit = value;
high_limit.value_namespace = name_space;
high_limit.value_namespace_prefix = name_space_prefix;
}
if(value_path == "additive")
{
additive = value;
additive.value_namespace = name_space;
additive.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Range::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "lower-limit")
{
lower_limit.yfilter = yfilter;
}
if(value_path == "high-limit")
{
high_limit.yfilter = yfilter;
}
if(value_path == "additive")
{
additive.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::Range::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "lower-limit" || name == "high-limit" || name == "additive")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Soo::Soo()
:
asn_nn{YType::str, "asn-nn"}
{
yang_name = "soo"; yang_parent_name = "extcommunity"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Soo::~Soo()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Soo::has_data() const
{
if (is_presence_container) return true;
return asn_nn.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Soo::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(asn_nn.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Soo::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "soo";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Soo::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (asn_nn.is_set || is_set(asn_nn.yfilter)) leaf_name_data.push_back(asn_nn.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Soo::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Soo::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Soo::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "asn-nn")
{
asn_nn = value;
asn_nn.value_namespace = name_space;
asn_nn.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Soo::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "asn-nn")
{
asn_nn.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Soo::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "asn-nn")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::VpnDistinguisher()
:
asn_nn{YType::str, "asn-nn"}
,
range(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::Range>())
{
range->parent = this;
yang_name = "vpn-distinguisher"; yang_parent_name = "extcommunity"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::~VpnDistinguisher()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::has_data() const
{
if (is_presence_container) return true;
return asn_nn.is_set
|| (range != nullptr && range->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(asn_nn.yfilter)
|| (range != nullptr && range->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "vpn-distinguisher";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (asn_nn.is_set || is_set(asn_nn.yfilter)) leaf_name_data.push_back(asn_nn.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "range")
{
if(range == nullptr)
{
range = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::Range>();
}
return range;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(range != nullptr)
{
_children["range"] = range;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "asn-nn")
{
asn_nn = value;
asn_nn.value_namespace = name_space;
asn_nn.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "asn-nn")
{
asn_nn.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "range" || name == "asn-nn")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::Range::Range()
:
lower_limit{YType::str, "lower-limit"},
high_limit{YType::str, "high-limit"},
additive{YType::empty, "additive"}
{
yang_name = "range"; yang_parent_name = "vpn-distinguisher"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::Range::~Range()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::Range::has_data() const
{
if (is_presence_container) return true;
return lower_limit.is_set
|| high_limit.is_set
|| additive.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::Range::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lower_limit.yfilter)
|| ydk::is_set(high_limit.yfilter)
|| ydk::is_set(additive.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::Range::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "range";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::Range::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lower_limit.is_set || is_set(lower_limit.yfilter)) leaf_name_data.push_back(lower_limit.get_name_leafdata());
if (high_limit.is_set || is_set(high_limit.yfilter)) leaf_name_data.push_back(high_limit.get_name_leafdata());
if (additive.is_set || is_set(additive.yfilter)) leaf_name_data.push_back(additive.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::Range::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::Range::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::Range::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "lower-limit")
{
lower_limit = value;
lower_limit.value_namespace = name_space;
lower_limit.value_namespace_prefix = name_space_prefix;
}
if(value_path == "high-limit")
{
high_limit = value;
high_limit.value_namespace = name_space;
high_limit.value_namespace_prefix = name_space_prefix;
}
if(value_path == "additive")
{
additive = value;
additive.value_namespace = name_space;
additive.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::Range::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "lower-limit")
{
lower_limit.yfilter = yfilter;
}
if(value_path == "high-limit")
{
high_limit.yfilter = yfilter;
}
if(value_path == "additive")
{
additive.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::VpnDistinguisher::Range::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "lower-limit" || name == "high-limit" || name == "additive")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::Interface()
:
appnav_compress{YType::uint16, "AppNav-Compress"},
appnav_uncompress{YType::uint16, "AppNav-UnCompress"},
atm{YType::str, "ATM"},
atm_acr{YType::str, "ATM-ACR"},
bdi{YType::str, "BDI"},
cem{YType::str, "CEM"},
cem_acr{YType::uint8, "CEM-ACR"},
embedded_service_engine{YType::str, "Embedded-Service-Engine"},
ethernet{YType::str, "Ethernet"},
fastethernet{YType::str, "FastEthernet"},
gigabitethernet{YType::str, "GigabitEthernet"},
fivegigabitethernet{YType::str, "FiveGigabitEthernet"},
twentyfivegige{YType::str, "TwentyFiveGigE"},
twogigabitethernet{YType::str, "TwoGigabitEthernet"},
fortygigabitethernet{YType::str, "FortyGigabitEthernet"},
hundredgige{YType::str, "HundredGigE"},
lisp{YType::str, "LISP"},
loopback{YType::uint32, "Loopback"},
multilink{YType::uint16, "Multilink"},
nve{YType::uint16, "nve"},
overlay{YType::uint16, "overlay"},
port_channel{YType::uint32, "Port-channel"},
pseudowire{YType::uint32, "pseudowire"},
sm{YType::str, "SM"},
cellular{YType::str, "Cellular"},
serial{YType::str, "Serial"},
tengigabitethernet{YType::str, "TenGigabitEthernet"},
tunnel{YType::uint32, "Tunnel"},
virtual_template{YType::uint16, "Virtual-Template"},
vlan{YType::uint16, "Vlan"},
virtualportgroup{YType::uint16, "VirtualPortGroup"},
vasileft{YType::uint16, "vasileft"},
vasiright{YType::uint16, "vasiright"}
,
atm_subinterface(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMSubinterface>())
, atm_acrsubinterface(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMACRsubinterface>())
, lisp_subinterface(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::LISPSubinterface>())
, port_channel_subinterface(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::PortChannelSubinterface>())
{
atm_subinterface->parent = this;
atm_acrsubinterface->parent = this;
lisp_subinterface->parent = this;
port_channel_subinterface->parent = this;
yang_name = "interface"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::~Interface()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::has_data() const
{
if (is_presence_container) return true;
return appnav_compress.is_set
|| appnav_uncompress.is_set
|| atm.is_set
|| atm_acr.is_set
|| bdi.is_set
|| cem.is_set
|| cem_acr.is_set
|| embedded_service_engine.is_set
|| ethernet.is_set
|| fastethernet.is_set
|| gigabitethernet.is_set
|| fivegigabitethernet.is_set
|| twentyfivegige.is_set
|| twogigabitethernet.is_set
|| fortygigabitethernet.is_set
|| hundredgige.is_set
|| lisp.is_set
|| loopback.is_set
|| multilink.is_set
|| nve.is_set
|| overlay.is_set
|| port_channel.is_set
|| pseudowire.is_set
|| sm.is_set
|| cellular.is_set
|| serial.is_set
|| tengigabitethernet.is_set
|| tunnel.is_set
|| virtual_template.is_set
|| vlan.is_set
|| virtualportgroup.is_set
|| vasileft.is_set
|| vasiright.is_set
|| (atm_subinterface != nullptr && atm_subinterface->has_data())
|| (atm_acrsubinterface != nullptr && atm_acrsubinterface->has_data())
|| (lisp_subinterface != nullptr && lisp_subinterface->has_data())
|| (port_channel_subinterface != nullptr && port_channel_subinterface->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(appnav_compress.yfilter)
|| ydk::is_set(appnav_uncompress.yfilter)
|| ydk::is_set(atm.yfilter)
|| ydk::is_set(atm_acr.yfilter)
|| ydk::is_set(bdi.yfilter)
|| ydk::is_set(cem.yfilter)
|| ydk::is_set(cem_acr.yfilter)
|| ydk::is_set(embedded_service_engine.yfilter)
|| ydk::is_set(ethernet.yfilter)
|| ydk::is_set(fastethernet.yfilter)
|| ydk::is_set(gigabitethernet.yfilter)
|| ydk::is_set(fivegigabitethernet.yfilter)
|| ydk::is_set(twentyfivegige.yfilter)
|| ydk::is_set(twogigabitethernet.yfilter)
|| ydk::is_set(fortygigabitethernet.yfilter)
|| ydk::is_set(hundredgige.yfilter)
|| ydk::is_set(lisp.yfilter)
|| ydk::is_set(loopback.yfilter)
|| ydk::is_set(multilink.yfilter)
|| ydk::is_set(nve.yfilter)
|| ydk::is_set(overlay.yfilter)
|| ydk::is_set(port_channel.yfilter)
|| ydk::is_set(pseudowire.yfilter)
|| ydk::is_set(sm.yfilter)
|| ydk::is_set(cellular.yfilter)
|| ydk::is_set(serial.yfilter)
|| ydk::is_set(tengigabitethernet.yfilter)
|| ydk::is_set(tunnel.yfilter)
|| ydk::is_set(virtual_template.yfilter)
|| ydk::is_set(vlan.yfilter)
|| ydk::is_set(virtualportgroup.yfilter)
|| ydk::is_set(vasileft.yfilter)
|| ydk::is_set(vasiright.yfilter)
|| (atm_subinterface != nullptr && atm_subinterface->has_operation())
|| (atm_acrsubinterface != nullptr && atm_acrsubinterface->has_operation())
|| (lisp_subinterface != nullptr && lisp_subinterface->has_operation())
|| (port_channel_subinterface != nullptr && port_channel_subinterface->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "interface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (appnav_compress.is_set || is_set(appnav_compress.yfilter)) leaf_name_data.push_back(appnav_compress.get_name_leafdata());
if (appnav_uncompress.is_set || is_set(appnav_uncompress.yfilter)) leaf_name_data.push_back(appnav_uncompress.get_name_leafdata());
if (atm.is_set || is_set(atm.yfilter)) leaf_name_data.push_back(atm.get_name_leafdata());
if (atm_acr.is_set || is_set(atm_acr.yfilter)) leaf_name_data.push_back(atm_acr.get_name_leafdata());
if (bdi.is_set || is_set(bdi.yfilter)) leaf_name_data.push_back(bdi.get_name_leafdata());
if (cem.is_set || is_set(cem.yfilter)) leaf_name_data.push_back(cem.get_name_leafdata());
if (cem_acr.is_set || is_set(cem_acr.yfilter)) leaf_name_data.push_back(cem_acr.get_name_leafdata());
if (embedded_service_engine.is_set || is_set(embedded_service_engine.yfilter)) leaf_name_data.push_back(embedded_service_engine.get_name_leafdata());
if (ethernet.is_set || is_set(ethernet.yfilter)) leaf_name_data.push_back(ethernet.get_name_leafdata());
if (fastethernet.is_set || is_set(fastethernet.yfilter)) leaf_name_data.push_back(fastethernet.get_name_leafdata());
if (gigabitethernet.is_set || is_set(gigabitethernet.yfilter)) leaf_name_data.push_back(gigabitethernet.get_name_leafdata());
if (fivegigabitethernet.is_set || is_set(fivegigabitethernet.yfilter)) leaf_name_data.push_back(fivegigabitethernet.get_name_leafdata());
if (twentyfivegige.is_set || is_set(twentyfivegige.yfilter)) leaf_name_data.push_back(twentyfivegige.get_name_leafdata());
if (twogigabitethernet.is_set || is_set(twogigabitethernet.yfilter)) leaf_name_data.push_back(twogigabitethernet.get_name_leafdata());
if (fortygigabitethernet.is_set || is_set(fortygigabitethernet.yfilter)) leaf_name_data.push_back(fortygigabitethernet.get_name_leafdata());
if (hundredgige.is_set || is_set(hundredgige.yfilter)) leaf_name_data.push_back(hundredgige.get_name_leafdata());
if (lisp.is_set || is_set(lisp.yfilter)) leaf_name_data.push_back(lisp.get_name_leafdata());
if (loopback.is_set || is_set(loopback.yfilter)) leaf_name_data.push_back(loopback.get_name_leafdata());
if (multilink.is_set || is_set(multilink.yfilter)) leaf_name_data.push_back(multilink.get_name_leafdata());
if (nve.is_set || is_set(nve.yfilter)) leaf_name_data.push_back(nve.get_name_leafdata());
if (overlay.is_set || is_set(overlay.yfilter)) leaf_name_data.push_back(overlay.get_name_leafdata());
if (port_channel.is_set || is_set(port_channel.yfilter)) leaf_name_data.push_back(port_channel.get_name_leafdata());
if (pseudowire.is_set || is_set(pseudowire.yfilter)) leaf_name_data.push_back(pseudowire.get_name_leafdata());
if (sm.is_set || is_set(sm.yfilter)) leaf_name_data.push_back(sm.get_name_leafdata());
if (cellular.is_set || is_set(cellular.yfilter)) leaf_name_data.push_back(cellular.get_name_leafdata());
if (serial.is_set || is_set(serial.yfilter)) leaf_name_data.push_back(serial.get_name_leafdata());
if (tengigabitethernet.is_set || is_set(tengigabitethernet.yfilter)) leaf_name_data.push_back(tengigabitethernet.get_name_leafdata());
if (tunnel.is_set || is_set(tunnel.yfilter)) leaf_name_data.push_back(tunnel.get_name_leafdata());
if (virtual_template.is_set || is_set(virtual_template.yfilter)) leaf_name_data.push_back(virtual_template.get_name_leafdata());
if (vlan.is_set || is_set(vlan.yfilter)) leaf_name_data.push_back(vlan.get_name_leafdata());
if (virtualportgroup.is_set || is_set(virtualportgroup.yfilter)) leaf_name_data.push_back(virtualportgroup.get_name_leafdata());
if (vasileft.is_set || is_set(vasileft.yfilter)) leaf_name_data.push_back(vasileft.get_name_leafdata());
if (vasiright.is_set || is_set(vasiright.yfilter)) leaf_name_data.push_back(vasiright.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ATM-subinterface")
{
if(atm_subinterface == nullptr)
{
atm_subinterface = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMSubinterface>();
}
return atm_subinterface;
}
if(child_yang_name == "ATM-ACRsubinterface")
{
if(atm_acrsubinterface == nullptr)
{
atm_acrsubinterface = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMACRsubinterface>();
}
return atm_acrsubinterface;
}
if(child_yang_name == "LISP-subinterface")
{
if(lisp_subinterface == nullptr)
{
lisp_subinterface = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::LISPSubinterface>();
}
return lisp_subinterface;
}
if(child_yang_name == "Port-channel-subinterface")
{
if(port_channel_subinterface == nullptr)
{
port_channel_subinterface = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::PortChannelSubinterface>();
}
return port_channel_subinterface;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(atm_subinterface != nullptr)
{
_children["ATM-subinterface"] = atm_subinterface;
}
if(atm_acrsubinterface != nullptr)
{
_children["ATM-ACRsubinterface"] = atm_acrsubinterface;
}
if(lisp_subinterface != nullptr)
{
_children["LISP-subinterface"] = lisp_subinterface;
}
if(port_channel_subinterface != nullptr)
{
_children["Port-channel-subinterface"] = port_channel_subinterface;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "AppNav-Compress")
{
appnav_compress = value;
appnav_compress.value_namespace = name_space;
appnav_compress.value_namespace_prefix = name_space_prefix;
}
if(value_path == "AppNav-UnCompress")
{
appnav_uncompress = value;
appnav_uncompress.value_namespace = name_space;
appnav_uncompress.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ATM")
{
atm = value;
atm.value_namespace = name_space;
atm.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ATM-ACR")
{
atm_acr = value;
atm_acr.value_namespace = name_space;
atm_acr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "BDI")
{
bdi = value;
bdi.value_namespace = name_space;
bdi.value_namespace_prefix = name_space_prefix;
}
if(value_path == "CEM")
{
cem = value;
cem.value_namespace = name_space;
cem.value_namespace_prefix = name_space_prefix;
}
if(value_path == "CEM-ACR")
{
cem_acr = value;
cem_acr.value_namespace = name_space;
cem_acr.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Embedded-Service-Engine")
{
embedded_service_engine = value;
embedded_service_engine.value_namespace = name_space;
embedded_service_engine.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Ethernet")
{
ethernet = value;
ethernet.value_namespace = name_space;
ethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FastEthernet")
{
fastethernet = value;
fastethernet.value_namespace = name_space;
fastethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "GigabitEthernet")
{
gigabitethernet = value;
gigabitethernet.value_namespace = name_space;
gigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FiveGigabitEthernet")
{
fivegigabitethernet = value;
fivegigabitethernet.value_namespace = name_space;
fivegigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TwentyFiveGigE")
{
twentyfivegige = value;
twentyfivegige.value_namespace = name_space;
twentyfivegige.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TwoGigabitEthernet")
{
twogigabitethernet = value;
twogigabitethernet.value_namespace = name_space;
twogigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "FortyGigabitEthernet")
{
fortygigabitethernet = value;
fortygigabitethernet.value_namespace = name_space;
fortygigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "HundredGigE")
{
hundredgige = value;
hundredgige.value_namespace = name_space;
hundredgige.value_namespace_prefix = name_space_prefix;
}
if(value_path == "LISP")
{
lisp = value;
lisp.value_namespace = name_space;
lisp.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Loopback")
{
loopback = value;
loopback.value_namespace = name_space;
loopback.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Multilink")
{
multilink = value;
multilink.value_namespace = name_space;
multilink.value_namespace_prefix = name_space_prefix;
}
if(value_path == "nve")
{
nve = value;
nve.value_namespace = name_space;
nve.value_namespace_prefix = name_space_prefix;
}
if(value_path == "overlay")
{
overlay = value;
overlay.value_namespace = name_space;
overlay.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Port-channel")
{
port_channel = value;
port_channel.value_namespace = name_space;
port_channel.value_namespace_prefix = name_space_prefix;
}
if(value_path == "pseudowire")
{
pseudowire = value;
pseudowire.value_namespace = name_space;
pseudowire.value_namespace_prefix = name_space_prefix;
}
if(value_path == "SM")
{
sm = value;
sm.value_namespace = name_space;
sm.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Cellular")
{
cellular = value;
cellular.value_namespace = name_space;
cellular.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Serial")
{
serial = value;
serial.value_namespace = name_space;
serial.value_namespace_prefix = name_space_prefix;
}
if(value_path == "TenGigabitEthernet")
{
tengigabitethernet = value;
tengigabitethernet.value_namespace = name_space;
tengigabitethernet.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Tunnel")
{
tunnel = value;
tunnel.value_namespace = name_space;
tunnel.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Virtual-Template")
{
virtual_template = value;
virtual_template.value_namespace = name_space;
virtual_template.value_namespace_prefix = name_space_prefix;
}
if(value_path == "Vlan")
{
vlan = value;
vlan.value_namespace = name_space;
vlan.value_namespace_prefix = name_space_prefix;
}
if(value_path == "VirtualPortGroup")
{
virtualportgroup = value;
virtualportgroup.value_namespace = name_space;
virtualportgroup.value_namespace_prefix = name_space_prefix;
}
if(value_path == "vasileft")
{
vasileft = value;
vasileft.value_namespace = name_space;
vasileft.value_namespace_prefix = name_space_prefix;
}
if(value_path == "vasiright")
{
vasiright = value;
vasiright.value_namespace = name_space;
vasiright.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "AppNav-Compress")
{
appnav_compress.yfilter = yfilter;
}
if(value_path == "AppNav-UnCompress")
{
appnav_uncompress.yfilter = yfilter;
}
if(value_path == "ATM")
{
atm.yfilter = yfilter;
}
if(value_path == "ATM-ACR")
{
atm_acr.yfilter = yfilter;
}
if(value_path == "BDI")
{
bdi.yfilter = yfilter;
}
if(value_path == "CEM")
{
cem.yfilter = yfilter;
}
if(value_path == "CEM-ACR")
{
cem_acr.yfilter = yfilter;
}
if(value_path == "Embedded-Service-Engine")
{
embedded_service_engine.yfilter = yfilter;
}
if(value_path == "Ethernet")
{
ethernet.yfilter = yfilter;
}
if(value_path == "FastEthernet")
{
fastethernet.yfilter = yfilter;
}
if(value_path == "GigabitEthernet")
{
gigabitethernet.yfilter = yfilter;
}
if(value_path == "FiveGigabitEthernet")
{
fivegigabitethernet.yfilter = yfilter;
}
if(value_path == "TwentyFiveGigE")
{
twentyfivegige.yfilter = yfilter;
}
if(value_path == "TwoGigabitEthernet")
{
twogigabitethernet.yfilter = yfilter;
}
if(value_path == "FortyGigabitEthernet")
{
fortygigabitethernet.yfilter = yfilter;
}
if(value_path == "HundredGigE")
{
hundredgige.yfilter = yfilter;
}
if(value_path == "LISP")
{
lisp.yfilter = yfilter;
}
if(value_path == "Loopback")
{
loopback.yfilter = yfilter;
}
if(value_path == "Multilink")
{
multilink.yfilter = yfilter;
}
if(value_path == "nve")
{
nve.yfilter = yfilter;
}
if(value_path == "overlay")
{
overlay.yfilter = yfilter;
}
if(value_path == "Port-channel")
{
port_channel.yfilter = yfilter;
}
if(value_path == "pseudowire")
{
pseudowire.yfilter = yfilter;
}
if(value_path == "SM")
{
sm.yfilter = yfilter;
}
if(value_path == "Cellular")
{
cellular.yfilter = yfilter;
}
if(value_path == "Serial")
{
serial.yfilter = yfilter;
}
if(value_path == "TenGigabitEthernet")
{
tengigabitethernet.yfilter = yfilter;
}
if(value_path == "Tunnel")
{
tunnel.yfilter = yfilter;
}
if(value_path == "Virtual-Template")
{
virtual_template.yfilter = yfilter;
}
if(value_path == "Vlan")
{
vlan.yfilter = yfilter;
}
if(value_path == "VirtualPortGroup")
{
virtualportgroup.yfilter = yfilter;
}
if(value_path == "vasileft")
{
vasileft.yfilter = yfilter;
}
if(value_path == "vasiright")
{
vasiright.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM-subinterface" || name == "ATM-ACRsubinterface" || name == "LISP-subinterface" || name == "Port-channel-subinterface" || name == "AppNav-Compress" || name == "AppNav-UnCompress" || name == "ATM" || name == "ATM-ACR" || name == "BDI" || name == "CEM" || name == "CEM-ACR" || name == "Embedded-Service-Engine" || name == "Ethernet" || name == "FastEthernet" || name == "GigabitEthernet" || name == "FiveGigabitEthernet" || name == "TwentyFiveGigE" || name == "TwoGigabitEthernet" || name == "FortyGigabitEthernet" || name == "HundredGigE" || name == "LISP" || name == "Loopback" || name == "Multilink" || name == "nve" || name == "overlay" || name == "Port-channel" || name == "pseudowire" || name == "SM" || name == "Cellular" || name == "Serial" || name == "TenGigabitEthernet" || name == "Tunnel" || name == "Virtual-Template" || name == "Vlan" || name == "VirtualPortGroup" || name == "vasileft" || name == "vasiright")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMSubinterface::ATMSubinterface()
:
atm{YType::str, "ATM"}
{
yang_name = "ATM-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMSubinterface::~ATMSubinterface()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMSubinterface::has_data() const
{
if (is_presence_container) return true;
return atm.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(atm.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ATM-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (atm.is_set || is_set(atm.yfilter)) leaf_name_data.push_back(atm.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ATM")
{
atm = value;
atm.value_namespace = name_space;
atm.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ATM")
{
atm.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMACRsubinterface::ATMACRsubinterface()
:
atm_acr{YType::str, "ATM-ACR"}
{
yang_name = "ATM-ACRsubinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMACRsubinterface::~ATMACRsubinterface()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMACRsubinterface::has_data() const
{
if (is_presence_container) return true;
return atm_acr.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMACRsubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(atm_acr.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMACRsubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ATM-ACRsubinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMACRsubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (atm_acr.is_set || is_set(atm_acr.yfilter)) leaf_name_data.push_back(atm_acr.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMACRsubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMACRsubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMACRsubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ATM-ACR")
{
atm_acr = value;
atm_acr.value_namespace = name_space;
atm_acr.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMACRsubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ATM-ACR")
{
atm_acr.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::ATMACRsubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ATM-ACR")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::LISPSubinterface::LISPSubinterface()
:
lisp{YType::str, "LISP"}
{
yang_name = "LISP-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::LISPSubinterface::~LISPSubinterface()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::LISPSubinterface::has_data() const
{
if (is_presence_container) return true;
return lisp.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::LISPSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(lisp.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::LISPSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "LISP-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::LISPSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (lisp.is_set || is_set(lisp.yfilter)) leaf_name_data.push_back(lisp.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::LISPSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::LISPSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::LISPSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "LISP")
{
lisp = value;
lisp.value_namespace = name_space;
lisp.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::LISPSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "LISP")
{
lisp.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::LISPSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "LISP")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::PortChannelSubinterface::PortChannelSubinterface()
:
port_channel{YType::str, "Port-channel"}
{
yang_name = "Port-channel-subinterface"; yang_parent_name = "interface"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::PortChannelSubinterface::~PortChannelSubinterface()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::PortChannelSubinterface::has_data() const
{
if (is_presence_container) return true;
return port_channel.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::PortChannelSubinterface::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(port_channel.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::PortChannelSubinterface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "Port-channel-subinterface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::PortChannelSubinterface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (port_channel.is_set || is_set(port_channel.yfilter)) leaf_name_data.push_back(port_channel.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::PortChannelSubinterface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::PortChannelSubinterface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::PortChannelSubinterface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "Port-channel")
{
port_channel = value;
port_channel.value_namespace = name_space;
port_channel.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::PortChannelSubinterface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "Port-channel")
{
port_channel.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Interface::PortChannelSubinterface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "Port-channel")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Ip()
:
df{YType::uint8, "df"}
,
address(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Address>())
, default_(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default>())
, global(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global>())
, next_hop(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop>())
, precedence(nullptr) // presence node
, qos_group(nullptr) // presence node
, tos(nullptr) // presence node
, vrf(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf>())
{
address->parent = this;
default_->parent = this;
global->parent = this;
next_hop->parent = this;
vrf->parent = this;
yang_name = "ip"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::~Ip()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::has_data() const
{
if (is_presence_container) return true;
return df.is_set
|| (address != nullptr && address->has_data())
|| (default_ != nullptr && default_->has_data())
|| (global != nullptr && global->has_data())
|| (next_hop != nullptr && next_hop->has_data())
|| (precedence != nullptr && precedence->has_data())
|| (qos_group != nullptr && qos_group->has_data())
|| (tos != nullptr && tos->has_data())
|| (vrf != nullptr && vrf->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(df.yfilter)
|| (address != nullptr && address->has_operation())
|| (default_ != nullptr && default_->has_operation())
|| (global != nullptr && global->has_operation())
|| (next_hop != nullptr && next_hop->has_operation())
|| (precedence != nullptr && precedence->has_operation())
|| (qos_group != nullptr && qos_group->has_operation())
|| (tos != nullptr && tos->has_operation())
|| (vrf != nullptr && vrf->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ip";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (df.is_set || is_set(df.yfilter)) leaf_name_data.push_back(df.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "address")
{
if(address == nullptr)
{
address = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Address>();
}
return address;
}
if(child_yang_name == "default")
{
if(default_ == nullptr)
{
default_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default>();
}
return default_;
}
if(child_yang_name == "global")
{
if(global == nullptr)
{
global = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global>();
}
return global;
}
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop>();
}
return next_hop;
}
if(child_yang_name == "precedence")
{
if(precedence == nullptr)
{
precedence = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence>();
}
return precedence;
}
if(child_yang_name == "qos-group")
{
if(qos_group == nullptr)
{
qos_group = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::QosGroup>();
}
return qos_group;
}
if(child_yang_name == "tos")
{
if(tos == nullptr)
{
tos = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos>();
}
return tos;
}
if(child_yang_name == "vrf")
{
if(vrf == nullptr)
{
vrf = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf>();
}
return vrf;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(address != nullptr)
{
_children["address"] = address;
}
if(default_ != nullptr)
{
_children["default"] = default_;
}
if(global != nullptr)
{
_children["global"] = global;
}
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
if(precedence != nullptr)
{
_children["precedence"] = precedence;
}
if(qos_group != nullptr)
{
_children["qos-group"] = qos_group;
}
if(tos != nullptr)
{
_children["tos"] = tos;
}
if(vrf != nullptr)
{
_children["vrf"] = vrf;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "df")
{
df = value;
df.value_namespace = name_space;
df.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "df")
{
df.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "default" || name == "global" || name == "next-hop" || name == "precedence" || name == "qos-group" || name == "tos" || name == "vrf" || name == "df")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Address::Address()
:
prefix_list{YType::str, "prefix-list"}
{
yang_name = "address"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Address::~Address()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Address::has_data() const
{
if (is_presence_container) return true;
return prefix_list.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Address::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Address::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "address";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Address::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (prefix_list.is_set || is_set(prefix_list.yfilter)) leaf_name_data.push_back(prefix_list.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Address::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Address::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Address::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "prefix-list")
{
prefix_list = value;
prefix_list.value_namespace = name_space;
prefix_list.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Address::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Address::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Default()
:
global(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global>())
, next_hop(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::NextHop>())
, vrf(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf>())
{
global->parent = this;
next_hop->parent = this;
vrf->parent = this;
yang_name = "default"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::~Default()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::has_data() const
{
if (is_presence_container) return true;
return (global != nullptr && global->has_data())
|| (next_hop != nullptr && next_hop->has_data())
|| (vrf != nullptr && vrf->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::has_operation() const
{
return is_set(yfilter)
|| (global != nullptr && global->has_operation())
|| (next_hop != nullptr && next_hop->has_operation())
|| (vrf != nullptr && vrf->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "default";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "global")
{
if(global == nullptr)
{
global = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global>();
}
return global;
}
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::NextHop>();
}
return next_hop;
}
if(child_yang_name == "vrf")
{
if(vrf == nullptr)
{
vrf = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf>();
}
return vrf;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(global != nullptr)
{
_children["global"] = global;
}
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
if(vrf != nullptr)
{
_children["vrf"] = vrf;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "global" || name == "next-hop" || name == "vrf")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::Global()
:
next_hop(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::NextHop>())
{
next_hop->parent = this;
yang_name = "global"; yang_parent_name = "default"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::~Global()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::has_data() const
{
if (is_presence_container) return true;
return (next_hop != nullptr && next_hop->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::has_operation() const
{
return is_set(yfilter)
|| (next_hop != nullptr && next_hop->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "global";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::NextHop>();
}
return next_hop;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "next-hop")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::NextHop::NextHop()
:
address{YType::str, "address"}
{
yang_name = "next-hop"; yang_parent_name = "global"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::NextHop::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : address.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::NextHop::has_operation() const
{
for (auto const & leaf : address.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(address.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto address_name_datas = address.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), address_name_datas.begin(), address_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Global::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::NextHop::NextHop()
:
address{YType::str, "address"}
{
yang_name = "next-hop"; yang_parent_name = "default"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::NextHop::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : address.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::NextHop::has_operation() const
{
for (auto const & leaf : address.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(address.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto address_name_datas = address.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), address_name_datas.begin(), address_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrf()
:
vrfs(this, {"vrf"})
{
yang_name = "vrf"; yang_parent_name = "default"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::~Vrf()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<vrfs.len(); index++)
{
if(vrfs[index]->has_data())
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::has_operation() const
{
for (std::size_t index=0; index<vrfs.len(); index++)
{
if(vrfs[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "vrf";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "vrfs")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs>();
ent_->parent = this;
vrfs.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : vrfs.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "vrfs")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::Vrfs()
:
vrf{YType::str, "vrf"}
,
next_hop(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::NextHop>())
{
next_hop->parent = this;
yang_name = "vrfs"; yang_parent_name = "vrf"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::~Vrfs()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::has_data() const
{
if (is_presence_container) return true;
return vrf.is_set
|| (next_hop != nullptr && next_hop->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(vrf.yfilter)
|| (next_hop != nullptr && next_hop->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "vrfs";
ADD_KEY_TOKEN(vrf, "vrf");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (vrf.is_set || is_set(vrf.yfilter)) leaf_name_data.push_back(vrf.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::NextHop>();
}
return next_hop;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "vrf")
{
vrf = value;
vrf.value_namespace = name_space;
vrf.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "vrf")
{
vrf.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "next-hop" || name == "vrf")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::NextHop::NextHop()
:
address{YType::str, "address"}
{
yang_name = "next-hop"; yang_parent_name = "vrfs"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::NextHop::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : address.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::NextHop::has_operation() const
{
for (auto const & leaf : address.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(address.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto address_name_datas = address.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), address_name_datas.begin(), address_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Default::Vrf::Vrfs::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::Global()
:
next_hop(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::NextHop>())
{
next_hop->parent = this;
yang_name = "global"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::~Global()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::has_data() const
{
if (is_presence_container) return true;
return (next_hop != nullptr && next_hop->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::has_operation() const
{
return is_set(yfilter)
|| (next_hop != nullptr && next_hop->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "global";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::NextHop>();
}
return next_hop;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "next-hop")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::NextHop::NextHop()
:
address{YType::str, "address"}
{
yang_name = "next-hop"; yang_parent_name = "global"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::NextHop::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : address.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::NextHop::has_operation() const
{
for (auto const & leaf : address.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(address.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto address_name_datas = address.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), address_name_datas.begin(), address_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Global::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::NextHop()
:
address{YType::str, "address"},
peer_address{YType::empty, "peer-address"},
self{YType::empty, "self"}
,
dynamic(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Dynamic>())
, encapsulate(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Encapsulate>())
, recursive(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive>())
, verify_availability(nullptr) // presence node
{
dynamic->parent = this;
encapsulate->parent = this;
recursive->parent = this;
yang_name = "next-hop"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : address.getYLeafs())
{
if(leaf.is_set)
return true;
}
return peer_address.is_set
|| self.is_set
|| (dynamic != nullptr && dynamic->has_data())
|| (encapsulate != nullptr && encapsulate->has_data())
|| (recursive != nullptr && recursive->has_data())
|| (verify_availability != nullptr && verify_availability->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::has_operation() const
{
for (auto const & leaf : address.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(address.yfilter)
|| ydk::is_set(peer_address.yfilter)
|| ydk::is_set(self.yfilter)
|| (dynamic != nullptr && dynamic->has_operation())
|| (encapsulate != nullptr && encapsulate->has_operation())
|| (recursive != nullptr && recursive->has_operation())
|| (verify_availability != nullptr && verify_availability->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (peer_address.is_set || is_set(peer_address.yfilter)) leaf_name_data.push_back(peer_address.get_name_leafdata());
if (self.is_set || is_set(self.yfilter)) leaf_name_data.push_back(self.get_name_leafdata());
auto address_name_datas = address.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), address_name_datas.begin(), address_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "dynamic")
{
if(dynamic == nullptr)
{
dynamic = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Dynamic>();
}
return dynamic;
}
if(child_yang_name == "encapsulate")
{
if(encapsulate == nullptr)
{
encapsulate = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Encapsulate>();
}
return encapsulate;
}
if(child_yang_name == "recursive")
{
if(recursive == nullptr)
{
recursive = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive>();
}
return recursive;
}
if(child_yang_name == "verify-availability")
{
if(verify_availability == nullptr)
{
verify_availability = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability>();
}
return verify_availability;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(dynamic != nullptr)
{
_children["dynamic"] = dynamic;
}
if(encapsulate != nullptr)
{
_children["encapsulate"] = encapsulate;
}
if(recursive != nullptr)
{
_children["recursive"] = recursive;
}
if(verify_availability != nullptr)
{
_children["verify-availability"] = verify_availability;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address.append(value);
}
if(value_path == "peer-address")
{
peer_address = value;
peer_address.value_namespace = name_space;
peer_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "self")
{
self = value;
self.value_namespace = name_space;
self.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
if(value_path == "peer-address")
{
peer_address.yfilter = yfilter;
}
if(value_path == "self")
{
self.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dynamic" || name == "encapsulate" || name == "recursive" || name == "verify-availability" || name == "address" || name == "peer-address" || name == "self")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Dynamic::Dynamic()
:
dhcp{YType::empty, "dhcp"}
{
yang_name = "dynamic"; yang_parent_name = "next-hop"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Dynamic::~Dynamic()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Dynamic::has_data() const
{
if (is_presence_container) return true;
return dhcp.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Dynamic::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(dhcp.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Dynamic::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "dynamic";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Dynamic::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (dhcp.is_set || is_set(dhcp.yfilter)) leaf_name_data.push_back(dhcp.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Dynamic::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Dynamic::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Dynamic::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "dhcp")
{
dhcp = value;
dhcp.value_namespace = name_space;
dhcp.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Dynamic::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "dhcp")
{
dhcp.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Dynamic::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dhcp")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Encapsulate::Encapsulate()
:
l3vpn{YType::str, "l3vpn"}
{
yang_name = "encapsulate"; yang_parent_name = "next-hop"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Encapsulate::~Encapsulate()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Encapsulate::has_data() const
{
if (is_presence_container) return true;
return l3vpn.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Encapsulate::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(l3vpn.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Encapsulate::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "encapsulate";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Encapsulate::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (l3vpn.is_set || is_set(l3vpn.yfilter)) leaf_name_data.push_back(l3vpn.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Encapsulate::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Encapsulate::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Encapsulate::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "l3vpn")
{
l3vpn = value;
l3vpn.value_namespace = name_space;
l3vpn.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Encapsulate::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "l3vpn")
{
l3vpn.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Encapsulate::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "l3vpn")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Recursive()
:
ipv4{YType::str, "ipv4"},
global{YType::str, "global"}
,
vrf(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf>())
{
vrf->parent = this;
yang_name = "recursive"; yang_parent_name = "next-hop"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::~Recursive()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::has_data() const
{
if (is_presence_container) return true;
return ipv4.is_set
|| global.is_set
|| (vrf != nullptr && vrf->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ipv4.yfilter)
|| ydk::is_set(global.yfilter)
|| (vrf != nullptr && vrf->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "recursive";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ipv4.is_set || is_set(ipv4.yfilter)) leaf_name_data.push_back(ipv4.get_name_leafdata());
if (global.is_set || is_set(global.yfilter)) leaf_name_data.push_back(global.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "vrf")
{
if(vrf == nullptr)
{
vrf = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf>();
}
return vrf;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(vrf != nullptr)
{
_children["vrf"] = vrf;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ipv4")
{
ipv4 = value;
ipv4.value_namespace = name_space;
ipv4.value_namespace_prefix = name_space_prefix;
}
if(value_path == "global")
{
global = value;
global.value_namespace = name_space;
global.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ipv4")
{
ipv4.yfilter = yfilter;
}
if(value_path == "global")
{
global.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "vrf" || name == "ipv4" || name == "global")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::Vrf()
:
vrfs(this, {"vrf"})
{
yang_name = "vrf"; yang_parent_name = "recursive"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::~Vrf()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<vrfs.len(); index++)
{
if(vrfs[index]->has_data())
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::has_operation() const
{
for (std::size_t index=0; index<vrfs.len(); index++)
{
if(vrfs[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "vrf";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "vrfs")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::Vrfs>();
ent_->parent = this;
vrfs.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : vrfs.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "vrfs")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::Vrfs::Vrfs()
:
vrf{YType::str, "vrf"},
ipv4{YType::str, "ipv4"}
{
yang_name = "vrfs"; yang_parent_name = "vrf"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::Vrfs::~Vrfs()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::Vrfs::has_data() const
{
if (is_presence_container) return true;
return vrf.is_set
|| ipv4.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::Vrfs::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(vrf.yfilter)
|| ydk::is_set(ipv4.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::Vrfs::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "vrfs";
ADD_KEY_TOKEN(vrf, "vrf");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::Vrfs::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (vrf.is_set || is_set(vrf.yfilter)) leaf_name_data.push_back(vrf.get_name_leafdata());
if (ipv4.is_set || is_set(ipv4.yfilter)) leaf_name_data.push_back(ipv4.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::Vrfs::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::Vrfs::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::Vrfs::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "vrf")
{
vrf = value;
vrf.value_namespace = name_space;
vrf.value_namespace_prefix = name_space_prefix;
}
if(value_path == "ipv4")
{
ipv4 = value;
ipv4.value_namespace = name_space;
ipv4.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::Vrfs::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "vrf")
{
vrf.yfilter = yfilter;
}
if(value_path == "ipv4")
{
ipv4.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::Recursive::Vrf::Vrfs::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "vrf" || name == "ipv4")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::VerifyAvailability()
:
ipv4(this, {"ipv4"})
{
yang_name = "verify-availability"; yang_parent_name = "next-hop"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::~VerifyAvailability()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<ipv4.len(); index++)
{
if(ipv4[index]->has_data())
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::has_operation() const
{
for (std::size_t index=0; index<ipv4.len(); index++)
{
if(ipv4[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "verify-availability";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ipv4")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::Ipv4>();
ent_->parent = this;
ipv4.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : ipv4.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::Ipv4::Ipv4()
:
ipv4{YType::str, "ipv4"},
range{YType::uint16, "range"},
track{YType::uint16, "track"}
{
yang_name = "ipv4"; yang_parent_name = "verify-availability"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::Ipv4::~Ipv4()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::Ipv4::has_data() const
{
if (is_presence_container) return true;
return ipv4.is_set
|| range.is_set
|| track.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::Ipv4::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ipv4.yfilter)
|| ydk::is_set(range.yfilter)
|| ydk::is_set(track.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::Ipv4::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv4";
ADD_KEY_TOKEN(ipv4, "ipv4");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::Ipv4::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ipv4.is_set || is_set(ipv4.yfilter)) leaf_name_data.push_back(ipv4.get_name_leafdata());
if (range.is_set || is_set(range.yfilter)) leaf_name_data.push_back(range.get_name_leafdata());
if (track.is_set || is_set(track.yfilter)) leaf_name_data.push_back(track.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::Ipv4::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::Ipv4::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::Ipv4::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ipv4")
{
ipv4 = value;
ipv4.value_namespace = name_space;
ipv4.value_namespace_prefix = name_space_prefix;
}
if(value_path == "range")
{
range = value;
range.value_namespace = name_space;
range.value_namespace_prefix = name_space_prefix;
}
if(value_path == "track")
{
track = value;
track.value_namespace = name_space;
track.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::Ipv4::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ipv4")
{
ipv4.yfilter = yfilter;
}
if(value_path == "range")
{
range.yfilter = yfilter;
}
if(value_path == "track")
{
track.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::NextHop::VerifyAvailability::Ipv4::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv4" || name == "range" || name == "track")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::Precedence()
:
precedence_value{YType::uint8, "precedence-value"},
precedence_fields{YType::enumeration, "precedence-fields"}
{
yang_name = "precedence"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::~Precedence()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::has_data() const
{
if (is_presence_container) return true;
return precedence_value.is_set
|| precedence_fields.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(precedence_value.yfilter)
|| ydk::is_set(precedence_fields.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "precedence";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (precedence_value.is_set || is_set(precedence_value.yfilter)) leaf_name_data.push_back(precedence_value.get_name_leafdata());
if (precedence_fields.is_set || is_set(precedence_fields.yfilter)) leaf_name_data.push_back(precedence_fields.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "precedence-value")
{
precedence_value = value;
precedence_value.value_namespace = name_space;
precedence_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "precedence-fields")
{
precedence_fields = value;
precedence_fields.value_namespace = name_space;
precedence_fields.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "precedence-value")
{
precedence_value.yfilter = yfilter;
}
if(value_path == "precedence-fields")
{
precedence_fields.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "precedence-value" || name == "precedence-fields")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::QosGroup::QosGroup()
:
qos_id{YType::uint8, "qos-id"}
{
yang_name = "qos-group"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::QosGroup::~QosGroup()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::QosGroup::has_data() const
{
if (is_presence_container) return true;
return qos_id.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::QosGroup::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(qos_id.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::QosGroup::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "qos-group";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::QosGroup::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (qos_id.is_set || is_set(qos_id.yfilter)) leaf_name_data.push_back(qos_id.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::QosGroup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::QosGroup::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::QosGroup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "qos-id")
{
qos_id = value;
qos_id.value_namespace = name_space;
qos_id.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::QosGroup::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "qos-id")
{
qos_id.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::QosGroup::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "qos-id")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::Tos()
:
service_value{YType::uint8, "service-value"},
tos_fields{YType::enumeration, "tos-fields"}
{
yang_name = "tos"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::~Tos()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::has_data() const
{
if (is_presence_container) return true;
return service_value.is_set
|| tos_fields.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(service_value.yfilter)
|| ydk::is_set(tos_fields.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tos";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (service_value.is_set || is_set(service_value.yfilter)) leaf_name_data.push_back(service_value.get_name_leafdata());
if (tos_fields.is_set || is_set(tos_fields.yfilter)) leaf_name_data.push_back(tos_fields.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "service-value")
{
service_value = value;
service_value.value_namespace = name_space;
service_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "tos-fields")
{
tos_fields = value;
tos_fields.value_namespace = name_space;
tos_fields.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "service-value")
{
service_value.yfilter = yfilter;
}
if(value_path == "tos-fields")
{
tos_fields.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "service-value" || name == "tos-fields")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrf()
:
vrfs(this, {"vrf"})
{
yang_name = "vrf"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::~Vrf()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<vrfs.len(); index++)
{
if(vrfs[index]->has_data())
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::has_operation() const
{
for (std::size_t index=0; index<vrfs.len(); index++)
{
if(vrfs[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "vrf";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "vrfs")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs>();
ent_->parent = this;
vrfs.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : vrfs.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "vrfs")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::Vrfs()
:
vrf{YType::str, "vrf"}
,
next_hop(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::NextHop>())
{
next_hop->parent = this;
yang_name = "vrfs"; yang_parent_name = "vrf"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::~Vrfs()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::has_data() const
{
if (is_presence_container) return true;
return vrf.is_set
|| (next_hop != nullptr && next_hop->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(vrf.yfilter)
|| (next_hop != nullptr && next_hop->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "vrfs";
ADD_KEY_TOKEN(vrf, "vrf");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (vrf.is_set || is_set(vrf.yfilter)) leaf_name_data.push_back(vrf.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::NextHop>();
}
return next_hop;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "vrf")
{
vrf = value;
vrf.value_namespace = name_space;
vrf.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "vrf")
{
vrf.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "next-hop" || name == "vrf")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::NextHop::NextHop()
:
address{YType::str, "address"}
{
yang_name = "next-hop"; yang_parent_name = "vrfs"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::NextHop::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : address.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::NextHop::has_operation() const
{
for (auto const & leaf : address.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(address.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto address_name_datas = address.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), address_name_datas.begin(), address_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "address")
{
address.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "address")
{
address.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Vrf::Vrfs::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Ipv6()
:
precedence{YType::uint8, "precedence"}
,
address(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Address>())
, default_(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default>())
, global(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global>())
, next_hop(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop>())
, bvrf(this, {"bvrf"})
{
address->parent = this;
default_->parent = this;
global->parent = this;
next_hop->parent = this;
yang_name = "ipv6"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::~Ipv6()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<bvrf.len(); index++)
{
if(bvrf[index]->has_data())
return true;
}
return precedence.is_set
|| (address != nullptr && address->has_data())
|| (default_ != nullptr && default_->has_data())
|| (global != nullptr && global->has_data())
|| (next_hop != nullptr && next_hop->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::has_operation() const
{
for (std::size_t index=0; index<bvrf.len(); index++)
{
if(bvrf[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(precedence.yfilter)
|| (address != nullptr && address->has_operation())
|| (default_ != nullptr && default_->has_operation())
|| (global != nullptr && global->has_operation())
|| (next_hop != nullptr && next_hop->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv6";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (precedence.is_set || is_set(precedence.yfilter)) leaf_name_data.push_back(precedence.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "address")
{
if(address == nullptr)
{
address = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Address>();
}
return address;
}
if(child_yang_name == "default")
{
if(default_ == nullptr)
{
default_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default>();
}
return default_;
}
if(child_yang_name == "global")
{
if(global == nullptr)
{
global = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global>();
}
return global;
}
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop>();
}
return next_hop;
}
if(child_yang_name == "bvrf")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf>();
ent_->parent = this;
bvrf.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(address != nullptr)
{
_children["address"] = address;
}
if(default_ != nullptr)
{
_children["default"] = default_;
}
if(global != nullptr)
{
_children["global"] = global;
}
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
count_ = 0;
for (auto ent_ : bvrf.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "precedence")
{
precedence = value;
precedence.value_namespace = name_space;
precedence.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "precedence")
{
precedence.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "default" || name == "global" || name == "next-hop" || name == "bvrf" || name == "precedence")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Address::Address()
:
prefix_list{YType::str, "prefix-list"}
{
yang_name = "address"; yang_parent_name = "ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Address::~Address()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Address::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : prefix_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Address::has_operation() const
{
for (auto const & leaf : prefix_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Address::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "address";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Address::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto prefix_list_name_datas = prefix_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Address::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Address::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Address::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "prefix-list")
{
prefix_list.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Address::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Address::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Default()
:
global(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Global>())
, next_hop(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop>())
, dvrf(this, {"dvrf"})
{
global->parent = this;
next_hop->parent = this;
yang_name = "default"; yang_parent_name = "ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::~Default()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<dvrf.len(); index++)
{
if(dvrf[index]->has_data())
return true;
}
return (global != nullptr && global->has_data())
|| (next_hop != nullptr && next_hop->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::has_operation() const
{
for (std::size_t index=0; index<dvrf.len(); index++)
{
if(dvrf[index]->has_operation())
return true;
}
return is_set(yfilter)
|| (global != nullptr && global->has_operation())
|| (next_hop != nullptr && next_hop->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "default";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "global")
{
if(global == nullptr)
{
global = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Global>();
}
return global;
}
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop>();
}
return next_hop;
}
if(child_yang_name == "dvrf")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf>();
ent_->parent = this;
dvrf.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(global != nullptr)
{
_children["global"] = global;
}
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
count_ = 0;
for (auto ent_ : dvrf.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "global" || name == "next-hop" || name == "dvrf")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Global::Global()
:
next_hop{YType::str, "next-hop"}
{
yang_name = "global"; yang_parent_name = "default"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Global::~Global()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Global::has_data() const
{
if (is_presence_container) return true;
return next_hop.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Global::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(next_hop.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Global::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "global";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Global::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (next_hop.is_set || is_set(next_hop.yfilter)) leaf_name_data.push_back(next_hop.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Global::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Global::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Global::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "next-hop")
{
next_hop = value;
next_hop.value_namespace = name_space;
next_hop.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Global::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "next-hop")
{
next_hop.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Global::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "next-hop")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::NextHop()
:
next_hop_address{YType::str, "next-hop-address"}
,
ipv6s(this, {"ipv6"})
{
yang_name = "next-hop"; yang_parent_name = "default"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<ipv6s.len(); index++)
{
if(ipv6s[index]->has_data())
return true;
}
return next_hop_address.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::has_operation() const
{
for (std::size_t index=0; index<ipv6s.len(); index++)
{
if(ipv6s[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(next_hop_address.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (next_hop_address.is_set || is_set(next_hop_address.yfilter)) leaf_name_data.push_back(next_hop_address.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "ipv6s")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::Ipv6s>();
ent_->parent = this;
ipv6s.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : ipv6s.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "next-hop-address")
{
next_hop_address = value;
next_hop_address.value_namespace = name_space;
next_hop_address.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "next-hop-address")
{
next_hop_address.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv6s" || name == "next-hop-address")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::Ipv6s::Ipv6s()
:
ipv6{YType::str, "ipv6"}
{
yang_name = "ipv6s"; yang_parent_name = "next-hop"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::Ipv6s::~Ipv6s()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::Ipv6s::has_data() const
{
if (is_presence_container) return true;
return ipv6.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::Ipv6s::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(ipv6.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::Ipv6s::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv6s";
ADD_KEY_TOKEN(ipv6, "ipv6");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::Ipv6s::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (ipv6.is_set || is_set(ipv6.yfilter)) leaf_name_data.push_back(ipv6.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::Ipv6s::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::Ipv6s::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::Ipv6s::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "ipv6")
{
ipv6 = value;
ipv6.value_namespace = name_space;
ipv6.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::Ipv6s::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "ipv6")
{
ipv6.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::NextHop::Ipv6s::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "ipv6")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::Dvrf()
:
dvrf{YType::str, "dvrf"}
,
dvrf0(this, {"dvrf0"})
{
yang_name = "dvrf"; yang_parent_name = "default"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::~Dvrf()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<dvrf0.len(); index++)
{
if(dvrf0[index]->has_data())
return true;
}
return dvrf.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::has_operation() const
{
for (std::size_t index=0; index<dvrf0.len(); index++)
{
if(dvrf0[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(dvrf.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "dvrf";
ADD_KEY_TOKEN(dvrf, "dvrf");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (dvrf.is_set || is_set(dvrf.yfilter)) leaf_name_data.push_back(dvrf.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "dvrf0")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::Dvrf0>();
ent_->parent = this;
dvrf0.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : dvrf0.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "dvrf")
{
dvrf = value;
dvrf.value_namespace = name_space;
dvrf.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "dvrf")
{
dvrf.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dvrf0" || name == "dvrf")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::Dvrf0::Dvrf0()
:
dvrf0{YType::str, "dvrf0"},
next_hop{YType::empty, "next-hop"}
{
yang_name = "dvrf0"; yang_parent_name = "dvrf"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::Dvrf0::~Dvrf0()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::Dvrf0::has_data() const
{
if (is_presence_container) return true;
return dvrf0.is_set
|| next_hop.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::Dvrf0::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(dvrf0.yfilter)
|| ydk::is_set(next_hop.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::Dvrf0::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "dvrf0";
ADD_KEY_TOKEN(dvrf0, "dvrf0");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::Dvrf0::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (dvrf0.is_set || is_set(dvrf0.yfilter)) leaf_name_data.push_back(dvrf0.get_name_leafdata());
if (next_hop.is_set || is_set(next_hop.yfilter)) leaf_name_data.push_back(next_hop.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::Dvrf0::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::Dvrf0::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::Dvrf0::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "dvrf0")
{
dvrf0 = value;
dvrf0.value_namespace = name_space;
dvrf0.value_namespace_prefix = name_space_prefix;
}
if(value_path == "next-hop")
{
next_hop = value;
next_hop.value_namespace = name_space;
next_hop.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::Dvrf0::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "dvrf0")
{
dvrf0.yfilter = yfilter;
}
if(value_path == "next-hop")
{
next_hop.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Default::Dvrf::Dvrf0::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dvrf0" || name == "next-hop")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::Global()
:
next_hop(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop>())
{
next_hop->parent = this;
yang_name = "global"; yang_parent_name = "ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::~Global()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::has_data() const
{
if (is_presence_container) return true;
return (next_hop != nullptr && next_hop->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::has_operation() const
{
return is_set(yfilter)
|| (next_hop != nullptr && next_hop->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "global";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop>();
}
return next_hop;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "next-hop")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::NextHop()
:
verify_availability{YType::str, "verify-availability"}
,
nh_ipv6(this, {"nh_ipv6"})
{
yang_name = "next-hop"; yang_parent_name = "global"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<nh_ipv6.len(); index++)
{
if(nh_ipv6[index]->has_data())
return true;
}
return verify_availability.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::has_operation() const
{
for (std::size_t index=0; index<nh_ipv6.len(); index++)
{
if(nh_ipv6[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(verify_availability.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (verify_availability.is_set || is_set(verify_availability.yfilter)) leaf_name_data.push_back(verify_availability.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "nh-ipv6")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::NhIpv6>();
ent_->parent = this;
nh_ipv6.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : nh_ipv6.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "verify-availability")
{
verify_availability = value;
verify_availability.value_namespace = name_space;
verify_availability.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "verify-availability")
{
verify_availability.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "nh-ipv6" || name == "verify-availability")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::NhIpv6::NhIpv6()
:
nh_ipv6{YType::str, "nh-ipv6"},
nh_ipv60{YType::str, "nh-ipv60"}
{
yang_name = "nh-ipv6"; yang_parent_name = "next-hop"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::NhIpv6::~NhIpv6()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::NhIpv6::has_data() const
{
if (is_presence_container) return true;
return nh_ipv6.is_set
|| nh_ipv60.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::NhIpv6::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(nh_ipv6.yfilter)
|| ydk::is_set(nh_ipv60.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::NhIpv6::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "nh-ipv6";
ADD_KEY_TOKEN(nh_ipv6, "nh-ipv6");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::NhIpv6::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (nh_ipv6.is_set || is_set(nh_ipv6.yfilter)) leaf_name_data.push_back(nh_ipv6.get_name_leafdata());
if (nh_ipv60.is_set || is_set(nh_ipv60.yfilter)) leaf_name_data.push_back(nh_ipv60.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::NhIpv6::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::NhIpv6::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::NhIpv6::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "nh-ipv6")
{
nh_ipv6 = value;
nh_ipv6.value_namespace = name_space;
nh_ipv6.value_namespace_prefix = name_space_prefix;
}
if(value_path == "nh-ipv60")
{
nh_ipv60 = value;
nh_ipv60.value_namespace = name_space;
nh_ipv60.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::NhIpv6::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "nh-ipv6")
{
nh_ipv6.yfilter = yfilter;
}
if(value_path == "nh-ipv60")
{
nh_ipv60.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Global::NextHop::NhIpv6::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "nh-ipv6" || name == "nh-ipv60")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NextHop()
:
peer_address{YType::empty, "peer-address"},
recursive{YType::str, "recursive"}
,
nha_ipv6(this, {"nha_ipv6"})
, encapsulate(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::Encapsulate>())
, verify_availability(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability>())
{
encapsulate->parent = this;
verify_availability->parent = this;
yang_name = "next-hop"; yang_parent_name = "ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<nha_ipv6.len(); index++)
{
if(nha_ipv6[index]->has_data())
return true;
}
return peer_address.is_set
|| recursive.is_set
|| (encapsulate != nullptr && encapsulate->has_data())
|| (verify_availability != nullptr && verify_availability->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::has_operation() const
{
for (std::size_t index=0; index<nha_ipv6.len(); index++)
{
if(nha_ipv6[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(peer_address.yfilter)
|| ydk::is_set(recursive.yfilter)
|| (encapsulate != nullptr && encapsulate->has_operation())
|| (verify_availability != nullptr && verify_availability->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (peer_address.is_set || is_set(peer_address.yfilter)) leaf_name_data.push_back(peer_address.get_name_leafdata());
if (recursive.is_set || is_set(recursive.yfilter)) leaf_name_data.push_back(recursive.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "nha-ipv6")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6>();
ent_->parent = this;
nha_ipv6.append(ent_);
return ent_;
}
if(child_yang_name == "encapsulate")
{
if(encapsulate == nullptr)
{
encapsulate = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::Encapsulate>();
}
return encapsulate;
}
if(child_yang_name == "verify-availability")
{
if(verify_availability == nullptr)
{
verify_availability = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability>();
}
return verify_availability;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : nha_ipv6.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
if(encapsulate != nullptr)
{
_children["encapsulate"] = encapsulate;
}
if(verify_availability != nullptr)
{
_children["verify-availability"] = verify_availability;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "peer-address")
{
peer_address = value;
peer_address.value_namespace = name_space;
peer_address.value_namespace_prefix = name_space_prefix;
}
if(value_path == "recursive")
{
recursive = value;
recursive.value_namespace = name_space;
recursive.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "peer-address")
{
peer_address.yfilter = yfilter;
}
if(value_path == "recursive")
{
recursive.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "nha-ipv6" || name == "encapsulate" || name == "verify-availability" || name == "peer-address" || name == "recursive")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::NhaIpv6()
:
nha_ipv6{YType::str, "nha-ipv6"}
,
nha_ipv60(this, {"nha_ipv60"})
{
yang_name = "nha-ipv6"; yang_parent_name = "next-hop"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::~NhaIpv6()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<nha_ipv60.len(); index++)
{
if(nha_ipv60[index]->has_data())
return true;
}
return nha_ipv6.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::has_operation() const
{
for (std::size_t index=0; index<nha_ipv60.len(); index++)
{
if(nha_ipv60[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(nha_ipv6.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "nha-ipv6";
ADD_KEY_TOKEN(nha_ipv6, "nha-ipv6");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (nha_ipv6.is_set || is_set(nha_ipv6.yfilter)) leaf_name_data.push_back(nha_ipv6.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "nha-ipv60")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::NhaIpv60>();
ent_->parent = this;
nha_ipv60.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : nha_ipv60.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "nha-ipv6")
{
nha_ipv6 = value;
nha_ipv6.value_namespace = name_space;
nha_ipv6.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "nha-ipv6")
{
nha_ipv6.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "nha-ipv60" || name == "nha-ipv6")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::NhaIpv60::NhaIpv60()
:
nha_ipv60{YType::str, "nha-ipv60"},
nh_ipv6{YType::str, "nh-ipv6"}
{
yang_name = "nha-ipv60"; yang_parent_name = "nha-ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::NhaIpv60::~NhaIpv60()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::NhaIpv60::has_data() const
{
if (is_presence_container) return true;
return nha_ipv60.is_set
|| nh_ipv6.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::NhaIpv60::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(nha_ipv60.yfilter)
|| ydk::is_set(nh_ipv6.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::NhaIpv60::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "nha-ipv60";
ADD_KEY_TOKEN(nha_ipv60, "nha-ipv60");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::NhaIpv60::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (nha_ipv60.is_set || is_set(nha_ipv60.yfilter)) leaf_name_data.push_back(nha_ipv60.get_name_leafdata());
if (nh_ipv6.is_set || is_set(nh_ipv6.yfilter)) leaf_name_data.push_back(nh_ipv6.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::NhaIpv60::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::NhaIpv60::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::NhaIpv60::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "nha-ipv60")
{
nha_ipv60 = value;
nha_ipv60.value_namespace = name_space;
nha_ipv60.value_namespace_prefix = name_space_prefix;
}
if(value_path == "nh-ipv6")
{
nh_ipv6 = value;
nh_ipv6.value_namespace = name_space;
nh_ipv6.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::NhaIpv60::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "nha-ipv60")
{
nha_ipv60.yfilter = yfilter;
}
if(value_path == "nh-ipv6")
{
nh_ipv6.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::NhaIpv6::NhaIpv60::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "nha-ipv60" || name == "nh-ipv6")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::Encapsulate::Encapsulate()
:
l3vpn{YType::str, "l3vpn"}
{
yang_name = "encapsulate"; yang_parent_name = "next-hop"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::Encapsulate::~Encapsulate()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::Encapsulate::has_data() const
{
if (is_presence_container) return true;
return l3vpn.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::Encapsulate::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(l3vpn.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::Encapsulate::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "encapsulate";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::Encapsulate::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (l3vpn.is_set || is_set(l3vpn.yfilter)) leaf_name_data.push_back(l3vpn.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::Encapsulate::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::Encapsulate::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::Encapsulate::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "l3vpn")
{
l3vpn = value;
l3vpn.value_namespace = name_space;
l3vpn.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::Encapsulate::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "l3vpn")
{
l3vpn.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::Encapsulate::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "l3vpn")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::VerifyAvailability()
:
va_ipv6(this, {"va_ipv6"})
{
yang_name = "verify-availability"; yang_parent_name = "next-hop"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::~VerifyAvailability()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<va_ipv6.len(); index++)
{
if(va_ipv6[index]->has_data())
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::has_operation() const
{
for (std::size_t index=0; index<va_ipv6.len(); index++)
{
if(va_ipv6[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "verify-availability";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "va-ipv6")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::VaIpv6>();
ent_->parent = this;
va_ipv6.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : va_ipv6.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "va-ipv6")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::VaIpv6::VaIpv6()
:
va_ipv6{YType::str, "va-ipv6"},
seq_nh{YType::uint16, "seq-nh"}
{
yang_name = "va-ipv6"; yang_parent_name = "verify-availability"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::VaIpv6::~VaIpv6()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::VaIpv6::has_data() const
{
if (is_presence_container) return true;
return va_ipv6.is_set
|| seq_nh.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::VaIpv6::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(va_ipv6.yfilter)
|| ydk::is_set(seq_nh.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::VaIpv6::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "va-ipv6";
ADD_KEY_TOKEN(va_ipv6, "va-ipv6");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::VaIpv6::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (va_ipv6.is_set || is_set(va_ipv6.yfilter)) leaf_name_data.push_back(va_ipv6.get_name_leafdata());
if (seq_nh.is_set || is_set(seq_nh.yfilter)) leaf_name_data.push_back(seq_nh.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::VaIpv6::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::VaIpv6::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::VaIpv6::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "va-ipv6")
{
va_ipv6 = value;
va_ipv6.value_namespace = name_space;
va_ipv6.value_namespace_prefix = name_space_prefix;
}
if(value_path == "seq-nh")
{
seq_nh = value;
seq_nh.value_namespace = name_space;
seq_nh.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::VaIpv6::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "va-ipv6")
{
va_ipv6.yfilter = yfilter;
}
if(value_path == "seq-nh")
{
seq_nh.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::NextHop::VerifyAvailability::VaIpv6::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "va-ipv6" || name == "seq-nh")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf()
:
bvrf{YType::str, "bvrf"}
,
bvrf0(this, {"bvrf0"})
{
yang_name = "bvrf"; yang_parent_name = "ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::~Bvrf()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<bvrf0.len(); index++)
{
if(bvrf0[index]->has_data())
return true;
}
return bvrf.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::has_operation() const
{
for (std::size_t index=0; index<bvrf0.len(); index++)
{
if(bvrf0[index]->has_operation())
return true;
}
return is_set(yfilter)
|| ydk::is_set(bvrf.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "bvrf";
ADD_KEY_TOKEN(bvrf, "bvrf");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (bvrf.is_set || is_set(bvrf.yfilter)) leaf_name_data.push_back(bvrf.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "bvrf0")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0>();
ent_->parent = this;
bvrf0.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : bvrf0.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "bvrf")
{
bvrf = value;
bvrf.value_namespace = name_space;
bvrf.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "bvrf")
{
bvrf.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "bvrf0" || name == "bvrf")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::Bvrf0()
:
bvrf0{YType::str, "bvrf0"}
,
next_hop(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::NextHop>())
{
next_hop->parent = this;
yang_name = "bvrf0"; yang_parent_name = "bvrf"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::~Bvrf0()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::has_data() const
{
if (is_presence_container) return true;
return bvrf0.is_set
|| (next_hop != nullptr && next_hop->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(bvrf0.yfilter)
|| (next_hop != nullptr && next_hop->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "bvrf0";
ADD_KEY_TOKEN(bvrf0, "bvrf0");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (bvrf0.is_set || is_set(bvrf0.yfilter)) leaf_name_data.push_back(bvrf0.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::NextHop>();
}
return next_hop;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "bvrf0")
{
bvrf0 = value;
bvrf0.value_namespace = name_space;
bvrf0.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "bvrf0")
{
bvrf0.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "next-hop" || name == "bvrf0")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::NextHop::NextHop()
:
bipv6{YType::str, "bipv6"},
verify_availability{YType::empty, "verify-availability"}
{
yang_name = "next-hop"; yang_parent_name = "bvrf0"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::NextHop::has_data() const
{
if (is_presence_container) return true;
return bipv6.is_set
|| verify_availability.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::NextHop::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(bipv6.yfilter)
|| ydk::is_set(verify_availability.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (bipv6.is_set || is_set(bipv6.yfilter)) leaf_name_data.push_back(bipv6.get_name_leafdata());
if (verify_availability.is_set || is_set(verify_availability.yfilter)) leaf_name_data.push_back(verify_availability.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "bipv6")
{
bipv6 = value;
bipv6.value_namespace = name_space;
bipv6.value_namespace_prefix = name_space_prefix;
}
if(value_path == "verify-availability")
{
verify_availability = value;
verify_availability.value_namespace = name_space;
verify_availability.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "bipv6")
{
bipv6.yfilter = yfilter;
}
if(value_path == "verify-availability")
{
verify_availability.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ipv6::Bvrf::Bvrf0::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "bipv6" || name == "verify-availability")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Level::Level()
:
level_1{YType::empty, "level-1"},
level_1_2{YType::empty, "level-1-2"},
level_2{YType::empty, "level-2"},
nssa_only{YType::empty, "nssa-only"}
{
yang_name = "level"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Level::~Level()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Level::has_data() const
{
if (is_presence_container) return true;
return level_1.is_set
|| level_1_2.is_set
|| level_2.is_set
|| nssa_only.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Level::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(level_1.yfilter)
|| ydk::is_set(level_1_2.yfilter)
|| ydk::is_set(level_2.yfilter)
|| ydk::is_set(nssa_only.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Level::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "level";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Level::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (level_1.is_set || is_set(level_1.yfilter)) leaf_name_data.push_back(level_1.get_name_leafdata());
if (level_1_2.is_set || is_set(level_1_2.yfilter)) leaf_name_data.push_back(level_1_2.get_name_leafdata());
if (level_2.is_set || is_set(level_2.yfilter)) leaf_name_data.push_back(level_2.get_name_leafdata());
if (nssa_only.is_set || is_set(nssa_only.yfilter)) leaf_name_data.push_back(nssa_only.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Level::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Level::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Level::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "level-1")
{
level_1 = value;
level_1.value_namespace = name_space;
level_1.value_namespace_prefix = name_space_prefix;
}
if(value_path == "level-1-2")
{
level_1_2 = value;
level_1_2.value_namespace = name_space;
level_1_2.value_namespace_prefix = name_space_prefix;
}
if(value_path == "level-2")
{
level_2 = value;
level_2.value_namespace = name_space;
level_2.value_namespace_prefix = name_space_prefix;
}
if(value_path == "nssa-only")
{
nssa_only = value;
nssa_only.value_namespace = name_space;
nssa_only.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Level::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "level-1")
{
level_1.yfilter = yfilter;
}
if(value_path == "level-1-2")
{
level_1_2.yfilter = yfilter;
}
if(value_path == "level-2")
{
level_2.yfilter = yfilter;
}
if(value_path == "nssa-only")
{
nssa_only.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Level::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "level-1" || name == "level-1-2" || name == "level-2" || name == "nssa-only")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Lisp::Lisp()
:
locator_set{YType::str, "locator-set"}
{
yang_name = "lisp"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Lisp::~Lisp()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Lisp::has_data() const
{
if (is_presence_container) return true;
return locator_set.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Lisp::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(locator_set.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Lisp::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "lisp";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Lisp::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (locator_set.is_set || is_set(locator_set.yfilter)) leaf_name_data.push_back(locator_set.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Lisp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Lisp::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Lisp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "locator-set")
{
locator_set = value;
locator_set.value_namespace = name_space;
locator_set.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Lisp::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "locator-set")
{
locator_set.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Lisp::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "locator-set")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Metric()
:
metric_change{YType::str, "metric-change"}
,
values(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Values>())
{
values->parent = this;
yang_name = "metric"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::~Metric()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::has_data() const
{
if (is_presence_container) return true;
return metric_change.is_set
|| (values != nullptr && values->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(metric_change.yfilter)
|| (values != nullptr && values->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "metric";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (metric_change.is_set || is_set(metric_change.yfilter)) leaf_name_data.push_back(metric_change.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "values")
{
if(values == nullptr)
{
values = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Values>();
}
return values;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(values != nullptr)
{
_children["values"] = values;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "metric-change")
{
metric_change = value;
metric_change.value_namespace = name_space;
metric_change.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "metric-change")
{
metric_change.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "values" || name == "metric-change")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Values::Values()
:
value_{YType::uint32, "value"},
delay{YType::str, "delay"},
reliability{YType::uint8, "reliability"},
loading{YType::uint8, "loading"},
mtu{YType::uint32, "MTU"}
{
yang_name = "values"; yang_parent_name = "metric"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Values::~Values()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Values::has_data() const
{
if (is_presence_container) return true;
return value_.is_set
|| delay.is_set
|| reliability.is_set
|| loading.is_set
|| mtu.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Values::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(value_.yfilter)
|| ydk::is_set(delay.yfilter)
|| ydk::is_set(reliability.yfilter)
|| ydk::is_set(loading.yfilter)
|| ydk::is_set(mtu.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Values::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "values";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Values::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (value_.is_set || is_set(value_.yfilter)) leaf_name_data.push_back(value_.get_name_leafdata());
if (delay.is_set || is_set(delay.yfilter)) leaf_name_data.push_back(delay.get_name_leafdata());
if (reliability.is_set || is_set(reliability.yfilter)) leaf_name_data.push_back(reliability.get_name_leafdata());
if (loading.is_set || is_set(loading.yfilter)) leaf_name_data.push_back(loading.get_name_leafdata());
if (mtu.is_set || is_set(mtu.yfilter)) leaf_name_data.push_back(mtu.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Values::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Values::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Values::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "value")
{
value_ = value;
value_.value_namespace = name_space;
value_.value_namespace_prefix = name_space_prefix;
}
if(value_path == "delay")
{
delay = value;
delay.value_namespace = name_space;
delay.value_namespace_prefix = name_space_prefix;
}
if(value_path == "reliability")
{
reliability = value;
reliability.value_namespace = name_space;
reliability.value_namespace_prefix = name_space_prefix;
}
if(value_path == "loading")
{
loading = value;
loading.value_namespace = name_space;
loading.value_namespace_prefix = name_space_prefix;
}
if(value_path == "MTU")
{
mtu = value;
mtu.value_namespace = name_space;
mtu.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Values::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "value")
{
value_.yfilter = yfilter;
}
if(value_path == "delay")
{
delay.yfilter = yfilter;
}
if(value_path == "reliability")
{
reliability.yfilter = yfilter;
}
if(value_path == "loading")
{
loading.yfilter = yfilter;
}
if(value_path == "MTU")
{
mtu.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Metric::Values::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "value" || name == "delay" || name == "reliability" || name == "loading" || name == "MTU")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Nlri::Nlri()
:
unicast{YType::empty, "unicast"},
multicast{YType::empty, "multicast"}
{
yang_name = "nlri"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Nlri::~Nlri()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Nlri::has_data() const
{
if (is_presence_container) return true;
return unicast.is_set
|| multicast.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Nlri::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(unicast.yfilter)
|| ydk::is_set(multicast.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Nlri::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "nlri";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Nlri::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (unicast.is_set || is_set(unicast.yfilter)) leaf_name_data.push_back(unicast.get_name_leafdata());
if (multicast.is_set || is_set(multicast.yfilter)) leaf_name_data.push_back(multicast.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Nlri::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Nlri::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Nlri::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "unicast")
{
unicast = value;
unicast.value_namespace = name_space;
unicast.value_namespace_prefix = name_space_prefix;
}
if(value_path == "multicast")
{
multicast = value;
multicast.value_namespace = name_space;
multicast.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Nlri::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "unicast")
{
unicast.yfilter = yfilter;
}
if(value_path == "multicast")
{
multicast.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Nlri::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "unicast" || name == "multicast")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin::Origin()
:
origin_value{YType::enumeration, "origin-value"},
egp{YType::uint32, "egp"}
{
yang_name = "origin"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin::~Origin()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin::has_data() const
{
if (is_presence_container) return true;
return origin_value.is_set
|| egp.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(origin_value.yfilter)
|| ydk::is_set(egp.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "origin";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (origin_value.is_set || is_set(origin_value.yfilter)) leaf_name_data.push_back(origin_value.get_name_leafdata());
if (egp.is_set || is_set(egp.yfilter)) leaf_name_data.push_back(egp.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "origin-value")
{
origin_value = value;
origin_value.value_namespace = name_space;
origin_value.value_namespace_prefix = name_space_prefix;
}
if(value_path == "egp")
{
egp = value;
egp.value_namespace = name_space;
egp.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "origin-value")
{
origin_value.yfilter = yfilter;
}
if(value_path == "egp")
{
egp.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "origin-value" || name == "egp")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Tag::Tag()
:
tag_val{YType::uint32, "tag-val"},
tag_ipv4{YType::str, "tag-ipv4"}
{
yang_name = "tag"; yang_parent_name = "set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Set::Tag::~Tag()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Tag::has_data() const
{
if (is_presence_container) return true;
return tag_val.is_set
|| tag_ipv4.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Tag::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(tag_val.yfilter)
|| ydk::is_set(tag_ipv4.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Set::Tag::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "tag";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Set::Tag::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (tag_val.is_set || is_set(tag_val.yfilter)) leaf_name_data.push_back(tag_val.get_name_leafdata());
if (tag_ipv4.is_set || is_set(tag_ipv4.yfilter)) leaf_name_data.push_back(tag_ipv4.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Tag::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Set::Tag::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Tag::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "tag-val")
{
tag_val = value;
tag_val.value_namespace = name_space;
tag_val.value_namespace_prefix = name_space_prefix;
}
if(value_path == "tag-ipv4")
{
tag_ipv4 = value;
tag_ipv4.value_namespace = name_space;
tag_ipv4.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Set::Tag::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "tag-val")
{
tag_val.yfilter = yfilter;
}
if(value_path == "tag-ipv4")
{
tag_ipv4.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Set::Tag::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "tag-val" || name == "tag-ipv4")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Match()
:
mpls_label{YType::empty, "mpls-label"},
track{YType::uint16, "track"}
,
additional_paths(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths>())
, as_path(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AsPath>())
, clns(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Clns>())
, community(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Community>())
, extcommunity(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Extcommunity>())
, interface(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Interface>())
, ip(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip>())
, ipv6(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6>())
, length(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length>())
, local_preference(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::LocalPreference>())
, mdt_group(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::MdtGroup>())
, metric(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Metric>())
, policy_list(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::PolicyList>())
, route_type(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::RouteType>())
, rpki(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Rpki>())
, source_protocol(nullptr) // presence node
, tag(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Tag>())
{
additional_paths->parent = this;
as_path->parent = this;
clns->parent = this;
community->parent = this;
extcommunity->parent = this;
interface->parent = this;
ip->parent = this;
ipv6->parent = this;
length->parent = this;
local_preference->parent = this;
mdt_group->parent = this;
metric->parent = this;
policy_list->parent = this;
route_type->parent = this;
rpki->parent = this;
tag->parent = this;
yang_name = "match"; yang_parent_name = "route-map-without-order-seq"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::~Match()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::has_data() const
{
if (is_presence_container) return true;
return mpls_label.is_set
|| track.is_set
|| (additional_paths != nullptr && additional_paths->has_data())
|| (as_path != nullptr && as_path->has_data())
|| (clns != nullptr && clns->has_data())
|| (community != nullptr && community->has_data())
|| (extcommunity != nullptr && extcommunity->has_data())
|| (interface != nullptr && interface->has_data())
|| (ip != nullptr && ip->has_data())
|| (ipv6 != nullptr && ipv6->has_data())
|| (length != nullptr && length->has_data())
|| (local_preference != nullptr && local_preference->has_data())
|| (mdt_group != nullptr && mdt_group->has_data())
|| (metric != nullptr && metric->has_data())
|| (policy_list != nullptr && policy_list->has_data())
|| (route_type != nullptr && route_type->has_data())
|| (rpki != nullptr && rpki->has_data())
|| (source_protocol != nullptr && source_protocol->has_data())
|| (tag != nullptr && tag->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(mpls_label.yfilter)
|| ydk::is_set(track.yfilter)
|| (additional_paths != nullptr && additional_paths->has_operation())
|| (as_path != nullptr && as_path->has_operation())
|| (clns != nullptr && clns->has_operation())
|| (community != nullptr && community->has_operation())
|| (extcommunity != nullptr && extcommunity->has_operation())
|| (interface != nullptr && interface->has_operation())
|| (ip != nullptr && ip->has_operation())
|| (ipv6 != nullptr && ipv6->has_operation())
|| (length != nullptr && length->has_operation())
|| (local_preference != nullptr && local_preference->has_operation())
|| (mdt_group != nullptr && mdt_group->has_operation())
|| (metric != nullptr && metric->has_operation())
|| (policy_list != nullptr && policy_list->has_operation())
|| (route_type != nullptr && route_type->has_operation())
|| (rpki != nullptr && rpki->has_operation())
|| (source_protocol != nullptr && source_protocol->has_operation())
|| (tag != nullptr && tag->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "match";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (mpls_label.is_set || is_set(mpls_label.yfilter)) leaf_name_data.push_back(mpls_label.get_name_leafdata());
if (track.is_set || is_set(track.yfilter)) leaf_name_data.push_back(track.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "additional-paths")
{
if(additional_paths == nullptr)
{
additional_paths = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths>();
}
return additional_paths;
}
if(child_yang_name == "as-path")
{
if(as_path == nullptr)
{
as_path = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AsPath>();
}
return as_path;
}
if(child_yang_name == "clns")
{
if(clns == nullptr)
{
clns = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Clns>();
}
return clns;
}
if(child_yang_name == "community")
{
if(community == nullptr)
{
community = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Community>();
}
return community;
}
if(child_yang_name == "extcommunity")
{
if(extcommunity == nullptr)
{
extcommunity = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Extcommunity>();
}
return extcommunity;
}
if(child_yang_name == "interface")
{
if(interface == nullptr)
{
interface = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Interface>();
}
return interface;
}
if(child_yang_name == "ip")
{
if(ip == nullptr)
{
ip = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip>();
}
return ip;
}
if(child_yang_name == "ipv6")
{
if(ipv6 == nullptr)
{
ipv6 = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6>();
}
return ipv6;
}
if(child_yang_name == "length")
{
if(length == nullptr)
{
length = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length>();
}
return length;
}
if(child_yang_name == "local-preference")
{
if(local_preference == nullptr)
{
local_preference = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::LocalPreference>();
}
return local_preference;
}
if(child_yang_name == "mdt-group")
{
if(mdt_group == nullptr)
{
mdt_group = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::MdtGroup>();
}
return mdt_group;
}
if(child_yang_name == "metric")
{
if(metric == nullptr)
{
metric = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Metric>();
}
return metric;
}
if(child_yang_name == "policy-list")
{
if(policy_list == nullptr)
{
policy_list = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::PolicyList>();
}
return policy_list;
}
if(child_yang_name == "route-type")
{
if(route_type == nullptr)
{
route_type = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::RouteType>();
}
return route_type;
}
if(child_yang_name == "rpki")
{
if(rpki == nullptr)
{
rpki = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Rpki>();
}
return rpki;
}
if(child_yang_name == "source-protocol")
{
if(source_protocol == nullptr)
{
source_protocol = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::SourceProtocol>();
}
return source_protocol;
}
if(child_yang_name == "tag")
{
if(tag == nullptr)
{
tag = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Tag>();
}
return tag;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(additional_paths != nullptr)
{
_children["additional-paths"] = additional_paths;
}
if(as_path != nullptr)
{
_children["as-path"] = as_path;
}
if(clns != nullptr)
{
_children["clns"] = clns;
}
if(community != nullptr)
{
_children["community"] = community;
}
if(extcommunity != nullptr)
{
_children["extcommunity"] = extcommunity;
}
if(interface != nullptr)
{
_children["interface"] = interface;
}
if(ip != nullptr)
{
_children["ip"] = ip;
}
if(ipv6 != nullptr)
{
_children["ipv6"] = ipv6;
}
if(length != nullptr)
{
_children["length"] = length;
}
if(local_preference != nullptr)
{
_children["local-preference"] = local_preference;
}
if(mdt_group != nullptr)
{
_children["mdt-group"] = mdt_group;
}
if(metric != nullptr)
{
_children["metric"] = metric;
}
if(policy_list != nullptr)
{
_children["policy-list"] = policy_list;
}
if(route_type != nullptr)
{
_children["route-type"] = route_type;
}
if(rpki != nullptr)
{
_children["rpki"] = rpki;
}
if(source_protocol != nullptr)
{
_children["source-protocol"] = source_protocol;
}
if(tag != nullptr)
{
_children["tag"] = tag;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "mpls-label")
{
mpls_label = value;
mpls_label.value_namespace = name_space;
mpls_label.value_namespace_prefix = name_space_prefix;
}
if(value_path == "track")
{
track = value;
track.value_namespace = name_space;
track.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "mpls-label")
{
mpls_label.yfilter = yfilter;
}
if(value_path == "track")
{
track.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "additional-paths" || name == "as-path" || name == "clns" || name == "community" || name == "extcommunity" || name == "interface" || name == "ip" || name == "ipv6" || name == "length" || name == "local-preference" || name == "mdt-group" || name == "metric" || name == "policy-list" || name == "route-type" || name == "rpki" || name == "source-protocol" || name == "tag" || name == "mpls-label" || name == "track")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdditionalPaths()
:
advertise_set(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet>())
{
advertise_set->parent = this;
yang_name = "additional-paths"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::~AdditionalPaths()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::has_data() const
{
if (is_presence_container) return true;
return (advertise_set != nullptr && advertise_set->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::has_operation() const
{
return is_set(yfilter)
|| (advertise_set != nullptr && advertise_set->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "additional-paths";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "advertise-set")
{
if(advertise_set == nullptr)
{
advertise_set = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet>();
}
return advertise_set;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(advertise_set != nullptr)
{
_children["advertise-set"] = advertise_set;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "advertise-set")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::AdvertiseSet()
:
all(nullptr) // presence node
, best(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best>())
, best_range(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange>())
, group_best(nullptr) // presence node
{
best->parent = this;
best_range->parent = this;
yang_name = "advertise-set"; yang_parent_name = "additional-paths"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::~AdvertiseSet()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::has_data() const
{
if (is_presence_container) return true;
return (all != nullptr && all->has_data())
|| (best != nullptr && best->has_data())
|| (best_range != nullptr && best_range->has_data())
|| (group_best != nullptr && group_best->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::has_operation() const
{
return is_set(yfilter)
|| (all != nullptr && all->has_operation())
|| (best != nullptr && best->has_operation())
|| (best_range != nullptr && best_range->has_operation())
|| (group_best != nullptr && group_best->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "advertise-set";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "all")
{
if(all == nullptr)
{
all = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All>();
}
return all;
}
if(child_yang_name == "best")
{
if(best == nullptr)
{
best = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best>();
}
return best;
}
if(child_yang_name == "best-range")
{
if(best_range == nullptr)
{
best_range = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange>();
}
return best_range;
}
if(child_yang_name == "group-best")
{
if(group_best == nullptr)
{
group_best = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::GroupBest>();
}
return group_best;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(all != nullptr)
{
_children["all"] = all;
}
if(best != nullptr)
{
_children["best"] = best;
}
if(best_range != nullptr)
{
_children["best-range"] = best_range;
}
if(group_best != nullptr)
{
_children["group-best"] = group_best;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "all" || name == "best" || name == "best-range" || name == "group-best")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::All()
:
best{YType::uint8, "best"},
best_range{YType::uint8, "best-range"}
,
group_best(nullptr) // presence node
{
yang_name = "all"; yang_parent_name = "advertise-set"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::~All()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::has_data() const
{
if (is_presence_container) return true;
return best.is_set
|| best_range.is_set
|| (group_best != nullptr && group_best->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(best.yfilter)
|| ydk::is_set(best_range.yfilter)
|| (group_best != nullptr && group_best->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "all";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (best.is_set || is_set(best.yfilter)) leaf_name_data.push_back(best.get_name_leafdata());
if (best_range.is_set || is_set(best_range.yfilter)) leaf_name_data.push_back(best_range.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "group-best")
{
if(group_best == nullptr)
{
group_best = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::GroupBest>();
}
return group_best;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(group_best != nullptr)
{
_children["group-best"] = group_best;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "best")
{
best = value;
best.value_namespace = name_space;
best.value_namespace_prefix = name_space_prefix;
}
if(value_path == "best-range")
{
best_range = value;
best_range.value_namespace = name_space;
best_range.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "best")
{
best.yfilter = yfilter;
}
if(value_path == "best-range")
{
best_range.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "group-best" || name == "best" || name == "best-range")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::GroupBest::GroupBest()
:
best{YType::empty, "best"},
best_range{YType::empty, "best-range"}
{
yang_name = "group-best"; yang_parent_name = "all"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::GroupBest::~GroupBest()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::GroupBest::has_data() const
{
if (is_presence_container) return true;
return best.is_set
|| best_range.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::GroupBest::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(best.yfilter)
|| ydk::is_set(best_range.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::GroupBest::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "group-best";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::GroupBest::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (best.is_set || is_set(best.yfilter)) leaf_name_data.push_back(best.get_name_leafdata());
if (best_range.is_set || is_set(best_range.yfilter)) leaf_name_data.push_back(best_range.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::GroupBest::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::GroupBest::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::GroupBest::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "best")
{
best = value;
best.value_namespace = name_space;
best.value_namespace_prefix = name_space_prefix;
}
if(value_path == "best-range")
{
best_range = value;
best_range.value_namespace = name_space;
best_range.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::GroupBest::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "best")
{
best.yfilter = yfilter;
}
if(value_path == "best-range")
{
best_range.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::All::GroupBest::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "best" || name == "best-range")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::Best()
:
best_range(this, {"best_range"})
{
yang_name = "best"; yang_parent_name = "advertise-set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::~Best()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<best_range.len(); index++)
{
if(best_range[index]->has_data())
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::has_operation() const
{
for (std::size_t index=0; index<best_range.len(); index++)
{
if(best_range[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "best";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "best-range")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::BestRange>();
ent_->parent = this;
best_range.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : best_range.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "best-range")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::BestRange::BestRange()
:
best_range{YType::uint8, "best-range"},
all{YType::empty, "all"},
group_best{YType::empty, "group-best"}
{
yang_name = "best-range"; yang_parent_name = "best"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::BestRange::~BestRange()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::BestRange::has_data() const
{
if (is_presence_container) return true;
return best_range.is_set
|| all.is_set
|| group_best.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::BestRange::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(best_range.yfilter)
|| ydk::is_set(all.yfilter)
|| ydk::is_set(group_best.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::BestRange::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "best-range";
ADD_KEY_TOKEN(best_range, "best-range");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::BestRange::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (best_range.is_set || is_set(best_range.yfilter)) leaf_name_data.push_back(best_range.get_name_leafdata());
if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata());
if (group_best.is_set || is_set(group_best.yfilter)) leaf_name_data.push_back(group_best.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::BestRange::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::BestRange::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::BestRange::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "best-range")
{
best_range = value;
best_range.value_namespace = name_space;
best_range.value_namespace_prefix = name_space_prefix;
}
if(value_path == "all")
{
all = value;
all.value_namespace = name_space;
all.value_namespace_prefix = name_space_prefix;
}
if(value_path == "group-best")
{
group_best = value;
group_best.value_namespace = name_space;
group_best.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::BestRange::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "best-range")
{
best_range.yfilter = yfilter;
}
if(value_path == "all")
{
all.yfilter = yfilter;
}
if(value_path == "group-best")
{
group_best.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::Best::BestRange::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "best-range" || name == "all" || name == "group-best")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::BestRange()
:
adv_path(this, {"adv_path"})
{
yang_name = "best-range"; yang_parent_name = "advertise-set"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::~BestRange()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<adv_path.len(); index++)
{
if(adv_path[index]->has_data())
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::has_operation() const
{
for (std::size_t index=0; index<adv_path.len(); index++)
{
if(adv_path[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "best-range";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "adv-path")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::AdvPath>();
ent_->parent = this;
adv_path.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : adv_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 Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "adv-path")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::AdvPath::AdvPath()
:
adv_path{YType::uint8, "adv-path"},
adv_path0{YType::uint8, "adv-path0"}
{
yang_name = "adv-path"; yang_parent_name = "best-range"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::AdvPath::~AdvPath()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::AdvPath::has_data() const
{
if (is_presence_container) return true;
return adv_path.is_set
|| adv_path0.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::AdvPath::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(adv_path.yfilter)
|| ydk::is_set(adv_path0.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::AdvPath::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "adv-path";
ADD_KEY_TOKEN(adv_path, "adv-path");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::AdvPath::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (adv_path.is_set || is_set(adv_path.yfilter)) leaf_name_data.push_back(adv_path.get_name_leafdata());
if (adv_path0.is_set || is_set(adv_path0.yfilter)) leaf_name_data.push_back(adv_path0.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::AdvPath::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::AdvPath::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::AdvPath::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "adv-path")
{
adv_path = value;
adv_path.value_namespace = name_space;
adv_path.value_namespace_prefix = name_space_prefix;
}
if(value_path == "adv-path0")
{
adv_path0 = value;
adv_path0.value_namespace = name_space;
adv_path0.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::AdvPath::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "adv-path")
{
adv_path.yfilter = yfilter;
}
if(value_path == "adv-path0")
{
adv_path0.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::BestRange::AdvPath::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "adv-path" || name == "adv-path0")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::GroupBest::GroupBest()
:
all{YType::empty, "all"},
best{YType::uint8, "best"},
best_range{YType::uint8, "best-range"}
{
yang_name = "group-best"; yang_parent_name = "advertise-set"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::GroupBest::~GroupBest()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::GroupBest::has_data() const
{
if (is_presence_container) return true;
return all.is_set
|| best.is_set
|| best_range.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::GroupBest::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(all.yfilter)
|| ydk::is_set(best.yfilter)
|| ydk::is_set(best_range.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::GroupBest::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "group-best";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::GroupBest::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata());
if (best.is_set || is_set(best.yfilter)) leaf_name_data.push_back(best.get_name_leafdata());
if (best_range.is_set || is_set(best_range.yfilter)) leaf_name_data.push_back(best_range.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::GroupBest::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::GroupBest::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::GroupBest::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "all")
{
all = value;
all.value_namespace = name_space;
all.value_namespace_prefix = name_space_prefix;
}
if(value_path == "best")
{
best = value;
best.value_namespace = name_space;
best.value_namespace_prefix = name_space_prefix;
}
if(value_path == "best-range")
{
best_range = value;
best_range.value_namespace = name_space;
best_range.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::GroupBest::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "all")
{
all.yfilter = yfilter;
}
if(value_path == "best")
{
best.yfilter = yfilter;
}
if(value_path == "best-range")
{
best_range.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AdditionalPaths::AdvertiseSet::GroupBest::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "all" || name == "best" || name == "best-range")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AsPath::AsPath()
:
access_list{YType::uint16, "access-list"}
{
yang_name = "as-path"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::AsPath::~AsPath()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AsPath::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : access_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AsPath::has_operation() const
{
for (auto const & leaf : access_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::AsPath::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "as-path";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::AsPath::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto access_list_name_datas = access_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), access_list_name_datas.begin(), access_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AsPath::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::AsPath::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AsPath::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::AsPath::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::AsPath::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Clns::Clns()
:
name{YType::str, "name"}
{
yang_name = "clns"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Clns::~Clns()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Clns::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : name.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Clns::has_operation() const
{
for (auto const & leaf : name.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(name.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Clns::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "clns";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Clns::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto name_name_datas = name.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), name_name_datas.begin(), name_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Clns::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Clns::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Clns::set_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.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Clns::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "name")
{
name.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Clns::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "name")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Community::Community()
:
name{YType::str, "name"}
{
yang_name = "community"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Community::~Community()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Community::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : name.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Community::has_operation() const
{
for (auto const & leaf : name.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(name.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Community::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "community";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Community::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto name_name_datas = name.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), name_name_datas.begin(), name_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Community::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Community::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Community::set_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.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Community::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "name")
{
name.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Community::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "name")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Extcommunity::Extcommunity()
:
name{YType::str, "name"}
{
yang_name = "extcommunity"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Extcommunity::~Extcommunity()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Extcommunity::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : name.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Extcommunity::has_operation() const
{
for (auto const & leaf : name.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(name.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Extcommunity::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "extcommunity";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Extcommunity::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto name_name_datas = name.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), name_name_datas.begin(), name_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Extcommunity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Extcommunity::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Extcommunity::set_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.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Extcommunity::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "name")
{
name.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Extcommunity::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "name")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Interface::Interface()
:
interface{YType::str, "interface"}
{
yang_name = "interface"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Interface::~Interface()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Interface::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : interface.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Interface::has_operation() const
{
for (auto const & leaf : interface.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(interface.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Interface::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "interface";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Interface::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto interface_name_datas = interface.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), interface_name_datas.begin(), interface_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Interface::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Interface::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Interface::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "interface")
{
interface.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Interface::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "interface")
{
interface.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Interface::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "interface")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Ip()
:
address(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Address>())
, flowspec(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec>())
, next_hop(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::NextHop>())
, redistribution_source(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RedistributionSource>())
, route_source(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RouteSource>())
{
address->parent = this;
flowspec->parent = this;
next_hop->parent = this;
redistribution_source->parent = this;
route_source->parent = this;
yang_name = "ip"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::~Ip()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::has_data() const
{
if (is_presence_container) return true;
return (address != nullptr && address->has_data())
|| (flowspec != nullptr && flowspec->has_data())
|| (next_hop != nullptr && next_hop->has_data())
|| (redistribution_source != nullptr && redistribution_source->has_data())
|| (route_source != nullptr && route_source->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::has_operation() const
{
return is_set(yfilter)
|| (address != nullptr && address->has_operation())
|| (flowspec != nullptr && flowspec->has_operation())
|| (next_hop != nullptr && next_hop->has_operation())
|| (redistribution_source != nullptr && redistribution_source->has_operation())
|| (route_source != nullptr && route_source->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ip";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "address")
{
if(address == nullptr)
{
address = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Address>();
}
return address;
}
if(child_yang_name == "flowspec")
{
if(flowspec == nullptr)
{
flowspec = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec>();
}
return flowspec;
}
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::NextHop>();
}
return next_hop;
}
if(child_yang_name == "redistribution-source")
{
if(redistribution_source == nullptr)
{
redistribution_source = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RedistributionSource>();
}
return redistribution_source;
}
if(child_yang_name == "route-source")
{
if(route_source == nullptr)
{
route_source = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RouteSource>();
}
return route_source;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(address != nullptr)
{
_children["address"] = address;
}
if(flowspec != nullptr)
{
_children["flowspec"] = flowspec;
}
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
if(redistribution_source != nullptr)
{
_children["redistribution-source"] = redistribution_source;
}
if(route_source != nullptr)
{
_children["route-source"] = route_source;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "flowspec" || name == "next-hop" || name == "redistribution-source" || name == "route-source")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Address::Address()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "address"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Address::~Address()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Address::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : access_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Address::has_operation() const
{
for (auto const & leaf : access_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Address::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "address";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Address::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto access_list_name_datas = access_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), access_list_name_datas.begin(), access_list_name_datas.end());
auto prefix_list_name_datas = prefix_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Address::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Address::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Address::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list.append(value);
}
if(value_path == "prefix-list")
{
prefix_list.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Address::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Address::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::Flowspec()
:
dest_pfx(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::DestPfx>())
, src_pfx(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::SrcPfx>())
{
dest_pfx->parent = this;
src_pfx->parent = this;
yang_name = "flowspec"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::~Flowspec()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::has_data() const
{
if (is_presence_container) return true;
return (dest_pfx != nullptr && dest_pfx->has_data())
|| (src_pfx != nullptr && src_pfx->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::has_operation() const
{
return is_set(yfilter)
|| (dest_pfx != nullptr && dest_pfx->has_operation())
|| (src_pfx != nullptr && src_pfx->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "flowspec";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "dest-pfx")
{
if(dest_pfx == nullptr)
{
dest_pfx = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::DestPfx>();
}
return dest_pfx;
}
if(child_yang_name == "src-pfx")
{
if(src_pfx == nullptr)
{
src_pfx = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::SrcPfx>();
}
return src_pfx;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(dest_pfx != nullptr)
{
_children["dest-pfx"] = dest_pfx;
}
if(src_pfx != nullptr)
{
_children["src-pfx"] = src_pfx;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dest-pfx" || name == "src-pfx")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::DestPfx::DestPfx()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "dest-pfx"; yang_parent_name = "flowspec"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::DestPfx::~DestPfx()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::DestPfx::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : access_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::DestPfx::has_operation() const
{
for (auto const & leaf : access_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::DestPfx::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "dest-pfx";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::DestPfx::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto access_list_name_datas = access_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), access_list_name_datas.begin(), access_list_name_datas.end());
auto prefix_list_name_datas = prefix_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::DestPfx::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::DestPfx::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::DestPfx::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list.append(value);
}
if(value_path == "prefix-list")
{
prefix_list.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::DestPfx::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::DestPfx::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::SrcPfx::SrcPfx()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "src-pfx"; yang_parent_name = "flowspec"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::SrcPfx::~SrcPfx()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::SrcPfx::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : access_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::SrcPfx::has_operation() const
{
for (auto const & leaf : access_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::SrcPfx::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "src-pfx";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::SrcPfx::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto access_list_name_datas = access_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), access_list_name_datas.begin(), access_list_name_datas.end());
auto prefix_list_name_datas = prefix_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::SrcPfx::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::SrcPfx::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::SrcPfx::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list.append(value);
}
if(value_path == "prefix-list")
{
prefix_list.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::SrcPfx::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::Flowspec::SrcPfx::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::NextHop::NextHop()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "next-hop"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::NextHop::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : access_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::NextHop::has_operation() const
{
for (auto const & leaf : access_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto access_list_name_datas = access_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), access_list_name_datas.begin(), access_list_name_datas.end());
auto prefix_list_name_datas = prefix_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list.append(value);
}
if(value_path == "prefix-list")
{
prefix_list.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RedistributionSource::RedistributionSource()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "redistribution-source"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RedistributionSource::~RedistributionSource()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RedistributionSource::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : access_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RedistributionSource::has_operation() const
{
for (auto const & leaf : access_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RedistributionSource::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "redistribution-source";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RedistributionSource::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto access_list_name_datas = access_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), access_list_name_datas.begin(), access_list_name_datas.end());
auto prefix_list_name_datas = prefix_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RedistributionSource::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RedistributionSource::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RedistributionSource::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list.append(value);
}
if(value_path == "prefix-list")
{
prefix_list.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RedistributionSource::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RedistributionSource::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RouteSource::RouteSource()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "route-source"; yang_parent_name = "ip"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RouteSource::~RouteSource()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RouteSource::has_data() const
{
if (is_presence_container) return true;
for (auto const & leaf : access_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(leaf.is_set)
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RouteSource::has_operation() const
{
for (auto const & leaf : access_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
for (auto const & leaf : prefix_list.getYLeafs())
{
if(is_set(leaf.yfilter))
return true;
}
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RouteSource::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "route-source";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RouteSource::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
auto access_list_name_datas = access_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), access_list_name_datas.begin(), access_list_name_datas.end());
auto prefix_list_name_datas = prefix_list.get_name_leafdata();
leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RouteSource::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RouteSource::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RouteSource::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list.append(value);
}
if(value_path == "prefix-list")
{
prefix_list.append(value);
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RouteSource::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ip::RouteSource::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Ipv6()
:
address(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Address>())
, flowspec(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec>())
, next_hop(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::NextHop>())
, route_source(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::RouteSource>())
{
address->parent = this;
flowspec->parent = this;
next_hop->parent = this;
route_source->parent = this;
yang_name = "ipv6"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::~Ipv6()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::has_data() const
{
if (is_presence_container) return true;
return (address != nullptr && address->has_data())
|| (flowspec != nullptr && flowspec->has_data())
|| (next_hop != nullptr && next_hop->has_data())
|| (route_source != nullptr && route_source->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::has_operation() const
{
return is_set(yfilter)
|| (address != nullptr && address->has_operation())
|| (flowspec != nullptr && flowspec->has_operation())
|| (next_hop != nullptr && next_hop->has_operation())
|| (route_source != nullptr && route_source->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "ipv6";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "address")
{
if(address == nullptr)
{
address = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Address>();
}
return address;
}
if(child_yang_name == "flowspec")
{
if(flowspec == nullptr)
{
flowspec = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec>();
}
return flowspec;
}
if(child_yang_name == "next-hop")
{
if(next_hop == nullptr)
{
next_hop = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::NextHop>();
}
return next_hop;
}
if(child_yang_name == "route-source")
{
if(route_source == nullptr)
{
route_source = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::RouteSource>();
}
return route_source;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(address != nullptr)
{
_children["address"] = address;
}
if(flowspec != nullptr)
{
_children["flowspec"] = flowspec;
}
if(next_hop != nullptr)
{
_children["next-hop"] = next_hop;
}
if(route_source != nullptr)
{
_children["route-source"] = route_source;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "address" || name == "flowspec" || name == "next-hop" || name == "route-source")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Address::Address()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "address"; yang_parent_name = "ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Address::~Address()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Address::has_data() const
{
if (is_presence_container) return true;
return access_list.is_set
|| prefix_list.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Address::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Address::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "address";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Address::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (access_list.is_set || is_set(access_list.yfilter)) leaf_name_data.push_back(access_list.get_name_leafdata());
if (prefix_list.is_set || is_set(prefix_list.yfilter)) leaf_name_data.push_back(prefix_list.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Address::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Address::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Address::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list = value;
access_list.value_namespace = name_space;
access_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-list")
{
prefix_list = value;
prefix_list.value_namespace = name_space;
prefix_list.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Address::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Address::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::Flowspec()
:
dest_pfx(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::DestPfx>())
, src_pfx(std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::SrcPfx>())
{
dest_pfx->parent = this;
src_pfx->parent = this;
yang_name = "flowspec"; yang_parent_name = "ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::~Flowspec()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::has_data() const
{
if (is_presence_container) return true;
return (dest_pfx != nullptr && dest_pfx->has_data())
|| (src_pfx != nullptr && src_pfx->has_data());
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::has_operation() const
{
return is_set(yfilter)
|| (dest_pfx != nullptr && dest_pfx->has_operation())
|| (src_pfx != nullptr && src_pfx->has_operation());
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "flowspec";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "dest-pfx")
{
if(dest_pfx == nullptr)
{
dest_pfx = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::DestPfx>();
}
return dest_pfx;
}
if(child_yang_name == "src-pfx")
{
if(src_pfx == nullptr)
{
src_pfx = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::SrcPfx>();
}
return src_pfx;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(dest_pfx != nullptr)
{
_children["dest-pfx"] = dest_pfx;
}
if(src_pfx != nullptr)
{
_children["src-pfx"] = src_pfx;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "dest-pfx" || name == "src-pfx")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::DestPfx::DestPfx()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "dest-pfx"; yang_parent_name = "flowspec"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::DestPfx::~DestPfx()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::DestPfx::has_data() const
{
if (is_presence_container) return true;
return access_list.is_set
|| prefix_list.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::DestPfx::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::DestPfx::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "dest-pfx";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::DestPfx::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (access_list.is_set || is_set(access_list.yfilter)) leaf_name_data.push_back(access_list.get_name_leafdata());
if (prefix_list.is_set || is_set(prefix_list.yfilter)) leaf_name_data.push_back(prefix_list.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::DestPfx::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::DestPfx::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::DestPfx::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list = value;
access_list.value_namespace = name_space;
access_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-list")
{
prefix_list = value;
prefix_list.value_namespace = name_space;
prefix_list.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::DestPfx::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::DestPfx::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::SrcPfx::SrcPfx()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "src-pfx"; yang_parent_name = "flowspec"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::SrcPfx::~SrcPfx()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::SrcPfx::has_data() const
{
if (is_presence_container) return true;
return access_list.is_set
|| prefix_list.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::SrcPfx::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::SrcPfx::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "src-pfx";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::SrcPfx::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (access_list.is_set || is_set(access_list.yfilter)) leaf_name_data.push_back(access_list.get_name_leafdata());
if (prefix_list.is_set || is_set(prefix_list.yfilter)) leaf_name_data.push_back(prefix_list.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::SrcPfx::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::SrcPfx::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::SrcPfx::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list = value;
access_list.value_namespace = name_space;
access_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-list")
{
prefix_list = value;
prefix_list.value_namespace = name_space;
prefix_list.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::SrcPfx::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::Flowspec::SrcPfx::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::NextHop::NextHop()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "next-hop"; yang_parent_name = "ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::NextHop::~NextHop()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::NextHop::has_data() const
{
if (is_presence_container) return true;
return access_list.is_set
|| prefix_list.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::NextHop::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::NextHop::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "next-hop";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::NextHop::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (access_list.is_set || is_set(access_list.yfilter)) leaf_name_data.push_back(access_list.get_name_leafdata());
if (prefix_list.is_set || is_set(prefix_list.yfilter)) leaf_name_data.push_back(prefix_list.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::NextHop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::NextHop::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::NextHop::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list = value;
access_list.value_namespace = name_space;
access_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-list")
{
prefix_list = value;
prefix_list.value_namespace = name_space;
prefix_list.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::NextHop::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::NextHop::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::RouteSource::RouteSource()
:
access_list{YType::str, "access-list"},
prefix_list{YType::str, "prefix-list"}
{
yang_name = "route-source"; yang_parent_name = "ipv6"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::RouteSource::~RouteSource()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::RouteSource::has_data() const
{
if (is_presence_container) return true;
return access_list.is_set
|| prefix_list.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::RouteSource::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(access_list.yfilter)
|| ydk::is_set(prefix_list.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::RouteSource::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "route-source";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::RouteSource::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (access_list.is_set || is_set(access_list.yfilter)) leaf_name_data.push_back(access_list.get_name_leafdata());
if (prefix_list.is_set || is_set(prefix_list.yfilter)) leaf_name_data.push_back(prefix_list.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::RouteSource::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::RouteSource::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::RouteSource::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "access-list")
{
access_list = value;
access_list.value_namespace = name_space;
access_list.value_namespace_prefix = name_space_prefix;
}
if(value_path == "prefix-list")
{
prefix_list = value;
prefix_list.value_namespace = name_space;
prefix_list.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::RouteSource::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "access-list")
{
access_list.yfilter = yfilter;
}
if(value_path == "prefix-list")
{
prefix_list.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Ipv6::RouteSource::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "access-list" || name == "prefix-list")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::Length()
:
lengths(this, {"min_len", "max_len"})
{
yang_name = "length"; yang_parent_name = "match"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::~Length()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::has_data() const
{
if (is_presence_container) return true;
for (std::size_t index=0; index<lengths.len(); index++)
{
if(lengths[index]->has_data())
return true;
}
return false;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::has_operation() const
{
for (std::size_t index=0; index<lengths.len(); index++)
{
if(lengths[index]->has_operation())
return true;
}
return is_set(yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "length";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "lengths")
{
auto ent_ = std::make_shared<Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::Lengths>();
ent_->parent = this;
lengths.append(ent_);
return ent_;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
count_ = 0;
for (auto ent_ : lengths.entities())
{
if(_children.find(ent_->get_segment_path()) == _children.end())
_children[ent_->get_segment_path()] = ent_;
else
_children[ent_->get_segment_path()+count_++] = ent_;
}
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::set_filter(const std::string & value_path, YFilter yfilter)
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "lengths")
return true;
return false;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::Lengths::Lengths()
:
min_len{YType::uint32, "min-len"},
max_len{YType::uint32, "max-len"}
{
yang_name = "lengths"; yang_parent_name = "length"; is_top_level_class = false; has_list_ancestor = true;
}
Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::Lengths::~Lengths()
{
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::Lengths::has_data() const
{
if (is_presence_container) return true;
return min_len.is_set
|| max_len.is_set;
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::Lengths::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(min_len.yfilter)
|| ydk::is_set(max_len.yfilter);
}
std::string Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::Lengths::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "lengths";
ADD_KEY_TOKEN(min_len, "min-len");
ADD_KEY_TOKEN(max_len, "max-len");
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::Lengths::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (min_len.is_set || is_set(min_len.yfilter)) leaf_name_data.push_back(min_len.get_name_leafdata());
if (max_len.is_set || is_set(max_len.yfilter)) leaf_name_data.push_back(max_len.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::Lengths::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::Lengths::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::Lengths::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "min-len")
{
min_len = value;
min_len.value_namespace = name_space;
min_len.value_namespace_prefix = name_space_prefix;
}
if(value_path == "max-len")
{
max_len = value;
max_len.value_namespace = name_space;
max_len.value_namespace_prefix = name_space_prefix;
}
}
void Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::Lengths::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "min-len")
{
min_len.yfilter = yfilter;
}
if(value_path == "max-len")
{
max_len.yfilter = yfilter;
}
}
bool Native::RouteMap::RouteMapWithoutOrderSeq::Match::Length::Lengths::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "min-len" || name == "max-len")
return true;
return false;
}
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Operation_::deny {0, "deny"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Operation_::permit {1, "permit"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::MetricType::external {0, "external"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::MetricType::internal {1, "internal"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::MetricType::type_1 {2, "type-1"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::MetricType::type_2 {3, "type-2"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Extcommunity::Rt::AsnNn::additive {0, "additive"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::PrecedenceFields::critical {0, "critical"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::PrecedenceFields::flash {1, "flash"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::PrecedenceFields::flash_override {2, "flash-override"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::PrecedenceFields::immediate {3, "immediate"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::PrecedenceFields::internet {4, "internet"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::PrecedenceFields::network {5, "network"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::PrecedenceFields::priority {6, "priority"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Precedence::PrecedenceFields::routine {7, "routine"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::TosFields::max_reliability {0, "max-reliability"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::TosFields::max_throughput {1, "max-throughput"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::TosFields::min_delay {2, "min-delay"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::TosFields::min_monetary_cost {3, "min-monetary-cost"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Ip::Tos::TosFields::normal {4, "normal"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin::OriginValue::igp {0, "igp"};
const Enum::YLeaf Native::RouteMap::RouteMapWithoutOrderSeq::Set::Origin::OriginValue::incomplete {1, "incomplete"};
}
}
| 32.336148 | 940 | 0.690074 | [
"vector"
] |
94c6c74320141dcaca8d6112714309286b5f36da | 135,036 | cpp | C++ | generated/MrubyCocos2dx.cpp | takeru/cocos2dx-mruby | 57eaabef05c80a57bfbdb308ff65f35f99a2022b | [
"MIT"
] | 3 | 2015-01-11T16:24:26.000Z | 2015-12-18T19:34:17.000Z | generated/MrubyCocos2dx.cpp | takeru/cocos2dx-mruby | 57eaabef05c80a57bfbdb308ff65f35f99a2022b | [
"MIT"
] | null | null | null | generated/MrubyCocos2dx.cpp | takeru/cocos2dx-mruby | 57eaabef05c80a57bfbdb308ff65f35f99a2022b | [
"MIT"
] | null | null | null | #include <string>
#include "cocos2d.h"
#include "SimpleAudioEngine.h"
#include "mruby/mruby.h"
#include "mruby/mruby/array.h"
extern int registerProc(mrb_state *mrb, mrb_value self, mrb_value proc);
using namespace cocos2d;
static CCSize* get_CCSize(mrb_state *mrb, mrb_value v);
static CCTouch* get_CCTouch(mrb_state *mrb, mrb_value v);
#include "mruby/mruby.h"
#include "mruby/mruby/class.h"
#include "mruby/mruby/data.h"
#include "mruby/mruby/string.h"
#include "mruby/mruby/variable.h"
#include <new>
#include <assert.h>
static bool get_bool(mrb_value x) {
return mrb_bool(x);
}
static int get_int(mrb_value x) {
if (mrb_fixnum_p(x)) {
return mrb_fixnum(x);
} else if (mrb_float_p(x)) {
return mrb_float(x);
} else {
return 0;
}
}
static float get_float(mrb_value x) {
if (mrb_fixnum_p(x)) {
return mrb_fixnum(x);
} else if (mrb_float_p(x)) {
return mrb_float(x);
} else {
return 0;
}
}
static struct RClass* getClass(mrb_state *mrb, const char* className) {
RClass* mod = mrb_module_get(mrb, "Cocos2dx");
return mrb_class_get_under(mrb, mod, className);
}
////////////////////////////////////////////////////////////////
// ccColor3B
static void _dfree_ccColor3B(mrb_state *mrb, void *ptr) {
((ccColor3B*)ptr)->~ccColor3B(); mrb_free(mrb, ptr);
}
static struct mrb_data_type _mrb_data_type_ccColor3B = { "ccColor3B", _dfree_ccColor3B };
mrb_value _wrap_ccColor3B(mrb_state *mrb, const ccColor3B* ptr) {
struct RClass* tc = getClass(mrb, "CcColor3B");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_ccColor3B, NULL));
DATA_TYPE(instance) = &_mrb_data_type_ccColor3B;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
ccColor3B* get_ccColor3B(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CcColor3B");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<ccColor3B*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is ccColor3B.");
return NULL;
}
}
static mrb_value ccColor3B_r(mrb_state *mrb, mrb_value self) {
ccColor3B* instance = static_cast<ccColor3B*>(DATA_PTR(self));
return mrb_fixnum_value(instance->r);
}
static mrb_value ccColor3B_set_r(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
ccColor3B* instance = static_cast<ccColor3B*>(DATA_PTR(self));
instance->r = get_int(o);
return mrb_nil_value();
}
static mrb_value ccColor3B_g(mrb_state *mrb, mrb_value self) {
ccColor3B* instance = static_cast<ccColor3B*>(DATA_PTR(self));
return mrb_fixnum_value(instance->g);
}
static mrb_value ccColor3B_set_g(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
ccColor3B* instance = static_cast<ccColor3B*>(DATA_PTR(self));
instance->g = get_int(o);
return mrb_nil_value();
}
static mrb_value ccColor3B_b(mrb_state *mrb, mrb_value self) {
ccColor3B* instance = static_cast<ccColor3B*>(DATA_PTR(self));
return mrb_fixnum_value(instance->b);
}
static mrb_value ccColor3B_set_b(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
ccColor3B* instance = static_cast<ccColor3B*>(DATA_PTR(self));
instance->b = get_int(o);
return mrb_nil_value();
}
static void installccColor3B(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = mrb->object_class;
struct RClass* tc = mrb_define_class_under(mrb, mod, "CcColor3B", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_method(mrb, tc, "r", ccColor3B_r, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "r=", ccColor3B_set_r, MRB_ARGS_REQ(1));
mrb_define_method(mrb, tc, "g", ccColor3B_g, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "g=", ccColor3B_set_g, MRB_ARGS_REQ(1));
mrb_define_method(mrb, tc, "b", ccColor3B_b, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "b=", ccColor3B_set_b, MRB_ARGS_REQ(1));
}
////////////////////////////////////////////////////////////////
// ccColor4F
static void _dfree_ccColor4F(mrb_state *mrb, void *ptr) {
((ccColor4F*)ptr)->~ccColor4F(); mrb_free(mrb, ptr);
}
static struct mrb_data_type _mrb_data_type_ccColor4F = { "ccColor4F", _dfree_ccColor4F };
mrb_value _wrap_ccColor4F(mrb_state *mrb, const ccColor4F* ptr) {
struct RClass* tc = getClass(mrb, "CcColor4F");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_ccColor4F, NULL));
DATA_TYPE(instance) = &_mrb_data_type_ccColor4F;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
ccColor4F* get_ccColor4F(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CcColor4F");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<ccColor4F*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is ccColor4F.");
return NULL;
}
}
static mrb_value ccColor4F_r(mrb_state *mrb, mrb_value self) {
ccColor4F* instance = static_cast<ccColor4F*>(DATA_PTR(self));
return mrb_float_value(mrb, instance->r);
}
static mrb_value ccColor4F_set_r(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
ccColor4F* instance = static_cast<ccColor4F*>(DATA_PTR(self));
instance->r = get_float(o);
return mrb_nil_value();
}
static mrb_value ccColor4F_g(mrb_state *mrb, mrb_value self) {
ccColor4F* instance = static_cast<ccColor4F*>(DATA_PTR(self));
return mrb_float_value(mrb, instance->g);
}
static mrb_value ccColor4F_set_g(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
ccColor4F* instance = static_cast<ccColor4F*>(DATA_PTR(self));
instance->g = get_float(o);
return mrb_nil_value();
}
static mrb_value ccColor4F_b(mrb_state *mrb, mrb_value self) {
ccColor4F* instance = static_cast<ccColor4F*>(DATA_PTR(self));
return mrb_float_value(mrb, instance->b);
}
static mrb_value ccColor4F_set_b(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
ccColor4F* instance = static_cast<ccColor4F*>(DATA_PTR(self));
instance->b = get_float(o);
return mrb_nil_value();
}
static mrb_value ccColor4F_a(mrb_state *mrb, mrb_value self) {
ccColor4F* instance = static_cast<ccColor4F*>(DATA_PTR(self));
return mrb_float_value(mrb, instance->a);
}
static mrb_value ccColor4F_set_a(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
ccColor4F* instance = static_cast<ccColor4F*>(DATA_PTR(self));
instance->a = get_float(o);
return mrb_nil_value();
}
static void installccColor4F(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = mrb->object_class;
struct RClass* tc = mrb_define_class_under(mrb, mod, "CcColor4F", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_method(mrb, tc, "r", ccColor4F_r, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "r=", ccColor4F_set_r, MRB_ARGS_REQ(1));
mrb_define_method(mrb, tc, "g", ccColor4F_g, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "g=", ccColor4F_set_g, MRB_ARGS_REQ(1));
mrb_define_method(mrb, tc, "b", ccColor4F_b, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "b=", ccColor4F_set_b, MRB_ARGS_REQ(1));
mrb_define_method(mrb, tc, "a", ccColor4F_a, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "a=", ccColor4F_set_a, MRB_ARGS_REQ(1));
}
////////////////////////////////////////////////////////////////
// ccBlendFunc
static void _dfree_ccBlendFunc(mrb_state *mrb, void *ptr) {
((ccBlendFunc*)ptr)->~ccBlendFunc(); mrb_free(mrb, ptr);
}
static struct mrb_data_type _mrb_data_type_ccBlendFunc = { "ccBlendFunc", _dfree_ccBlendFunc };
mrb_value _wrap_ccBlendFunc(mrb_state *mrb, const ccBlendFunc* ptr) {
struct RClass* tc = getClass(mrb, "CcBlendFunc");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_ccBlendFunc, NULL));
DATA_TYPE(instance) = &_mrb_data_type_ccBlendFunc;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
ccBlendFunc* get_ccBlendFunc(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CcBlendFunc");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<ccBlendFunc*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is ccBlendFunc.");
return NULL;
}
}
static mrb_value ccBlendFunc_src(mrb_state *mrb, mrb_value self) {
ccBlendFunc* instance = static_cast<ccBlendFunc*>(DATA_PTR(self));
return mrb_fixnum_value(instance->src);
}
static mrb_value ccBlendFunc_set_src(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
ccBlendFunc* instance = static_cast<ccBlendFunc*>(DATA_PTR(self));
instance->src = get_int(o);
return mrb_nil_value();
}
static mrb_value ccBlendFunc_dst(mrb_state *mrb, mrb_value self) {
ccBlendFunc* instance = static_cast<ccBlendFunc*>(DATA_PTR(self));
return mrb_fixnum_value(instance->dst);
}
static mrb_value ccBlendFunc_set_dst(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
ccBlendFunc* instance = static_cast<ccBlendFunc*>(DATA_PTR(self));
instance->dst = get_int(o);
return mrb_nil_value();
}
static void installccBlendFunc(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = mrb->object_class;
struct RClass* tc = mrb_define_class_under(mrb, mod, "CcBlendFunc", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_method(mrb, tc, "src", ccBlendFunc_src, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "src=", ccBlendFunc_set_src, MRB_ARGS_REQ(1));
mrb_define_method(mrb, tc, "dst", ccBlendFunc_dst, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "dst=", ccBlendFunc_set_dst, MRB_ARGS_REQ(1));
}
////////////////////////////////////////////////////////////////
// CCPoint
static void _dfree_CCPoint(mrb_state *mrb, void *ptr) {
((CCPoint*)ptr)->~CCPoint(); mrb_free(mrb, ptr);
}
static struct mrb_data_type _mrb_data_type_CCPoint = { "CCPoint", _dfree_CCPoint };
mrb_value _wrap_CCPoint(mrb_state *mrb, const CCPoint* ptr) {
struct RClass* tc = getClass(mrb, "CCPoint");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCPoint, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCPoint;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCPoint* get_CCPoint(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCPoint");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCPoint*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCPoint.");
return NULL;
}
}
static mrb_value CCPoint___ctor(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 0) {
CCPoint* retval = new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint();
DATA_TYPE(self) = &_mrb_data_type_CCPoint; DATA_PTR(self) = retval; return self;
} else if (arg_count == 2) {
float p0 = get_float(args[0]);
float p1 = get_float(args[1]);
CCPoint* retval = new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(p0, p1);
DATA_TYPE(self) = &_mrb_data_type_CCPoint; DATA_PTR(self) = retval; return self;
} else if (arg_count == 1) {
const CCPoint& p0 = *get_CCPoint(mrb, args[0]);
CCPoint* retval = new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(p0);
DATA_TYPE(self) = &_mrb_data_type_CCPoint; DATA_PTR(self) = retval; return self;
} else if (arg_count == 1) {
const CCSize& p0 = *get_CCSize(mrb, args[0]);
CCPoint* retval = new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(p0);
DATA_TYPE(self) = &_mrb_data_type_CCPoint; DATA_PTR(self) = retval; return self;
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCPoint#__ctor Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCPoint_x(mrb_state *mrb, mrb_value self) {
CCPoint* instance = static_cast<CCPoint*>(DATA_PTR(self));
return mrb_float_value(mrb, instance->x);
}
static mrb_value CCPoint_set_x(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
CCPoint* instance = static_cast<CCPoint*>(DATA_PTR(self));
instance->x = get_float(o);
return mrb_nil_value();
}
static mrb_value CCPoint_y(mrb_state *mrb, mrb_value self) {
CCPoint* instance = static_cast<CCPoint*>(DATA_PTR(self));
return mrb_float_value(mrb, instance->y);
}
static mrb_value CCPoint_set_y(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
CCPoint* instance = static_cast<CCPoint*>(DATA_PTR(self));
instance->y = get_float(o);
return mrb_nil_value();
}
static void installCCPoint(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = mrb->object_class;
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCPoint", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_method(mrb, tc, "initialize", CCPoint___ctor, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "x", CCPoint_x, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "x=", CCPoint_set_x, MRB_ARGS_REQ(1));
mrb_define_method(mrb, tc, "y", CCPoint_y, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "y=", CCPoint_set_y, MRB_ARGS_REQ(1));
}
////////////////////////////////////////////////////////////////
// CCSize
static void _dfree_CCSize(mrb_state *mrb, void *ptr) {
((CCSize*)ptr)->~CCSize(); mrb_free(mrb, ptr);
}
static struct mrb_data_type _mrb_data_type_CCSize = { "CCSize", _dfree_CCSize };
mrb_value _wrap_CCSize(mrb_state *mrb, const CCSize* ptr) {
struct RClass* tc = getClass(mrb, "CCSize");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCSize, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCSize;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCSize* get_CCSize(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCSize");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCSize*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCSize.");
return NULL;
}
}
static mrb_value CCSize___ctor(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 0) {
CCSize* retval = new(mrb_malloc(mrb, sizeof(CCSize))) CCSize();
DATA_TYPE(self) = &_mrb_data_type_CCSize; DATA_PTR(self) = retval; return self;
} else if (arg_count == 2) {
float p0 = get_float(args[0]);
float p1 = get_float(args[1]);
CCSize* retval = new(mrb_malloc(mrb, sizeof(CCSize))) CCSize(p0, p1);
DATA_TYPE(self) = &_mrb_data_type_CCSize; DATA_PTR(self) = retval; return self;
} else if (arg_count == 1) {
const CCPoint& p0 = *get_CCPoint(mrb, args[0]);
CCSize* retval = new(mrb_malloc(mrb, sizeof(CCSize))) CCSize(p0);
DATA_TYPE(self) = &_mrb_data_type_CCSize; DATA_PTR(self) = retval; return self;
} else if (arg_count == 1) {
const CCSize& p0 = *get_CCSize(mrb, args[0]);
CCSize* retval = new(mrb_malloc(mrb, sizeof(CCSize))) CCSize(p0);
DATA_TYPE(self) = &_mrb_data_type_CCSize; DATA_PTR(self) = retval; return self;
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCSize#__ctor Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCSize_width(mrb_state *mrb, mrb_value self) {
CCSize* instance = static_cast<CCSize*>(DATA_PTR(self));
return mrb_float_value(mrb, instance->width);
}
static mrb_value CCSize_set_width(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
CCSize* instance = static_cast<CCSize*>(DATA_PTR(self));
instance->width = get_float(o);
return mrb_nil_value();
}
static mrb_value CCSize_height(mrb_state *mrb, mrb_value self) {
CCSize* instance = static_cast<CCSize*>(DATA_PTR(self));
return mrb_float_value(mrb, instance->height);
}
static mrb_value CCSize_set_height(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
CCSize* instance = static_cast<CCSize*>(DATA_PTR(self));
instance->height = get_float(o);
return mrb_nil_value();
}
static void installCCSize(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = mrb->object_class;
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCSize", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_method(mrb, tc, "initialize", CCSize___ctor, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "width", CCSize_width, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "width=", CCSize_set_width, MRB_ARGS_REQ(1));
mrb_define_method(mrb, tc, "height", CCSize_height, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "height=", CCSize_set_height, MRB_ARGS_REQ(1));
}
////////////////////////////////////////////////////////////////
// CCRect
static void _dfree_CCRect(mrb_state *mrb, void *ptr) {
((CCRect*)ptr)->~CCRect(); mrb_free(mrb, ptr);
}
static struct mrb_data_type _mrb_data_type_CCRect = { "CCRect", _dfree_CCRect };
mrb_value _wrap_CCRect(mrb_state *mrb, const CCRect* ptr) {
struct RClass* tc = getClass(mrb, "CCRect");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCRect, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCRect;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCRect* get_CCRect(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCRect");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCRect*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCRect.");
return NULL;
}
}
static mrb_value CCRect___ctor(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 0) {
CCRect* retval = new(mrb_malloc(mrb, sizeof(CCRect))) CCRect();
DATA_TYPE(self) = &_mrb_data_type_CCRect; DATA_PTR(self) = retval; return self;
} else if (arg_count == 4) {
float p0 = get_float(args[0]);
float p1 = get_float(args[1]);
float p2 = get_float(args[2]);
float p3 = get_float(args[3]);
CCRect* retval = new(mrb_malloc(mrb, sizeof(CCRect))) CCRect(p0, p1, p2, p3);
DATA_TYPE(self) = &_mrb_data_type_CCRect; DATA_PTR(self) = retval; return self;
} else if (arg_count == 1) {
const CCRect& p0 = *get_CCRect(mrb, args[0]);
CCRect* retval = new(mrb_malloc(mrb, sizeof(CCRect))) CCRect(p0);
DATA_TYPE(self) = &_mrb_data_type_CCRect; DATA_PTR(self) = retval; return self;
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCRect#__ctor Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCRect_origin(mrb_state *mrb, mrb_value self) {
CCRect* instance = static_cast<CCRect*>(DATA_PTR(self));
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(instance->origin));
}
static mrb_value CCRect_set_origin(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
CCRect* instance = static_cast<CCRect*>(DATA_PTR(self));
instance->origin = *get_CCPoint(mrb, o);
return mrb_nil_value();
}
static mrb_value CCRect_size(mrb_state *mrb, mrb_value self) {
CCRect* instance = static_cast<CCRect*>(DATA_PTR(self));
return _wrap_CCSize(mrb, new(mrb_malloc(mrb, sizeof(CCSize))) CCSize(instance->size));
}
static mrb_value CCRect_set_size(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
CCRect* instance = static_cast<CCRect*>(DATA_PTR(self));
instance->size = *get_CCSize(mrb, o);
return mrb_nil_value();
}
static mrb_value CCRect_containsPoint(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const CCPoint& p0 = *get_CCPoint(mrb, args[0]);
CCRect* instance = static_cast<CCRect*>(DATA_PTR(self));
bool retval = instance->containsPoint(p0);
return mrb_bool_value(retval);
}
static mrb_value CCRect_intersectsRect(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const CCRect& p0 = *get_CCRect(mrb, args[0]);
CCRect* instance = static_cast<CCRect*>(DATA_PTR(self));
bool retval = instance->intersectsRect(p0);
return mrb_bool_value(retval);
}
static void installCCRect(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = mrb->object_class;
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCRect", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_method(mrb, tc, "initialize", CCRect___ctor, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "origin", CCRect_origin, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "origin=", CCRect_set_origin, MRB_ARGS_REQ(1));
mrb_define_method(mrb, tc, "size", CCRect_size, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "size=", CCRect_set_size, MRB_ARGS_REQ(1));
mrb_define_method(mrb, tc, "containsPoint", CCRect_containsPoint, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "intersectsRect", CCRect_intersectsRect, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCObject
static void _dfree_CCObject(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCObject = { "CCObject", _dfree_CCObject };
mrb_value _wrap_CCObject(mrb_state *mrb, const CCObject* ptr) {
struct RClass* tc = getClass(mrb, "CCObject");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCObject, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCObject;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCObject* get_CCObject(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCObject");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCObject*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCObject.");
return NULL;
}
}
static mrb_value CCObject_release(mrb_state *mrb, mrb_value self) {
CCObject* instance = static_cast<CCObject*>(DATA_PTR(self));
instance->release();
return mrb_nil_value();
}
static mrb_value CCObject_autorelease(mrb_state *mrb, mrb_value self) {
CCObject* instance = static_cast<CCObject*>(DATA_PTR(self));
CCObject* retval = instance->autorelease();
return (retval == NULL ? mrb_nil_value() : _wrap_CCObject(mrb, retval));
}
static mrb_value CCObject_retainCount(mrb_state *mrb, mrb_value self) {
CCObject* instance = static_cast<CCObject*>(DATA_PTR(self));
unsigned int retval = instance->retainCount();
return mrb_fixnum_value(retval);
}
static mrb_value CCObject_m_nLuaID(mrb_state *mrb, mrb_value self) {
CCObject* instance = static_cast<CCObject*>(DATA_PTR(self));
return mrb_fixnum_value(instance->m_nLuaID);
}
static mrb_value CCObject_set_m_nLuaID(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
CCObject* instance = static_cast<CCObject*>(DATA_PTR(self));
instance->m_nLuaID = get_int(o);
return mrb_nil_value();
}
static mrb_value CCObject_m_uID(mrb_state *mrb, mrb_value self) {
CCObject* instance = static_cast<CCObject*>(DATA_PTR(self));
return mrb_fixnum_value(instance->m_uID);
}
static mrb_value CCObject_set_m_uID(mrb_state *mrb, mrb_value self) {
mrb_value o;
mrb_get_args(mrb, "o", &o);
CCObject* instance = static_cast<CCObject*>(DATA_PTR(self));
instance->m_uID = get_int(o);
return mrb_nil_value();
}
static void installCCObject(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = mrb->object_class;
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCObject", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_method(mrb, tc, "release", CCObject_release, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "autorelease", CCObject_autorelease, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "retainCount", CCObject_retainCount, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "m_nLuaID", CCObject_m_nLuaID, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "m_nLuaID=", CCObject_set_m_nLuaID, MRB_ARGS_REQ(1));
mrb_define_method(mrb, tc, "m_uID", CCObject_m_uID, MRB_ARGS_NONE());
mrb_define_method(mrb, tc, "m_uID=", CCObject_set_m_uID, MRB_ARGS_REQ(1));
}
////////////////////////////////////////////////////////////////
// CCArray
static void _dfree_CCArray(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCArray = { "CCArray", _dfree_CCArray };
mrb_value _wrap_CCArray(mrb_state *mrb, const CCArray* ptr) {
struct RClass* tc = getClass(mrb, "CCArray");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCArray, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCArray;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCArray* get_CCArray(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCArray");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCArray*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCArray.");
return NULL;
}
}
static mrb_value CCArray_create(mrb_state *mrb, mrb_value self) {
CCArray* retval = CCArray::create();
return (retval == NULL ? mrb_nil_value() : _wrap_CCArray(mrb, retval));
}
static mrb_value CCArray_addObject(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCObject* p0 = get_CCObject(mrb, args[0]);
CCArray* instance = static_cast<CCArray*>(DATA_PTR(self));
instance->addObject(p0);
return mrb_nil_value();
}
static void installCCArray(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCObject");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCArray", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCArray_create, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "addObject", CCArray_addObject, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCAction
static void _dfree_CCAction(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCAction = { "CCAction", _dfree_CCAction };
mrb_value _wrap_CCAction(mrb_state *mrb, const CCAction* ptr) {
struct RClass* tc = getClass(mrb, "CCAction");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCAction, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCAction;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCAction* get_CCAction(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCAction");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCAction*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCAction.");
return NULL;
}
}
static void installCCAction(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCObject");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCAction", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
}
////////////////////////////////////////////////////////////////
// CCFiniteTimeAction
static void _dfree_CCFiniteTimeAction(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCFiniteTimeAction = { "CCFiniteTimeAction", _dfree_CCFiniteTimeAction };
mrb_value _wrap_CCFiniteTimeAction(mrb_state *mrb, const CCFiniteTimeAction* ptr) {
struct RClass* tc = getClass(mrb, "CCFiniteTimeAction");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCFiniteTimeAction, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCFiniteTimeAction;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCFiniteTimeAction* get_CCFiniteTimeAction(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCFiniteTimeAction");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCFiniteTimeAction*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCFiniteTimeAction.");
return NULL;
}
}
static void installCCFiniteTimeAction(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCAction");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCFiniteTimeAction", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
}
////////////////////////////////////////////////////////////////
// CCActionInterval
static void _dfree_CCActionInterval(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCActionInterval = { "CCActionInterval", _dfree_CCActionInterval };
mrb_value _wrap_CCActionInterval(mrb_state *mrb, const CCActionInterval* ptr) {
struct RClass* tc = getClass(mrb, "CCActionInterval");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCActionInterval, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCActionInterval;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCActionInterval* get_CCActionInterval(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCActionInterval");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCActionInterval*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCActionInterval.");
return NULL;
}
}
static void installCCActionInterval(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCFiniteTimeAction");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCActionInterval", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
}
////////////////////////////////////////////////////////////////
// CCActionInstant
static void _dfree_CCActionInstant(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCActionInstant = { "CCActionInstant", _dfree_CCActionInstant };
mrb_value _wrap_CCActionInstant(mrb_state *mrb, const CCActionInstant* ptr) {
struct RClass* tc = getClass(mrb, "CCActionInstant");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCActionInstant, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCActionInstant;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCActionInstant* get_CCActionInstant(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCActionInstant");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCActionInstant*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCActionInstant.");
return NULL;
}
}
static void installCCActionInstant(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCFiniteTimeAction");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCActionInstant", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
}
////////////////////////////////////////////////////////////////
// CCNode
static void _dfree_CCNode(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCNode = { "CCNode", _dfree_CCNode };
mrb_value _wrap_CCNode(mrb_state *mrb, const CCNode* ptr) {
struct RClass* tc = getClass(mrb, "CCNode");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCNode, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCNode;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCNode* get_CCNode(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCNode");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCNode*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCNode.");
return NULL;
}
}
static mrb_value CCNode_setPosition(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 1) {
const CCPoint& p0 = *get_CCPoint(mrb, args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->setPosition(p0);
return mrb_nil_value();
} else if (arg_count == 2) {
float p0 = get_float(args[0]);
float p1 = get_float(args[1]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->setPosition(p0, p1);
return mrb_nil_value();
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCNode#setPosition Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCNode_setPositionX(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->setPositionX(p0);
return mrb_nil_value();
}
static mrb_value CCNode_getPositionX(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
float retval = instance->getPositionX();
return mrb_float_value(mrb, retval);
}
static mrb_value CCNode_setPositionY(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->setPositionY(p0);
return mrb_nil_value();
}
static mrb_value CCNode_getPositionY(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
float retval = instance->getPositionY();
return mrb_float_value(mrb, retval);
}
static mrb_value CCNode_getPosition(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
const CCPoint& retval = instance->getPosition();
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCNode_setRotation(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->setRotation(p0);
return mrb_nil_value();
}
static mrb_value CCNode_getRotation(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
float retval = instance->getRotation();
return mrb_float_value(mrb, retval);
}
static mrb_value CCNode_setAnchorPoint(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const CCPoint& p0 = *get_CCPoint(mrb, args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->setAnchorPoint(p0);
return mrb_nil_value();
}
static mrb_value CCNode_getAnchorPoint(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
const CCPoint& retval = instance->getAnchorPoint();
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCNode_setScale(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->setScale(p0);
return mrb_nil_value();
}
static mrb_value CCNode_getScale(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
float retval = instance->getScale();
return mrb_float_value(mrb, retval);
}
static mrb_value CCNode_addChild(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 1) {
CCNode* p0 = get_CCNode(mrb, args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->addChild(p0);
return mrb_nil_value();
} else if (arg_count == 2) {
CCNode* p0 = get_CCNode(mrb, args[0]);
int p1 = get_int(args[1]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->addChild(p0, p1);
return mrb_nil_value();
} else if (arg_count == 3) {
CCNode* p0 = get_CCNode(mrb, args[0]);
int p1 = get_int(args[1]);
int p2 = get_int(args[2]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->addChild(p0, p1, p2);
return mrb_nil_value();
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCNode#addChild Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCNode_getChildByTag(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
int p0 = get_int(args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
CCNode* retval = instance->getChildByTag(p0);
return (retval == NULL ? mrb_nil_value() : _wrap_CCNode(mrb, retval));
}
static mrb_value CCNode_runAction(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCAction* p0 = get_CCAction(mrb, args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->runAction(p0);
return mrb_nil_value();
}
static mrb_value CCNode_getContentSize(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
const CCSize& retval = instance->getContentSize();
return _wrap_CCSize(mrb, new(mrb_malloc(mrb, sizeof(CCSize))) CCSize(retval));
}
static mrb_value CCNode_setContentSize(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const CCSize& p0 = *get_CCSize(mrb, args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->setContentSize(p0);
return mrb_nil_value();
}
static mrb_value CCNode_setVisible(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
bool p0 = get_bool(args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->setVisible(p0);
return mrb_nil_value();
}
static mrb_value CCNode_scheduleUpdate(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->scheduleUpdate();
return mrb_nil_value();
}
static mrb_value CCNode_scheduleUpdateWithPriorityLua(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_value block;
mrb_get_args(mrb, "*&", &args, &arg_count, &block);
int blockHandler = registerProc(mrb, self, block);
int p0 = get_int(args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->scheduleUpdateWithPriorityLua(blockHandler, p0);
return mrb_nil_value();
}
static mrb_value CCNode_boundingBox(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
CCRect retval = instance->boundingBox();
return _wrap_CCRect(mrb, new(mrb_malloc(mrb, sizeof(CCRect))) CCRect(retval));
}
static mrb_value CCNode_convertTouchToNodeSpace(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCTouch* p0 = get_CCTouch(mrb, args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
CCPoint retval = instance->convertTouchToNodeSpace(p0);
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCNode_convertToNodeSpace(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const CCPoint& p0 = *get_CCPoint(mrb, args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
CCPoint retval = instance->convertToNodeSpace(p0);
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCNode_getTag(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
int retval = instance->getTag();
return mrb_fixnum_value(retval);
}
static mrb_value CCNode_setTag(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
int p0 = get_int(args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->setTag(p0);
return mrb_nil_value();
}
static mrb_value CCNode_getZOrder(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
int retval = instance->getZOrder();
return mrb_fixnum_value(retval);
}
static mrb_value CCNode_setZOrder(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
int p0 = get_int(args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->setZOrder(p0);
return mrb_nil_value();
}
static mrb_value CCNode_getUserObject(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
CCObject* retval = instance->getUserObject();
return (retval == NULL ? mrb_nil_value() : _wrap_CCObject(mrb, retval));
}
static mrb_value CCNode_setUserObject(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCObject* p0 = get_CCObject(mrb, args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->setUserObject(p0);
return mrb_nil_value();
}
static mrb_value CCNode_removeFromParentAndCleanup(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
bool p0 = get_bool(args[0]);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->removeFromParentAndCleanup(p0);
return mrb_nil_value();
}
static mrb_value CCNode_registerScriptHandler(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_value block;
mrb_get_args(mrb, "*&", &args, &arg_count, &block);
int blockHandler = registerProc(mrb, self, block);
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->registerScriptHandler(blockHandler);
return mrb_nil_value();
}
static mrb_value CCNode_unregisterScriptHandler(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
instance->unregisterScriptHandler();
return mrb_nil_value();
}
static mrb_value CCNode_getScriptHandler(mrb_state *mrb, mrb_value self) {
CCNode* instance = static_cast<CCNode*>(DATA_PTR(self));
int retval = instance->getScriptHandler();
return mrb_fixnum_value(retval);
}
static void installCCNode(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCObject");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCNode", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_method(mrb, tc, "setPosition", CCNode_setPosition, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setPositionX", CCNode_setPositionX, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getPositionX", CCNode_getPositionX, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setPositionY", CCNode_setPositionY, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getPositionY", CCNode_getPositionY, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getPosition", CCNode_getPosition, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setRotation", CCNode_setRotation, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getRotation", CCNode_getRotation, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setAnchorPoint", CCNode_setAnchorPoint, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getAnchorPoint", CCNode_getAnchorPoint, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setScale", CCNode_setScale, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getScale", CCNode_getScale, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "addChild", CCNode_addChild, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getChildByTag", CCNode_getChildByTag, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "runAction", CCNode_runAction, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getContentSize", CCNode_getContentSize, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setContentSize", CCNode_setContentSize, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setVisible", CCNode_setVisible, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "scheduleUpdate", CCNode_scheduleUpdate, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "scheduleUpdateWithPriorityLua", CCNode_scheduleUpdateWithPriorityLua, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "boundingBox", CCNode_boundingBox, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "convertTouchToNodeSpace", CCNode_convertTouchToNodeSpace, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "convertToNodeSpace", CCNode_convertToNodeSpace, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getTag", CCNode_getTag, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setTag", CCNode_setTag, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getZOrder", CCNode_getZOrder, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setZOrder", CCNode_setZOrder, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getUserObject", CCNode_getUserObject, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setUserObject", CCNode_setUserObject, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "removeFromParentAndCleanup", CCNode_removeFromParentAndCleanup, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "registerScriptHandler", CCNode_registerScriptHandler, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "unregisterScriptHandler", CCNode_unregisterScriptHandler, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getScriptHandler", CCNode_getScriptHandler, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCNodeRGBA
static void _dfree_CCNodeRGBA(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCNodeRGBA = { "CCNodeRGBA", _dfree_CCNodeRGBA };
mrb_value _wrap_CCNodeRGBA(mrb_state *mrb, const CCNodeRGBA* ptr) {
struct RClass* tc = getClass(mrb, "CCNodeRGBA");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCNodeRGBA, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCNodeRGBA;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCNodeRGBA* get_CCNodeRGBA(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCNodeRGBA");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCNodeRGBA*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCNodeRGBA.");
return NULL;
}
}
static mrb_value CCNodeRGBA_setColor(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const ccColor3B& p0 = *get_ccColor3B(mrb, args[0]);
CCNodeRGBA* instance = static_cast<CCNodeRGBA*>(DATA_PTR(self));
instance->setColor(p0);
return mrb_nil_value();
}
static void installCCNodeRGBA(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCNode");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCNodeRGBA", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_method(mrb, tc, "setColor", CCNodeRGBA_setColor, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCTexture2D
static void _dfree_CCTexture2D(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCTexture2D = { "CCTexture2D", _dfree_CCTexture2D };
mrb_value _wrap_CCTexture2D(mrb_state *mrb, const CCTexture2D* ptr) {
struct RClass* tc = getClass(mrb, "CCTexture2D");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCTexture2D, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCTexture2D;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCTexture2D* get_CCTexture2D(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCTexture2D");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCTexture2D*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCTexture2D.");
return NULL;
}
}
static void installCCTexture2D(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCObject");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCTexture2D", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
}
////////////////////////////////////////////////////////////////
// CCTextureCache
static void _dfree_CCTextureCache(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCTextureCache = { "CCTextureCache", _dfree_CCTextureCache };
mrb_value _wrap_CCTextureCache(mrb_state *mrb, const CCTextureCache* ptr) {
struct RClass* tc = getClass(mrb, "CCTextureCache");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCTextureCache, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCTextureCache;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCTextureCache* get_CCTextureCache(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCTextureCache");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCTextureCache*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCTextureCache.");
return NULL;
}
}
static mrb_value CCTextureCache_sharedTextureCache(mrb_state *mrb, mrb_value self) {
CCTextureCache* retval = CCTextureCache::sharedTextureCache();
return (retval == NULL ? mrb_nil_value() : _wrap_CCTextureCache(mrb, retval));
}
static mrb_value CCTextureCache_addImage(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
CCTextureCache* instance = static_cast<CCTextureCache*>(DATA_PTR(self));
CCTexture2D* retval = instance->addImage(p0);
return (retval == NULL ? mrb_nil_value() : _wrap_CCTexture2D(mrb, retval));
}
static mrb_value CCTextureCache_removeAllTextures(mrb_state *mrb, mrb_value self) {
CCTextureCache* instance = static_cast<CCTextureCache*>(DATA_PTR(self));
instance->removeAllTextures();
return mrb_nil_value();
}
static void installCCTextureCache(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCObject");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCTextureCache", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "sharedTextureCache", CCTextureCache_sharedTextureCache, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "addImage", CCTextureCache_addImage, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "removeAllTextures", CCTextureCache_removeAllTextures, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCSpriteFrame
static void _dfree_CCSpriteFrame(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCSpriteFrame = { "CCSpriteFrame", _dfree_CCSpriteFrame };
mrb_value _wrap_CCSpriteFrame(mrb_state *mrb, const CCSpriteFrame* ptr) {
struct RClass* tc = getClass(mrb, "CCSpriteFrame");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCSpriteFrame, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCSpriteFrame;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCSpriteFrame* get_CCSpriteFrame(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCSpriteFrame");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCSpriteFrame*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCSpriteFrame.");
return NULL;
}
}
static mrb_value CCSpriteFrame_create(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
const CCRect& p1 = *get_CCRect(mrb, args[1]);
CCSpriteFrame* retval = CCSpriteFrame::create(p0, p1);
return (retval == NULL ? mrb_nil_value() : _wrap_CCSpriteFrame(mrb, retval));
}
static mrb_value CCSpriteFrame_createWithTexture(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCTexture2D* p0 = get_CCTexture2D(mrb, args[0]);
const CCRect& p1 = *get_CCRect(mrb, args[1]);
CCSpriteFrame* retval = CCSpriteFrame::createWithTexture(p0, p1);
return (retval == NULL ? mrb_nil_value() : _wrap_CCSpriteFrame(mrb, retval));
}
static void installCCSpriteFrame(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCObject");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCSpriteFrame", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCSpriteFrame_create, MRB_ARGS_ANY());
mrb_define_class_method(mrb, tc, "createWithTexture", CCSpriteFrame_createWithTexture, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCAnimation
static void _dfree_CCAnimation(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCAnimation = { "CCAnimation", _dfree_CCAnimation };
mrb_value _wrap_CCAnimation(mrb_state *mrb, const CCAnimation* ptr) {
struct RClass* tc = getClass(mrb, "CCAnimation");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCAnimation, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCAnimation;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCAnimation* get_CCAnimation(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCAnimation");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCAnimation*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCAnimation.");
return NULL;
}
}
static mrb_value CCAnimation_createWithSpriteFrames(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCArray* p0 = get_CCArray(mrb, args[0]);
float p1 = get_float(args[1]);
CCAnimation* retval = CCAnimation::createWithSpriteFrames(p0, p1);
return (retval == NULL ? mrb_nil_value() : _wrap_CCAnimation(mrb, retval));
}
static void installCCAnimation(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCObject");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCAnimation", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "createWithSpriteFrames", CCAnimation_createWithSpriteFrames, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCAnimate
static void _dfree_CCAnimate(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCAnimate = { "CCAnimate", _dfree_CCAnimate };
mrb_value _wrap_CCAnimate(mrb_state *mrb, const CCAnimate* ptr) {
struct RClass* tc = getClass(mrb, "CCAnimate");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCAnimate, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCAnimate;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCAnimate* get_CCAnimate(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCAnimate");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCAnimate*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCAnimate.");
return NULL;
}
}
static mrb_value CCAnimate_create(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCAnimation* p0 = get_CCAnimation(mrb, args[0]);
CCAnimate* retval = CCAnimate::create(p0);
return (retval == NULL ? mrb_nil_value() : _wrap_CCAnimate(mrb, retval));
}
static void installCCAnimate(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCActionInterval");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCAnimate", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCAnimate_create, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCRepeatForever
static void _dfree_CCRepeatForever(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCRepeatForever = { "CCRepeatForever", _dfree_CCRepeatForever };
mrb_value _wrap_CCRepeatForever(mrb_state *mrb, const CCRepeatForever* ptr) {
struct RClass* tc = getClass(mrb, "CCRepeatForever");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCRepeatForever, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCRepeatForever;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCRepeatForever* get_CCRepeatForever(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCRepeatForever");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCRepeatForever*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCRepeatForever.");
return NULL;
}
}
static mrb_value CCRepeatForever_create(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCActionInterval* p0 = get_CCActionInterval(mrb, args[0]);
CCRepeatForever* retval = CCRepeatForever::create(p0);
return (retval == NULL ? mrb_nil_value() : _wrap_CCRepeatForever(mrb, retval));
}
static void installCCRepeatForever(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCActionInterval");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCRepeatForever", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCRepeatForever_create, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCScaleTo
static void _dfree_CCScaleTo(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCScaleTo = { "CCScaleTo", _dfree_CCScaleTo };
mrb_value _wrap_CCScaleTo(mrb_state *mrb, const CCScaleTo* ptr) {
struct RClass* tc = getClass(mrb, "CCScaleTo");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCScaleTo, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCScaleTo;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCScaleTo* get_CCScaleTo(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCScaleTo");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCScaleTo*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCScaleTo.");
return NULL;
}
}
static mrb_value CCScaleTo_create(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
float p1 = get_float(args[1]);
CCScaleTo* retval = CCScaleTo::create(p0, p1);
return (retval == NULL ? mrb_nil_value() : _wrap_CCScaleTo(mrb, retval));
}
static void installCCScaleTo(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCActionInterval");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCScaleTo", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCScaleTo_create, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCMoveBy
static void _dfree_CCMoveBy(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCMoveBy = { "CCMoveBy", _dfree_CCMoveBy };
mrb_value _wrap_CCMoveBy(mrb_state *mrb, const CCMoveBy* ptr) {
struct RClass* tc = getClass(mrb, "CCMoveBy");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCMoveBy, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCMoveBy;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCMoveBy* get_CCMoveBy(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCMoveBy");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCMoveBy*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCMoveBy.");
return NULL;
}
}
static mrb_value CCMoveBy_create(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
const CCPoint& p1 = *get_CCPoint(mrb, args[1]);
CCMoveBy* retval = CCMoveBy::create(p0, p1);
return (retval == NULL ? mrb_nil_value() : _wrap_CCMoveBy(mrb, retval));
}
static void installCCMoveBy(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCActionInterval");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCMoveBy", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCMoveBy_create, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCMoveTo
static void _dfree_CCMoveTo(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCMoveTo = { "CCMoveTo", _dfree_CCMoveTo };
mrb_value _wrap_CCMoveTo(mrb_state *mrb, const CCMoveTo* ptr) {
struct RClass* tc = getClass(mrb, "CCMoveTo");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCMoveTo, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCMoveTo;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCMoveTo* get_CCMoveTo(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCMoveTo");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCMoveTo*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCMoveTo.");
return NULL;
}
}
static mrb_value CCMoveTo_create(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
const CCPoint& p1 = *get_CCPoint(mrb, args[1]);
CCMoveTo* retval = CCMoveTo::create(p0, p1);
return (retval == NULL ? mrb_nil_value() : _wrap_CCMoveTo(mrb, retval));
}
static void installCCMoveTo(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCMoveBy");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCMoveTo", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCMoveTo_create, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCCallFunc
static void _dfree_CCCallFunc(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCCallFunc = { "CCCallFunc", _dfree_CCCallFunc };
mrb_value _wrap_CCCallFunc(mrb_state *mrb, const CCCallFunc* ptr) {
struct RClass* tc = getClass(mrb, "CCCallFunc");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCCallFunc, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCCallFunc;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCCallFunc* get_CCCallFunc(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCCallFunc");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCCallFunc*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCCallFunc.");
return NULL;
}
}
static mrb_value CCCallFunc_create(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_value block;
mrb_get_args(mrb, "*&", &args, &arg_count, &block);
int blockHandler = registerProc(mrb, self, block);
CCCallFunc* retval = CCCallFunc::create(blockHandler);
return (retval == NULL ? mrb_nil_value() : _wrap_CCCallFunc(mrb, retval));
}
static void installCCCallFunc(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCActionInstant");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCCallFunc", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCCallFunc_create, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCSequence
static void _dfree_CCSequence(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCSequence = { "CCSequence", _dfree_CCSequence };
mrb_value _wrap_CCSequence(mrb_state *mrb, const CCSequence* ptr) {
struct RClass* tc = getClass(mrb, "CCSequence");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCSequence, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCSequence;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCSequence* get_CCSequence(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCSequence");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCSequence*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCSequence.");
return NULL;
}
}
static mrb_value CCSequence_createWithTwoActions(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCFiniteTimeAction* p0 = get_CCFiniteTimeAction(mrb, args[0]);
CCFiniteTimeAction* p1 = get_CCFiniteTimeAction(mrb, args[1]);
CCActionInterval* retval = CCSequence::createWithTwoActions(p0, p1);
return (retval == NULL ? mrb_nil_value() : _wrap_CCActionInterval(mrb, retval));
}
static void installCCSequence(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCActionInterval");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCSequence", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "createWithTwoActions", CCSequence_createWithTwoActions, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCSpawn
static void _dfree_CCSpawn(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCSpawn = { "CCSpawn", _dfree_CCSpawn };
mrb_value _wrap_CCSpawn(mrb_state *mrb, const CCSpawn* ptr) {
struct RClass* tc = getClass(mrb, "CCSpawn");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCSpawn, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCSpawn;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCSpawn* get_CCSpawn(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCSpawn");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCSpawn*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCSpawn.");
return NULL;
}
}
static mrb_value CCSpawn_createWithTwoActions(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCFiniteTimeAction* p0 = get_CCFiniteTimeAction(mrb, args[0]);
CCFiniteTimeAction* p1 = get_CCFiniteTimeAction(mrb, args[1]);
CCActionInterval* retval = CCSpawn::createWithTwoActions(p0, p1);
return (retval == NULL ? mrb_nil_value() : _wrap_CCActionInterval(mrb, retval));
}
static void installCCSpawn(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCActionInterval");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCSpawn", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "createWithTwoActions", CCSpawn_createWithTwoActions, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCSprite
static void _dfree_CCSprite(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCSprite = { "CCSprite", _dfree_CCSprite };
mrb_value _wrap_CCSprite(mrb_state *mrb, const CCSprite* ptr) {
struct RClass* tc = getClass(mrb, "CCSprite");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCSprite, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCSprite;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCSprite* get_CCSprite(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCSprite");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCSprite*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCSprite.");
return NULL;
}
}
static mrb_value CCSprite_create(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 0) {
CCSprite* retval = CCSprite::create();
return (retval == NULL ? mrb_nil_value() : _wrap_CCSprite(mrb, retval));
} else if (arg_count == 1) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
CCSprite* retval = CCSprite::create(p0);
return (retval == NULL ? mrb_nil_value() : _wrap_CCSprite(mrb, retval));
} else if (arg_count == 2) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
const CCRect& p1 = *get_CCRect(mrb, args[1]);
CCSprite* retval = CCSprite::create(p0, p1);
return (retval == NULL ? mrb_nil_value() : _wrap_CCSprite(mrb, retval));
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCSprite#create Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCSprite_createWithSpriteFrame(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCSpriteFrame* p0 = get_CCSpriteFrame(mrb, args[0]);
CCSprite* retval = CCSprite::createWithSpriteFrame(p0);
return (retval == NULL ? mrb_nil_value() : _wrap_CCSprite(mrb, retval));
}
static mrb_value CCSprite_createWithTexture(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 1) {
CCTexture2D* p0 = get_CCTexture2D(mrb, args[0]);
CCSprite* retval = CCSprite::createWithTexture(p0);
return (retval == NULL ? mrb_nil_value() : _wrap_CCSprite(mrb, retval));
} else if (arg_count == 2) {
CCTexture2D* p0 = get_CCTexture2D(mrb, args[0]);
const CCRect& p1 = *get_CCRect(mrb, args[1]);
CCSprite* retval = CCSprite::createWithTexture(p0, p1);
return (retval == NULL ? mrb_nil_value() : _wrap_CCSprite(mrb, retval));
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCSprite#createWithTexture Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCSprite_setTextureRect(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 1) {
const CCRect& p0 = *get_CCRect(mrb, args[0]);
CCSprite* instance = static_cast<CCSprite*>(DATA_PTR(self));
instance->setTextureRect(p0);
return mrb_nil_value();
} else if (arg_count == 3) {
const CCRect& p0 = *get_CCRect(mrb, args[0]);
bool p1 = get_bool(args[1]);
const CCSize& p2 = *get_CCSize(mrb, args[2]);
CCSprite* instance = static_cast<CCSprite*>(DATA_PTR(self));
instance->setTextureRect(p0, p1, p2);
return mrb_nil_value();
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCSprite#setTextureRect Wrong count of arguments.");
return mrb_nil_value();
}
}
static void installCCSprite(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCNodeRGBA");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCSprite", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCSprite_create, MRB_ARGS_ANY());
mrb_define_class_method(mrb, tc, "createWithSpriteFrame", CCSprite_createWithSpriteFrame, MRB_ARGS_ANY());
mrb_define_class_method(mrb, tc, "createWithTexture", CCSprite_createWithTexture, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setTextureRect", CCSprite_setTextureRect, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCSpriteBatchNode
static void _dfree_CCSpriteBatchNode(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCSpriteBatchNode = { "CCSpriteBatchNode", _dfree_CCSpriteBatchNode };
mrb_value _wrap_CCSpriteBatchNode(mrb_state *mrb, const CCSpriteBatchNode* ptr) {
struct RClass* tc = getClass(mrb, "CCSpriteBatchNode");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCSpriteBatchNode, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCSpriteBatchNode;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCSpriteBatchNode* get_CCSpriteBatchNode(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCSpriteBatchNode");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCSpriteBatchNode*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCSpriteBatchNode.");
return NULL;
}
}
static mrb_value CCSpriteBatchNode_create(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 2) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
unsigned int p1 = get_int(args[1]);
CCSpriteBatchNode* retval = CCSpriteBatchNode::create(p0, p1);
return (retval == NULL ? mrb_nil_value() : _wrap_CCSpriteBatchNode(mrb, retval));
} else if (arg_count == 1) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
CCSpriteBatchNode* retval = CCSpriteBatchNode::create(p0);
return (retval == NULL ? mrb_nil_value() : _wrap_CCSpriteBatchNode(mrb, retval));
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCSpriteBatchNode#create Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCSpriteBatchNode_getTexture(mrb_state *mrb, mrb_value self) {
CCSpriteBatchNode* instance = static_cast<CCSpriteBatchNode*>(DATA_PTR(self));
CCTexture2D* retval = instance->getTexture();
return (retval == NULL ? mrb_nil_value() : _wrap_CCTexture2D(mrb, retval));
}
static void installCCSpriteBatchNode(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCNode");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCSpriteBatchNode", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCSpriteBatchNode_create, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getTexture", CCSpriteBatchNode_getTexture, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCLabelTTF
static void _dfree_CCLabelTTF(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCLabelTTF = { "CCLabelTTF", _dfree_CCLabelTTF };
mrb_value _wrap_CCLabelTTF(mrb_state *mrb, const CCLabelTTF* ptr) {
struct RClass* tc = getClass(mrb, "CCLabelTTF");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCLabelTTF, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCLabelTTF;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCLabelTTF* get_CCLabelTTF(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCLabelTTF");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCLabelTTF*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCLabelTTF.");
return NULL;
}
}
static mrb_value CCLabelTTF_create(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 3) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
const char* p1 = mrb_string_value_ptr(mrb, args[1]);
float p2 = get_float(args[2]);
CCLabelTTF* retval = CCLabelTTF::create(p0, p1, p2);
return (retval == NULL ? mrb_nil_value() : _wrap_CCLabelTTF(mrb, retval));
} else if (arg_count == 5) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
const char* p1 = mrb_string_value_ptr(mrb, args[1]);
float p2 = get_float(args[2]);
const CCSize& p3 = *get_CCSize(mrb, args[3]);
CCTextAlignment p4 = (CCTextAlignment)mrb_fixnum(args[4]);
CCLabelTTF* retval = CCLabelTTF::create(p0, p1, p2, p3, p4);
return (retval == NULL ? mrb_nil_value() : _wrap_CCLabelTTF(mrb, retval));
} else if (arg_count == 6) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
const char* p1 = mrb_string_value_ptr(mrb, args[1]);
float p2 = get_float(args[2]);
const CCSize& p3 = *get_CCSize(mrb, args[3]);
CCTextAlignment p4 = (CCTextAlignment)mrb_fixnum(args[4]);
CCVerticalTextAlignment p5 = (CCVerticalTextAlignment)mrb_fixnum(args[5]);
CCLabelTTF* retval = CCLabelTTF::create(p0, p1, p2, p3, p4, p5);
return (retval == NULL ? mrb_nil_value() : _wrap_CCLabelTTF(mrb, retval));
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCLabelTTF#create Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCLabelTTF_setString(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
CCLabelTTF* instance = static_cast<CCLabelTTF*>(DATA_PTR(self));
instance->setString(p0);
return mrb_nil_value();
}
static void installCCLabelTTF(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCSprite");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCLabelTTF", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCLabelTTF_create, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setString", CCLabelTTF_setString, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCLabelBMFont
static void _dfree_CCLabelBMFont(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCLabelBMFont = { "CCLabelBMFont", _dfree_CCLabelBMFont };
mrb_value _wrap_CCLabelBMFont(mrb_state *mrb, const CCLabelBMFont* ptr) {
struct RClass* tc = getClass(mrb, "CCLabelBMFont");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCLabelBMFont, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCLabelBMFont;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCLabelBMFont* get_CCLabelBMFont(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCLabelBMFont");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCLabelBMFont*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCLabelBMFont.");
return NULL;
}
}
static mrb_value CCLabelBMFont_create(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 3) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
const char* p1 = mrb_string_value_ptr(mrb, args[1]);
float p2 = get_float(args[2]);
CCLabelBMFont* retval = CCLabelBMFont::create(p0, p1, p2);
return (retval == NULL ? mrb_nil_value() : _wrap_CCLabelBMFont(mrb, retval));
} else if (arg_count == 2) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
const char* p1 = mrb_string_value_ptr(mrb, args[1]);
CCLabelBMFont* retval = CCLabelBMFont::create(p0, p1);
return (retval == NULL ? mrb_nil_value() : _wrap_CCLabelBMFont(mrb, retval));
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCLabelBMFont#create Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCLabelBMFont_setString(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
CCLabelBMFont* instance = static_cast<CCLabelBMFont*>(DATA_PTR(self));
instance->setString(p0);
return mrb_nil_value();
}
static void installCCLabelBMFont(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCSpriteBatchNode");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCLabelBMFont", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCLabelBMFont_create, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setString", CCLabelBMFont_setString, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCDrawNode
static void _dfree_CCDrawNode(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCDrawNode = { "CCDrawNode", _dfree_CCDrawNode };
mrb_value _wrap_CCDrawNode(mrb_state *mrb, const CCDrawNode* ptr) {
struct RClass* tc = getClass(mrb, "CCDrawNode");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCDrawNode, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCDrawNode;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCDrawNode* get_CCDrawNode(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCDrawNode");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCDrawNode*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCDrawNode.");
return NULL;
}
}
static mrb_value CCDrawNode_create(mrb_state *mrb, mrb_value self) {
CCDrawNode* retval = CCDrawNode::create();
return (retval == NULL ? mrb_nil_value() : _wrap_CCDrawNode(mrb, retval));
}
static mrb_value CCDrawNode_drawDot(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const CCPoint& p0 = *get_CCPoint(mrb, args[0]);
float p1 = get_float(args[1]);
const ccColor4F& p2 = *get_ccColor4F(mrb, args[2]);
CCDrawNode* instance = static_cast<CCDrawNode*>(DATA_PTR(self));
instance->drawDot(p0, p1, p2);
return mrb_nil_value();
}
static mrb_value CCDrawNode_drawSegment(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const CCPoint& p0 = *get_CCPoint(mrb, args[0]);
const CCPoint& p1 = *get_CCPoint(mrb, args[1]);
float p2 = get_float(args[2]);
const ccColor4F& p3 = *get_ccColor4F(mrb, args[3]);
CCDrawNode* instance = static_cast<CCDrawNode*>(DATA_PTR(self));
instance->drawSegment(p0, p1, p2, p3);
return mrb_nil_value();
}
static mrb_value CCDrawNode_drawPolygon(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
mrb_value array = args[0];
unsigned int p1 = mrb_ary_ptr(array)->len;
CCPoint* p0 = new CCPoint[p1];
for(int i=0; i<p1; i++){
CCPoint* p = static_cast<CCPoint*>(DATA_PTR(mrb_ary_ref(mrb,array,i)));
p0[i] = *p;
}
const ccColor4F& p2 = *static_cast<ccColor4F*>(DATA_PTR(args[1]));
float p3 = get_float(args[2]);
const ccColor4F& p4 = *static_cast<ccColor4F*>(DATA_PTR(args[3]));
CCDrawNode* instance = static_cast<CCDrawNode*>(DATA_PTR(self));
instance->drawPolygon(p0, p1, p2, p3, p4);
delete[] p0;
return mrb_nil_value();
}
static mrb_value CCDrawNode_clear(mrb_state *mrb, mrb_value self) {
CCDrawNode* instance = static_cast<CCDrawNode*>(DATA_PTR(self));
instance->clear();
return mrb_nil_value();
}
static mrb_value CCDrawNode_getBlendFunc(mrb_state *mrb, mrb_value self) {
CCDrawNode* instance = static_cast<CCDrawNode*>(DATA_PTR(self));
ccBlendFunc retval = instance->getBlendFunc();
return _wrap_ccBlendFunc(mrb, new(mrb_malloc(mrb, sizeof(ccBlendFunc))) ccBlendFunc(retval));
}
static mrb_value CCDrawNode_setBlendFunc(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const ccBlendFunc& p0 = *get_ccBlendFunc(mrb, args[0]);
CCDrawNode* instance = static_cast<CCDrawNode*>(DATA_PTR(self));
instance->setBlendFunc(p0);
return mrb_nil_value();
}
static void installCCDrawNode(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCNode");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCDrawNode", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCDrawNode_create, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "drawDot", CCDrawNode_drawDot, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "drawSegment", CCDrawNode_drawSegment, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "drawPolygon", CCDrawNode_drawPolygon, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "clear", CCDrawNode_clear, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getBlendFunc", CCDrawNode_getBlendFunc, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setBlendFunc", CCDrawNode_setBlendFunc, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCLayer
static void _dfree_CCLayer(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCLayer = { "CCLayer", _dfree_CCLayer };
mrb_value _wrap_CCLayer(mrb_state *mrb, const CCLayer* ptr) {
struct RClass* tc = getClass(mrb, "CCLayer");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCLayer, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCLayer;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCLayer* get_CCLayer(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCLayer");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCLayer*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCLayer.");
return NULL;
}
}
static mrb_value CCLayer_create(mrb_state *mrb, mrb_value self) {
CCLayer* retval = CCLayer::create();
return (retval == NULL ? mrb_nil_value() : _wrap_CCLayer(mrb, retval));
}
static mrb_value CCLayer_registerScriptTouchHandler(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_value block;
mrb_get_args(mrb, "*&", &args, &arg_count, &block);
if (arg_count == 0) {
int blockHandler = registerProc(mrb, self, block);
CCLayer* instance = static_cast<CCLayer*>(DATA_PTR(self));
instance->registerScriptTouchHandler(blockHandler);
return mrb_nil_value();
} else if (arg_count == 1) {
int blockHandler = registerProc(mrb, self, block);
bool p0 = get_bool(args[0]);
CCLayer* instance = static_cast<CCLayer*>(DATA_PTR(self));
instance->registerScriptTouchHandler(blockHandler, p0);
return mrb_nil_value();
} else if (arg_count == 2) {
int blockHandler = registerProc(mrb, self, block);
bool p0 = get_bool(args[0]);
int p1 = get_int(args[1]);
CCLayer* instance = static_cast<CCLayer*>(DATA_PTR(self));
instance->registerScriptTouchHandler(blockHandler, p0, p1);
return mrb_nil_value();
} else if (arg_count == 3) {
int blockHandler = registerProc(mrb, self, block);
bool p0 = get_bool(args[0]);
int p1 = get_int(args[1]);
bool p2 = get_bool(args[2]);
CCLayer* instance = static_cast<CCLayer*>(DATA_PTR(self));
instance->registerScriptTouchHandler(blockHandler, p0, p1, p2);
return mrb_nil_value();
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCLayer#registerScriptTouchHandler Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCLayer_setTouchEnabled(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
bool p0 = get_bool(args[0]);
CCLayer* instance = static_cast<CCLayer*>(DATA_PTR(self));
instance->setTouchEnabled(p0);
return mrb_nil_value();
}
static mrb_value CCLayer_setAccelerometerEnabled(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
bool p0 = get_bool(args[0]);
CCLayer* instance = static_cast<CCLayer*>(DATA_PTR(self));
instance->setAccelerometerEnabled(p0);
return mrb_nil_value();
}
static mrb_value CCLayer_setTouchMode(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
ccTouchesMode p0 = (ccTouchesMode)mrb_fixnum(args[0]);
CCLayer* instance = static_cast<CCLayer*>(DATA_PTR(self));
instance->setTouchMode(p0);
return mrb_nil_value();
}
static void installCCLayer(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCNode");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCLayer", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCLayer_create, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "registerScriptTouchHandler", CCLayer_registerScriptTouchHandler, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setTouchEnabled", CCLayer_setTouchEnabled, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setAccelerometerEnabled", CCLayer_setAccelerometerEnabled, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setTouchMode", CCLayer_setTouchMode, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCLayerRGBA
static void _dfree_CCLayerRGBA(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCLayerRGBA = { "CCLayerRGBA", _dfree_CCLayerRGBA };
mrb_value _wrap_CCLayerRGBA(mrb_state *mrb, const CCLayerRGBA* ptr) {
struct RClass* tc = getClass(mrb, "CCLayerRGBA");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCLayerRGBA, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCLayerRGBA;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCLayerRGBA* get_CCLayerRGBA(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCLayerRGBA");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCLayerRGBA*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCLayerRGBA.");
return NULL;
}
}
static void installCCLayerRGBA(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCLayer");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCLayerRGBA", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
}
////////////////////////////////////////////////////////////////
// CCScene
static void _dfree_CCScene(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCScene = { "CCScene", _dfree_CCScene };
mrb_value _wrap_CCScene(mrb_state *mrb, const CCScene* ptr) {
struct RClass* tc = getClass(mrb, "CCScene");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCScene, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCScene;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCScene* get_CCScene(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCScene");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCScene*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCScene.");
return NULL;
}
}
static mrb_value CCScene_create(mrb_state *mrb, mrb_value self) {
CCScene* retval = CCScene::create();
return (retval == NULL ? mrb_nil_value() : _wrap_CCScene(mrb, retval));
}
static void installCCScene(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCNode");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCScene", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCScene_create, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCScheduler
static void _dfree_CCScheduler(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCScheduler = { "CCScheduler", _dfree_CCScheduler };
mrb_value _wrap_CCScheduler(mrb_state *mrb, const CCScheduler* ptr) {
struct RClass* tc = getClass(mrb, "CCScheduler");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCScheduler, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCScheduler;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCScheduler* get_CCScheduler(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCScheduler");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCScheduler*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCScheduler.");
return NULL;
}
}
static mrb_value CCScheduler_scheduleScriptFunc(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_value block;
mrb_get_args(mrb, "*&", &args, &arg_count, &block);
int blockHandler = registerProc(mrb, self, block);
float p0 = get_float(args[0]);
bool p1 = get_bool(args[1]);
CCScheduler* instance = static_cast<CCScheduler*>(DATA_PTR(self));
unsigned int retval = instance->scheduleScriptFunc(blockHandler, p0, p1);
return mrb_fixnum_value(retval);
}
static mrb_value CCScheduler_unscheduleScriptEntry(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
unsigned int p0 = get_int(args[0]);
CCScheduler* instance = static_cast<CCScheduler*>(DATA_PTR(self));
instance->unscheduleScriptEntry(p0);
return mrb_nil_value();
}
static void installCCScheduler(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCObject");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCScheduler", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_method(mrb, tc, "scheduleScriptFunc", CCScheduler_scheduleScriptFunc, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "unscheduleScriptEntry", CCScheduler_unscheduleScriptEntry, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCDirector
static void _dfree_CCDirector(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCDirector = { "CCDirector", _dfree_CCDirector };
mrb_value _wrap_CCDirector(mrb_state *mrb, const CCDirector* ptr) {
struct RClass* tc = getClass(mrb, "CCDirector");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCDirector, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCDirector;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCDirector* get_CCDirector(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCDirector");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCDirector*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCDirector.");
return NULL;
}
}
static mrb_value CCDirector_sharedDirector(mrb_state *mrb, mrb_value self) {
CCDirector* retval = CCDirector::sharedDirector();
return (retval == NULL ? mrb_nil_value() : _wrap_CCDirector(mrb, retval));
}
static mrb_value CCDirector_getWinSize(mrb_state *mrb, mrb_value self) {
CCDirector* instance = static_cast<CCDirector*>(DATA_PTR(self));
CCSize retval = instance->getWinSize();
return _wrap_CCSize(mrb, new(mrb_malloc(mrb, sizeof(CCSize))) CCSize(retval));
}
static mrb_value CCDirector_getVisibleOrigin(mrb_state *mrb, mrb_value self) {
CCDirector* instance = static_cast<CCDirector*>(DATA_PTR(self));
CCPoint retval = instance->getVisibleOrigin();
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCDirector_getVisibleSize(mrb_state *mrb, mrb_value self) {
CCDirector* instance = static_cast<CCDirector*>(DATA_PTR(self));
CCSize retval = instance->getVisibleSize();
return _wrap_CCSize(mrb, new(mrb_malloc(mrb, sizeof(CCSize))) CCSize(retval));
}
static mrb_value CCDirector_convertToGL(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const CCPoint& p0 = *get_CCPoint(mrb, args[0]);
CCDirector* instance = static_cast<CCDirector*>(DATA_PTR(self));
CCPoint retval = instance->convertToGL(p0);
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCDirector_runWithScene(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCScene* p0 = get_CCScene(mrb, args[0]);
CCDirector* instance = static_cast<CCDirector*>(DATA_PTR(self));
instance->runWithScene(p0);
return mrb_nil_value();
}
static mrb_value CCDirector_replaceScene(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCScene* p0 = get_CCScene(mrb, args[0]);
CCDirector* instance = static_cast<CCDirector*>(DATA_PTR(self));
instance->replaceScene(p0);
return mrb_nil_value();
}
static mrb_value CCDirector_pushScene(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCScene* p0 = get_CCScene(mrb, args[0]);
CCDirector* instance = static_cast<CCDirector*>(DATA_PTR(self));
instance->pushScene(p0);
return mrb_nil_value();
}
static mrb_value CCDirector_getScheduler(mrb_state *mrb, mrb_value self) {
CCDirector* instance = static_cast<CCDirector*>(DATA_PTR(self));
CCScheduler* retval = instance->getScheduler();
return (retval == NULL ? mrb_nil_value() : _wrap_CCScheduler(mrb, retval));
}
static mrb_value CCDirector_setContentScaleFactor(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
CCDirector* instance = static_cast<CCDirector*>(DATA_PTR(self));
instance->setContentScaleFactor(p0);
return mrb_nil_value();
}
static mrb_value CCDirector_setDisplayStats(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
bool p0 = get_bool(args[0]);
CCDirector* instance = static_cast<CCDirector*>(DATA_PTR(self));
instance->setDisplayStats(p0);
return mrb_nil_value();
}
static void installCCDirector(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCObject");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCDirector", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "sharedDirector", CCDirector_sharedDirector, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getWinSize", CCDirector_getWinSize, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getVisibleOrigin", CCDirector_getVisibleOrigin, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getVisibleSize", CCDirector_getVisibleSize, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "convertToGL", CCDirector_convertToGL, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "runWithScene", CCDirector_runWithScene, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "replaceScene", CCDirector_replaceScene, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "pushScene", CCDirector_pushScene, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getScheduler", CCDirector_getScheduler, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setContentScaleFactor", CCDirector_setContentScaleFactor, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setDisplayStats", CCDirector_setDisplayStats, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCEGLView
static void _dfree_CCEGLView(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCEGLView = { "CCEGLView", _dfree_CCEGLView };
mrb_value _wrap_CCEGLView(mrb_state *mrb, const CCEGLView* ptr) {
struct RClass* tc = getClass(mrb, "CCEGLView");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCEGLView, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCEGLView;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCEGLView* get_CCEGLView(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCEGLView");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCEGLView*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCEGLView.");
return NULL;
}
}
static mrb_value CCEGLView_sharedOpenGLView(mrb_state *mrb, mrb_value self) {
CCEGLView* retval = CCEGLView::sharedOpenGLView();
return (retval == NULL ? mrb_nil_value() : _wrap_CCEGLView(mrb, retval));
}
static mrb_value CCEGLView_getDesignResolutionSize(mrb_state *mrb, mrb_value self) {
CCEGLView* instance = static_cast<CCEGLView*>(DATA_PTR(self));
const CCSize& retval = instance->getDesignResolutionSize();
return _wrap_CCSize(mrb, new(mrb_malloc(mrb, sizeof(CCSize))) CCSize(retval));
}
static mrb_value CCEGLView_setDesignResolutionSize(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
float p1 = get_float(args[1]);
ResolutionPolicy p2 = (ResolutionPolicy)mrb_fixnum(args[2]);
CCEGLView* instance = static_cast<CCEGLView*>(DATA_PTR(self));
instance->setDesignResolutionSize(p0, p1, p2);
return mrb_nil_value();
}
static mrb_value CCEGLView_getFrameSize(mrb_state *mrb, mrb_value self) {
CCEGLView* instance = static_cast<CCEGLView*>(DATA_PTR(self));
const CCSize& retval = instance->getFrameSize();
return _wrap_CCSize(mrb, new(mrb_malloc(mrb, sizeof(CCSize))) CCSize(retval));
}
static void installCCEGLView(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = mrb->object_class;
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCEGLView", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "sharedOpenGLView", CCEGLView_sharedOpenGLView, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getDesignResolutionSize", CCEGLView_getDesignResolutionSize, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setDesignResolutionSize", CCEGLView_setDesignResolutionSize, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getFrameSize", CCEGLView_getFrameSize, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCFileUtils
static void _dfree_CCFileUtils(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCFileUtils = { "CCFileUtils", _dfree_CCFileUtils };
mrb_value _wrap_CCFileUtils(mrb_state *mrb, const CCFileUtils* ptr) {
struct RClass* tc = getClass(mrb, "CCFileUtils");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCFileUtils, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCFileUtils;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCFileUtils* get_CCFileUtils(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCFileUtils");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCFileUtils*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCFileUtils.");
return NULL;
}
}
static mrb_value CCFileUtils_sharedFileUtils(mrb_state *mrb, mrb_value self) {
CCFileUtils* retval = CCFileUtils::sharedFileUtils();
return (retval == NULL ? mrb_nil_value() : _wrap_CCFileUtils(mrb, retval));
}
static mrb_value CCFileUtils_purgeCachedEntries(mrb_state *mrb, mrb_value self) {
CCFileUtils* instance = static_cast<CCFileUtils*>(DATA_PTR(self));
instance->purgeCachedEntries();
return mrb_nil_value();
}
static mrb_value CCFileUtils_fullPathForFilename(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
CCFileUtils* instance = static_cast<CCFileUtils*>(DATA_PTR(self));
std::string retval = instance->fullPathForFilename(p0);
return mrb_str_new(mrb, retval.c_str(), retval.size());
}
static mrb_value CCFileUtils_fullPathFromRelativeFile(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
const char* p1 = mrb_string_value_ptr(mrb, args[1]);
CCFileUtils* instance = static_cast<CCFileUtils*>(DATA_PTR(self));
const char* retval = instance->fullPathFromRelativeFile(p0, p1);
return mrb_str_new_cstr(mrb, retval);
}
static mrb_value CCFileUtils_addSearchPath(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
CCFileUtils* instance = static_cast<CCFileUtils*>(DATA_PTR(self));
instance->addSearchPath(p0);
return mrb_nil_value();
}
static mrb_value CCFileUtils_removeSearchPath(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
CCFileUtils* instance = static_cast<CCFileUtils*>(DATA_PTR(self));
instance->removeSearchPath(p0);
return mrb_nil_value();
}
static mrb_value CCFileUtils_removeAllPaths(mrb_state *mrb, mrb_value self) {
CCFileUtils* instance = static_cast<CCFileUtils*>(DATA_PTR(self));
instance->removeAllPaths();
return mrb_nil_value();
}
static mrb_value CCFileUtils_getSearchPaths(mrb_state *mrb, mrb_value self) {
CCFileUtils* instance = static_cast<CCFileUtils*>(DATA_PTR(self));
const std::vector<std::string>& retval = instance->getSearchPaths();
mrb_value array = mrb_ary_new(mrb);
for(auto s:retval){
mrb_value v = mrb_str_new(mrb, s.c_str(), s.size());
mrb_ary_push(mrb, array, v);
}
return array;
}
static mrb_value CCFileUtils_isFileExist(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const std::string& p0 = std::string(mrb_string_value_ptr(mrb, args[0]));
CCFileUtils* instance = static_cast<CCFileUtils*>(DATA_PTR(self));
bool retval = instance->isFileExist(p0);
return mrb_bool_value(retval);
}
static mrb_value CCFileUtils_isAbsolutePath(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const std::string& p0 = std::string(mrb_string_value_ptr(mrb, args[0]));
CCFileUtils* instance = static_cast<CCFileUtils*>(DATA_PTR(self));
bool retval = instance->isAbsolutePath(p0);
return mrb_bool_value(retval);
}
static void installCCFileUtils(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = mrb->object_class;
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCFileUtils", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "sharedFileUtils", CCFileUtils_sharedFileUtils, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "purgeCachedEntries", CCFileUtils_purgeCachedEntries, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "fullPathForFilename", CCFileUtils_fullPathForFilename, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "fullPathFromRelativeFile", CCFileUtils_fullPathFromRelativeFile, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "addSearchPath", CCFileUtils_addSearchPath, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "removeSearchPath", CCFileUtils_removeSearchPath, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "removeAllPaths", CCFileUtils_removeAllPaths, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getSearchPaths", CCFileUtils_getSearchPaths, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "isFileExist", CCFileUtils_isFileExist, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "isAbsolutePath", CCFileUtils_isAbsolutePath, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCMenuItem
static void _dfree_CCMenuItem(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCMenuItem = { "CCMenuItem", _dfree_CCMenuItem };
mrb_value _wrap_CCMenuItem(mrb_state *mrb, const CCMenuItem* ptr) {
struct RClass* tc = getClass(mrb, "CCMenuItem");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCMenuItem, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCMenuItem;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCMenuItem* get_CCMenuItem(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCMenuItem");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCMenuItem*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCMenuItem.");
return NULL;
}
}
static mrb_value CCMenuItem_registerScriptTapHandler(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_value block;
mrb_get_args(mrb, "*&", &args, &arg_count, &block);
int blockHandler = registerProc(mrb, self, block);
CCMenuItem* instance = static_cast<CCMenuItem*>(DATA_PTR(self));
instance->registerScriptTapHandler(blockHandler);
return mrb_nil_value();
}
static void installCCMenuItem(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCNodeRGBA");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCMenuItem", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_method(mrb, tc, "registerScriptTapHandler", CCMenuItem_registerScriptTapHandler, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCMenuItemSprite
static void _dfree_CCMenuItemSprite(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCMenuItemSprite = { "CCMenuItemSprite", _dfree_CCMenuItemSprite };
mrb_value _wrap_CCMenuItemSprite(mrb_state *mrb, const CCMenuItemSprite* ptr) {
struct RClass* tc = getClass(mrb, "CCMenuItemSprite");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCMenuItemSprite, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCMenuItemSprite;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCMenuItemSprite* get_CCMenuItemSprite(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCMenuItemSprite");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCMenuItemSprite*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCMenuItemSprite.");
return NULL;
}
}
static void installCCMenuItemSprite(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCMenuItem");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCMenuItemSprite", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
}
////////////////////////////////////////////////////////////////
// CCMenuItemImage
static void _dfree_CCMenuItemImage(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCMenuItemImage = { "CCMenuItemImage", _dfree_CCMenuItemImage };
mrb_value _wrap_CCMenuItemImage(mrb_state *mrb, const CCMenuItemImage* ptr) {
struct RClass* tc = getClass(mrb, "CCMenuItemImage");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCMenuItemImage, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCMenuItemImage;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCMenuItemImage* get_CCMenuItemImage(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCMenuItemImage");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCMenuItemImage*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCMenuItemImage.");
return NULL;
}
}
static mrb_value CCMenuItemImage_create(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
const char* p1 = mrb_string_value_ptr(mrb, args[1]);
CCMenuItemImage* retval = CCMenuItemImage::create(p0, p1);
return (retval == NULL ? mrb_nil_value() : _wrap_CCMenuItemImage(mrb, retval));
}
static void installCCMenuItemImage(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCMenuItemSprite");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCMenuItemImage", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCMenuItemImage_create, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCMenuItemLabel
static void _dfree_CCMenuItemLabel(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCMenuItemLabel = { "CCMenuItemLabel", _dfree_CCMenuItemLabel };
mrb_value _wrap_CCMenuItemLabel(mrb_state *mrb, const CCMenuItemLabel* ptr) {
struct RClass* tc = getClass(mrb, "CCMenuItemLabel");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCMenuItemLabel, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCMenuItemLabel;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCMenuItemLabel* get_CCMenuItemLabel(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCMenuItemLabel");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCMenuItemLabel*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCMenuItemLabel.");
return NULL;
}
}
static void installCCMenuItemLabel(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCMenuItem");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCMenuItemLabel", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
}
////////////////////////////////////////////////////////////////
// CCMenuItemFont
static void _dfree_CCMenuItemFont(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCMenuItemFont = { "CCMenuItemFont", _dfree_CCMenuItemFont };
mrb_value _wrap_CCMenuItemFont(mrb_state *mrb, const CCMenuItemFont* ptr) {
struct RClass* tc = getClass(mrb, "CCMenuItemFont");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCMenuItemFont, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCMenuItemFont;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCMenuItemFont* get_CCMenuItemFont(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCMenuItemFont");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCMenuItemFont*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCMenuItemFont.");
return NULL;
}
}
static mrb_value CCMenuItemFont_create(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
CCMenuItemFont* retval = CCMenuItemFont::create(p0);
return (retval == NULL ? mrb_nil_value() : _wrap_CCMenuItemFont(mrb, retval));
}
static mrb_value CCMenuItemFont_setFontSizeObj(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
unsigned int p0 = get_int(args[0]);
CCMenuItemFont* instance = static_cast<CCMenuItemFont*>(DATA_PTR(self));
instance->setFontSizeObj(p0);
return mrb_nil_value();
}
static void installCCMenuItemFont(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCMenuItemLabel");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCMenuItemFont", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCMenuItemFont_create, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setFontSizeObj", CCMenuItemFont_setFontSizeObj, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCMenu
static void _dfree_CCMenu(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCMenu = { "CCMenu", _dfree_CCMenu };
mrb_value _wrap_CCMenu(mrb_state *mrb, const CCMenu* ptr) {
struct RClass* tc = getClass(mrb, "CCMenu");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCMenu, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCMenu;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCMenu* get_CCMenu(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCMenu");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCMenu*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCMenu.");
return NULL;
}
}
static mrb_value CCMenu_create(mrb_state *mrb, mrb_value self) {
CCMenu* retval = CCMenu::create();
return (retval == NULL ? mrb_nil_value() : _wrap_CCMenu(mrb, retval));
}
static mrb_value CCMenu_createWithItem(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
CCMenuItem* p0 = get_CCMenuItem(mrb, args[0]);
CCMenu* retval = CCMenu::createWithItem(p0);
return (retval == NULL ? mrb_nil_value() : _wrap_CCMenu(mrb, retval));
}
static void installCCMenu(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCLayerRGBA");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCMenu", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "create", CCMenu_create, MRB_ARGS_ANY());
mrb_define_class_method(mrb, tc, "createWithItem", CCMenu_createWithItem, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCTouch
static void _dfree_CCTouch(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCTouch = { "CCTouch", _dfree_CCTouch };
mrb_value _wrap_CCTouch(mrb_state *mrb, const CCTouch* ptr) {
struct RClass* tc = getClass(mrb, "CCTouch");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCTouch, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCTouch;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCTouch* get_CCTouch(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCTouch");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCTouch*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCTouch.");
return NULL;
}
}
static mrb_value CCTouch_getLocation(mrb_state *mrb, mrb_value self) {
CCTouch* instance = static_cast<CCTouch*>(DATA_PTR(self));
CCPoint retval = instance->getLocation();
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCTouch_getPreviousLocation(mrb_state *mrb, mrb_value self) {
CCTouch* instance = static_cast<CCTouch*>(DATA_PTR(self));
CCPoint retval = instance->getPreviousLocation();
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCTouch_getStartLocation(mrb_state *mrb, mrb_value self) {
CCTouch* instance = static_cast<CCTouch*>(DATA_PTR(self));
CCPoint retval = instance->getStartLocation();
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCTouch_getDelta(mrb_state *mrb, mrb_value self) {
CCTouch* instance = static_cast<CCTouch*>(DATA_PTR(self));
CCPoint retval = instance->getDelta();
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCTouch_getLocationInView(mrb_state *mrb, mrb_value self) {
CCTouch* instance = static_cast<CCTouch*>(DATA_PTR(self));
CCPoint retval = instance->getLocationInView();
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCTouch_getPreviousLocationInView(mrb_state *mrb, mrb_value self) {
CCTouch* instance = static_cast<CCTouch*>(DATA_PTR(self));
CCPoint retval = instance->getPreviousLocationInView();
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCTouch_getStartLocationInView(mrb_state *mrb, mrb_value self) {
CCTouch* instance = static_cast<CCTouch*>(DATA_PTR(self));
CCPoint retval = instance->getStartLocationInView();
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCTouch_getID(mrb_state *mrb, mrb_value self) {
CCTouch* instance = static_cast<CCTouch*>(DATA_PTR(self));
int retval = instance->getID();
return mrb_fixnum_value(retval);
}
static void installCCTouch(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = getClass(mrb, "CCObject");
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCTouch", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_method(mrb, tc, "getLocation", CCTouch_getLocation, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getPreviousLocation", CCTouch_getPreviousLocation, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getStartLocation", CCTouch_getStartLocation, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getDelta", CCTouch_getDelta, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getLocationInView", CCTouch_getLocationInView, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getPreviousLocationInView", CCTouch_getPreviousLocationInView, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getStartLocationInView", CCTouch_getStartLocationInView, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getID", CCTouch_getID, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// CCUserDefault
static void _dfree_CCUserDefault(mrb_state *mrb, void *ptr) {
//nop
}
static struct mrb_data_type _mrb_data_type_CCUserDefault = { "CCUserDefault", _dfree_CCUserDefault };
mrb_value _wrap_CCUserDefault(mrb_state *mrb, const CCUserDefault* ptr) {
struct RClass* tc = getClass(mrb, "CCUserDefault");
assert(tc != NULL);
mrb_value instance = mrb_obj_value(Data_Wrap_Struct(mrb, tc, &_mrb_data_type_CCUserDefault, NULL));
DATA_TYPE(instance) = &_mrb_data_type_CCUserDefault;
DATA_PTR(instance) = (void*)ptr;
return instance;
}
CCUserDefault* get_CCUserDefault(mrb_state *mrb, mrb_value v)
{
struct RClass *c = getClass(mrb, "CCUserDefault");
if(mrb_obj_is_kind_of(mrb, v, c)){
return static_cast<CCUserDefault*>(DATA_PTR(v));
}else{
mrb_raise(mrb, E_ARGUMENT_ERROR, "Wrong type for argument. required class is CCUserDefault.");
return NULL;
}
}
static mrb_value CCUserDefault_sharedUserDefault(mrb_state *mrb, mrb_value self) {
CCUserDefault* retval = CCUserDefault::sharedUserDefault();
return (retval == NULL ? mrb_nil_value() : _wrap_CCUserDefault(mrb, retval));
}
static mrb_value CCUserDefault_flush(mrb_state *mrb, mrb_value self) {
CCUserDefault* instance = static_cast<CCUserDefault*>(DATA_PTR(self));
instance->flush();
return mrb_nil_value();
}
static mrb_value CCUserDefault_getIntegerForKey(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 1) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
CCUserDefault* instance = static_cast<CCUserDefault*>(DATA_PTR(self));
int retval = instance->getIntegerForKey(p0);
return mrb_fixnum_value(retval);
} else if (arg_count == 2) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
int p1 = get_int(args[1]);
CCUserDefault* instance = static_cast<CCUserDefault*>(DATA_PTR(self));
int retval = instance->getIntegerForKey(p0, p1);
return mrb_fixnum_value(retval);
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCUserDefault#getIntegerForKey Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCUserDefault_setIntegerForKey(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
int p1 = get_int(args[1]);
CCUserDefault* instance = static_cast<CCUserDefault*>(DATA_PTR(self));
instance->setIntegerForKey(p0, p1);
return mrb_nil_value();
}
static mrb_value CCUserDefault_getFloatForKey(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 1) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
CCUserDefault* instance = static_cast<CCUserDefault*>(DATA_PTR(self));
float retval = instance->getFloatForKey(p0);
return mrb_float_value(mrb, retval);
} else if (arg_count == 2) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
float p1 = get_float(args[1]);
CCUserDefault* instance = static_cast<CCUserDefault*>(DATA_PTR(self));
float retval = instance->getFloatForKey(p0, p1);
return mrb_float_value(mrb, retval);
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCUserDefault#getFloatForKey Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCUserDefault_setFloatForKey(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
float p1 = get_float(args[1]);
CCUserDefault* instance = static_cast<CCUserDefault*>(DATA_PTR(self));
instance->setFloatForKey(p0, p1);
return mrb_nil_value();
}
static mrb_value CCUserDefault_getBoolForKey(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 1) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
CCUserDefault* instance = static_cast<CCUserDefault*>(DATA_PTR(self));
bool retval = instance->getBoolForKey(p0);
return mrb_bool_value(retval);
} else if (arg_count == 2) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
bool p1 = get_bool(args[1]);
CCUserDefault* instance = static_cast<CCUserDefault*>(DATA_PTR(self));
bool retval = instance->getBoolForKey(p0, p1);
return mrb_bool_value(retval);
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCUserDefault#getBoolForKey Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCUserDefault_setBoolForKey(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
bool p1 = get_bool(args[1]);
CCUserDefault* instance = static_cast<CCUserDefault*>(DATA_PTR(self));
instance->setBoolForKey(p0, p1);
return mrb_nil_value();
}
static mrb_value CCUserDefault_getStringForKey(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
if (arg_count == 1) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
CCUserDefault* instance = static_cast<CCUserDefault*>(DATA_PTR(self));
std::string retval = instance->getStringForKey(p0);
return mrb_str_new(mrb, retval.c_str(), retval.size());
} else if (arg_count == 2) {
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
const std::string& p1 = std::string(mrb_string_value_ptr(mrb, args[1]));
CCUserDefault* instance = static_cast<CCUserDefault*>(DATA_PTR(self));
std::string retval = instance->getStringForKey(p0, p1);
return mrb_str_new(mrb, retval.c_str(), retval.size());
} else {
mrb_raise(mrb, E_ARGUMENT_ERROR, "CCUserDefault#getStringForKey Wrong count of arguments.");
return mrb_nil_value();
}
}
static mrb_value CCUserDefault_setStringForKey(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
const char* p0 = mrb_string_value_ptr(mrb, args[0]);
const std::string& p1 = std::string(mrb_string_value_ptr(mrb, args[1]));
CCUserDefault* instance = static_cast<CCUserDefault*>(DATA_PTR(self));
instance->setStringForKey(p0, p1);
return mrb_nil_value();
}
static void installCCUserDefault(mrb_state *mrb, struct RClass *mod) {
struct RClass* parent = mrb->object_class;
struct RClass* tc = mrb_define_class_under(mrb, mod, "CCUserDefault", parent);
MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA);
mrb_define_class_method(mrb, tc, "sharedUserDefault", CCUserDefault_sharedUserDefault, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "flush", CCUserDefault_flush, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getIntegerForKey", CCUserDefault_getIntegerForKey, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setIntegerForKey", CCUserDefault_setIntegerForKey, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getFloatForKey", CCUserDefault_getFloatForKey, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setFloatForKey", CCUserDefault_setFloatForKey, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getBoolForKey", CCUserDefault_getBoolForKey, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setBoolForKey", CCUserDefault_setBoolForKey, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "getStringForKey", CCUserDefault_getStringForKey, MRB_ARGS_ANY());
mrb_define_method(mrb, tc, "setStringForKey", CCUserDefault_setStringForKey, MRB_ARGS_ANY());
}
////////////////////////////////////////////////////////////////
// Functions.
static mrb_value CCPointMake__(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
float p1 = get_float(args[1]);
CCPoint retval = CCPointMake(p0, p1);
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value ccp__(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
float p1 = get_float(args[1]);
CCPoint retval = ccp(p0, p1);
return _wrap_CCPoint(mrb, new(mrb_malloc(mrb, sizeof(CCPoint))) CCPoint(retval));
}
static mrb_value CCSizeMake__(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
float p1 = get_float(args[1]);
CCSize retval = CCSizeMake(p0, p1);
return _wrap_CCSize(mrb, new(mrb_malloc(mrb, sizeof(CCSize))) CCSize(retval));
}
static mrb_value CCRectMake__(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
float p1 = get_float(args[1]);
float p2 = get_float(args[2]);
float p3 = get_float(args[3]);
CCRect retval = CCRectMake(p0, p1, p2, p3);
return _wrap_CCRect(mrb, new(mrb_malloc(mrb, sizeof(CCRect))) CCRect(retval));
}
static mrb_value ccc3__(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
unsigned char p0 = get_int(args[0]);
unsigned char p1 = get_int(args[1]);
unsigned char p2 = get_int(args[2]);
ccColor3B retval = ccc3(p0, p1, p2);
return _wrap_ccColor3B(mrb, new(mrb_malloc(mrb, sizeof(ccColor3B))) ccColor3B(retval));
}
static mrb_value CCRANDOM_0_1__(mrb_state *mrb, mrb_value self) {
float retval = CCRANDOM_0_1();
return mrb_float_value(mrb, retval);
}
static mrb_value ccc4f__(mrb_state *mrb, mrb_value self) {
mrb_value* args;
int arg_count;
mrb_get_args(mrb, "*", &args, &arg_count);
float p0 = get_float(args[0]);
float p1 = get_float(args[1]);
float p2 = get_float(args[2]);
float p3 = get_float(args[3]);
ccColor4F retval = ccc4f(p0, p1, p2, p3);
return _wrap_ccColor4F(mrb, new(mrb_malloc(mrb, sizeof(ccColor4F))) ccColor4F(retval));
}
void installMrubyCocos2dx(mrb_state *mrb) {
struct RClass* mod = mrb_define_module(mrb, "Cocos2dx");
mrb_define_const(mrb, mod, "CCTOUCHBEGAN", mrb_fixnum_value(CCTOUCHBEGAN));
mrb_define_const(mrb, mod, "CCTOUCHMOVED", mrb_fixnum_value(CCTOUCHMOVED));
mrb_define_const(mrb, mod, "CCTOUCHENDED", mrb_fixnum_value(CCTOUCHENDED));
mrb_define_const(mrb, mod, "CCTOUCHCANCELLED", mrb_fixnum_value(CCTOUCHCANCELLED));
mrb_define_const(mrb, mod, "KCCNodeOnEnter", mrb_fixnum_value(kCCNodeOnEnter));
mrb_define_const(mrb, mod, "KCCNodeOnExit", mrb_fixnum_value(kCCNodeOnExit));
mrb_define_const(mrb, mod, "KCCNodeOnEnterTransitionDidFinish", mrb_fixnum_value(kCCNodeOnEnterTransitionDidFinish));
mrb_define_const(mrb, mod, "KCCNodeOnExitTransitionDidStart", mrb_fixnum_value(kCCNodeOnExitTransitionDidStart));
mrb_define_const(mrb, mod, "KCCNodeOnCleanup", mrb_fixnum_value(kCCNodeOnCleanup));
mrb_define_const(mrb, mod, "KCCTouchesAllAtOnce", mrb_fixnum_value(kCCTouchesAllAtOnce));
mrb_define_const(mrb, mod, "KCCTouchesOneByOne", mrb_fixnum_value(kCCTouchesOneByOne));
mrb_define_const(mrb, mod, "KResolutionExactFit", mrb_fixnum_value(kResolutionExactFit));
mrb_define_const(mrb, mod, "KResolutionNoBorder", mrb_fixnum_value(kResolutionNoBorder));
mrb_define_const(mrb, mod, "KResolutionShowAll", mrb_fixnum_value(kResolutionShowAll));
mrb_define_const(mrb, mod, "KResolutionFixedHeight", mrb_fixnum_value(kResolutionFixedHeight));
mrb_define_const(mrb, mod, "KResolutionFixedWidth", mrb_fixnum_value(kResolutionFixedWidth));
mrb_define_const(mrb, mod, "KResolutionUnKnown", mrb_fixnum_value(kResolutionUnKnown));
mrb_define_const(mrb, mod, "KCCTextAlignmentLeft", mrb_fixnum_value(kCCTextAlignmentLeft));
mrb_define_const(mrb, mod, "KCCTextAlignmentCenter", mrb_fixnum_value(kCCTextAlignmentCenter));
mrb_define_const(mrb, mod, "KCCTextAlignmentRight", mrb_fixnum_value(kCCTextAlignmentRight));
mrb_define_const(mrb, mod, "KCCVerticalTextAlignmentTop", mrb_fixnum_value(kCCVerticalTextAlignmentTop));
mrb_define_const(mrb, mod, "KCCVerticalTextAlignmentCenter", mrb_fixnum_value(kCCVerticalTextAlignmentCenter));
mrb_define_const(mrb, mod, "KCCVerticalTextAlignmentBottom", mrb_fixnum_value(kCCVerticalTextAlignmentBottom));
mrb_define_module_function(mrb, mod, "cCPointMake", CCPointMake__, MRB_ARGS_ANY());
mrb_define_module_function(mrb, mod, "ccp", ccp__, MRB_ARGS_ANY());
mrb_define_module_function(mrb, mod, "cCSizeMake", CCSizeMake__, MRB_ARGS_ANY());
mrb_define_module_function(mrb, mod, "cCRectMake", CCRectMake__, MRB_ARGS_ANY());
mrb_define_module_function(mrb, mod, "ccc3", ccc3__, MRB_ARGS_ANY());
mrb_define_module_function(mrb, mod, "cCRANDOM_0_1", CCRANDOM_0_1__, MRB_ARGS_ANY());
mrb_define_module_function(mrb, mod, "ccc4f", ccc4f__, MRB_ARGS_ANY());
installccColor3B(mrb, mod);
installccColor4F(mrb, mod);
installccBlendFunc(mrb, mod);
installCCPoint(mrb, mod);
installCCSize(mrb, mod);
installCCRect(mrb, mod);
installCCObject(mrb, mod);
installCCArray(mrb, mod);
installCCAction(mrb, mod);
installCCFiniteTimeAction(mrb, mod);
installCCActionInterval(mrb, mod);
installCCActionInstant(mrb, mod);
installCCNode(mrb, mod);
installCCNodeRGBA(mrb, mod);
installCCTexture2D(mrb, mod);
installCCTextureCache(mrb, mod);
installCCSpriteFrame(mrb, mod);
installCCAnimation(mrb, mod);
installCCAnimate(mrb, mod);
installCCRepeatForever(mrb, mod);
installCCScaleTo(mrb, mod);
installCCMoveBy(mrb, mod);
installCCMoveTo(mrb, mod);
installCCCallFunc(mrb, mod);
installCCSequence(mrb, mod);
installCCSpawn(mrb, mod);
installCCSprite(mrb, mod);
installCCSpriteBatchNode(mrb, mod);
installCCLabelTTF(mrb, mod);
installCCLabelBMFont(mrb, mod);
installCCDrawNode(mrb, mod);
installCCLayer(mrb, mod);
installCCLayerRGBA(mrb, mod);
installCCScene(mrb, mod);
installCCScheduler(mrb, mod);
installCCDirector(mrb, mod);
installCCEGLView(mrb, mod);
installCCFileUtils(mrb, mod);
installCCMenuItem(mrb, mod);
installCCMenuItemSprite(mrb, mod);
installCCMenuItemImage(mrb, mod);
installCCMenuItemLabel(mrb, mod);
installCCMenuItemFont(mrb, mod);
installCCMenu(mrb, mod);
installCCTouch(mrb, mod);
installCCUserDefault(mrb, mod);
}
| 38.68118 | 119 | 0.720341 | [
"vector"
] |
94c89015db95f41e9516cb9ed9a522b724453de4 | 136 | hpp | C++ | src/mesh_loader.hpp | hadalhw17/meshloader | 411babf21a6bddf61c6ea8fc8b8ffce325ae5e52 | [
"MIT"
] | null | null | null | src/mesh_loader.hpp | hadalhw17/meshloader | 411babf21a6bddf61c6ea8fc8b8ffce325ae5e52 | [
"MIT"
] | null | null | null | src/mesh_loader.hpp | hadalhw17/meshloader | 411babf21a6bddf61c6ea8fc8b8ffce325ae5e52 | [
"MIT"
] | null | null | null | #pragma once
#include "structures.hpp"
#include <optional>
namespace loader
{
std::optional<Model> loadMesh(const char*InFilename);
}
| 13.6 | 53 | 0.757353 | [
"model"
] |
94cf823d72d7582efd2cb5fcadd21983a99036ff | 26,439 | cpp | C++ | src/AGC/agcevent.cpp | FreeAllegiance/AllegianceDX7 | 3955756dffea8e7e31d3a55fcf6184232b792195 | [
"MIT"
] | 76 | 2015-08-18T19:18:40.000Z | 2022-01-08T12:47:22.000Z | src/AGC/agcevent.cpp | StudentAlleg/Allegiance | e91660a471eb4e57e9cea4c743ad43a82f8c7b18 | [
"MIT"
] | 37 | 2015-08-14T22:44:12.000Z | 2020-01-21T01:03:06.000Z | src/AGC/agcevent.cpp | FreeAllegiance/Allegiance-AZ | 1d8678ddff9e2efc79ed449de6d47544989bc091 | [
"MIT"
] | 42 | 2015-08-13T23:31:35.000Z | 2022-03-17T02:20:26.000Z | /////////////////////////////////////////////////////////////////////////////
// AGCEvent.cpp : Implementation of CAGCEvent
//
#include "pch.h"
#include "AGCEvent.h"
#include "AGCEventDef.h"
#include "AGCEventData.h"
#include <..\TCLib\UtilImpl.h>
#include <..\TCLib\BinString.h>
#include <..\TCAtl\SimpleStream.h>
/////////////////////////////////////////////////////////////////////////////
// CAGCEvent
TC_OBJECT_EXTERN_IMPL(CAGCEvent)
/////////////////////////////////////////////////////////////////////////////
// Construction
HRESULT CAGCEvent::FinalConstruct()
{
// #define CAGCEvent_TRACE_CONSTRUCTION
#ifdef CAGCEvent_TRACE_CONSTRUCTION
_TRACE_BEGIN
DWORD id = GetCurrentThreadId();
_TRACE_PART2("CAGCEvent::FinalConstruct(): ThreadId = %d (0x%X)\n", id, id);
_TRACE_PART1("\tRaw pointer = 0x%08X", this);
_TRACE_PART1(", IAGCEvent* = 0x%08X\n", static_cast<IAGCEvent*>(this));
_TRACE_END
#endif // !CAGCEvent_TRACE_CONSTRUCTION
// Indicate success
return S_OK;
}
void CAGCEvent::FinalRelease()
{
#if 0
#pragma pack(push, 4)
static long s_cIterations = 0;
#pragma pack(pop)
debugf("E:%06d\n", InterlockedIncrement(&s_cIterations));
#endif
}
HRESULT CAGCEvent::Init(AGCEventID idEvent, LPCSTR pszContext,
LPCOLESTR pszSubject, long idSubject, long cArgTriplets, va_list argptr)
{
XLock lock(this);
m_id = idEvent;
m_time = GetVariantDateTime();
m_idSubject = idSubject;
m_bstrSubjectName = pszSubject;
m_bstrContext = pszContext;
// Clear the property map
m_Properties.clear();
// Add the static properties to the dictionary
RETURN_FAILED(AddStaticFields());
// Add the specified properties to the dictionary
return AddToDictionaryV(cArgTriplets, argptr);
}
HRESULT CAGCEvent::Init(const CAGCEventData& data)
{
XLock lock(this);
// Get the fixed data
m_id = data.GetEventID();
m_time = data.GetTime();
m_idSubject = data.GetSubjectID();
// Clear the dictionary
m_Properties.clear();
// Get the variable data
data.GetVarData(&m_bstrContext, &m_bstrSubjectName, &m_Properties);
// Add the static properties to the dictionary
return AddStaticFields();
}
/////////////////////////////////////////////////////////////////////////////
// Operations
HRESULT CAGCEvent::AddToDictionary(long cArgTriplets, ...)
{
va_list argptr;
va_start(argptr, cArgTriplets);
HRESULT hr = AddToDictionaryV(cArgTriplets, argptr);
va_end(argptr);
return hr;
}
HRESULT CAGCEvent::AddToDictionaryV(long cArgTriplets, va_list argptr)
{
XLock lock(this);
// Iterate through the argument triplets
for (long i = 0; i < cArgTriplets; ++i)
{
// Get the argument name
LPCSTR pszArgName = va_arg(argptr, LPCSTR);
assert(!IsBadStringPtrA(pszArgName, UINT(-1)));
// Get the argument variant type and value
CComVariant var;
VARTYPE vt = va_arg(argptr, VARTYPE);
switch (V_VT(&var) = vt)
{
case VT_BOOL:
V_BOOL(&var) = va_arg(argptr, VARIANT_BOOL);
break;
case VT_I1:
V_I1(&var) = va_arg(argptr, CHAR);
break;
case VT_I2:
V_I2(&var) = va_arg(argptr, SHORT);
break;
case VT_I4:
V_I4(&var) = va_arg(argptr, LONG);
break;
case VT_UI1:
V_UI1(&var) = va_arg(argptr, BYTE);
break;
case VT_UI2:
V_UI2(&var) = va_arg(argptr, USHORT);
break;
case VT_ERROR:
V_ERROR(&var) = va_arg(argptr, SCODE);
break;
case VT_R4:
{
// (...) pushes a float argument onto the stack as a double
DOUBLE dblTemp = va_arg(argptr, DOUBLE);
V_R4(&var) = (float)dblTemp;
break;
}
case VT_R8:
V_R8(&var) = va_arg(argptr, DOUBLE);
break;
case VT_DECIMAL:
V_DECIMAL(&var) = va_arg(argptr, DECIMAL);
break;
case VT_CY:
V_CY(&var) = va_arg(argptr, CY);
break;
case VT_DATE:
V_DATE(&var) = va_arg(argptr, DATE);
break;
case VT_BSTR:
V_BSTR(&var) = SysAllocString(va_arg(argptr, BSTR));
break;
case VT_UNKNOWN:
V_UNKNOWN(&var) = va_arg(argptr, IUnknown*);
V_UNKNOWN(&var)->AddRef();
break;
case VT_DISPATCH:
V_DISPATCH(&var) = va_arg(argptr, IDispatch*);
V_DISPATCH(&var)->AddRef();
break;
case VT_VARIANT:
var.Copy(va_arg(argptr, VARIANT*));
break;
case VT_LPSTR:
{
V_VT(&var) = VT_BSTR;
LPCSTR psz = va_arg(argptr, LPCSTR);
USES_CONVERSION;
V_BSTR(&var) = (psz && '\0' != *psz) ? ::SysAllocString(A2COLE(psz)) : NULL;
break;
}
case VT_LPWSTR:
{
V_VT(&var) = VT_BSTR;
LPCWSTR psz = va_arg(argptr, LPCWSTR);
V_BSTR(&var) = (psz && L'\0' != *psz) ? ::SysAllocString(psz) : NULL;
break;
}
default:
if (vt & VT_BYREF)
{
V_BYREF(&var) = va_arg(argptr, void*);
break;
}
debugf("CAGCEvent::Init(): Specified VARTYPE %hu (0x%04X) is unsupported\n", vt, vt);
assert(false);
}
// Add the named value to the property map
m_Properties.insert(XProperties::value_type(CComBSTR(pszArgName), var));
}
// Indicate success
return S_OK;
}
HRESULT CAGCEvent::AddStaticFields()
{
// Add the static properties to the dictionary
XLock lock(this);
RETURN_FAILED(get_ComputerName(NULL));
return AddToDictionary(6,
".ID" , VT_I4 , m_id,
".Time" , VT_DATE, m_time,
".ComputerName", VT_BSTR, (BSTR)m_bstrComputerName,
".SubjectID" , VT_I4 , m_idSubject,
".SubjectName" , VT_BSTR, (BSTR)m_bstrSubjectName,
".Context" , VT_BSTR, (BSTR)m_bstrContext);
}
/////////////////////////////////////////////////////////////////////////////
// Implementation
bool CAGCEvent::IsStaticField(BSTR bstr)
{
if (!BSTRLen(bstr))
return false;
if (!_wcsicmp(bstr, OLESTR(".ID")))
return true;
if (!_wcsicmp(bstr, OLESTR(".Time")))
return true;
if (!_wcsicmp(bstr, OLESTR(".ComputerName")))
return true;
if (!_wcsicmp(bstr, OLESTR(".SubjectID")))
return true;
if (!_wcsicmp(bstr, OLESTR(".SubjectName")))
return true;
if (!_wcsicmp(bstr, OLESTR(".Context")))
return true;
return false;
}
HRESULT CAGCEvent::WriteStringToStream(IStream* pStm, BSTR bstr)
{
// Get the character length of the specified BSTR
ULONG cchBSTR = BSTRLen(bstr);
// Determine the number of bytes needed for conversion to ANSI
ULONG cchAnsi = cchBSTR ?
WideCharToMultiByte(CP_ACP, 0, bstr, cchBSTR, NULL, 0, NULL, NULL) : 0;
// Write an indicator of how many following bytes represent the length
BYTE bIndicator = GetSizePrefix(cchAnsi);
RETURN_FAILED(pStm->Write(&bIndicator, sizeof(bIndicator), NULL));
// Write the number of ANSI characters that follow
switch (bIndicator)
{
case LengthZero:
return S_OK;
case Length1Byte:
{
BYTE cch = (BYTE)cchAnsi;
RETURN_FAILED(pStm->Write(&cch, sizeof(cch), NULL));
break;
}
case Length2Bytes:
{
WORD cch = (WORD)cchAnsi;
RETURN_FAILED(pStm->Write(&cch, sizeof(cch), NULL));
break;
}
case Length4Bytes:
{
RETURN_FAILED(pStm->Write(&cchAnsi, sizeof(cchAnsi), NULL));
break;
}
default:
ZError("bad switch case in WriteStringToStream");
}
// Allocate the buffer for conversion
LPSTR psz = (LPSTR)_alloca(cchAnsi);
// Convert the BSTR to ANSI
if (!WideCharToMultiByte(CP_ACP, 0, bstr, cchBSTR, psz, cchAnsi, NULL, NULL))
return HRESULT_FROM_WIN32(GetLastError());
// Write the ANSI characters
RETURN_FAILED(pStm->Write(psz, cchAnsi, NULL));
// Indicate success
return S_OK;
}
HRESULT CAGCEvent::WriteVariantToStream(IStream* pStm, CComVariant& var)
{
// Special processing for VT_BSTR
if (VT_BSTR == V_VT(&var))
{
// Delegate to WriteStringToStream
RETURN_FAILED(WriteStringToStream(pStm, V_BSTR(&var)));
}
else
{
// Indicate a non-custom variant
BYTE bCustom = 0x00;
RETURN_FAILED(pStm->Write(&bCustom, sizeof(bCustom), NULL));
// Delegate non-custom variant types to CComVariant's implementation
RETURN_FAILED(var.WriteToStream(pStm));
}
// Indicate success
return S_OK;
}
HRESULT CAGCEvent::ReadStringFromStream(IStream* pStm, BSTR* pbstr, BYTE bIndicator)
{
assert(!*pbstr);
// Read the size indicator if zero was specified
if (!bIndicator)
{
RETURN_FAILED(pStm->Read(&bIndicator, sizeof(bIndicator), NULL));
}
// Read the number of ANSI character to follow
ULONG cchAnsi;
switch (bIndicator)
{
case LengthZero:
return S_OK;
case Length1Byte:
{
BYTE cch;
RETURN_FAILED(pStm->Read(&cch, sizeof(cch), NULL));
cchAnsi = cch;
break;
}
case Length2Bytes:
{
WORD cch;
RETURN_FAILED(pStm->Read(&cch, sizeof(cch), NULL));
cchAnsi = cch;
break;
}
case Length4Bytes:
{
RETURN_FAILED(pStm->Read(&cchAnsi, sizeof(cchAnsi), NULL));
break;
}
default:
ZError("bad switch case in ReadStringFromStream");
}
if (cchAnsi)
{
// Allocate a buffer for the ANSI characters and read them in
LPSTR pszAnsi = (LPSTR)_alloca(cchAnsi);
RETURN_FAILED(pStm->Read(pszAnsi, cchAnsi, NULL));
// Determine the number of bytes needed for conversion to Unicode
ULONG cchWide = MultiByteToWideChar(CP_ACP, 0, pszAnsi, cchAnsi, NULL, 0);
// Allocate a buffer for the conversion and convert it
LPWSTR pszWide = (LPWSTR)_alloca(cchWide);
if (!MultiByteToWideChar(CP_ACP, 0, pszAnsi, cchAnsi, pszWide, cchWide))
return HRESULT_FROM_WIN32(GetLastError());
// Allocate the BSTR
*pbstr = SysAllocStringLen(pszWide, cchWide);
if (!*pbstr)
return E_OUTOFMEMORY;
}
// Indicate success
return S_OK;
}
HRESULT CAGCEvent::ReadVariantFromStream(IStream* pStm, CComVariant& var)
{
// Clear the specified variant
var.Clear();
// Read the custom byte indicator
BYTE bCustom;
RETURN_FAILED(pStm->Read(&bCustom, sizeof(bCustom), NULL));
if (bCustom)
{
// Delegate to ReadStringFromStream
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = NULL;
RETURN_FAILED(ReadStringFromStream(pStm, &V_BSTR(&var), bCustom));
}
else
{
// Delegate non-custom variant types to CComVariant's implementation
RETURN_FAILED(var.ReadFromStream(pStm));
}
// Indicate success
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////
// This method is much like our IPersistStreamInit::Save implementation, but
// it ensures that all strings are written out as ANSI characters to save
// space.
//
// However, the IPersistStreamInit::Save implementation should not be changed
// as long as support is needed for the old format, which uses the ObjRef
// moniker.
//
HRESULT CAGCEvent::SaveToStream(IStream* pStm, BOOL fClearDirty)
{
XLock lock(this);
// Write out a short signature string (allows for future version checking)
LPCSTR pszSignature = "1:";
RETURN_FAILED(pStm->Write(pszSignature, strlen(pszSignature), NULL));
// Write out the ID and time
RETURN_FAILED(pStm->Write(&m_id, sizeof(m_id), NULL));
RETURN_FAILED(pStm->Write(&m_time, sizeof(m_time), NULL));
// Count the number of non-static fields
long cPairs = 0;
// mdvalley: again with the variable declarations
XPropertyIt it;
for (it = m_Properties.begin(); m_Properties.end() != it; ++it)
if (!IsStaticField(it->first))
++cPairs;
// Write out the number of non-static Key/Item pairs in the property map
RETURN_FAILED(pStm->Write(&cPairs, sizeof(cPairs), NULL));
// Write out each non-static Key/Item pair in the property map
for (it = m_Properties.begin(); m_Properties.end() != it; ++it)
{
CComBSTR& bstrKey = const_cast<CComBSTR&>(it->first);
CComVariant& varItem = it->second;
if (!IsStaticField(bstrKey))
{
RETURN_FAILED(WriteStringToStream(pStm, bstrKey));
RETURN_FAILED(WriteVariantToStream(pStm, varItem));
}
}
// Write out the computer name
RETURN_FAILED(get_ComputerName(NULL));
RETURN_FAILED(WriteStringToStream(pStm, m_bstrComputerName));
// Write out the subject ID and name
RETURN_FAILED(pStm->Write(&m_idSubject, sizeof(m_idSubject), NULL));
RETURN_FAILED(WriteStringToStream(pStm, m_bstrSubjectName));
// Write out the Context string
RETURN_FAILED(WriteStringToStream(pStm, m_bstrContext));
// Indicate success
return S_OK;
}
HRESULT CAGCEvent::LoadFromStream(IStream* pStm)
{
XLock lock(this);
// Read the signature string (allows for future version checking)
char szSignature[2];
RETURN_FAILED(pStm->Read(szSignature, sizeof(szSignature), NULL));
// Check the signature string
int iSignature = -1;
const static LPCSTR szSignatures[] = {"0:", "1:"};
for (int i = 0; i < sizeofArray(szSignatures); ++i)
{
if (0 == strncmp(szSignature, szSignatures[i], strlen(szSignatures[i])))
{
iSignature = i;
break;
}
}
if (-1 == iSignature)
return E_INVALIDARG;
// Read the ID and time
RETURN_FAILED(pStm->Read(&m_id, sizeof(m_id), NULL));
RETURN_FAILED(pStm->Read(&m_time, sizeof(m_time), NULL));
// Read the number of key/item pairs being read
long cCount = 0;
RETURN_FAILED(pStm->Read(&cCount, sizeof(cCount), NULL));
// Clear all items from the property map
m_Properties.clear();
// Read each pair from the stream
while (cCount--)
{
// Read the Key/Item pair from the stream
CComBSTR bstrKey;
CComVariant varItem;
RETURN_FAILED(ReadStringFromStream(pStm, &bstrKey));
RETURN_FAILED(ReadVariantFromStream(pStm, varItem));
// Add the Key/Item pair to the property map
m_Properties.insert(XProperties::value_type(bstrKey, varItem));
}
// Read the computer name
m_bstrComputerName.Empty();
RETURN_FAILED(ReadStringFromStream(pStm, &m_bstrComputerName));
// Read the subject ID and name
RETURN_FAILED(pStm->Read(&m_idSubject, sizeof(m_idSubject), NULL));
m_bstrSubjectName.Empty();
RETURN_FAILED(ReadStringFromStream(pStm, &m_bstrSubjectName));
// Read the context string
m_bstrContext.Empty();
if (iSignature >= 1)
{
RETURN_FAILED(ReadStringFromStream(pStm, &m_bstrContext));
}
// Add the static fields
RETURN_FAILED(AddStaticFields());
// Indicate success
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////
// ISupportErrorInfo Interface Methods
STDMETHODIMP CAGCEvent::InterfaceSupportsErrorInfo(REFIID riid)
{
static const IID* arr[] =
{
&IID_IAGCEvent
};
for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
{
if (InlineIsEqualGUID(*arr[i],riid))
return S_OK;
}
return S_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// IPersist Interface Methods
STDMETHODIMP CAGCEvent::GetClassID(CLSID* pClassID)
{
__try
{
*pClassID = GetObjectCLSID();
}
__except(1)
{
return E_POINTER;
}
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////
// IPersistStreamInit Interface Methods
STDMETHODIMP CAGCEvent::IsDirty()
{
// Always is dirty, since we don't keep a dirty flag
return S_OK;
}
STDMETHODIMP CAGCEvent::Load(LPSTREAM pStm)
{
XLock lock(this);
// Read the ID and time
RETURN_FAILED(pStm->Read(&m_id, sizeof(m_id), NULL));
RETURN_FAILED(pStm->Read(&m_time, sizeof(m_time), NULL));
// Read the number of key/item pairs being read
long cCount = 0;
RETURN_FAILED(pStm->Read(&cCount, sizeof(cCount), NULL));
// Clear all items from the property map
m_Properties.clear();
// Read each pair from the stream
while (cCount--)
{
// Read the Key/Item pair from the stream
CComBSTR bstrKey;
CComVariant varItem;
RETURN_FAILED(bstrKey.ReadFromStream(pStm));
RETURN_FAILED(varItem.ReadFromStream(pStm));
// Add the Key/Item pair to the property map
m_Properties.insert(XProperties::value_type(bstrKey, varItem));
}
// Read the computer name
m_bstrComputerName.Empty();
RETURN_FAILED(m_bstrComputerName.ReadFromStream(pStm));
// Read the subject ID and name
RETURN_FAILED(pStm->Read(&m_idSubject, sizeof(m_idSubject), NULL));
m_bstrSubjectName.Empty();
RETURN_FAILED(m_bstrSubjectName.ReadFromStream(pStm));
// Read the context string
m_bstrContext.Empty();
RETURN_FAILED(m_bstrContext.ReadFromStream(pStm));
// Add the static fields
RETURN_FAILED(AddStaticFields());
// Indicate success
return S_OK;
}
STDMETHODIMP CAGCEvent::Save(LPSTREAM pStm, BOOL fClearDirty)
{
XLock lock(this);
// Write out the ID and time
RETURN_FAILED(pStm->Write(&m_id, sizeof(m_id), NULL));
RETURN_FAILED(pStm->Write(&m_time, sizeof(m_time), NULL));
// Count the number of non-static fields
long cPairs = 0;
// mdvalley: Declaration motion makes me seasick.
XPropertyIt it;
for (it = m_Properties.begin(); m_Properties.end() != it; ++it)
if (!IsStaticField(it->first))
++cPairs;
// Write out the number of non-static Key/Item pairs in the property map
RETURN_FAILED(pStm->Write(&cPairs, sizeof(cPairs), NULL));
// Write out each non-static Key/Item pair in the property map
for (it = m_Properties.begin(); m_Properties.end() != it; ++it)
{
CComBSTR& bstrKey = const_cast<CComBSTR&>(it->first);
CComVariant& varItem = it->second;
if (!IsStaticField(bstrKey))
{
RETURN_FAILED(bstrKey.WriteToStream(pStm));
RETURN_FAILED(varItem.WriteToStream(pStm));
}
}
// Write out the computer name
RETURN_FAILED(get_ComputerName(NULL));
RETURN_FAILED(m_bstrComputerName.WriteToStream(pStm));
// Write out the subject ID and name
RETURN_FAILED(pStm->Write(&m_idSubject, sizeof(m_idSubject), NULL));
RETURN_FAILED(m_bstrSubjectName.WriteToStream(pStm));
// Write out the context string
RETURN_FAILED(m_bstrContext.WriteToStream(pStm));
// Indicate success
return S_OK;
}
STDMETHODIMP CAGCEvent::GetSizeMax(ULARGE_INTEGER* pCbSize)
{
return TCGetPersistStreamSize(GetUnknown(), pCbSize);
}
STDMETHODIMP CAGCEvent::InitNew()
{
// Initialize the Event object
XLock lock(this);
m_id = EventID_Unknown;
m_time = GetVariantDateTime();
m_Properties.clear();
// Indicate success
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////
// IAGCEvent Interface Methods
STDMETHODIMP CAGCEvent::get_Description(BSTR* pbstrDisplayString)
{
// Delegate to the CAGCEventDef class
return CAGCEventDef::GetEventDescription(this, pbstrDisplayString);
}
STDMETHODIMP CAGCEvent::get_ID(AGCEventID* pVal)
{
XLock lock(this);
CLEAROUT(pVal, m_id);
return S_OK;
}
STDMETHODIMP CAGCEvent::get_Time(DATE* pVal)
{
XLock lock(this);
CLEAROUT(pVal, m_time);
return S_OK;
}
STDMETHODIMP CAGCEvent::get_PropertyCount(long* pnCount)
{
XLock lock(this);
CLEAROUT(pnCount, (long)m_Properties.size());
return S_OK;
}
STDMETHODIMP CAGCEvent::get_PropertyExists(BSTR bstrKey,
VARIANT_BOOL* pbExists)
{
XLock lock(this);
XPropertyIt it = m_Properties.find(bstrKey);
CLEAROUT(pbExists, VARBOOL(m_Properties.end() != it));
return S_OK;
}
STDMETHODIMP CAGCEvent::get_Property(VARIANT* pvKey, VARIANT* pvValue)
{
// Check for default value
CComVariant var;
if (pvKey)
{
CComVariant varKey(*pvKey);
// Check for an index first
if (SUCCEEDED(varKey.ChangeType(VT_UI4)))
{
XLock lock(this);
ULONG iIndex = V_UI4(&varKey);
bool bGetKey = !!(iIndex & 0x80000000);
iIndex &= 0x7FFFFFFF;
if (iIndex >= m_Properties.size())
return E_INVALIDARG;
if (iIndex < (m_Properties.size() + 1) / 2)
{
XPropertyIt it = m_Properties.begin();
for (ULONG i = 0; i < iIndex; ++i)
++it;
if (bGetKey)
var = it->first;
else
var = it->second;
}
else
{
XPropertyRevIt rit = m_Properties.rbegin();
for (ULONG i = m_Properties.size() - 1; i > iIndex; --i)
++rit;
if (bGetKey)
var = rit->first;
else
var = rit->second;
}
}
else
{
// Only support VT_BSTR at this time
CComVariant varKey(*pvKey);
RETURN_FAILED(varKey.ChangeType(VT_BSTR));
CComBSTR bstrKey(V_BSTR(&varKey));
// Find the specified string or not
XLock lock(this);
XPropertyIt it = m_Properties.find(bstrKey);
if (m_Properties.end() != it)
{
// Get the value associated with the key
var = it->second;
}
else
{
// Add it since it wasn't there
m_Properties.insert(XProperties::value_type(bstrKey, var));
}
}
}
else
{
RETURN_FAILED(get_Description(&V_BSTR(&var)));
V_VT(&var) = VT_BSTR;
}
return var.Detach(pvValue);
}
STDMETHODIMP CAGCEvent::get_ComputerName(BSTR* pbstrComputerName)
{
// Initialize the [out] parameter
if (pbstrComputerName)
CLEAROUT(pbstrComputerName, (BSTR)NULL);
// Copy the stored name, if any
XLock lock(this);
if (!m_bstrComputerName.Length())
{
// Get the computer name
TCHAR szName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD cchName = sizeofArray(szName);
GetComputerName(szName, &cchName);
// Save the computer name
m_bstrComputerName = szName;
}
// Copy the name to the [out] parameter
if (pbstrComputerName)
{
USES_CONVERSION;
*pbstrComputerName = m_bstrComputerName.Copy();
}
// Indicate success
return S_OK;
}
STDMETHODIMP CAGCEvent::get_SubjectID(long* pidSubject)
{
XLock lock(this);
CLEAROUT(pidSubject, m_idSubject);
return S_OK;
}
STDMETHODIMP CAGCEvent::get_SubjectName(BSTR* pbstrSubject)
{
XLock lock(this);
CComBSTR bstrTemp(m_bstrSubjectName);
CLEAROUT(pbstrSubject, (BSTR)bstrTemp);
bstrTemp.Detach();
return S_OK;
}
STDMETHODIMP CAGCEvent::SaveToString(BSTR* pbstr)
{
// Create a memory stream
IStreamPtr spStm;
RETURN_FAILED(CreateStreamOnHGlobal(NULL, true, &spStm));
// Persist this object to the stream
RETURN_FAILED(SaveToStream(spStm, false));
// Get the size of the binary data in the stream
ULARGE_INTEGER uli;
LARGE_INTEGER liMove = {0, 0};
ZSucceeded(spStm->Seek(liMove, STREAM_SEEK_CUR, &uli));
assert(0 == uli.HighPart);
DWORD cbData = uli.LowPart;
// Get the HGLOBAL from the stream
HGLOBAL hGlobal;
RETURN_FAILED(GetHGlobalFromStream(spStm, &hGlobal));
// Lock the HGLOBAL to resolve it to a pointer
void* pvData = GlobalLock(hGlobal);
// Determine the length of the string representation of binary data
DWORD cch = TCBinString<OLECHAR>::GetEncodedStringLength(pvData, cbData);
// Allocate a buffer for the encoded string
LPOLESTR psz = (LPOLESTR)_alloca((cch + 1) * sizeof(OLECHAR));
// Encode the binary data to a string
HRESULT hr = TCBinString<OLECHAR>::EncodeToString(pvData, cbData, psz);
// Unlock the HGLOBAL
GlobalUnlock(hGlobal);
// Return if the encoding failed
RETURN_FAILED(hr);
// Allocate the BSTR
*pbstr = SysAllocStringLen(psz, cch);
if (!*pbstr)
return E_OUTOFMEMORY;
// Indicate success
return S_OK;
}
STDMETHODIMP CAGCEvent::LoadFromString(BSTR bstr)
{
///////////////////////////////////////////////////////////////////////////
// Support the old format
const static OLECHAR szObjRef[] = OLESTR("objref:");
const static int cchObjRef = sizeofArray(szObjRef) - 1;
if (0 == wcsncmp(bstr, szObjRef, cchObjRef))
{
// Create an object from the specified BSTR
IUnknownPtr spUnk;
RETURN_FAILED(TCUtilImpl::GetObject(bstr, VARIANT_FALSE, INFINITE, &spUnk));
// Load ourself as a copy of the new object
return CopyObjectThruStream(GetUnknown(), spUnk);
}
///////////////////////////////////////////////////////////////////////////
// Must be the newer format
///////////////////////////////////////////////////////////////////////////
// Get the number of bytes the encoded string will decode to
DWORD cbData = TCBinString<OLECHAR>::GetDecodedDataSize(bstr);
if (0xFFFFFFFF == cbData)
return E_INVALIDARG;
// Allocate a buffer for the decoded binary data
void* pvData = _alloca(cbData);
// Decode the data
RETURN_FAILED(TCBinString<OLECHAR>::DecodeFromString(bstr, pvData, NULL));
// Create a simple stream on the data buffer
TCSimpleStream stm;
stm.Init(cbData, pvData);
// Load the object from the stream
RETURN_FAILED(LoadFromStream(&stm));
// Indicate success
return S_OK;
}
STDMETHODIMP CAGCEvent::get_Context(BSTR* pbstrContext)
{
XLock lock(this);
CComBSTR bstrTemp(m_bstrContext);
CLEAROUT(pbstrContext, (BSTR)bstrTemp);
bstrTemp.Detach();
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////
// IAGCEventCreate Interface Methods
STDMETHODIMP CAGCEvent::Init()
{
// Delegate to InitNew
return InitNew();
}
STDMETHODIMP CAGCEvent::put_ID(AGCEventID Val)
{
XLock lock(this);
m_id = Val;
// Indicate success
return S_OK;
}
STDMETHODIMP CAGCEvent::put_Time(DATE Val)
{
XLock lock(this);
m_time = Val;
// Indicate success
return S_OK;
}
STDMETHODIMP CAGCEvent::SetTimeNow()
{
XLock lock(this);
m_time = GetVariantDateTime();
// Indicate success
return S_OK;
}
STDMETHODIMP CAGCEvent::AddProperty(BSTR pbstrKey, VARIANT* pvValue)
{
if (!pbstrKey)
return E_INVALIDARG;
XLock lock(this);
m_Properties[pbstrKey] = *pvValue;
// Indicate success
return S_OK;
}
STDMETHODIMP CAGCEvent::RemoveProperty(BSTR pbstrKey, VARIANT* pvValue)
{
if (!pbstrKey)
return E_INVALIDARG;
XLock lock(this);
XPropertyIt it = m_Properties.find(*pbstrKey);
if (m_Properties.end() != it)
m_Properties.erase(it);
// Indicate success
return S_OK;
}
STDMETHODIMP CAGCEvent::put_SubjectID(long idSubject)
{
XLock lock(this);
m_idSubject = idSubject;
// Indicate success
return S_OK;
}
STDMETHODIMP CAGCEvent::put_SubjectName(BSTR bstrSubject)
{
XLock lock(this);
m_bstrSubjectName = bstrSubject;
// Indicate success
return S_OK;
}
STDMETHODIMP CAGCEvent::put_Context(BSTR bstrContext)
{
XLock lock(this);
m_bstrContext = bstrContext;
// Indicate success
return S_OK;
}
| 25.08444 | 93 | 0.645788 | [
"object"
] |
94d49aa209fa9ada2881efb27f6ee5ce2051de09 | 1,346 | hpp | C++ | source/backend/cpu/CPUConvArm82Int8.hpp | zhangzan1997/MNN | 2860411058fcd5f5d4848b92b571276bda00e12b | [
"Apache-2.0"
] | 1 | 2021-06-01T03:02:29.000Z | 2021-06-01T03:02:29.000Z | source/backend/cpu/CPUConvArm82Int8.hpp | zhangzan1997/MNN | 2860411058fcd5f5d4848b92b571276bda00e12b | [
"Apache-2.0"
] | null | null | null | source/backend/cpu/CPUConvArm82Int8.hpp | zhangzan1997/MNN | 2860411058fcd5f5d4848b92b571276bda00e12b | [
"Apache-2.0"
] | null | null | null | //
// CPUConvArm82Int8.hpp
// MNN
//
// Created by MNN on b'2020/12/30'.
// Copyright © 2018, Alibaba Group Holding Limited
//
#ifndef CPUConvArm82Int8_hpp
#define CPUConvArm82Int8_hpp
#if defined(ENABLE_ARMV82) && (defined(__ANDROID__) || defined(__aarch64__))
#include "backend/cpu/CPUConvolution.hpp"
#include "backend/cpu/CPUConvInt8.hpp"
#include <MNN/Tensor.hpp>
namespace MNN {
class CPUConvArm82Int8 : public CPUConvolution {
public:
CPUConvArm82Int8(Backend *backend, const MNN::Convolution2D *convParam, float inputScale, float outputScale);
CPUConvArm82Int8(std::shared_ptr<CPUConvInt8::ResourceInt8> res, Backend* backend, const MNN::Convolution2DCommon* common);
virtual ~CPUConvArm82Int8() {
// Do nothing
}
virtual ErrorCode onResize(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
virtual ErrorCode onExecute(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
virtual bool onClone(Backend* bn, const Op* op, Execution** dst) override;
private:
// relu or relu6
bool mRelu;
std::shared_ptr<CPUConvInt8::ResourceInt8> mResource;
ConvolutionCommon::Im2ColParameter mIm2ColParamter;
int mTileCount;
int mThreadNums;
Tensor mTempIm2ColBuffer;
Tensor mTempRemainBuffer;
};
};
#endif
#endif
| 32.829268 | 127 | 0.736256 | [
"vector"
] |
94dcdc05d2369bcc1a2cbd188c98d403db555b67 | 2,491 | hpp | C++ | framework/api/sys/helpers/macros/function_pointer.hpp | dterletskiy/carpc | c98d84e5bce69fb30a0f34e7b6cd82b4c98ba9b5 | [
"MIT"
] | 6 | 2022-03-24T15:40:03.000Z | 2022-03-30T09:40:20.000Z | framework/api/sys/helpers/macros/function_pointer.hpp | dterletskiy/carpc | c98d84e5bce69fb30a0f34e7b6cd82b4c98ba9b5 | [
"MIT"
] | 7 | 2022-03-24T18:53:52.000Z | 2022-03-30T10:15:50.000Z | framework/api/sys/helpers/macros/function_pointer.hpp | dterletskiy/carpc | c98d84e5bce69fb30a0f34e7b6cd82b4c98ba9b5 | [
"MIT"
] | 1 | 2022-03-20T21:22:09.000Z | 2022-03-20T21:22:09.000Z | #pragma once
/****************************************************************************************************
*
* Function pointer helper macros
*
* Examples:
*
* class Consumer
* {
* public:
* void print( int value ) { MSG_INF( "%d", value ); }
* };
* void print( int value ) { MSG_INF( "%d", value ); }
* void print( ) { MSG_INF( ); }
* int main( int argc, char *argv[] )
* {
* Consumer consumer;
* DEFINE_FUNCTION_POINTER( void, pf_void );
* SET_FUNCTION_POINTER( pf_void, print );
* CALL_FUNCTION_POINTER( pf_void );
* DEFINE_FUNCTION_POINTER( void, pf_int, int );
* SET_FUNCTION_POINTER( pf_int, print );
* CALL_FUNCTION_POINTER( pf_int, 123 );
* DEFINE_CLASS_FUNCTION_POINTER( void, Consumer, pf_class_int, int );
* SET_CLASS_FUNCTION_POINTER( pf_class_int, Consumer, print );
* CALL_CLASS_FUNCTION_POINTER( consumer, pf_class_int, 456 );
* DEFINE_FUNCTION_POINTER_TYPE( void, tpf_int, int );
* SET_FUNCTION_POINTER_TYPE( tpf_int, pf1, print );
* CALL_FUNCTION_POINTER( pf1, 123 );
* DEFINE_CLASS_FUNCTION_POINTER_TYPE( void, Consumer, tpf_class_int, int );
* SET_CLASS_FUNCTION_POINTER_TYPE( tpf_class_int, pf2, Consumer, print );
* CALL_CLASS_FUNCTION_POINTER( consumer, pf2, 456 );
* return 0;
* }
*
***************************************************************************************************/
#define DEFINE_FUNCTION_POINTER_TYPE( RETURN_TYPE, TYPE, ... ) \
typedef RETURN_TYPE ( *TYPE ) ( __VA_ARGS__ );
// using TYPE = RETURN_TYPE (*)( __VA_ARGS__ );
#define DEFINE_FUNCTION_POINTER( RETURN_TYPE, NAME, ... ) \
RETURN_TYPE ( *NAME )( __VA_ARGS__ );
#define SET_FUNCTION_POINTER_TYPE( TYPE, NAME, FUNCTION ) \
TYPE NAME = &FUNCTION;
#define SET_FUNCTION_POINTER( NAME, FUNCTION ) \
NAME = &FUNCTION;
#define CALL_FUNCTION_POINTER( NAME, ... ) \
NAME( __VA_ARGS__ );
#define DEFINE_CLASS_FUNCTION_POINTER_TYPE( RETURN_TYPE, NS, TYPE, ... ) \
typedef RETURN_TYPE ( NS::*TYPE ) ( __VA_ARGS__ );
// using TYPE = RETURN_TYPE ( NS::* )( __VA_ARGS__ );
#define DEFINE_CLASS_FUNCTION_POINTER( RETURN_TYPE, NS, NAME, ... ) \
RETURN_TYPE ( NS::*NAME )( __VA_ARGS__ );
#define SET_CLASS_FUNCTION_POINTER_TYPE( TYPE, NAME, NS, FUNCTION ) \
TYPE NAME = &NS::FUNCTION;
#define SET_CLASS_FUNCTION_POINTER( NAME, NS, FUNCTION ) \
NAME = &NS::FUNCTION;
#define CALL_CLASS_FUNCTION_POINTER( OBJECT, NAME, ... ) \
( OBJECT.*NAME )( __VA_ARGS__ );
| 35.084507 | 101 | 0.621839 | [
"object"
] |
94eadd9f99ab3fd731db46b7a44f37b2e8aab887 | 2,081 | hpp | C++ | liboh/plugins/js/JSObjectStructs/JSVisibleStruct.hpp | sirikata/sirikata | 3a0d54a8c4778ad6e25ef031d461b2bc3e264860 | [
"BSD-3-Clause"
] | 31 | 2015-01-28T17:01:10.000Z | 2021-11-04T08:30:37.000Z | liboh/plugins/js/JSObjectStructs/JSVisibleStruct.hpp | sirikata/sirikata | 3a0d54a8c4778ad6e25ef031d461b2bc3e264860 | [
"BSD-3-Clause"
] | null | null | null | liboh/plugins/js/JSObjectStructs/JSVisibleStruct.hpp | sirikata/sirikata | 3a0d54a8c4778ad6e25ef031d461b2bc3e264860 | [
"BSD-3-Clause"
] | 9 | 2015-08-02T18:39:49.000Z | 2019-10-11T10:32:30.000Z | #ifndef __SIRIKATA_JS_VISIBLE_STRUCT_HPP__
#define __SIRIKATA_JS_VISIBLE_STRUCT_HPP__
#include <sirikata/oh/HostedObject.hpp>
#include <v8.h>
#include <vector>
#include "JSPositionListener.hpp"
#include "../JSCtx.hpp"
#include "../JSVisibleData.hpp"
namespace Sirikata {
namespace JS {
//need to forward-declare this so that can reference this inside
class EmersonScript;
class JSVisibleManager;
struct JSVisibleStruct : public JSPositionListener
{
public:
virtual ~JSVisibleStruct();
//for decoding
static JSVisibleStruct* decodeVisible(v8::Handle<v8::Value> senderVal,std::string& errorMessage);
//methods mapped to javascript's visible object
v8::Handle<v8::Value> toString();
v8::Handle<v8::Value> printData();
// Increases weak ref count when creating a weak v8 reference to
// this object
void createWeakRef();
/**
Should be auto-called by v8 when the last emerson object with a reference
to this struct has been garbage collected.
Frees memory associated with visStruct field in
containsVisStruct. otherArg should be null.
*/
static void visibleWeakReferenceCleanup(v8::Persistent<v8::Value> containsVisStruct, void* otherArg);
private:
JSVisibleStruct(EmersonScript* parent, JSAggregateVisibleDataPtr jspd, JSCtx* ctx);
friend class JSVisibleManager;
// JSVisibleDataEventListener Interface
virtual void visiblePositionChanged(JSVisibleData* data);
virtual void visibleVelocityChanged(JSVisibleData* data);
virtual void visibleOrientationChanged(JSVisibleData* data);
virtual void visibleOrientationVelChanged(JSVisibleData* data);
virtual void visibleScaleChanged(JSVisibleData* data);
virtual void visibleMeshChanged(JSVisibleData* data);
virtual void visiblePhysicsChanged(JSVisibleData* data);
// Refcount for garbage collection from V8
AtomicValue<uint32> mV8RefCount;
};
typedef std::vector<JSVisibleStruct*> JSVisibleVec;
typedef JSVisibleVec::iterator JSVisibleVecIter;
}//end namespace js
}//end namespace sirikata
#endif
| 30.602941 | 105 | 0.760692 | [
"object",
"vector"
] |
94f06645b7376e84c178e76bbf13afc3068ae4fa | 873 | cpp | C++ | NeuralNetwork/SingleLayerNeuralNetwork/NeuralNetwork.cpp | gopiraj15/DeepLearning | 7a61209ca294d818ff5f413a223ac4f0f1893f79 | [
"MIT"
] | null | null | null | NeuralNetwork/SingleLayerNeuralNetwork/NeuralNetwork.cpp | gopiraj15/DeepLearning | 7a61209ca294d818ff5f413a223ac4f0f1893f79 | [
"MIT"
] | null | null | null | NeuralNetwork/SingleLayerNeuralNetwork/NeuralNetwork.cpp | gopiraj15/DeepLearning | 7a61209ca294d818ff5f413a223ac4f0f1893f79 | [
"MIT"
] | null | null | null | #include "NeuralNetwork.h"
using namespace cv;
using namespace std;
void load_dataset(std::string x_data, std::string y_data, vector<double>& X, vector<double>& Y)
{
ifstream xf(x_data), yf(y_data);
while (!xf.eof())
{
double x;
xf >> x;
X.emplace_back(x);
}
xf.close();
X.erase(X.begin() + X.size() - 1);
while (!yf.eof())
{
double y;
yf >> y;
Y.emplace_back(y);
}
yf.close();
Y.erase(Y.begin() + Y.size() - 1);
}
//This function computes tanh on the input
cv::Mat tanh(cv::Mat ip)
{
Mat p_exp, n_exp;
cv::exp(ip, p_exp);
cv::exp(-ip, n_exp);
return (p_exp - n_exp) / (p_exp + n_exp);
}
//computes sigmoid on the input
cv::Mat sigmoid(cv::Mat ip)
{
Mat n_exp;
cv::exp(-ip, n_exp);
return cv::Mat(1 / (1 + n_exp));
}
cv::Mat col_sum(cv::Mat ip, double m)
{
cv::Mat res;
cv::reduce(ip, res, 1, REDUCE_SUM);
return res / m;
}
| 14.311475 | 95 | 0.608247 | [
"vector"
] |
94fafa11bd9b4b9c02195ad2c351ef85cab49d36 | 5,989 | cpp | C++ | openbr/plugins/imgproc/integralsampler.cpp | kassemitani/openbr | 7b453f7abc6f997839a858f4b7686bc5e21ef7b2 | [
"Apache-2.0"
] | 61 | 2016-01-27T04:23:04.000Z | 2020-06-19T20:45:16.000Z | openbr/plugins/imgproc/integralsampler.cpp | kassemitani/openbr | 7b453f7abc6f997839a858f4b7686bc5e21ef7b2 | [
"Apache-2.0"
] | 2 | 2016-04-09T13:55:15.000Z | 2017-11-21T03:08:08.000Z | openbr/plugins/imgproc/integralsampler.cpp | kassemitani/openbr | 7b453f7abc6f997839a858f4b7686bc5e21ef7b2 | [
"Apache-2.0"
] | 18 | 2016-01-27T13:07:47.000Z | 2022-01-22T17:19:18.000Z | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright 2012 The MITRE Corporation *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <Eigen/Dense>
#include <openbr/plugins/openbr_internal.h>
using namespace cv;
namespace br
{
/*!
* \ingroup transforms
* \brief Sliding window feature extraction from a multi-channel integral image.
* \author Josh Klontz \cite jklontz
*/
class IntegralSamplerTransform : public UntrainableTransform
{
Q_OBJECT
Q_PROPERTY(int scales READ get_scales WRITE set_scales RESET reset_scales STORED false)
Q_PROPERTY(float scaleFactor READ get_scaleFactor WRITE set_scaleFactor RESET reset_scaleFactor STORED false)
Q_PROPERTY(float stepFactor READ get_stepFactor WRITE set_stepFactor RESET reset_stepFactor STORED false)
Q_PROPERTY(int minSize READ get_minSize WRITE set_minSize RESET reset_minSize STORED false)
Q_PROPERTY(bool secondOrder READ get_secondOrder WRITE set_secondOrder RESET reset_secondOrder STORED false)
BR_PROPERTY(int, scales, 6)
BR_PROPERTY(float, scaleFactor, 2)
BR_PROPERTY(float, stepFactor, 0.75)
BR_PROPERTY(int, minSize, 8)
BR_PROPERTY(bool, secondOrder, false)
void project(const Template &src, Template &dst) const
{
typedef Eigen::Map< const Eigen::Matrix<qint32,Eigen::Dynamic,1> > InputDescriptor;
typedef Eigen::Map< const Eigen::Matrix<float,Eigen::Dynamic,1> > SecondOrderInputDescriptor;
typedef Eigen::Map< Eigen::Matrix<float,Eigen::Dynamic,1> > OutputDescriptor;
const Mat &m = src.m();
if (m.depth() != CV_32S) qFatal("Expected CV_32S matrix depth.");
const int channels = m.channels();
const int rowStep = channels * m.cols;
int descriptors = 0;
float idealSize = min(m.rows, m.cols)-1;
for (int scale=0; scale<scales; scale++) {
const int currentSize(idealSize);
const int numDown = 1+(m.rows-currentSize-1)/int(idealSize*stepFactor);
const int numAcross = 1+(m.cols-currentSize-1)/int(idealSize*stepFactor);
descriptors += numDown*numAcross;
if (secondOrder) descriptors += numDown*(numAcross-1) + (numDown-1)*numAcross;
idealSize /= scaleFactor;
if (idealSize < minSize) break;
}
Mat n(descriptors, channels, CV_32FC1);
const qint32 *dataIn = (qint32*)m.data;
float *dataOut = (float*)n.data;
idealSize = min(m.rows, m.cols)-1;
int index = 0;
for (int scale=0; scale<scales; scale++) {
const int currentSize(idealSize);
const int currentStep(idealSize*stepFactor);
for (int i=currentSize; i<m.rows; i+=currentStep) {
for (int j=currentSize; j<m.cols; j+=currentStep) {
InputDescriptor a(dataIn+((i-currentSize)*rowStep+(j-currentSize)*channels), channels, 1);
InputDescriptor b(dataIn+((i-currentSize)*rowStep+ j *channels), channels, 1);
InputDescriptor c(dataIn+(i *rowStep+(j-currentSize)*channels), channels, 1);
InputDescriptor d(dataIn+(i *rowStep+ j *channels), channels, 1);
OutputDescriptor y(dataOut+(index*channels), channels, 1);
y = (d-b-c+a).cast<float>()/(currentSize*currentSize);
index++;
}
}
if (secondOrder) {
const int numDown = 1+(m.rows-currentSize-1)/currentStep;
const int numAcross = 1+(m.cols-currentSize-1)/currentStep;
const float *dataIn = n.ptr<float>(index - numDown*numAcross);
for (int i=0; i<numDown; i++) {
for (int j=0; j<numAcross; j++) {
SecondOrderInputDescriptor a(dataIn + (i*numAcross+j)*channels, channels, 1);
if (j < numAcross-1) {
OutputDescriptor y(dataOut+(index*channels), channels, 1);
y = a - SecondOrderInputDescriptor(dataIn + (i*numAcross+j+1)*channels, channels, 1);
index++;
}
if (i < numDown-1) {
OutputDescriptor y(dataOut+(index*channels), channels, 1);
y = a - SecondOrderInputDescriptor(dataIn + ((i+1)*numAcross+j)*channels, channels, 1);
index++;
}
}
}
}
idealSize /= scaleFactor;
if (idealSize < minSize) break;
}
if (descriptors != index)
qFatal("Allocated %d descriptors but computed %d.", descriptors, index);
dst.m() = n;
}
};
BR_REGISTER(Transform, IntegralSamplerTransform)
} // namespace br
#include "imgproc/integralsampler.moc"
| 48.691057 | 115 | 0.54717 | [
"transform"
] |
94fced861ac1aef92defd369cabd6586cd9944e6 | 1,114 | cpp | C++ | source/FAST/Examples/DataImport/importVertexMeshFromFile.cpp | andreped/FAST | 361819190ea0ae5a2f068e7bd808a1c70af5a171 | [
"BSD-2-Clause"
] | null | null | null | source/FAST/Examples/DataImport/importVertexMeshFromFile.cpp | andreped/FAST | 361819190ea0ae5a2f068e7bd808a1c70af5a171 | [
"BSD-2-Clause"
] | null | null | null | source/FAST/Examples/DataImport/importVertexMeshFromFile.cpp | andreped/FAST | 361819190ea0ae5a2f068e7bd808a1c70af5a171 | [
"BSD-2-Clause"
] | null | null | null | /**
* @example importVertexMeshFromFile.cpp
* An example of importing and visualizing a mesh containing vertices from a file using the VTKMeshFileImporter
*/
#include <FAST/Tools/CommandLineParser.hpp>
#include "FAST/Importers/VTKMeshFileImporter.hpp"
#include "FAST/Visualization/VertexRenderer/VertexRenderer.hpp"
#include "FAST/Visualization/SimpleWindow.hpp"
using namespace fast;
int main(int argc, char** argv) {
CommandLineParser parser("Import point set from file");
parser.addPositionVariable(1, "filename", Config::getTestDataPath() + "Surface_LV.vtk");
parser.parse(argc, argv);
// Import line set from vtk file
auto importer = VTKMeshFileImporter::create(parser.get("filename"));
// Render vertices
auto renderer = VertexRenderer::create()->connect(importer);
// Setup window
auto window = SimpleWindow3D::create()->connect(renderer);
#ifdef FAST_CONTINUOUS_INTEGRATION
// This will automatically close the window after 5 seconds, used for CI testing
window->setTimeout(5*1000);
#endif
// Run entire pipeline and display window
window->run();
}
| 34.8125 | 111 | 0.745063 | [
"mesh",
"render"
] |
94fdf7db1e182e744e4b3edc13c5bc4b86e3d6be | 4,125 | cc | C++ | src/sas/sascalc/simulation/pointsmodelpy/tests/testlores.cc | opendatafit/sasview | c470220eecfc9f6d8a0e27e2ea8919dcb1b38e39 | [
"BSD-3-Clause"
] | null | null | null | src/sas/sascalc/simulation/pointsmodelpy/tests/testlores.cc | opendatafit/sasview | c470220eecfc9f6d8a0e27e2ea8919dcb1b38e39 | [
"BSD-3-Clause"
] | 1 | 2021-09-20T13:20:35.000Z | 2021-09-20T13:20:35.000Z | src/sas/sascalc/simulation/pointsmodelpy/tests/testlores.cc | opendatafit/sasview | c470220eecfc9f6d8a0e27e2ea8919dcb1b38e39 | [
"BSD-3-Clause"
] | null | null | null | #include <cstdlib>
#include <iostream>
#include <fstream>
#include <vector>
#include "lores_model.h"
#include "sphere.h"
#include "cylinder.h"
#include "ellipsoid.h"
#include "Point3D.h"
using namespace std;
void test_calculateIQ(LORESModel &lm);
void WritePointsCoor(vector<Point3D> &vp){
ofstream outfile("testcc.coor");
for(size_t i=0; i<vp.size(); ++i){
outfile<<vp[i].getX()<<" "<<vp[i].getY()<<" "<<vp[i].getZ()<<" "<<1.0<<endl;
}
}
void test_lores(){
LORESModel lm(0.5);
cout << "density is:" << lm.GetDensity() << endl;
Sphere s1(10);
s1.SetOrientation(10,10,20);
s1.SetCenter(10,10,10);
lm.Add(s1,1.0);
Cylinder c1(5,20);
c1.SetCenter(0,0,0);
c1.SetOrientation(10,20,30);
lm.Add(c1,1.0);
/*
Cylinder c2(40,100);
c2.SetCenter(-30,-40,-35);
lm.Add(c2,1.0);
*/
/*
Ellipsoid e1(20,15,10);
e1.SetCenter(0,0,0);
e1.SetOrientation(10,10,20);
lm.Add(e1,1.0);
*/
/*test multiple spheres
int range = 20;
int r = 5;
for (int k = 0; k < 1000; ++k) {
Sphere s(r + rand() % r);
s.SetCenter(rand() % range, rand() % range, rand() % range);
lm.Add(s, 1.0);
}
*/
/*
Sphere s1(10);
cout << "sphere information:" << s1.GetVolume() << " " << s1.GetRadius() <<endl;
s1.SetOrientation(10,20,10);
s1.SetCenter(1,5,2);
lm.Add(s1,1.0);
Sphere s2(15);
s2.SetCenter(20,20,20);
lm.Add(s2,2.0);
Sphere s3(5);
s3.SetCenter(0,0,0);
lm.Add(s3,2.0);
Sphere s4(5);
s4.SetCenter(0,0,10);
lm.Add(s4,2.0);
Sphere s5(10);
s5.SetCenter(20,0,0);
lm.Add(s5,2.0);
*/
test_calculateIQ(lm);
}
void test_calculateIQ(LORESModel &lm){
IQ iq1(10,0.001,0.3);
cout << "iq information:" << iq1.GetQmin() <<endl;
vector<Point3D> vp;
lm.GetPoints(vp);
WritePointsCoor(vp);
cout << "vp size:" <<vp.size()<<endl;
cout << "save into pdb file" << endl;
lm.OutputPDB(vp,"model.pdb");
// for (vector<Point3D>::iterator iter = vp.begin();
// iter != vp.end(); ++iter){
// cout << *iter << endl;
//}
lm.DistDistribution(vp);
Array2D<double> pr(lm.GetPr());
//for(int i = 0; i< pr.dim1(); ++i)
// cout << pr[i][0] << " " << pr[i][1] << " " << pr[i][2] << endl;
lm.OutputPR("test.pr");
cout << "pass ddfunction, and print out the pr file" <<endl;
lm.CalculateIQ(&iq1);
cout <<"I(Q): \n" ;
//for (int i = 0; i< iq1.iq_data.dim1(); i++)
// cout << iq1.iq_data[i][0]<< " " << iq1.iq_data[i][1] <<endl;
}
void test_lores2d(){
LORESModel lm(0.1);
Cylinder c1(5,20);
c1.SetCenter(0,0,0);
c1.SetOrientation(10,20,30);
lm.Add(c1,1.0);
vector<Point3D> vp;
lm.GetPoints(vp);
lm.DistDistributionXY(vp);
lm.OutputPR_XY("test2d.pr");
IQ iq(10,0.001,0.3);
lm.CalculateIQ_2D(&iq,10);
iq.OutputIQ("test2d.iq");
}
void test_lores2d_qxqy(){
LORESModel lm(0.1);
Cylinder c1(5,20);
c1.SetCenter(0,0,0);
c1.SetOrientation(10,20,30);
lm.Add(c1,1.0);
vector<Point3D> vp;
lm.GetPoints(vp);
lm.DistDistributionXY(vp);
double aI = lm.CalculateIQ_2D(0.1,0.2);
cout << " a single I is: "<<aI<<" at Qx,Qy = 0.1,0.2" <<endl;
}
void test_GetCenter()
{
LORESModel lm(0.1);
Sphere s1(10);
s1.SetCenter(-1,-1,-1);
Sphere s2(20);
s2.SetCenter(1,1,1);
lm.Add(s1,1.0);
lm.Add(s2,1.0);
vector<double> center(3);
center = lm.GetCenter();
cout << "center should be (0,0,0) after adding two spheres:"<<endl;
cout << center[0] <<" "<< center[1] <<" "<< center[2]<<endl;
}
void test_CalSingleI(){
LORESModel lm(0.1);
Cylinder cyn(10,40);
lm.Add(cyn,1.0);
vector<Point3D> vp;
lm.GetPoints(vp);
lm.DistDistribution(vp);
double result = lm.CalculateIQ(0.1);
cout << "The I(0.1) is: " << result << endl;
}
int main(){
printf("this\n");
cout << "Start" << endl;
//test_lores();
cout <<"testing DistDistributionXY"<<endl;
test_lores2d();
cout <<"testing GetCenter (center of the list of shapes)"<<endl;
test_GetCenter();
cout <<"testing calculate_2d(Qx,Qy)"<<endl;
test_lores2d_qxqy();
cout << "Pass" << endl;
cout <<"testing CalculateIQ(q)"<<endl;
test_CalSingleI();
return 0;
}
| 19.642857 | 82 | 0.587879 | [
"vector",
"model"
] |
a201fb7b00b84d73f7dfecba65edffd9fbf1ccab | 7,907 | cpp | C++ | zeek-remote/src/utils.cpp | kumarak/osquery-extension | a984b24720cb4bd3a867e6037fea13f2ce31de92 | [
"BSD-3-Clause"
] | null | null | null | zeek-remote/src/utils.cpp | kumarak/osquery-extension | a984b24720cb4bd3a867e6037fea13f2ce31de92 | [
"BSD-3-Clause"
] | null | null | null | zeek-remote/src/utils.cpp | kumarak/osquery-extension | a984b24720cb4bd3a867e6037fea13f2ce31de92 | [
"BSD-3-Clause"
] | null | null | null | /**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under both the Apache 2.0 license (found in the
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
* in the COPYING file in the root directory of this source tree).
* You may select, at your option, one of the above-listed licenses.
*/
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <broker/bro.hh>
#include <broker/broker.hh>
#include <broker/endpoint.hh>
#include <osquery/config.h>
#include <osquery/logger.h>
#include <osquery/query.h>
#include <osquery/sdk.h>
#include <osquery/sql.h>
#include "osquery/core/json.h"
#include <zeek-remote/utils.h>
namespace zeek {
osquery::Status getOsqueryConfiguration(
ConfigurationFileMap& configuration_file_map) {
configuration_file_map.clear();
osquery::PluginResponse gen_config_response_list;
auto status = osquery::Registry::call(
"config", {{"action", "genConfig"}}, gen_config_response_list);
if (!status.ok()) {
LOG(WARNING) << "Unable to retrieve initial config: "
<< status.getMessage();
}
for (const auto& gen_config_response : gen_config_response_list) {
for (const auto& configuration_descriptor : gen_config_response) {
const auto& config_file_path = configuration_descriptor.first;
const auto& config_contents = configuration_descriptor.second;
VLOG(1) << "Found configuration file: " << config_file_path;
configuration_file_map.insert({config_file_path, config_contents});
}
}
return osquery::Status::success();
}
osquery::Status createSubscriptionRequest(const BrokerRequestType& rType,
const broker::bro::Event& event,
const std::string& incoming_topic,
SubscriptionRequest& sr) {
// Check number of fields
auto event_args = event.args();
unsigned long numFields;
if (rType == EXECUTE) {
numFields = 5;
} else if (rType == SUBSCRIBE || rType == UNSUBSCRIBE) {
numFields = 6;
} else {
return osquery::Status::failure("Unknown Subscription Request Type '" +
std::to_string(rType) + "'");
}
if (event_args.size() != numFields) {
return osquery::Status::failure(
std::to_string(event_args.size()) + " instead of " +
std::to_string(numFields) + " fields in '" +
kBrokerRequestTypeNames.at(rType) + "' message '" + event.name());
}
// Query String
if (!broker::is<std::string>(event_args[1])) {
return osquery::Status::failure("SQL query is not a string");
}
sr.query = broker::get<std::string>(event_args[1]);
// Response Event Name
if (!broker::is<std::string>(event_args[0])) {
return osquery::Status::failure("Response Event Name is not a string");
}
sr.response_event = broker::get<std::string>(event_args[0]);
// Cookie
auto cookie = broker::to_string(event_args[2]);
sr.cookie = cookie;
// Response Topic
if (!broker::is<std::string>(event_args[3])) {
return osquery::Status::failure("Response Topic Name is not a string");
}
if (broker::get<std::string>(event_args[3]).empty()) {
sr.response_topic = incoming_topic;
LOG(WARNING) << "No response topic given for event '" << sr.response_event
<< "' reporting back to "
"incoming topic '"
<< incoming_topic << "'";
} else {
sr.response_topic = broker::get<std::string>(event_args[3]);
}
// Update Type
std::string update_type = broker::to_string(event_args[4]);
if (update_type == "ADDED") {
sr.added = true;
sr.removed = false;
sr.snapshot = false;
} else if (update_type == "REMOVED") {
sr.added = false;
sr.removed = true;
sr.snapshot = false;
} else if (update_type == "BOTH") {
sr.added = true;
sr.removed = true;
sr.snapshot = false;
} else if (update_type == "SNAPSHOT") {
sr.added = false;
sr.removed = false;
sr.snapshot = true;
} else {
return osquery::Status::failure("Unknown update type");
}
// If one-time query
if (rType == EXECUTE) {
if (sr.added || sr.removed || !sr.snapshot) {
LOG(WARNING) << "Only possible to query SNAPSHOT for one-time queries";
}
return osquery::Status::success();
}
// SUBSCRIBE or UNSUBSCRIBE
if (sr.snapshot) {
LOG(WARNING)
<< "Only possible to query ADD and/or REMOVE for scheduled queries";
}
// Interval
if (!broker::is<uint64_t>(event_args[5])) {
return osquery::Status::failure("Interval is not a number");
}
sr.interval = broker::get<uint64_t>(event_args[5]);
return osquery::Status::success();
}
osquery::Status serializeDistributedQueryRequestsJSON(
const std::vector<osquery::DistributedQueryRequest>& rs,
std::string& json) {
auto doc = osquery::JSON::newObject();
auto queries_obj = doc.getObject();
for (const auto r : rs) {
doc.addCopy(r.id, r.query, queries_obj);
}
doc.add("queries", queries_obj);
return doc.toString(json);
}
osquery::Status parseDistributedQueryResultsJSON(
const std::string& json,
std::vector<std::pair<std::string, std::pair<osquery::QueryData, int>>>&
rs) {
auto doc = osquery::JSON::newObject();
auto s = doc.fromString(json);
if (!s.ok()) {
return s;
}
// Browse query results
std::vector<std::string> qd_ids;
std::vector<osquery::QueryData> qds;
if (doc.doc().HasMember("queries")) {
const auto& queries = doc.doc()["queries"];
assert(queries.IsObject());
if (queries.IsObject()) {
for (const auto& query_entry : queries.GetObject()) {
// Get Request ID
if (!query_entry.name.IsString()) {
return osquery::Status::failure(
"Distributed query result name is not a string");
}
auto name = std::string(query_entry.name.GetString());
if (name.empty()) {
return osquery::Status::failure(
"Distributed query result name is empty");
}
qd_ids.push_back(name);
// Get Request Results
if (!query_entry.value.IsArray()) {
return osquery::Status::failure(
"Distributed query result is not an array");
}
osquery::QueryData qd;
osquery::deserializeQueryData(query_entry.value, qd);
if (!s.ok()) {
return s;
}
qds.push_back(qd);
}
}
}
// Browse query osquery::Statuses
std::vector<std::string> st_ids;
std::vector<int> sts;
if (doc.doc().HasMember("statuses")) {
const auto& statuses = doc.doc()["statuses"];
assert(statuses.IsObject());
if (statuses.IsObject()) {
for (const auto& status_entry : statuses.GetObject()) {
// Get Request ID
if (!status_entry.name.IsString()) {
return osquery::Status::failure(
"Distributed query status name is not a string");
}
auto name = std::string(status_entry.name.GetString());
if (name.empty()) {
return osquery::Status::failure(
"Distributed query status name is empty");
}
st_ids.push_back(name);
// Get Query osquery::Status
if (!status_entry.value.IsInt()) {
return osquery::Status::failure(
"Distributed query status is not an int");
}
auto code = status_entry.value.GetInt();
sts.push_back(code);
}
}
}
assert(qd_ids.size() == st_ids.size());
int idx = 0;
for (const auto& name : qd_ids) {
assert(qd_ids[idx] == st_ids[idx]);
assert(name == qd_ids[idx]);
rs.emplace_back(name, std::make_pair(qds.at(idx), sts.at(idx)));
idx += 1;
}
return osquery::Status::success();
}
} // namespace zeek
| 30.528958 | 80 | 0.618945 | [
"vector"
] |
a21856f1c95e34c732813c3ae9193c4b2b201125 | 2,990 | hpp | C++ | src/app/bc-selector.hpp | mimo31/fluid-sim | 481c3e5a5456350bccb8795aa119a3487dff3021 | [
"MIT"
] | 1 | 2020-11-26T17:20:28.000Z | 2020-11-26T17:20:28.000Z | src/app/bc-selector.hpp | mimo31/brandy0 | 481c3e5a5456350bccb8795aa119a3487dff3021 | [
"MIT"
] | null | null | null | src/app/bc-selector.hpp | mimo31/brandy0 | 481c3e5a5456350bccb8795aa119a3487dff3021 | [
"MIT"
] | null | null | null | /**
* bc-selector.hpp
*
* Author: Viktor Fukala
* Created on 2020/12/27
*/
#ifndef BC_SELECTOR_HPP
#define BC_SELECTOR_HPP
#include <functional>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/entry.h>
#include <gtkmm/frame.h>
#include <gtkmm/grid.h>
#include <gtkmm/label.h>
#include "annotated-entry.hpp"
#include "boundary-cond.hpp"
#include "func.hpp"
#include "str.hpp"
namespace brandy0
{
/// A custom widget containing all the fields necessary for configuring one boundary condition of a simulation
class BCSelector : public Gtk::Frame
{
private:
/// Grid containing all the input widgets and the only direct child of *this
Gtk::Grid grid;
/// Label explaining that the pressure type selector is for selecting the type of the pressure b.c.
Gtk::Label pressureTypeLabel;
/// ComboBox for selecting the type of the pressure b.c.
Gtk::ComboBoxText pressureTypeSelector;
/// AnnotatedEntry for specifying the value of pressure at the boundary provided that the pressure b.c. type is Dirichlet
AnnotatedEntry pEntry;
/// Label explaining that the velocity type selector is for selecting the type of the velocity b.c.
Gtk::Label velocityTypeLabel;
/// ComboBox for selecting the type of the velocity b.c.
Gtk::ComboBoxText velocityTypeSelector;
/**
* AnnotatedEntry for specifying the value of the x coordinate of velocity at the boundary
* provided that the velocity b.c. type is Dirichlet
*/
AnnotatedEntry uxEntry;
/**
* AnnotatedEntry for specifying the value of the y coordinate of velocity at the boundary
* provided that the velocity b.c. type is Dirichlet
*/
AnnotatedEntry uyEntry;
/// Representation of the boundary condition as currently displayed by the widgets
BoundaryCond bc;
/// A callback passed by whoever created this object that is called whenever the user changes the input
VoidFunc inputChangeHandler;
/**
* The method that handles signal changed on the pressure type selector
*/
void onPressureTypeChange();
/**
* The method that handles signal changed on the velocity type selector
*/
void onVelocityTypeChange();
/**
* Sets the input widgets to display values currently stored in this->bc
*/
void setEntryFields();
public:
/**
* Constructs the b.c. selector without initializing the values.
* @param atDescriptor string to be shown in the frame's label (something like "x = w" is expected here)
* @param inputChangeHandler function to be called whenever the represented b. c. configuration changes
*/
BCSelector(const str& atDescriptor, const VoidFunc& inputChangeHandler, StyleManager *styleManager);
/**
* @return true iff the input currently entered by the user represents a valid b.c. configuration
*/
bool hasValidInput() const;
/**
* @return the b.c. currently stored
*/
BoundaryCond getBc() const;
/**
* Sets the b.c. stored in this widget. Updates the values in the contained accordingly.
*/
void setBc(const BoundaryCond& bc);
};
}
#endif // BC_SELECTOR_HPP | 31.145833 | 122 | 0.747157 | [
"object"
] |
a21b833b50c85f4d9f1183ae32e7d153e62936f1 | 2,803 | cpp | C++ | BOJ/17144.미세먼지 안녕!.cpp | Jeongseo21/Algorithm-1 | 1bce4f3d2328c3b3e24b9d7772fca43090a285e1 | [
"MIT"
] | null | null | null | BOJ/17144.미세먼지 안녕!.cpp | Jeongseo21/Algorithm-1 | 1bce4f3d2328c3b3e24b9d7772fca43090a285e1 | [
"MIT"
] | null | null | null | BOJ/17144.미세먼지 안녕!.cpp | Jeongseo21/Algorithm-1 | 1bce4f3d2328c3b3e24b9d7772fca43090a285e1 | [
"MIT"
] | null | null | null | /**
* problem : https://www.acmicpc.net/problem/17144
* time complexity : O(RCT)
*/
#include <iostream>
#include <vector>
#include <algorithm>
#define CLOCK_DIRECTION 0
#define COUNTER_CLOCK_DIRECTION 1
using namespace std;
int dx[] = {0, -1, 0, 1};
int dy[] = {1, 0, -1, 0};
// 오른쪽 아래 왼쪽 위 (시계방향)
pair<int,int> clock[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
// 오른쪽 위 왼쪽 아래 (시계반대방향)
pair<int,int> counterClock[] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
int R, C, T;
// move arr[x][y]
void moveCleaner(const vector<vector<int>>& arr,
vector<vector<int>>& newArr,
int x, int y, int index, int direction) {
int nx, ny;
if(direction == CLOCK_DIRECTION) {
nx = x + clock[index].first;
ny = y + clock[index].second;
} else {
nx = x + counterClock[index].first;
ny = y + counterClock[index].second;
}
if(nx < 0 || nx >= R || ny < 0 || ny >= C) {
moveCleaner(arr, newArr, x, y, index+1, direction);
return;
}
if(arr[nx][ny] == -1) return;
newArr[nx][ny] = max(0, arr[x][y]);
moveCleaner(arr, newArr, nx, ny, index, direction);
}
int main() {
cin >> R >> C >> T;
vector<vector<int>> arr(R, vector<int>(C));
for(int i=0;i<R;i++){
for(int j=0;j<C;j++){
cin >> arr[i][j];
}
}
while(T--) {
vector<vector<int>> newArr(R, vector<int>(C, 0));
vector<pair<int,int>> cleaners;
// dust
for(int i=0;i<R;i++){
for(int j=0;j<C;j++){
int now = arr[i][j];
if(now == -1) {
cleaners.push_back({i, j});
newArr[i][j] = -1;
continue;
}
if(now == 0) continue;
int cnt = 0;
for(int k=0;k<4;k++){
int nx = i + dx[k];
int ny = j + dy[k];
if(nx < 0 || nx >= R || ny < 0 || ny >= C) continue;
if(newArr[nx][ny] == -1) continue;
newArr[nx][ny] += now / 5;
cnt++;
}
newArr[i][j] += now - (now/5)*cnt;
}
}
arr = newArr;
// cleaner
moveCleaner(arr, newArr,
cleaners[0].first, cleaners[0].second,
0, COUNTER_CLOCK_DIRECTION);
moveCleaner(arr, newArr,
cleaners[1].first, cleaners[1].second,
0, CLOCK_DIRECTION);
arr = newArr;
}
int answer = 0;
for(int i=0;i<R;i++){
for(int j=0;j<C;j++){
answer += max(0, arr[i][j]);
}
}
cout << answer << endl;
return 0;
}
| 26.196262 | 72 | 0.426329 | [
"vector"
] |
b8c48b06b6055065de29e428ea0fb9167e209ae0 | 2,460 | cpp | C++ | theory/bst/code.cpp | ideahitme/coursera | af44c8d817481d4f9025205284f109d95a9bb45d | [
"MIT"
] | null | null | null | theory/bst/code.cpp | ideahitme/coursera | af44c8d817481d4f9025205284f109d95a9bb45d | [
"MIT"
] | null | null | null | theory/bst/code.cpp | ideahitme/coursera | af44c8d817481d4f9025205284f109d95a9bb45d | [
"MIT"
] | null | null | null | #include <vector>
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
struct node{
int key;
unsigned char height = 0; //c++11
node *parent = NULL;
node *left = NULL;
node *right = NULL;
};
class BST //binary search tree with no duplicated key
{
private:
node *root = NULL;
int height(node *n){
if (n == NULL) return 0;
else return n->height;
}
node* find(node* n, int key){
if (n->key == key) return n;
else if (n->key > key){
if (n->left == NULL){
return n;
}
return find(n->left, key);
}
else{
if (n->right == NULL){
return n;
}
return find(n->right, key);
}
}
node* right_ancestor(node *n){
node *p = n->parent;
if (p == NULL) return NULL;
if (p->key > n->key) return p;
else return right_ancestor(p);
}
node* next(node *n){
if (n->right != NULL){
node *r = n->right;
while(r->left != NULL){
r = r->left;
}
return r;
}
else {
return right_ancestor(n);
}
}
public:
BST();
~BST();
void insert(int key){
node *n = new node;
n->key = key;
if (root == NULL){
root = n;
return;
}
node *parent = find(root, n->key);
if (parent->key > n->key){
parent->left = n;
n->parent = parent;
}
else if (parent->key < n->key){
parent->right = n;
n->parent = parent;
}
}
void del(int key){
node *n = find(root, key);
if (n->key != key) return;
node *parent = n->parent;
if (n->right == NULL){
if (n->left != NULL) n->left->parent = parent;
if (parent == NULL){
root = n->left;
}
else if (n->key > parent->key){
parent->right = n->left;
}
else parent->left = n->left;
}
else {
node *x = next(n); // not NULL because n->right is not NULL
n->key = x->key;
node *px = x->parent;
if (px->key > x->key){
px->left = x->right;
}
else {
px->right = x->right;
}
if (x->right != NULL) x->right->parent = px;
}
}
vector<node*> find(int l, int r){
vector<node*> res;
if (root == NULL) return res;
node *n = find(root, l);
while(n != NULL && n->key <= r){
if (n->key >= l){
res.push_back(n);
}
n = next(n);
}
return res;
}
};
BST::BST(){
}
BST::~BST(){
}
int main(int argc, char const *argv[])
{
ios::sync_with_stdio(false);
BST tree;
tree.insert(6);
tree.insert(5);
tree.insert(7);
tree.del(6);
vector<node*> q = tree.find(5, 8);
for(auto i = q.begin(); i != q.end(); i++){
cout << (*i)->key << endl;
}
return 0;
}
| 17.571429 | 62 | 0.54065 | [
"vector"
] |
b8dfc93090e7e1492c3979473cf917ab0dcf86e0 | 7,284 | cpp | C++ | implementations/Bullet/World.cpp | ronsaldo/abstract-physics | dbc23a57bfa369139c786071b2a6db4e84bb16fe | [
"MIT"
] | 10 | 2016-12-11T04:54:18.000Z | 2022-02-27T18:12:18.000Z | implementations/Bullet/World.cpp | ronsaldo/abstract-physics | dbc23a57bfa369139c786071b2a6db4e84bb16fe | [
"MIT"
] | null | null | null | implementations/Bullet/World.cpp | ronsaldo/abstract-physics | dbc23a57bfa369139c786071b2a6db4e84bb16fe | [
"MIT"
] | null | null | null | #include "Broadphase.hpp"
#include "CollisionConfiguration.hpp"
#include "CollisionDispatcher.hpp"
#include "CollisionObject.hpp"
#include "ConstraintSolver.hpp"
#include "CharacterController.hpp"
#include "World.hpp"
#include <vector>
namespace APhyBullet
{
class BulletWorldDebugDrawer : public btIDebugDraw
{
public:
void reset()
{
instructions.clear();
}
void putOpcode(aphy_debug_draw_opcode opcode)
{
instructions.push_back(opcode);
}
void putInt32(int32_t value)
{
instructions.push_back(0);
instructions.push_back(0);
instructions.push_back(0);
instructions.push_back(0);
*reinterpret_cast<int32_t*> (&instructions[instructions.size() - 4]) = value;
}
void putScalar(float scalar)
{
instructions.push_back(0);
instructions.push_back(0);
instructions.push_back(0);
instructions.push_back(0);
*reinterpret_cast<float*> (&instructions[instructions.size() - 4]) = scalar;
}
void putVector3(const btVector3 &vector)
{
putScalar(vector.x());
putScalar(vector.y());
putScalar(vector.z());
}
void drawLine(const btVector3& from,const btVector3& to,const btVector3& color) override
{
putOpcode(APHY_DEBUG_DRAW_OP_LINE);
putVector3(from);
putVector3(to);
putVector3(color);
}
void drawLine(const btVector3& from,const btVector3& to, const btVector3& fromColor, const btVector3& toColor) override
{
putOpcode(APHY_DEBUG_DRAW_OP_LINE_GRADIENT);
putVector3(from);
putVector3(to);
putVector3(fromColor);
putVector3(toColor);
}
virtual void drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& n0,const btVector3& n1,const btVector3& n2,const btVector3& color, btScalar alpha) override
{
putOpcode(APHY_DEBUG_DRAW_OP_TRIANGLE_LIGHTED);
putVector3(v0);
putVector3(v1);
putVector3(v2);
putVector3(n0);
putVector3(n1);
putVector3(n2);
putVector3(color);
putScalar(alpha);
}
virtual void drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& color, btScalar alpha) override
{
putOpcode(APHY_DEBUG_DRAW_OP_TRIANGLE_FLAT);
putVector3(v0);
putVector3(v1);
putVector3(v2);
putVector3(color);
putScalar(alpha);
}
void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color) override
{
putOpcode(APHY_DEBUG_DRAW_OP_CONTACT_POINT);
putVector3(PointOnB);
putVector3(normalOnB);
putScalar(distance);
putInt32(lifeTime);
putVector3(color);
}
void reportErrorWarning(const char* warningString) override
{
}
void draw3dText(const btVector3& location,const char* textString) override
{
}
void setDebugMode(int debugMode) override
{
currentDebugMode = debugMode;
}
int getDebugMode() const override
{
return currentDebugMode;
}
int currentDebugMode = 0;
std::vector<uint8_t> instructions;
};
BulletWorld::BulletWorld(btDynamicsWorld *handle)
: handle(handle)
{
}
BulletWorld::~BulletWorld()
{
delete handle;
}
aphy_uint BulletWorld::getNumberOfCollisionObject()
{
return handle->getNumCollisionObjects();
}
aphy_uint BulletWorld::getNumberOfConstraints()
{
return handle->getNumConstraints();
}
aphy_error BulletWorld::addCollisionObject(const collision_object_ref &object, aphy_short collision_filter_group, aphy_short collision_filter_mask)
{
CHECK_POINTER(object);
handle->addCollisionObject(object.as<BulletCollisionObject>()->handle, collision_filter_group, collision_filter_mask);
collisionObjects.insert(object);
return APHY_OK;
}
aphy_error BulletWorld::removeCollisionObject(const collision_object_ref &object)
{
CHECK_POINTER(object);
handle->removeCollisionObject(object.as<BulletCollisionObject>()->handle);
auto it = collisionObjects.find(object);
if(it != collisionObjects.end())
collisionObjects.erase(it);
return APHY_OK;
}
aphy_error BulletWorld::addRigidBody(const collision_object_ref &object)
{
CHECK_POINTER(object);
auto rigidBody = btRigidBody::upcast(object.as<BulletCollisionObject>()->handle);
if(!rigidBody)
return APHY_INVALID_PARAMETER;
handle->addRigidBody(rigidBody);
collisionObjects.insert(object);
return APHY_OK;
}
aphy_error BulletWorld::removeRigidBody(const collision_object_ref &object)
{
auto rigidBody = btRigidBody::upcast(object.as<BulletCollisionObject>()->handle);
if(!rigidBody)
return APHY_INVALID_PARAMETER;
handle->removeRigidBody(rigidBody);
auto it = collisionObjects.find(object);
if(it != collisionObjects.end())
collisionObjects.erase(it);
return APHY_OK;
}
aphy_error BulletWorld::addCharacterController(const character_controller_ref &character)
{
CHECK_POINTER(character);
handle->addAction(character.as<BulletCharacterController>()->handle);
characterControllers.insert(character);
return APHY_OK;
}
aphy_error BulletWorld::removeCharacterController(const character_controller_ref &character)
{
CHECK_POINTER(character);
handle->removeAction(character.as<BulletCharacterController>()->handle);
auto it = characterControllers.find(character);
if(it != characterControllers.end())
characterControllers.erase(it);
return APHY_OK;
}
aphy_error BulletWorld::addRigidBodyWithFilter(const collision_object_ref &object, aphy_short collision_filter_group, aphy_short collision_filter_mask)
{
CHECK_POINTER(object);
auto rigidBody = btRigidBody::upcast(object.as<BulletCollisionObject>()->handle);
if(!rigidBody)
return APHY_INVALID_PARAMETER;
handle->addRigidBody(rigidBody, collision_filter_group, collision_filter_mask);
collisionObjects.insert(object);
return APHY_OK;
}
aphy_error BulletWorld::stepSimulation(aphy_scalar time_step, aphy_int max_sub_steps, aphy_scalar fixed_time_step)
{
handle->stepSimulation(time_step, max_sub_steps, fixed_time_step);
return APHY_OK;
}
aphy_error BulletWorld::setGravity(aphy_scalar x, aphy_scalar y, aphy_scalar z)
{
handle->setGravity(btVector3(x, y, z));
return APHY_OK;
}
aphy_size BulletWorld::encodeDebugDrawing()
{
if(!debugDrawer)
{
debugDrawer = std::make_shared<BulletWorldDebugDrawer> ();
handle->setDebugDrawer(debugDrawer.get());
}
debugDrawer->reset();
debugDrawer->setDebugMode(/*btIDebugDraw::DBG_DrawWireframe |*/ btIDebugDraw::DBG_DrawAabb);
handle->debugDrawWorld();
return aphy_size(debugDrawer->instructions.size());
}
aphy_error BulletWorld::getDebugDrawingData(aphy_size buffer_size, aphy_pointer buffer )
{
CHECK_POINTER(buffer);
if(!debugDrawer || buffer_size < debugDrawer->instructions.size())
return APHY_INVALID_OPERATION;
memcpy(buffer, debugDrawer->instructions.data(), debugDrawer->instructions.size());
return APHY_OK;
}
} // End of namespace APhyBullet
| 27.078067 | 198 | 0.711422 | [
"object",
"vector"
] |
b8e54d0395cdfda6a4a43ae37cb640010c9c869e | 674 | cxx | C++ | POSN Camp2/exact_sum.cxx | ParamaaS/ParamaaS-Cpp-code- | a6c78151defe38d1460cde2b005a67be5a1d092d | [
"MIT"
] | null | null | null | POSN Camp2/exact_sum.cxx | ParamaaS/ParamaaS-Cpp-code- | a6c78151defe38d1460cde2b005a67be5a1d092d | [
"MIT"
] | null | null | null | POSN Camp2/exact_sum.cxx | ParamaaS/ParamaaS-Cpp-code- | a6c78151defe38d1460cde2b005a67be5a1d092d | [
"MIT"
] | null | null | null | /*/
- Paramaa Sawanpanyalert -
Lang : c++
/*/
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
map<long long,long long> mmp;
map<long long,long long>::iterator it;
int n,m,d,c,c2,f,s,ff,ss;
vector<int> vec;
main()
{
scanf("%d%d",&n,&m);
for(c=0;c<n;c++)
{
scanf("%d",&d);
vec.pb(d);
}
for(c=0;c<n;c++)
{
for(c2=0;c2<n;c2++)
{
mmp[vec[c]+vec[c2]]++;
}
}
it=mmp.begin();
long long cnt=0;
while(it!=mmp.end())
{
f=(*it).first;
s=(*it).second;
if(mmp.find(m-f)!=mmp.end())
{
cnt+=(mmp[f]*mmp[m-f]);
}
it++;
}
printf("%lld",cnt);
}
| 15.318182 | 39 | 0.52819 | [
"vector"
] |
b8fc1cb4407069ad9e695caed455f17b3d1e4967 | 514 | cpp | C++ | String/26_longest_common_prefix.cpp | ritikrajdev/450DSA | a9efa8c8be781fd7b101407ac807a83b8a0929f4 | [
"MIT"
] | null | null | null | String/26_longest_common_prefix.cpp | ritikrajdev/450DSA | a9efa8c8be781fd7b101407ac807a83b8a0929f4 | [
"MIT"
] | null | null | null | String/26_longest_common_prefix.cpp | ritikrajdev/450DSA | a9efa8c8be781fd7b101407ac807a83b8a0929f4 | [
"MIT"
] | null | null | null | #include <string>
#include <vector>
using namespace std;
class Solution {
public:
string longestCommonPrefix(vector<string>& strs) {
string x = "";
x.reserve(strs[0].length());
for (int i = 0; i < strs[0].size(); i++) {
char prefix = strs[0][i];
for (int j = 1; j < strs.size(); j++)
if (i >= strs[j].length() || strs[j][i] != prefix)
return x;
x.push_back(prefix);
}
return x;
}
};
| 23.363636 | 66 | 0.463035 | [
"vector"
] |
77021088e5828cdc6cb944fe113dafa199c755fa | 492 | cpp | C++ | test/assets/asset_manager.cpp | Wzz1252/leveldb | d3c204b15f9b5bbb3fb75e870b9693805a067df2 | [
"BSD-3-Clause"
] | null | null | null | test/assets/asset_manager.cpp | Wzz1252/leveldb | d3c204b15f9b5bbb3fb75e870b9693805a067df2 | [
"BSD-3-Clause"
] | null | null | null | test/assets/asset_manager.cpp | Wzz1252/leveldb | d3c204b15f9b5bbb3fb75e870b9693805a067df2 | [
"BSD-3-Clause"
] | null | null | null | //
// Created by torment on 2020/4/8.
//
#include "asset_manager.h"
namespace assets {
int asset_manager::add_asset(asset *asset) {
assets.push_back(asset);
return 0;
}
std::vector<asset *> asset_manager::get_asset() {
return assets;
}
double asset_manager::get_total_assets() {
double total_assets = 0;
for (auto &asset : assets) {
total_assets += asset->get_price();
}
return total_assets;
}
} | 19.68 | 53 | 0.581301 | [
"vector"
] |
770bcf82b7862cabb1d915d421432607b36b2eff | 6,071 | cc | C++ | Modules/Numerics/src/Vector.cc | lisurui6/MIRTK | 5a06041102d7205b5aac147ff768df6e9415bd03 | [
"Apache-2.0"
] | 146 | 2016-01-15T15:02:02.000Z | 2022-03-24T01:43:30.000Z | Modules/Numerics/src/Vector.cc | aria-rui/MIRTK | 877917b1b3ec9e602f7395dbbb1270e4334fc311 | [
"Apache-2.0"
] | 196 | 2016-01-15T16:45:58.000Z | 2022-03-24T01:06:53.000Z | Modules/Numerics/src/Vector.cc | aria-rui/MIRTK | 877917b1b3ec9e602f7395dbbb1270e4334fc311 | [
"Apache-2.0"
] | 72 | 2016-01-15T15:04:32.000Z | 2022-03-25T11:05:16.000Z | /*
* Medical Image Registration ToolKit (MIRTK)
*
* Copyright 2008-2015 Imperial College London
* Copyright 2008-2015 Daniel Rueckert, Julia Schnabel
*
* 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 "mirtk/Vector.h"
#include "mirtk/Assert.h"
#include "mirtk/Memory.h"
#include "mirtk/Array.h"
#include "mirtk/Indent.h"
#include "mirtk/Cfstream.h"
#include "mirtk/NumericsConfig.h"
#if MIRTK_Numerics_WITH_MATLAB
# include "mirtk/Matlab.h"
#endif
namespace mirtk {
// -----------------------------------------------------------------------------
void Vector::PermuteRows(Array<int> idx)
{
mirtkAssert(idx.size() <= static_cast<size_t>(_rows), "valid permutation");
for (int r1 = 0; r1 < static_cast<int>(idx.size()); ++r1) {
int r2 = idx[r1];
if (r2 == r1) continue;
swap(_vector[r1], _vector[r2]);
for (int r = r1 + 1; r < _rows; ++r) {
if (idx[r] == r1) {
swap(idx[r], idx[r1]);
break;
}
}
}
}
// -----------------------------------------------------------------------------
ostream &operator <<(ostream &os, const Vector &v)
{
os << "irtkVector " << max(0, v._rows) << endl;
if (v._rows > 0) {
const bool swapped = (GetByteOrder() == LittleEndian);
if (swapped) {
swap64((char *)v._vector, (char *)v._vector, v._rows);
}
os.write((char *)v._vector, v._rows * sizeof(double));
if (swapped) {
swap64((char *)v._vector, (char *)v._vector, v._rows);
}
}
return os;
}
// -----------------------------------------------------------------------------
istream &operator >> (istream &is, Vector &v)
{
// Read file type identifier
char keyword[11];
is.read(keyword, 11);
if (strncmp(keyword, "irtkVector ", 11) != 0) {
cerr << "Vector: File does not appear to be a binary (M)IRTK Vector file" << endl;
exit(1);
}
// Read vector size
int rows = 0;
is >> rows;
if (!is || rows < 0) {
cerr << "Vector: Failed to read vector size from binary file" << endl;
exit(1);
}
// Skip remaining characters (e.g., comment) on first line
char buffer[256];
while (is.get() != '\n') {
is.get(buffer, 256);
}
// Read vector data
v.Initialize(rows);
if (rows > 0) {
is.read((char *)v._vector, rows * sizeof(double));
if (is.fail()) {
cerr << "Vector: File contains fewer values than expected: #rows = " << rows << endl;
exit(1);
}
if (GetByteOrder() == LittleEndian) {
swap64((char *)v._vector, (char *)v._vector, v._rows);
}
}
return is;
}
// -----------------------------------------------------------------------------
Cofstream &operator <<(Cofstream& to, const Vector &v)
{
to.WriteAsChar("irtkVector", 11);
const int rows = max(0, v._rows);
to.WriteAsInt(&rows, 1);
if (v._rows > 0) to.WriteAsDouble(v._vector, v._rows);
return to;
}
// -----------------------------------------------------------------------------
Cifstream &operator >>(Cifstream &from, Vector &v)
{
char keyword[11];
from.ReadAsChar(keyword, 11);
keyword[10] = '\0';
if (strcmp(keyword, "irtkVector") != 0) {
cerr << "Vector: File does not appear to be a binary (M)IRTK Vector file" << endl;
exit(1);
}
int rows = 0;
if (!from.ReadAsInt(&rows, 1) || rows < 0) {
cerr << "Vector: Failed to read vector size from binary file" << endl;
exit(1);
}
v.Initialize(rows);
if (rows > 0 && !from.ReadAsDouble(v._vector, rows)) {
cerr << "Vector: File contains fewer values than expected: #rows = " << rows << endl;
exit(1);
}
return from;
}
// -----------------------------------------------------------------------------
void Vector::Print(Indent indent) const
{
cout << indent << "Vector " << _rows << endl;
++indent;
cout.setf(ios::right);
cout.setf(ios::fixed);
cout.precision(4);
for (int i = 0; i < _rows; i++) {
cout << indent << setw(15) << _vector[i] << endl;
}
cout.precision(6);
cout.unsetf(ios::right);
cout.unsetf(ios::fixed);
}
// -----------------------------------------------------------------------------
void Vector::Read(const char *filename)
{
// Open file stream
ifstream from(filename, ios::in | ios::binary);
// Check whether file opened ok
if (!from) {
cerr << "Vector::Read: Can't open file " << filename << endl;
exit(1);
}
// Read vector
from >> *this;
}
// -----------------------------------------------------------------------------
void Vector::Write(const char *filename) const
{
// Open file stream
ofstream to(filename, ios::out | ios::binary);
// Check whether file opened ok
if (!to) {
cerr << "Vector::Write: Can't open file " << filename << endl;
exit(1);
}
// Write vector
to << *this;
}
#if MIRTK_Numerics_WITH_MATLAB
// -----------------------------------------------------------------------------
inline mxArray *VectorToMxArray(const Vector &v)
{
Matlab::Initialize();
mxArray *m = mxCreateDoubleMatrix(v.Rows(), 1, mxREAL);
memcpy(mxGetPr(m), v.RawPointer(), v.Rows() * sizeof(double));
return m;
}
// -----------------------------------------------------------------------------
bool Vector::WriteMAT(const char *fname, const char *varname) const
{
Matlab::Initialize();
MATFile *fp = matOpen(fname, "w");
if (fp == NULL) return false;
mxArray *m = VectorToMxArray(*this);
if (matPutVariable(fp, varname, m) != 0) {
mxDestroyArray(m);
matClose(fp);
return false;
}
mxDestroyArray(m);
return (matClose(fp) == 0);
}
#endif // MIRTK_Numerics_WITH_MATLAB
} // namespace mirtk
| 26.744493 | 91 | 0.540273 | [
"vector"
] |
770c3483c5e4def1c34c12949533e8d4bdbe79ce | 1,054 | cpp | C++ | legacy/hmmFuns.cpp | stanley-rozell/hmm | 21dc000961b960a5e1fbf66cb11e74c4e1532ad2 | [
"Apache-2.0"
] | null | null | null | legacy/hmmFuns.cpp | stanley-rozell/hmm | 21dc000961b960a5e1fbf66cb11e74c4e1532ad2 | [
"Apache-2.0"
] | 12 | 2021-03-09T23:04:14.000Z | 2021-05-17T16:02:29.000Z | legacy/hmmFuns.cpp | stanley-rozell/hmm | 21dc000961b960a5e1fbf66cb11e74c4e1532ad2 | [
"Apache-2.0"
] | null | null | null | //
// hmmFuns.cpp
// xRue
//
// Created by Adam Willats on 7/19/17.
// Copyright © 2017 Adam Willats. All rights reserved.
//
#include "hmmFuns.hpp" //not needed here?
#include <iostream>
//#include <vector>
using namespace std;
vector<int> genHMM(vector<double> frs, vector<double> trs, int numSteps){
vector<int> states(numSteps);
vector<int> spikes(numSteps);
states[0] = 0;
//intialize random number generator
random_device rd;
mt19937 gen(rd());
uniform_real_distribution<double> unif(0, 1);
for (int i=0; i<numSteps; i++){
//get emiss
//get transit
//spit spikes
// double r1 = rand()/double(RAND_MAX);
spikes[i] = (unif(gen) < frs[states[i]]) ? 1 : 0;
//update future state from current transition probability
//NB: this clause is not necessary outside rtxi...
if (i<(numSteps-1))
{
states[i+1] = (unif(gen) < trs[states[i]]) ? 1-states[i] : states[i];
}
else
{
spikes[0]=i;
}
}
return spikes;
}
| 19.163636 | 78 | 0.589184 | [
"vector"
] |
77169df2264514ce49f99b942334bd8f2f47c62f | 919 | cc | C++ | test/utils.cc | iszczesniak/gd | cb076aa99f0dcb940388c664f07904440506b218 | [
"BSL-1.0"
] | 3 | 2019-07-04T15:37:51.000Z | 2022-01-11T08:13:13.000Z | test/utils.cc | iszczesniak/gd | cb076aa99f0dcb940388c664f07904440506b218 | [
"BSL-1.0"
] | null | null | null | test/utils.cc | iszczesniak/gd | cb076aa99f0dcb940388c664f07904440506b218 | [
"BSL-1.0"
] | null | null | null | #define BOOST_TEST_MODULE Utils
#include "cunits.hpp"
#include "sunits.hpp"
#include "utils.hpp"
#include "sample_graphs.hpp"
#include <boost/test/unit_test.hpp>
#include <random>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
BOOST_AUTO_TEST_CASE(get_random_int_test)
{
std::default_random_engine eng;
for(int i = 0; i < 100; ++i)
for(int j = 0; j < 10; ++j)
{
int n = get_random_int(0, j, eng);
BOOST_CHECK(0 <= n && n <= j);
}
}
BOOST_AUTO_TEST_CASE(find_path_su_test)
{
graph g;
vector<vertex> vs;
vector<edge> es;
sample_graph1(g, vs, es);
// The su of an empty path.
SU su1 = find_path_su(g, path());
BOOST_CHECK(su1.empty());
// The su of es[0].
SU su2 = find_path_su(g, path{es[0]});
BOOST_CHECK((su2 == SU{{0, 2}}));
// The su of {es[0], es[1]}.
SU su3 = find_path_su(g, path{es[0], es[1]});
BOOST_CHECK((su3 == SU{{1, 2}}));
}
| 19.145833 | 47 | 0.628945 | [
"vector"
] |
772254abdcc5540cf1f9d04bc91774e8c654be54 | 964 | cpp | C++ | server/src/entities/structures/Wall.cpp | gabyrobles93/worms-game-remake | b97781f39369f807ae8c8316f7f313353d7a2df7 | [
"MIT"
] | 2 | 2019-04-24T18:27:29.000Z | 2020-04-06T17:15:34.000Z | server/src/entities/structures/Wall.cpp | gabyrobles93/tp-final-taller | b97781f39369f807ae8c8316f7f313353d7a2df7 | [
"MIT"
] | null | null | null | server/src/entities/structures/Wall.cpp | gabyrobles93/tp-final-taller | b97781f39369f807ae8c8316f7f313353d7a2df7 | [
"MIT"
] | null | null | null | #include "Wall.h"
Wall::Wall(b2World& world, float posX, float posY, float width, float height) :
world(world) {
b2BodyDef wallDef;
wallDef.type = b2_staticBody;
wallDef.position.Set(posX, posY);
wallDef.allowSleep = true;
b2Body* body = world.CreateBody(&wallDef);
body->SetAwake(false);
body->SetUserData(this);
b2PolygonShape wallShape;
wallShape.SetAsBox(width/2, height/2);
b2FixtureDef wallFixture;
wallFixture.shape = &wallShape;
wallFixture.density = 1;
wallFixture.friction = 0.3;
wallFixture.filter.categoryBits = STRUCTURE_PHYSIC;
wallFixture.filter.maskBits = WORM_PHYSIC;
body->CreateFixture(&wallFixture);
this->body = body;
}
Wall::~Wall() {
this->world.DestroyBody(this->body);
}
void Wall::update() {
this->body->SetAwake(false);
}
float Wall::getPosX() {
return this->body->GetPosition().x;
}
float Wall::getPosY() {
return this->body->GetPosition().y;
} | 23.512195 | 79 | 0.677386 | [
"shape"
] |
7723fcd1cd02cbdd0b86a0f2a6988a71fdecfd4d | 7,977 | cpp | C++ | Marlin-1.1.9/Marlin/fwretract.cpp | sdsd4564/Ender-5-Configurations | 8846a01257538770d2cd7514b46ad8f12d3685b1 | [
"MIT"
] | 12 | 2020-05-23T22:55:34.000Z | 2020-12-24T13:53:43.000Z | Marlin-1.1.9/Marlin/fwretract.cpp | sdsd4564/Ender-5-Configurations | 8846a01257538770d2cd7514b46ad8f12d3685b1 | [
"MIT"
] | 1 | 2019-09-12T02:01:05.000Z | 2019-09-12T02:01:05.000Z | Marlin-1.1.9/Marlin/fwretract.cpp | sdsd4564/Ender-5-Configurations | 8846a01257538770d2cd7514b46ad8f12d3685b1 | [
"MIT"
] | 4 | 2020-05-24T10:26:49.000Z | 2020-06-01T19:14:08.000Z | /**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* fwretract.cpp - Implement firmware-based retraction
*/
#include "MarlinConfig.h"
#if ENABLED(FWRETRACT)
#include "fwretract.h"
#include "Marlin.h"
#include "planner.h"
#include "stepper.h"
FWRetract fwretract; // Single instance - this calls the constructor
// private:
#if EXTRUDERS > 1
bool FWRetract::retracted_swap[EXTRUDERS]; // Which extruders are swap-retracted
#endif
// public:
bool FWRetract::autoretract_enabled, // M209 S - Autoretract switch
FWRetract::retracted[EXTRUDERS]; // Which extruders are currently retracted
float FWRetract::retract_length, // M207 S - G10 Retract length
FWRetract::retract_feedrate_mm_s, // M207 F - G10 Retract feedrate
FWRetract::retract_zlift, // M207 Z - G10 Retract hop size
FWRetract::retract_recover_length, // M208 S - G11 Recover length
FWRetract::retract_recover_feedrate_mm_s, // M208 F - G11 Recover feedrate
FWRetract::swap_retract_length, // M207 W - G10 Swap Retract length
FWRetract::swap_retract_recover_length, // M208 W - G11 Swap Recover length
FWRetract::swap_retract_recover_feedrate_mm_s, // M208 R - G11 Swap Recover feedrate
FWRetract::hop_amount;
void FWRetract::reset() {
autoretract_enabled = false;
retract_length = RETRACT_LENGTH;
retract_feedrate_mm_s = RETRACT_FEEDRATE;
retract_zlift = RETRACT_ZLIFT;
retract_recover_length = RETRACT_RECOVER_LENGTH;
retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE;
swap_retract_length = RETRACT_LENGTH_SWAP;
swap_retract_recover_length = RETRACT_RECOVER_LENGTH_SWAP;
swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
hop_amount = 0.0;
for (uint8_t i = 0; i < EXTRUDERS; ++i) {
retracted[i] = false;
#if EXTRUDERS > 1
retracted_swap[i] = false;
#endif
}
}
/**
* Retract or recover according to firmware settings
*
* This function handles retract/recover moves for G10 and G11,
* plus auto-retract moves sent from G0/G1 when E-only moves are done.
*
* To simplify the logic, doubled retract/recover moves are ignored.
*
* Note: Z lift is done transparently to the planner. Aborting
* a print between G10 and G11 may corrupt the Z position.
*
* Note: Auto-retract will apply the set Z hop in addition to any Z hop
* included in the G-code. Use M207 Z0 to to prevent double hop.
*/
void FWRetract::retract(const bool retracting
#if EXTRUDERS > 1
, bool swapping /* =false */
#endif
) {
static float hop_amount = 0.0; // Total amount lifted, for use in recover
// Prevent two retracts or recovers in a row
if (retracted[active_extruder] == retracting) return;
// Prevent two swap-retract or recovers in a row
#if EXTRUDERS > 1
// Allow G10 S1 only after G10
if (swapping && retracted_swap[active_extruder] == retracting) return;
// G11 priority to recover the long retract if activated
if (!retracting) swapping = retracted_swap[active_extruder];
#else
constexpr bool swapping = false;
#endif
/* // debugging
SERIAL_ECHOLNPAIR("retracting ", retracting);
SERIAL_ECHOLNPAIR("swapping ", swapping);
SERIAL_ECHOLNPAIR("active extruder ", active_extruder);
for (uint8_t i = 0; i < EXTRUDERS; ++i) {
SERIAL_ECHOPAIR("retracted[", i);
SERIAL_ECHOLNPAIR("] ", retracted[i]);
#if EXTRUDERS > 1
SERIAL_ECHOPAIR("retracted_swap[", i);
SERIAL_ECHOLNPAIR("] ", retracted_swap[i]);
#endif
}
SERIAL_ECHOLNPAIR("current_position[z] ", current_position[Z_AXIS]);
SERIAL_ECHOLNPAIR("current_position[e] ", current_position[E_CART]);
SERIAL_ECHOLNPAIR("hop_amount ", hop_amount);
//*/
const float old_feedrate_mm_s = feedrate_mm_s,
renormalize = RECIPROCAL(planner.e_factor[active_extruder]),
base_retract = swapping ? swap_retract_length : retract_length,
old_z = current_position[Z_AXIS],
old_e = current_position[E_CART];
// The current position will be the destination for E and Z moves
set_destination_from_current();
if (retracting) {
// Retract by moving from a faux E position back to the current E position
feedrate_mm_s = retract_feedrate_mm_s;
destination[E_CART] -= base_retract * renormalize;
prepare_move_to_destination(); // set_current_to_destination
// Is a Z hop set, and has the hop not yet been done?
if (retract_zlift > 0.01 && !hop_amount) { // Apply hop only once
hop_amount += retract_zlift; // Add to the hop total (again, only once)
destination[Z_AXIS] += retract_zlift; // Raise Z by the zlift (M207 Z) amount
feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Maximum Z feedrate
prepare_move_to_destination(); // Raise up, set_current_to_destination
}
}
else {
// If a hop was done and Z hasn't changed, undo the Z hop
if (hop_amount) {
current_position[Z_AXIS] += hop_amount; // Restore the actual Z position
SYNC_PLAN_POSITION_KINEMATIC(); // Unspoof the position planner
feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max
prepare_move_to_destination(); // Lower Z, set_current_to_destination
hop_amount = 0.0; // Clear the hop amount
}
destination[E_CART] += (base_retract + (swapping ? swap_retract_recover_length : retract_recover_length)) * renormalize;
feedrate_mm_s = swapping ? swap_retract_recover_feedrate_mm_s : retract_recover_feedrate_mm_s;
prepare_move_to_destination(); // Recover E, set_current_to_destination
}
feedrate_mm_s = old_feedrate_mm_s; // Restore original feedrate
current_position[Z_AXIS] = old_z; // Restore Z and E positions
current_position[E_CART] = old_e;
SYNC_PLAN_POSITION_KINEMATIC(); // As if the move never took place
retracted[active_extruder] = retracting; // Active extruder now retracted / recovered
// If swap retract/recover update the retracted_swap flag too
#if EXTRUDERS > 1
if (swapping) retracted_swap[active_extruder] = retracting;
#endif
/* // debugging
SERIAL_ECHOLNPAIR("retracting ", retracting);
SERIAL_ECHOLNPAIR("swapping ", swapping);
SERIAL_ECHOLNPAIR("active_extruder ", active_extruder);
for (uint8_t i = 0; i < EXTRUDERS; ++i) {
SERIAL_ECHOPAIR("retracted[", i);
SERIAL_ECHOLNPAIR("] ", retracted[i]);
#if EXTRUDERS > 1
SERIAL_ECHOPAIR("retracted_swap[", i);
SERIAL_ECHOLNPAIR("] ", retracted_swap[i]);
#endif
}
SERIAL_ECHOLNPAIR("current_position[z] ", current_position[Z_AXIS]);
SERIAL_ECHOLNPAIR("current_position[e] ", current_position[E_CART]);
SERIAL_ECHOLNPAIR("hop_amount ", hop_amount);
//*/
}
#endif // FWRETRACT
| 39.885 | 124 | 0.677072 | [
"3d"
] |
772c259bb9afd708ff513bca85726de4e4b8b3d8 | 3,541 | cc | C++ | lib/utility/libgclgrid/remapgrid.cc | jreyes1108/antelope_contrib | be2354605d8463d6067029eb16464a0bf432a41b | [
"BSD-2-Clause",
"MIT"
] | 30 | 2015-02-20T21:44:29.000Z | 2021-09-27T02:53:14.000Z | lib/utility/libgclgrid/remapgrid.cc | jreyes1108/antelope_contrib | be2354605d8463d6067029eb16464a0bf432a41b | [
"BSD-2-Clause",
"MIT"
] | 14 | 2015-07-07T19:17:24.000Z | 2020-12-19T19:18:53.000Z | lib/utility/libgclgrid/remapgrid.cc | jreyes1108/antelope_contrib | be2354605d8463d6067029eb16464a0bf432a41b | [
"BSD-2-Clause",
"MIT"
] | 46 | 2015-02-06T16:22:41.000Z | 2022-03-30T11:46:37.000Z | #include "gclgrid.h"
/* This set of functions take the input grid g and remap the
internal coordinates to be consistent with the coordinate system
in pattern. The same function exists for both 2d and 3d grid.
The field objects can use this function using a dynamic cast
to the parent grid because they do not alter the field variable
only the grid cartesian coordinate system.
All return an object rather than a pointer under and assumption
that this process will not be done a lot. There is a large overhead
in returning the object instead of a pointer to the object.
If that need arises a pointer version of these functions would be
easy to create from these.
Major modification May 2005
Original functions did indeed return a new object. I realized thought
it worked better to modify the object in place. The reason for this is
that the same algorithm can be applied to field objects using a dynamic_cast
back to the parent grid. The reason this is possible is that remap_grid
does not alter the grid geometry but only the coordinate system used to
reference each grid point. This feature MUST be recognized by the caller,
however, this alters the parent object.
*/
void remap_grid(GCLgrid& g, BasicGCLgrid& pattern)
{
// return immediately if these grids are congruent
if(g==pattern) return;
// First copy g
GCLgrid oldgrid(g);
// We have a copy of the original in oldgrid so now
// modify g in place.
// This requires only setting the origin and azimuth_y
// followed by use of the set_transsformation_matrix function
g.lat0=pattern.lat0;
g.lon0=pattern.lon0;
g.r0=pattern.r0;
g.azimuth_y=pattern.azimuth_y;
g.set_transformation_matrix();
// Now loop through the grid converting all the points
// to the coordinate system of parent
int i,j;
Geographic_point geo;
Cartesian_point p;
for(i=0;i<oldgrid.n1;++i)
for(j=0;j<oldgrid.n2;++j)
{
geo.lat=oldgrid.lat(i,j);
geo.lon=oldgrid.lon(i,j);
geo.r=oldgrid.r(i,j);
p=pattern.gtoc(geo);
g.x1[i][j]=p.x1;
g.x2[i][j]=p.x2;
g.x3[i][j]=p.x3;
}
g.compute_extents();
return;
}
void remap_grid(GCLgrid3d& g, BasicGCLgrid& pattern)
{
// return immediately if these grids are congruent
if(g==pattern) return;
// First copy g
GCLgrid3d oldgrid(g);
g.lat0=pattern.lat0;
g.lon0=pattern.lon0;
g.r0=pattern.r0;
g.azimuth_y=pattern.azimuth_y;
g.set_transformation_matrix();
// Now loop through the grid converting all the points
// to the coordinate system of parent
int i,j,k;
Geographic_point geo;
Cartesian_point p;
for(i=0;i<oldgrid.n1;++i)
for(j=0;j<oldgrid.n2;++j)
for(k=0;k<oldgrid.n3;++k)
{
geo.lat=oldgrid.lat(i,j,k);
geo.lon=oldgrid.lon(i,j,k);
geo.r=oldgrid.r(i,j,k);
p=pattern.gtoc(geo);
g.x1[i][j][k]=p.x1;
g.x2[i][j][k]=p.x2;
g.x3[i][j][k]=p.x3;
}
g.compute_extents();
return;
}
/* This procedure is a wrapper that uses an inheritance trick.
It builds a minimal sized and then will use one of the above
procedures to do the actual work. Inheritance sorts out the
2d or 3d form. */
void remap_grid(BasicGCLgrid *g,
double olat, double olon, double oradius, double azn)
{
GCLgrid rmg(2,2,string("dummy"),olat,olon,oradius,azn,1.0,1.0,0,0);
GCLgrid *g2d;
GCLgrid3d *g3d;
g2d=dynamic_cast<GCLgrid *>(g);
if(g2d!=NULL)
remap_grid(*g2d,rmg);
else
{
g3d=dynamic_cast<GCLgrid3d *>(g);
if(g3d==NULL) throw GCLgridError("remap_grid - downcast failed from BasicGCLgrid pointer");
}
}
| 31.336283 | 99 | 0.708839 | [
"geometry",
"object",
"3d"
] |
77339a8b6662095eee7373b8f00e4828c618ed75 | 613 | cpp | C++ | LightAndDarkness/LightAndDarkness/Globals.cpp | McCampins/LightAndDarkness | 3d1ab368df359d5ca294fcc2b4b8a2d54a1a6430 | [
"Apache-2.0"
] | null | null | null | LightAndDarkness/LightAndDarkness/Globals.cpp | McCampins/LightAndDarkness | 3d1ab368df359d5ca294fcc2b4b8a2d54a1a6430 | [
"Apache-2.0"
] | null | null | null | LightAndDarkness/LightAndDarkness/Globals.cpp | McCampins/LightAndDarkness | 3d1ab368df359d5ca294fcc2b4b8a2d54a1a6430 | [
"Apache-2.0"
] | null | null | null | #include "Globals.h"
using namespace std;
bool Same(const string& a, const string& b)
{
return _stricmp(a.c_str(), b.c_str()) == 0;
}
bool Same(const char* a, const char* b)
{
return _stricmp(a, b) == 0;
}
bool Same(const string& a, const char* b)
{
return _stricmp(a.c_str(), b) == 0;
}
bool Same(const char* a, const string& b)
{
return _stricmp(a, b.c_str()) == 0;
}
void Tokenize(const string& line, vector<string>& args)
{
const char* str = line.c_str();
do {
const char* begin = str;
while (*str != ' ' && *str)
{
str++;
}
args.push_back(string(begin, str));
} while (*str++);
} | 15.717949 | 55 | 0.606852 | [
"vector"
] |
77366a059e8fff53fbca5a6bc23f8ef388bd86b5 | 1,878 | cpp | C++ | clients/cpp-tiny/generated/lib/TestFiles/DefaultCrumbIssuerTest.cpp | cliffano/jenkins-api-clients-generator | 522d02b3a130a29471df5ec1d3d22c822b3d0813 | [
"MIT"
] | null | null | null | clients/cpp-tiny/generated/lib/TestFiles/DefaultCrumbIssuerTest.cpp | cliffano/jenkins-api-clients-generator | 522d02b3a130a29471df5ec1d3d22c822b3d0813 | [
"MIT"
] | null | null | null | clients/cpp-tiny/generated/lib/TestFiles/DefaultCrumbIssuerTest.cpp | cliffano/jenkins-api-clients-generator | 522d02b3a130a29471df5ec1d3d22c822b3d0813 | [
"MIT"
] | null | null | null |
#include "DefaultCrumbIssuer.h"
using namespace Tiny;
#include <string>
#include <list>
#include <unity.h>
#include "bourne/json.hpp"
void test_DefaultCrumbIssuer__class_is_assigned_from_json()
{
bourne::json input =
{
"_class", "hello"
};
DefaultCrumbIssuer obj(input.dump());
TEST_ASSERT_EQUAL_STRING("hello", obj.getClass().c_str());
}
void test_DefaultCrumbIssuer_crumb_is_assigned_from_json()
{
bourne::json input =
{
"crumb", "hello"
};
DefaultCrumbIssuer obj(input.dump());
TEST_ASSERT_EQUAL_STRING("hello", obj.getCrumb().c_str());
}
void test_DefaultCrumbIssuer_crumbRequestField_is_assigned_from_json()
{
bourne::json input =
{
"crumbRequestField", "hello"
};
DefaultCrumbIssuer obj(input.dump());
TEST_ASSERT_EQUAL_STRING("hello", obj.getCrumbRequestField().c_str());
}
void test_DefaultCrumbIssuer__class_is_converted_to_json()
{
bourne::json input =
{
"_class", "hello"
};
DefaultCrumbIssuer obj(input.dump());
bourne::json output = bourne::json::object();
output = obj.toJson();
TEST_ASSERT(input["_class"] == output["_class"]);
}
void test_DefaultCrumbIssuer_crumb_is_converted_to_json()
{
bourne::json input =
{
"crumb", "hello"
};
DefaultCrumbIssuer obj(input.dump());
bourne::json output = bourne::json::object();
output = obj.toJson();
TEST_ASSERT(input["crumb"] == output["crumb"]);
}
void test_DefaultCrumbIssuer_crumbRequestField_is_converted_to_json()
{
bourne::json input =
{
"crumbRequestField", "hello"
};
DefaultCrumbIssuer obj(input.dump());
bourne::json output = bourne::json::object();
output = obj.toJson();
TEST_ASSERT(input["crumbRequestField"] == output["crumbRequestField"]);
}
| 13.414286 | 75 | 0.649627 | [
"object"
] |
773d6ae5b474d2aed62ae3173a07fa6388271b50 | 1,314 | cpp | C++ | examples/google-code-jam/slowpoke/B.cpp | rbenic-fer/progauthfp | d0fd96c31ab0aab1a9acdcb7c75f2b430f51c675 | [
"MIT"
] | null | null | null | examples/google-code-jam/slowpoke/B.cpp | rbenic-fer/progauthfp | d0fd96c31ab0aab1a9acdcb7c75f2b430f51c675 | [
"MIT"
] | null | null | null | examples/google-code-jam/slowpoke/B.cpp | rbenic-fer/progauthfp | d0fd96c31ab0aab1a9acdcb7c75f2b430f51c675 | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <array>
#include <string>
#include <deque>
#include <list>
#include <numeric>
#include <limits>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <assert.h>
#include <iomanip>
using namespace std;
void comp(int tc){
int N;
double V, X;
cin >> N >> V >> X;
vector<double> r(N), c(N);
for (int i = 0; i < N; ++i){
cin >> r[i] >> c[i];
}
cout << "Case #" << tc << ": ";
double res = 0;
if (N == 1){
if (c[0] != X){
cout << "IMPOSSIBLE" << endl;
return;
}
res = V / r[0];
}
else if (N == 2){
if ((c[0] > X && c[1] > X) ||
(c[0] < X && c[1] < X)){
cout << "IMPOSSIBLE" << endl;
return;
}
if (r[0] < r[1]){
swap(r[0], r[1]);
swap(c[0], c[1]);
}
if (c[0] == X){
res = V / r[0];
}
else if(c[1] == X){
res = V / r[1];
}
else{
double v0 = -V*(c[1] - X) / (c[0] - c[1]);
double v1 = V - v0;
res = max(v0 / r[0], v1 / r[1]);
}
}
cout << fixed << setprecision(20) << res << endl;
}
int main(){
int T;
cin >> T;
for (int i = 1; i <= T; ++i){
comp(i);
}
} | 16.632911 | 51 | 0.469559 | [
"vector"
] |
773dfedfe4192430b3743fc0c22589620566f09f | 11,233 | cpp | C++ | src/RenderMeshMatch/main.cpp | mmrwizard/RenderMatch-1 | a427138e6823675eaa76c693bc31a28566b4dcd8 | [
"MIT"
] | null | null | null | src/RenderMeshMatch/main.cpp | mmrwizard/RenderMatch-1 | a427138e6823675eaa76c693bc31a28566b4dcd8 | [
"MIT"
] | null | null | null | src/RenderMeshMatch/main.cpp | mmrwizard/RenderMatch-1 | a427138e6823675eaa76c693bc31a28566b4dcd8 | [
"MIT"
] | 1 | 2020-05-12T08:19:14.000Z | 2020-05-12T08:19:14.000Z | /*
* @Author: Han
* @Date: 2019-11-15 20:01:59
* The pipeline for render image and aerial-ground match with rendered images as delegates
*/
#include <cxxopts.hpp>
#include <opencv2/imgcodecs.hpp>
#include <osg/PagedLOD>
#include <osgDB/DatabasePager>
#include <osgDB/ReadFile>
#include <osgDB/Registry>
#include <osgDB/WriteFile>
#include <osgUtil/SmoothingVisitor>
#include <osgViewer/Viewer>
#include <RenderMatch/block.h>
#include <base/base.h>
#include <gdal.h>
#include "render_matcher.h"
using namespace h2o;
struct ScreenShot : public osg::Camera::DrawCallback {
ScreenShot(const h2o::Block &block) : block_ground_(block) { iid_ = INVALID_INDEX; }
void set_iid(uint32_t iid) { iid_ = iid; }
void set_buffer(const std::shared_ptr<cv::Mat> &rgb, const std::shared_ptr<cv::Mat> &dep) {
mat_rgb_ = rgb;
mat_dep_ = dep;
}
virtual void operator()(osg::RenderInfo &renderInfo) const {
if (iid_ == INVALID_INDEX) {
return;
}
osg::Camera *camera = renderInfo.getCurrentCamera();
osg::Viewport *viewport = camera ? camera->getViewport() : 0;
if (viewport) {
osg::ref_ptr<osg::Image> image = new osg::Image;
std::string name = block_ground_.photos.at(iid_).path;
cv::Mat mat_rgb;
cv::Mat mat_dep;
// read the rgb value
{
glReadBuffer(camera->getDrawBuffer());
image->readPixels(viewport->x(), viewport->y(), viewport->width(), viewport->height(), GL_RGBA,
GL_UNSIGNED_BYTE, 1);
image->flipVertical();
mat_rgb = cv::Mat(viewport->height(), viewport->width(), CV_8UC4, (void *)image->getDataPointer(),
(size_t)image->getRowStepInBytes())
.clone();
cv::cvtColor(mat_rgb, mat_rgb, cv::COLOR_RGBA2BGRA);
*mat_rgb_ = mat_rgb.clone();
}
// read the depth value
{
glReadBuffer(camera->getDrawBuffer());
image->readPixels(viewport->x(), viewport->y(), viewport->width(), viewport->height(),
GL_DEPTH_COMPONENT, GL_FLOAT);
image->flipVertical();
mat_dep = cv::Mat(viewport->height(), viewport->width(), CV_32FC1, (void *)image->getDataPointer(),
(size_t)image->getRowStepInBytes());
*mat_dep_ = mat_dep.clone();
}
}
}
h2o::Block block_ground_;
uint32_t iid_;
// render function only support const, we must pass pointer here
std::shared_ptr<cv::Mat> mat_rgb_;
std::shared_ptr<cv::Mat> mat_dep_;
};
int main(int argc, char **argv) {
GDALAllRegister();
cxxopts::Options options("RenderMeshMatch",
"The pipeline for render image and aerial-ground match with rendered images as delegates");
std::string path_ground_at;
std::string path_aerial_at;
std::string path_model;
std::string path_config;
std::string origin_coord_at;
// clang-format off
options.add_options("RenderMeshMatch")
("a,aerial", "Aerial AT file", cxxopts::value(path_aerial_at))
("g,ground", "Ground AT file", cxxopts::value(path_ground_at))
("m,model", "Path to the mesh", cxxopts::value(path_model))
("c,config", "Path to the match parameters", cxxopts::value(path_config))
("t,transform","original coordinate", cxxopts::value(origin_coord_at))
("h,help", "Print this help message");
// clang-format on
auto results = options.parse(argc, argv);
if (results.arguments().empty() || results.count("help")) {
std::cout << options.help({"UndistortImage"}) << std::endl;
return 1;
}
path_ground_at = QFileInfo(QString::fromLocal8Bit(path_ground_at.c_str())).absoluteFilePath().toStdString();
path_aerial_at = QFileInfo(QString::fromLocal8Bit(path_aerial_at.c_str())).absoluteFilePath().toStdString();
path_model = QFileInfo(QString::fromLocal8Bit(path_model.c_str())).absoluteFilePath().toStdString();
RenderMeshMatchConfig param = load_config(path_config);
Eigen::Vector3d origin_coord;
const char *s = origin_coord_at.data();
double a, b, c;
std::sscanf(s, "%lf,%lf,%lf", &a, &b, &c);
origin_coord << a, b, c;
h2o::Block block_aerial = load_block(path_aerial_at,origin_coord);
h2o::Block block_ground = load_block(path_ground_at,origin_coord);
h2o::Block block_ground_rectified = undistort_block(block_ground);
osgViewer::Viewer viewer;
osg::ref_ptr<ScreenShot> screen_shot = new ScreenShot(block_ground_rectified);
osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFile(path_model);
viewer.setSceneData(model);
RenderMatcher matcher;
matcher.set_block(block_aerial, block_ground);
matcher.set_param(param);
RenderMatchResults match_results;
// for each photo groups, set the viewport for rendering and do the rendering
for (const auto &pgroups : block_ground_rectified.groups) {
uint32_t cid = pgroups.first;
PhotoGroup pgroup = pgroups.second;
uint32_t width = pgroup.width;
uint32_t height = pgroup.height;
double focal = pgroup.f;
// setup per camera settings
{
osg::ref_ptr<osg::DisplaySettings> ds = new osg::DisplaySettings;
ds->setScreenWidth((float)width);
ds->setScreenHeight((float)height);
ds->setScreenDistance((float)focal);
ds->setStereo(false);
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(ds.get());
traits->readDISPLAY();
if (traits->displayNum < 0)
traits->displayNum = 0;
traits->x = 0;
traits->y = 0;
traits->width = width;
traits->height = height;
traits->alpha = 8;
traits->windowDecoration = false;
traits->doubleBuffer = true;
traits->sharedContext = 0;
traits->pbuffer = true;
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!gc) {
LOG(ERROR) << "Failed to created requested graphics context";
return 1;
}
// transparent background
viewer.getCamera()->setClearColor(osg::Vec4(255.0f, 255.0f, 255.0f, 0.0f));
viewer.getCamera()->setGraphicsContext(gc.get());
viewer.getCamera()->setDisplaySettings(ds.get());
osgViewer::GraphicsWindow *gw = dynamic_cast<osgViewer::GraphicsWindow *>(gc.get());
if (gw) {
LOG(INFO) << "GraphicsWindow has been created successfully." << std::endl;
gw->getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, width, height);
} else {
LOG(INFO) << "PixelBuffer has been created succseffully " << traits->width << ", " << traits->height
<< std::endl;
}
viewer.getCamera()->setCullMask(0xffffffff);
viewer.getCamera()->setCullMaskLeft(0x00000001);
viewer.getCamera()->setCullMaskRight(0x00000002);
viewer.getCamera()->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
viewer.getCamera()->setDrawBuffer(buffer);
viewer.getCamera()->setReadBuffer(buffer);
viewer.getCamera()->setFinalDrawCallback(screen_shot);
viewer.getCamera()->setComputeNearFarMode(osgUtil::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR);
viewer.getCamera()->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
viewer.getCamera()->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
viewer.realize();
}
// set up the viewport
auto photos = pgroup.photos;
for (uint32_t iid : photos) {
Photo photo = block_ground_rectified.photos.at(iid);
// near and far are used to determine the projection matrix in ogl
double znear = photo.znear;
double zfar = photo.zfar;
double zmed = photo.zmed;
Matrix3d R = photo.R;
Vector3d dir = R.transpose() * Vector3d(0, 0, 1);
dir.normalize();
// used to compute the view matrix in ogl
/* The up direction is (0, -1, 0) in object space
* ------->
* |
* |
* \/
*/
Vector3d eye = photo.C;
Vector3d target = eye + dir * zmed;
Vector3d up = R.transpose() * Vector3d(0, -1, 0);
// set up matices and do the rendering
{
// per photo settings
double vfov = atan2((double)height / 2.0, focal) * RAD2DEG * 2.0;
viewer.getCamera()->setProjectionMatrixAsPerspective(vfov, (double)width / (double)height, znear, zfar);
viewer.getCamera()->setViewMatrixAsLookAt(osg::Vec3(eye.x(), eye.y(), eye.z()),
osg::Vec3(target.x(), target.y(), target.z()),
osg::Vec3(up.x(), up.y(), up.z()));
}
// initialize the paged lod, waiting for loading
screen_shot->set_iid(INVALID_INDEX);
// there are at most 21 levels, and each frame will request all the nodes in the next level
for (int i = 0; i < 21; ++i) {
viewer.frame();
int node_num = viewer.getDatabasePager()->getFileRequestListSize();
while (viewer.getDatabasePager()->getFileRequestListSize()) {
// waiting for loading
}
}
std::shared_ptr<cv::Mat> mat_rgb = std::make_shared<cv::Mat>();
std::shared_ptr<cv::Mat> mat_dep = std::make_shared<cv::Mat>();
screen_shot->set_buffer(mat_rgb, mat_dep);
screen_shot->set_iid(iid);
viewer.frame();
// we have finished the rendering, now we have the rgb and depth image
osg::Matrixd proj = viewer.getCamera()->getProjectionMatrix();
osg::Matrixd view = viewer.getCamera()->getViewMatrix();
Matrix4f eproj, eview;
for (int r = 0; r < 4; ++r) {
for (int c = 0; c < 4; ++c) {
eproj(r, c) = proj(c, r);
eview(r, c) = view(c, r);
}
}
matcher.set_ogl_matrices(eview, eproj);
RenderMatchResults results_image = matcher.match(iid, *mat_rgb, *mat_dep);
match_results.insert(end(match_results), begin(results_image), end(results_image));
}
}
matcher.save_match(match_results);
return 0;
}
| 38.868512 | 120 | 0.580077 | [
"mesh",
"render",
"object",
"model",
"transform"
] |
773f1fb6ec5bbe63b8cad816cfe79d44f5c66823 | 397 | cpp | C++ | source/engine/render/shaders/Compiler.cpp | aviktorov/pbr-sandbox | 66a71c741dac2d2dd46668a506d02de88f05e399 | [
"MIT"
] | 19 | 2020-02-11T19:57:41.000Z | 2022-02-20T14:11:33.000Z | source/engine/render/shaders/Compiler.cpp | aviktorov/pbr-sandbox | 66a71c741dac2d2dd46668a506d02de88f05e399 | [
"MIT"
] | null | null | null | source/engine/render/shaders/Compiler.cpp | aviktorov/pbr-sandbox | 66a71c741dac2d2dd46668a506d02de88f05e399 | [
"MIT"
] | 5 | 2019-11-05T17:38:33.000Z | 2022-03-04T12:49:58.000Z | #include <render/shaders/Compiler.h>
#include "render/shaders/spirv/Compiler.h"
#include <cassert>
namespace render::shaders
{
Compiler *Compiler::create(ShaderILType type, io::IFileSystem *file_system)
{
switch (type)
{
case ShaderILType::SPIRV: return new spirv::Compiler(file_system);
}
return nullptr;
}
void Compiler::destroy(Compiler *compiler)
{
delete compiler;
}
}
| 17.26087 | 76 | 0.722922 | [
"render"
] |
774372cbe872e96e92d28a60fe5ac5b9e69efafe | 1,094 | cpp | C++ | src/999 Available Captures for Rook.cpp | LL-Pengfei/LL-Pengfei-Leetcode-Solutions | 3ae358877bdb943bef67a55372ce7f04d2881072 | [
"MIT"
] | null | null | null | src/999 Available Captures for Rook.cpp | LL-Pengfei/LL-Pengfei-Leetcode-Solutions | 3ae358877bdb943bef67a55372ce7f04d2881072 | [
"MIT"
] | null | null | null | src/999 Available Captures for Rook.cpp | LL-Pengfei/LL-Pengfei-Leetcode-Solutions | 3ae358877bdb943bef67a55372ce7f04d2881072 | [
"MIT"
] | null | null | null | //999. Available Captures for Rook
//https://leetcode.com/problems/available-captures-for-rook/
class Solution {
public:
int numRookCaptures(vector<vector<char>>& board) {
int ii,jj,res=0,A[8][8]={{0}}; //0 empty; 1 white; 2 black
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (board[i][j]>='A' && board[i][j]<='Z') {
A[i][j] = 1;
} else if (board[i][j]>='a' && board[i][j]<='z') {
A[i][j] = 2;
}
if (board[i][j] == 'R') ii=i, jj=j, A[i][j]=0;
//to aid the looping later on
}
}
int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
for (int i = 0; i < 4; ++i) {
int iii=ii, jjj=jj; bool flag = false;
while (iii>=0 && iii<8 && jjj>=0 && jjj<8) {
if (A[iii][jjj] != 0) {flag = true; break;}
iii += dr[i];
jjj += dc[i];
}
if (flag && (A[iii][jjj]==2)) ++res;
}
return res;
}
};
| 33.151515 | 66 | 0.379342 | [
"vector"
] |
774813f913e2f20e3517741666a11f5471701ab3 | 50,204 | hpp | C++ | ext/bliss/retired/src/io/message_buffers.hpp | tuan1225/parconnect_sc16 | bcd6f99101685d746cf30e22fa3c3f63ddd950c9 | [
"Apache-2.0"
] | null | null | null | ext/bliss/retired/src/io/message_buffers.hpp | tuan1225/parconnect_sc16 | bcd6f99101685d746cf30e22fa3c3f63ddd950c9 | [
"Apache-2.0"
] | null | null | null | ext/bliss/retired/src/io/message_buffers.hpp | tuan1225/parconnect_sc16 | bcd6f99101685d746cf30e22fa3c3f63ddd950c9 | [
"Apache-2.0"
] | null | null | null | /**
* @file message_buffers.hpp
* @ingroup io
* @author Tony Pan <tpan7@gatech.edu>
* @brief MessageBuffers base class and SendMessageBuffers subclass for buffering data for MPI send/receive
* @details MessageBuffers is a collection of in-memory Buffers that containing data that
* 1. will be sent to remote destinations, such as a MPI process
* 2. was received from remote destinations, such as a MPI process (not implemented)
*
* MessageBuffer's purpose is to batch the data to be transmitted, using BufferPool to prevent local process from blocking waiting
* for a writable buffer.
*
* As there may be several different patterns of interactions between MessageBuffers and other MessageBuffers, MessageBuffers and
* local thread/process, there is a base class MessageBuffers that acts as proxy to the underlying ObjectPool (memory management).
* Two subclasses are planned: SendMessageBuffers and RecvMessageBuffers, but only SendMessageBuffers has been implemented.
*
* Envisioned patterns of interaction:
* Send: MessageBuffers -> mpi send
* Recv: mpi recv -> MessageBuffers
* Forward: mpi recv -> mpi send
* Local: MessageBuffers -> MessageBuffers
*
* The SendMessageBuffers accumulates data in its internal buffer, and notifies the caller when a buffer is full. The caller then
* can send the buffer. SendMessageBuffers swaps in an empty buffer meanwhile.
*
* The (unimplemented) RecvMessageBuffers requires an event notification mechanism that works with callbacks to handle the received messages.
* This is currently implemented in CommunicationLayer.
*
* Copyright (c) 2014 Georgia Institute of Technology. All Rights Reserved.
*
* TODO add License
*/
#ifndef MESSAGEBUFFERS_HPP_
#define MESSAGEBUFFERS_HPP_
#include <vector>
#include <type_traits>
#include <typeinfo>
#include <iostream>
#include <sstream>
#include <iterator> // for ostream_iterator
#include <xmmintrin.h>
#include "bliss-config.hpp"
#include "config/relacy_config.hpp"
#include "concurrent/buffer.hpp"
#include "concurrent/object_pool.hpp"
#include "concurrent/copyable_atomic.hpp"
#include "omp.h"
namespace bliss
{
namespace io
{
template<typename BufferPool>
class MessageBuffers;
/**
* @class MessageBuffers
* @brief a data structure to buffering/batching messages for communication
* @details Templated base class for a collection of buffers that are used for communication.
*
* @tparam PoolLT Object Pool's thread safety model
* @tparam BufferLT Buffer's thread safety model
* @tparam BufferCapacity capacity of Buffers to create
*/
template<bliss::concurrent::LockType PoolLT, bliss::concurrent::LockType BufferLT, size_t BufferCapacity, size_t MetadataSize, bool ref>
class MessageBuffers<bliss::concurrent::ObjectPool<bliss::io::Buffer<BufferLT, BufferCapacity, MetadataSize>, PoolLT, ref> >
{
public:
/// DEFINE type of the buffer.
typedef bliss::io::Buffer<BufferLT, BufferCapacity, MetadataSize> BufferType;
protected:
/// Internal BufferPool Type. typedefed only to shorten the usage.
typedef typename bliss::concurrent::ObjectPool<BufferType, PoolLT, ref> BufferPoolType;
public:
/// Pointer type of a Buffer, aliased from BufferPool
typedef typename BufferPoolType::ObjectPtrType BufferPtrType;
protected:
/// ObjectPool for memory management.
BufferPoolType& pool;
/**
* Gets the capacity of the Buffer instances.
* @return capacity of each buffer.
*/
size_t getBufferCapacity() const {
return BufferCapacity;
}
/**
* @brief Constructor. creates a buffer given a specified per-buffer capacity, and the BufferPool capacity.
* @note Protected so base class function is not called directly.
*
* limit BufferPool to have unlimited capacity, so as to ensure that we don't get nullptrs and thus don't need to
* check in code.
*
* @param buffer_capacity the Buffer's maximum capacity. default to 8192.
* @param pool_capacity the BufferPool's capacity. default to unlimited.
*/
explicit MessageBuffers(BufferPoolType & _pool) : pool(_pool) {}; // unlimited size pool
/**
* @brief default copy constructor. deleted. since internal BufferPool does not allow copy construction/assignment.
* @note Protected so base class function is not called directly.
*
* @param other source MessageBuffers to copy from
*/
explicit DELETED_FUNC_DECL(MessageBuffers(const MessageBuffers& other));
/**
* @brief default copy assignment operator. deleted. since internal BufferPool does not allow copy construction/assignment.
* @note Protected so base class function is not called directly.
*
* @param other source MessageBuffers to copy from
* @return self.
*/
MessageBuffers& DELETED_FUNC_DECL(operator=(const MessageBuffers& other));
/**
* @brief default move constructor.
* @note Protected so base class function is not called directly.
*
* @param other source MessageBuffers to move from
*/
explicit MessageBuffers(MessageBuffers&& other) : pool(other.pool) {};
/**
* @brief default move assignment operator.
* @note Protected so base class function is not called directly.
*
* @param other source MessageBuffers to move from
* @return self.
*/
MessageBuffers& operator=(MessageBuffers&& other) {
pool = other.pool;
return *this;
}
public:
/**
* @brief default destructor
*/
virtual ~MessageBuffers() {};
/**
* @brief Releases a Buffer by pointer, after the buffer is no longer needed.
* @note this should be called on a buffer that is not being used. e,g, after the buffer has been transmitted
* this also includes potential multithreaded use of the same buffer.
*
* @note This to be called after the communication logic is done with the Send or Recv buffer.
*
* @param id Buffer's id (assigned from BufferPool)
*/
virtual void releaseBuffer(BufferPtrType ptr) {
pool.releaseObject(ptr);
}
protected:
/**
* @brief Convenience method to release and clear all current Buffers in the pool.
*/
virtual void PURE_VIRTUAL_FUNC(reset());
};
/**
* @class SendMessageBuffers
* @brief SendMessageBuffers is a subclass of MessageBuffers designed to manage the actual buffering of data for a set of messaging targets.
* @details
*
* DISABLED BECAUSE SWAPPING BUFFER PTR IS NOT SAFE in multiple threaded code.
*
* The class is designed with the following requirements in mind:
* 1. data is destined for some remote process identifiable by a process id (e.g. rank)
* 2. data is appended to buffer incrementally and with minimal blocking
* 3. calling thread has a mechanism to process a full buffer. e.g. send it
* 4. all data in a SendMessageBuffers are homogeneously typed.
*
* The class is implemented to support the requirement:
* 1. SendMessageBuffers is not aware of its data's type or metadata specifying its type.
* 2. SendMessageBuffers uses the base MessageBuffers class' internal BufferPool to reuse memory
* 3. SendMessageBuffers maps from target process Ranks to Buffers.
* 4. SendMessageBuffers provides an Append function to incrementally add data to the Buffer object for the targt process rank.
* 5. When a particular buffer is full, return the Buffer Id to the calling thread for it to process (send), and swap in an empty
* Buffer from BufferPool.
*
* An internal vector is used to map from target process rank to Buffer pointer. For multithreading flavors of message buffers,
* atomic<BufferType*> instead of BufferType* is used.
*
* @note
* pool size is unlimited so we would not get nullptr, and therefore do not need to check it.
*
* @note
* For Buffers that are full, the calling thread will need to track the full buffer as this class evicts a full Buffer from it's
* vector of Buffer Ptrs. The Calling Thread can do this via a queue, as in the case of CommunicationLayer.
* Note that a Buffer is "in use" from the first call to the Buffer's append function to the completion of the send (e.g. via MPI Isend)
*
* @tparam LockType determines if this class should be thread safe
*
*
*/
// template<bliss::concurrent::LockType ArrayLT, bliss::concurrent::LockType PoolLT, bliss::concurrent::LockType BufferLT,
// size_t BufferCapacity = 1048576, size_t MetadataSize>
template<bliss::concurrent::LockType ArrayLT, typename BufferPool>
class SendMessageBuffers;
// template<bliss::concurrent::LockType ArrayLT, bliss::concurrent::LockType PoolLT, bliss::concurrent::LockType BufferLT, size_t BufferCapacity = 8192>
// class SendMessageBuffers : public MessageBuffers<PoolLT, BufferLT, BufferCapacity>
// {
// protected:
// using BaseType = MessageBuffers<PoolLT, BufferLT, BufferCapacity>;
// using MyType = SendMessageBuffers<ArrayLT, PoolLT, BufferLT, BufferCapacity>;
//
// public:
// /// Id type of the Buffers
// using BufferType = typename BaseType::BufferType;
// using BufferPtrType = typename BaseType::BufferPtrType;
//
// /// the BufferPoolType from parent class
// using BufferPoolType = typename BaseType::BufferPoolType;
//
// protected:
//
// /// Vector of pointers (atomic). Provides a mapping from process id (0 to vector size), to bufferPtr (from BufferPool)
// /// using vector of atomic pointers allows atomic swap of each pointer, without array of mutex or atomic_flags.
// typedef typename std::conditional<PoolLT == bliss::concurrent::LockType::NONE, BufferType*, std::atomic<BufferType*> >::type BufferPtrTypeInternal;
// std::vector< BufferPtrTypeInternal > buffers;
//
// /// for synchronizing access to buffers (and pool).
// mutable std::mutex mutex;
// mutable std::atomic_flag spinlock;
//
// private:
//
// // private copy contructor
// SendMessageBuffers(MyType&& other, const std::lock_guard<std::mutex>&) :
// BaseType(std::move(other)), buffers(std::move(other.buffers))
// {};
//
// /**
// * @brief default copy constructor. deleted.
// * @param other source SendMessageBuffers to copy from.
// */
// explicit SendMessageBuffers(const MyType &other) = delete;
//
// /**
// * @brief default copy assignment operator, deleted.
// * @param other source SendMessageBuffers to copy from.
// * @return self
// */
// MyType& operator=(const MyType &other) = delete;
//
//
// /**
// * @brief Default constructor, deleted
// */
// SendMessageBuffers() = delete;
//
// public:
// /**
// * @brief Constructor.
// * @param numDests The number of messaging targets/destinations
// * @param bufferCapacity The capacity of the individual buffers. default 8192.
// * @param poolCapacity The capacity of the pool. default unbounded.
// */
// explicit SendMessageBuffers(const int & numDests, int numThreads = 0) :
// BaseType(), buffers(numDests)
// {
// this->reset();
// };
//
//
//
// /**
// * default move constructor. calls superclass move constructor first.
// * @param other source SendMessageBuffers to move from.
// */
// explicit SendMessageBuffers(MyType && other) :
// SendMessageBuffers(std::forward<MyType >(other), std::lock_guard<std::mutex>(other.mutex)) {};
//
//
// /**
// * @brief default move assignment operator.
// * @param other source SendMessageBuffers to move from.
// * @return self
// */
// MyType& operator=(MyType && other) {
// std::unique_lock<std::mutex> mine(mutex, std::defer_lock),
// hers(other.mutex, std::defer_lock);
// std::lock(mine, hers);
//
// this->pool = std::move(other.pool);
// buffers.clear(); std::swap(buffers, other.buffers);
//
// return *this;
// }
//
// /**
// * @brief default destructor
// */
// virtual ~SendMessageBuffers() {
// // when pool destructs, all buffers will be destroyed.
// buffers.clear();
// };
//
// /**
// * @brief get the number of buffers. should be same as number of targets for messages
// * @return number of buffers
// */
// const size_t getSize() const {
// return buffers.size();
// }
//
// /**
// * @brief get a raw pointer to the the BufferId that a messaging target maps to.
// * @details for simplicity, not distinguishing between thread safe and unsafe versions
// *
// * @param targetRank the target id for the messages.
// * @return reference to the unique_ptr. when swapping, the content of the unique ptrs are swapped.
// */
// // template<bliss::concurrent::LockType LT = PoolLT>
// // const typename std::enable_if<LT != bliss::concurrent::LockType::NONE, BufferType*>::type at(const int targetRank) const {
// // return buffers.at(targetRank).load(); // can use reference since we made pool unlimited, so never get nullptr
// // }
// BufferType* at(const int targetRank) {
// return (BufferType*)(buffers.at(targetRank)); // if atomic pointer, then will do load()
// }
//
// BufferType* operator[](const int targetRank) {
// return at(targetRank);
// }
//
//
// /**
// * @brief Reset the current MessageBuffers instance by first clearing its list of Buffer Ids, then repopulate it from the pool.
// * @note One thread only should call this.
// */
// virtual void reset() {
//
// std::lock_guard<std::mutex> lock(mutex);
// int count = buffers.size();
// // release all buffers back to pool
// for (int i = 0; i < count; ++i) {
// if (this->at(i)) {
// this->at(i)->block_and_flush();
// this->pool.releaseObject(this->at(i));
// buffers.at(i) = nullptr;
// }
// }
// // reset the pool. local vector should contain a bunch of nullptrs.
// this->pool.reset();
// // buffers.clear();
// // buffers.resize(count);
//
// // populate the buffers from the pool
// for (int i = 0; i < count; ++i) {
// //INFOF("initializing buffer %p \n", this->at(i));
// swapInEmptyBuffer<PoolLT>(i);
// //INFOF("initialized buffer %p blocked? %s, empty? %s\n", this->at(i), this->at(i)->is_read_only()? "y" : "n", this->at(i)->isEmpty() ? "y" : "n");
//
// }
// }
//
// /** thread safety:
// * called by commlayer's send/recv thread, so single threaded there
// * called by sendMessageBuffer's swapInEmptyBuffer
// * if threadsafe version of sendMessageBuffer, then the pointer to buffer to be released will be unique.
// * if not threadsafe version, then the sendMessageBuffer should be used by a single threaded program, so buffer to release should be unique.
// *
// * overall, do not need to worry about multiple threads releasing the same buffer.
// */
// virtual void releaseBuffer(BufferPtrType ptr) {
// if (ptr) {
// ptr->block_and_flush(); // if already blocked and flushed, no op.
//
// BaseType::releaseBuffer(ptr);
// }
// }
//
// /**
// * @brief Appends data to the target message buffer.
// * @details internally will try to swap in a new buffer when full, and notify the caller of the full buffer's id.
// * need to return 2 things:
// * 1. success/failure of current insert
// * 2. indicator that there is a full buffer (the full buffer's id).
// *
// * Notes:
// * on left side -
// * targetBufferId is obtained outside of CAS, so when CAS is called to update bufferIdForProcId[dest], it may be different already (on left side)
// * on right side -
// * fullBufferId and bufferId[dest] are set atomically, but newTargetBufferId is obtained outside of CAS, so the id of the TargetBufferId
// * may be more up to date than the CAS function results, which is okay. Note that a fullBuffer will be marked as blocked to prevent further append.
// *
// * Table of values and compare exchange behavior (called when a buffer if full and an empty buffer is swapped in.)
// * targetBufferId, bufferIdForProcId[dest], newBufferId (from pool) -> fullBufferId, bufferId[dest], newTargetBufferId
// * x x y x y y
// * x x -1 x -1 -1
// * x z y -1 z z
// * x z -1 -1 z z
// * x -1 y -1 -1 -1
// * x -1 -1 -1 -1 -1
// * -1 -1 y -1 y y
// * -1 -1 -1 -1 -1 -1
// * -1 z y -1 -1 -1
// * -1 z -1 -1 -1 -1
// *
// * @note if failure, data to be inserted would need to be handled by the caller.
// *
// * @param[in] data data to be inserted, as byteArray
// * @param[in] count number of bytes to be inserted in the the Buffer
// * @param[in] dest messaging target for the data, decides which buffer to append into.
// * @return std::pair containing the status of the append (boolean success/fail), and the id of a full buffer if there is one.
// */
// std::pair<bool, BufferType*> append(const void* data, const size_t count, const int targetProc) {
//
// //== if data being set is null, throw error
// if (data == nullptr || count <= 0) {
// throw (std::invalid_argument("ERROR: calling MessageBuffer append with nullptr"));
// }
//
// //== if there is not enough room for the new data in even a new buffer, LOGIC ERROR IN CODE: throw exception
// if (count > this->getBufferCapacity()) {
// throw (std::invalid_argument("ERROR: messageBuffer append with count exceeding Buffer capacity"));
// }
//
// //== if targetProc is outside the valid range, throw an error
// if (targetProc < 0 || targetProc > getSize()) {
// throw (std::invalid_argument("ERROR: messageBuffer append with invalid targetProc"));
// }
//
//
//
// // NOTE: BufferPool is unlimited in size, so don't need to check for nullptr, can just append directly. is append really atomic?
// // question is what happens in unique_ptr when dereferencing the internal pointer - if the dereference happens before a unique_ptr swap
// // from swapInEmptyBuffer, then append would use the old object. however, it was probably swapped because it's full,
// // or flushing, so lock_read() would have been set for the full case. now it depends on what happens in append.
// // if flush, then block is set just before swap, so it's more likely this thread enters append without a block.
//
// unsigned int appendResult = 0x0;
// auto ptr = this->at(targetProc);
//
// if (ptr) {
// // // DEBUGGING ONLY - for testCommLayer only. test if call from CommLayer appended the wrong message to MessageBuffers. Buffer has test for before and after as well.
// // int m = *((int*)data);
// // if ((m / 1000) % 10 == 1) {
// // if (m / 100000 != targetProc + 1) ERRORF("ERROR: DEBUG: MessageBuffers Append wrong input message: %d to proc %d", m, targetProc);
// // }
// // else {
// // if (m % 1000 != targetProc + 1) ERRORF("ERROR: DEBUG: MessageBuffers Append wrong input message: %d to proc %d", m, targetProc);
// // }
// void * result = nullptr;
//
// appendResult = ptr->append(data, count, result); //DEBUGGING FORM
//
// // // DEBUGGING ONLY - for testCommLayer only. test if call from CommLayer appended the wrong message to MessageBuffers. Buffer has test for before and after as well.
// // if (result != nullptr) {
// // m = *((int*)result);
// // if ((m / 1000) % 10 == 1) {
// // if (m / 100000 != targetProc + 1) ERRORF("ERROR: DEBUG: MessageBuffers Append wrong outputmessage: %d to proc %d", m, targetProc);
// // }
// // else {
// // if (m % 1000 != targetProc + 1) ERRORF("ERROR: DEBUG: MessageBuffers Append wrong output message: %d to proc %d", m, targetProc);
// // }
// // } else {
// // if (appendResult & 0x1) {
// // ERRORF("ERROR: successful append but result ptr is null!");
// // }
// // }
// }
// else {
// ERRORF("ERROR: Append: shared Buffer ptr is null and no way to swap in a different one.");
// throw std::logic_error("ERROR: Append: Shared Buffer ptr is null and no way to swap in a different one.");
// }
//
//
// // unsigned int appendResult = this->at(targetProc)->append(data, count);
//
// // INFOF("buffer blocked? %s, empty? %s\n", this->at(targetProc)->is_read_only()? "y" : "n", this->at(targetProc)->isEmpty() ? "y" : "n");
//
// // now if appendResult is false, then we return false, but also swap in a new buffer.
// // conditions are either full buffer, or blocked buffer.
// // this call will mark the fullBuffer as blocked to prevent multiple write attempts while flushing the buffer
// // ideally, we want it to be a reference that gets updated for all threads.
//
// if (appendResult & 0x2) { // only 1 thread gets 0x2 result for a buffer. all other threads either writes successfully or fails.
//
// return std::move(std::make_pair(appendResult & 0x1, swapInEmptyBuffer<PoolLT>(targetProc) ) );
// } else {
// //if (preswap != postswap) ERRORF("ERROR: NOSWAP: preswap %p and postswap %p are not the same.\n", preswap, postswap);
// return std::move(std::make_pair(appendResult & 0x1, nullptr));
// }
//
// }
//
// /**
// * flushes the buffer at rank targetProc.
// *
// * @note only 1 thread should call this per proc.
// * multiple calls to this may be needed to get all data that are written to the new empty buffer.
// *
// * @param targetProc
// * @return
// */
// std::vector<BufferType*> flushBufferForRank(const int targetProc) {
// //== if targetProc is outside the valid range, throw an error
// if (targetProc < 0 || targetProc > getSize()) {
// throw (std::invalid_argument("ERROR: messageBuffer append with invalid targetProc"));
// }
//
// std::vector<BufferType*> result;
// // // block the old buffer (when append full, will block as well). each proc has a unique buffer.
// // this->at(targetProc)->block_and_flush(); // this part can be concurrent.
// //
// // passing in getBufferIdForRank result to ensure atomicity.
// // may return ABSENT if there is no available buffer to use.
// auto old = swapInEmptyBuffer<PoolLT>(targetProc);
// if (old) {
// old->block_and_flush();
// result.push_back(old);
// }
// return result;
// }
//
// /**
// * flushes the buffer at rank targetProc.
// *
// * @note only 1 thread should call this per proc.
// * multiple calls to this may be needed to get all data that are written to the new empty buffer.
// *
// * @param targetProc
// * @return
// */
// BufferType* threadFlushBufferForRank(const int targetProc, int thread_id = 0) {
// //== if targetProc is outside the valid range, throw an error
// if (targetProc < 0 || targetProc > getSize()) {
// throw (std::invalid_argument("ERROR: messageBuffer append with invalid targetProc"));
// }
//
// // // block the old buffer (when append full, will block as well). each proc has a unique buffer.
// // this->at(targetProc)->block_and_flush(); // this part can be concurrent.
// //
// // passing in getBufferIdForRank result to ensure atomicity.
// // may return ABSENT if there is no available buffer to use.
// auto old = swapInEmptyBuffer<PoolLT>(targetProc);
// if (old) old->block_and_flush();
// return old;
// }
//
//
//
// protected:
//
// /**
// * @brief Swap in an empty Buffer from BufferPool at the dest location in MessageBuffers. The old buffer is returned. allows swapping in a nullptr if pool is full.
// * @details The new buffer may be BufferPoolType::ABSENT (invalid buffer, when there is no available Buffer from pool)
// *
// * Effect: bufferIdForProcId[dest] gets a new Buffer Id, full Buffer is set to "blocked" to prevent further append.
// *
// * This is the THREAD SAFE version. Uses std::compare_exchange_strong to ensure that another thread hasn't swapped in a new Empty one already.
// *
// * @note we make the caller get the new bufferIdForProcId[dest] directly instead of returning by reference in the method parameter variable
// * because this way there is less of a chance of race condition if a shared "old" variable was accidentally used.
// * and the caller will likely prefer the most up to date bufferIdForProcId[dest] anyway.
// *
// * @note below is now relevant any more now that message buffer hold buffer ptrs and pool is unlimited.. we only have line 5 here.
// * old is old assignment action
// * ABSENT available not a valid case
// * ABSENT at dest swap, return ABS
// * ABSENT not at dest dest is already swapped. no op, return ABS
// * not ABS available not used. block old, no swap. return ABS
// * not ABS at dest swap, block old. return old
// * not ABS not at dest being used. no op. return ABS
// *
// *
// * @note: exchanges buffer at dest atomically.
// * @note: because only thread that just fills a buffer will do exchange, only 1 thread does exchange at a time. can rely on pool's Lock to get one new buffer
// * can be assured that each acquired new buffer will be used, and can ascertain that no 2 threads will replace the same full buffer.
// *
// * @tparam used to choose thread safe vs not verfsion of the method.
// * @param dest position in bufferIdForProcId array to swap out
// * @return the BufferId that was swapped out.
// */
// template<bliss::concurrent::LockType LT = PoolLT>
// typename std::enable_if<LT != bliss::concurrent::LockType::NONE, BufferType*>::type swapInEmptyBuffer(const int dest) {
//
// auto ptr = this->pool.tryAcquireObject();
// int i = 1;
// while (!ptr) {
// _mm_pause();
// ptr = this->pool.tryAcquireObject();
// ++i;
// }
// if (i > 200) WARNINGF("NOTICE: Concurrent Pool shared Buffer ptr took %d iterations to acquire, %d threads.", i, omp_get_num_threads());
//
// if (ptr) {
// ptr->clear_and_unblock_writes();
// memset(ptr->operator int*(), 0, ptr->getCapacity());
// }
//
// auto oldbuf = buffers.at(dest).exchange(ptr);
// if (oldbuf && oldbuf->isEmpty()) {
// // INFOF("oldbuf %p, blocked? %s\n", oldbuf, oldbuf->is_read_only() ? "y" : "n");
// releaseBuffer(oldbuf);
// return nullptr;
// }
// else return oldbuf;
// }
//
//
// /**
// * @brief Swap in an empty Buffer from BufferPool at the dest location in MessageBuffers. The old buffer is returned.
// * @details The new buffer may be BufferPoolType::ABSENT (invalid buffer, when there is no available Buffer from pool)
// *
// * effect: bufferIdForProcId[dest] gets a new Buffer Id, full Buffer is set to "blocked" to prevent further append.
// *
// * this is the THREAD UNSAFE version
//
// * @note we make the caller get the new bufferIdForProcId[dest] directly instead of returning by reference in the method parameter variable
// * because this way there is less of a chance of race condition if a shared "old" variable was accidentally used.
// * and the caller will likely prefer the most up to date bufferIdForProcId[dest] anyway.
// *
// * @note
// * ABSENT available not a valid case
// * ABSENT at dest swap, return ABS
// * ABSENT not at dest dest is already swapped. no op, return ABS
// * not ABS available not used. block old, no swap. return ABS
// * not ABS at dest swap, block old. return old
// * not ABS not at dest being used. no op. return ABS
// *
// * @note: requires that the queue at dest to be blocked.
// *
// *
// * @tparam LT used to choose thread safe vs not verfsion of the method.
// * @param dest position in bufferIdForProcId array to swap out
// * @return the BufferId that was swapped out.
// */
// template<bliss::concurrent::LockType LT = PoolLT>
// typename std::enable_if<LT == bliss::concurrent::LockType::NONE, BufferType*>::type swapInEmptyBuffer(const int dest) {
//
// auto oldbuf = this->at(dest);
// auto ptr = this->pool.tryAcquireObject();
// int i = 1;
// while (!ptr) {
// _mm_pause();
// ptr = this->pool.tryAcquireObject();
// ++i;
// }
// if (i > 200) WARNINGF("NOTICE: non Concurrent Pool shared Buffer ptr took %d iterations to acquire, %d threads.", i, omp_get_num_threads());
//
// if (ptr) {
// ptr->clear_and_unblock_writes();
// memset(ptr->operator int*(), 0, ptr->getCapacity());
// }
//
// buffers.at(dest) = ptr;
// if (oldbuf && oldbuf->isEmpty()) {
// // INFOF("oldbuf %p, empty? %s\n", oldbuf, oldbuf->isEmpty() ? "y" : "n");
//
// releaseBuffer(oldbuf);
// return nullptr;
// }
// else return oldbuf; // swap the pointer to Buffer object, not Buffer's internal "data" pointer
// }
//
//
// };
/**
* @class SendMessageBuffers
* @brief SendMessageBuffers is a subclass of MessageBuffers designed to manage the actual buffering of data for a set of messaging targets.
* @details
*
* This version uses a single ObjectPool for memory management, and thread local message buffer vectors
* each thread has its own set of buffers, one per target MPI Process.
*
* The class is designed with the following requirements in mind:
* 1. data is destined for some remote process identifiable by a process id (e.g. rank)
* 2. data is appended to buffer incrementally and with minimal blocking
* 3. calling thread has a mechanism to process a full buffer. e.g. send it
* 4. all data in a SendMessageBuffers are homogeneously typed.
*
* The class is implemented to support the requirement:
* 1. SendMessageBuffers is not aware of its data's type or metadata specifying its type.
* 2. SendMessageBuffers uses the base MessageBuffers class' internal BufferPool to reuse memory
* 3. SendMessageBuffers maps from target process Ranks to Buffers.
* 4. SendMessageBuffers provides an Append function to incrementally add data to the Buffer object for the targt process rank.
* 5. When a particular buffer is full, return the Buffer Id to the calling thread for it to process (send), and swap in an empty
* Buffer from BufferPool.
*
* An internal vector is used to map from target process rank to Buffer pointer. For multithreading flavors of message buffers,
* atomic<BufferType*> instead of BufferType* is used.
*
* @note
* pool size is unlimited so we would not get nullptr, and therefore do not need to check it.
*
* @note
* For Buffers that are full, the calling thread will need to track the full buffer as this class evicts a full Buffer from it's
* vector of Buffer Ptrs. The Calling Thread can do this via a queue, as in the case of CommunicationLayer.
* Note that a Buffer is "in use" from the first call to the Buffer's append function to the completion of the send (e.g. via MPI Isend)
*
* @tparam LockType determines if this class should be thread safe
*
*
*/
template<bliss::concurrent::LockType PoolLT, bliss::concurrent::LockType BufferLT, size_t BufferCapacity, size_t MetadataSize, bool ref>
class SendMessageBuffers<bliss::concurrent::LockType::THREADLOCAL,
bliss::concurrent::ObjectPool<bliss::io::Buffer<BufferLT, BufferCapacity, MetadataSize>, PoolLT, ref > > :
public MessageBuffers<bliss::concurrent::ObjectPool<bliss::io::Buffer<BufferLT, BufferCapacity, MetadataSize>, PoolLT, ref > >
{
protected:
using BaseType = MessageBuffers<bliss::concurrent::ObjectPool<bliss::io::Buffer<BufferLT, BufferCapacity, MetadataSize>, PoolLT, ref > >;
using MyType = SendMessageBuffers<bliss::concurrent::LockType::THREADLOCAL, BaseType>;
public:
/// type of the Buffers
using BufferType = typename BaseType::BufferType;
/// pointer type of the Buffers
using BufferPtrType = typename BaseType::BufferPtrType;
/// the BufferPoolType from parent class
using BufferPoolType = typename BaseType::BufferPoolType;
protected:
using BufferPtrTypeInternal = VAR_T(BufferType*);
/**
* @brief Vector of vector of buffer pointers that avoids sharing buffers between threads.
* @details primiarily, this speeds up access to buffers, and avoid thread data race when
* buffers are swapped out.
* top level vector denotes target MPI Rank to local buffers mapping.
* bottom level vector maps thread to buffers.
* since each thread has its own buffer, no synchronization is required.
*/
std::vector< std::vector< BufferPtrTypeInternal > > buffers;
/// for synchronizing access to buffers (and pool) during construction.
mutable std::mutex mutex;
private:
/// move constructor with mutex lock
SendMessageBuffers(MyType&& other, const std::lock_guard<std::mutex>&) :
BaseType(std::move(other)), buffers(std::move(other.buffers))
{};
/**
* @brief default copy constructor. deleted.
* @param other source SendMessageBuffers to copy from.
*/
explicit DELETED_FUNC_DECL(SendMessageBuffers(const MyType &other));
/**
* @brief default copy assignment operator, deleted.
* @param other source SendMessageBuffers to copy from.
* @return self
*/
MyType& DELETED_FUNC_DECL(operator=(const MyType &other));
/**
* @brief Default constructor, deleted
*/
DELETED_FUNC_DECL(SendMessageBuffers());
mutable int nDests;
public:
/**
* @brief Constructor.
* @param pool ObjectPool for buffers
* @param num_dests The number of messaging targets/destinations
* @param num_threads The number of threads accessing this MessageBuffer
*/
explicit SendMessageBuffers(BufferPoolType& _pool, const int num_dests, const int num_threads = 0) :
BaseType(_pool), buffers(num_dests), nDests(num_dests)
{
int nThreads = (num_threads <= 0 ? omp_get_max_threads() : num_threads);
// top level vector maps buffers to MPI rank.
for (int i = 0; i < num_dests; ++i) {
buffers[i] = std::vector<BufferPtrTypeInternal>(nThreads, nullptr);
}
DEBUGF("MessageBuffers CTOR");
this->reset();
};
/**
* default move constructor. calls superclass move constructor first.
* @param other source SendMessageBuffers to move from.
*/
explicit SendMessageBuffers(MyType && other) :
MyType(std::forward< MyType >(other), std::lock_guard<std::mutex>(other.mutex)) {};
/**
* @brief default move assignment operator.
* @param other source SendMessageBuffers to move from.
* @return self
*/
MyType& operator=(MyType && other) {
std::unique_lock<std::mutex> mine(mutex, std::defer_lock),
hers(other.mutex, std::defer_lock);
std::lock(mine, hers);
this->pool = other.pool;
buffers.clear(); buffers = std::move(other.buffers);
return *this;
}
/**
* @brief default destructor
*/
virtual ~SendMessageBuffers() {
// when pool destructs, all buffers will be destroyed.
buffers.clear();
};
/**
* @brief get the number of buffers. should be same as number of targets for messages
* @return number of buffers
*/
size_t getNumDests() const {
return nDests;
}
size_t getNumThreads() const {
return buffers[0].size();
}
/**
* @brief get a raw pointer to the buffer that a messaging target maps to (FOR THE CALLING THREAD)
* @details thread local version.
*
* @param targetRank the target id for the messages.
* @return reference to the buffer.
*/
BufferType* at(const int targetRank, int srcThread = -1) {
// openmp - thread ids are sequential from 0 to nThreads - 1, so can use directly as vector index.
int tid = (srcThread == -1 ? omp_get_thread_num() : srcThread);
return VAR(buffers.at(targetRank).at(tid));
}
/**
* @brief get a raw pointer to the the BufferId that a messaging target maps to (FOR THE CALLING THREAD)
*/
BufferType* operator[](const int targetRank) {
return at(targetRank, omp_get_thread_num());
}
/**
* @brief Reset the current MessageBuffers instance by first clearing its list of Buffers, then repopulate it from the pool.
* @note One thread only should call this.
*/
virtual void reset() {
DEBUGF("Reset Start");
std::lock_guard<std::mutex> lock(mutex);
int count = buffers.size();
BufferType* ptr;
int tid, nthreads;
// release all buffers back to pool
for (int i = 0; i < count; ++i) {
nthreads = buffers.at(i).size();
for (tid = 0; tid < nthreads; ++tid) {
// get pointer to it (not using iter's copy of it, avoid changing the iterator)
ptr = this->at(i, tid);
if (ptr) {
ptr->block_and_flush();
DEBUGF("Reset release tid %d target %d ptr %p->nullptr", tid, i, ptr);
this->pool.releaseObject(ptr);
VAR(buffers.at(i).at(tid)) = nullptr;
}
}
}
// reset the pool. local vector should contain a bunch of nullptrs. - if we have multiple message buffers, resetting pool is a BAD thing.
// this->pool.reset();
// populate the buffers from the pool
for (int i = 0; i < count; ++i) {
nthreads = buffers.at(i).size();
for (tid = 0; tid < nthreads; ++tid) {
DEBUGF("MessageBuffer Swapping %d %d", tid, i);
swapInEmptyBuffer(i, tid);
}
}
DEBUGF("Reset End");
}
/**
* @brief release a buffer, by pointer, back to the ObjectPool associated with this MessageBuffers class.
* @details: called by commlayer's send/recv thread, so single threaded there
* called by sendMessageBuffer's swapInEmptyBuffer
* if threadsafe version of sendMessageBuffer, then the pointer to buffer to be released will be unique.
* if not threadsafe version, then the sendMessageBuffer should be used by a single threaded program, so buffer to release should be unique.
*
* overall, do not need to worry about multiple threads releasing the same buffer.
*/
virtual void releaseBuffer(BufferPtrType ptr) {
if (ptr) {
ptr->block_and_flush(); // if already blocked and flushed, no op.
BaseType::releaseBuffer(ptr);
}
}
/**
* @brief Appends data to the target message buffer.
* @details internally will try to swap in a new buffer when full, and notify the caller of the full buffer's id.
* need to return 2 things:
* 1. success/failure of current insert
* 2. indicator that there is a full buffer (the full buffer's id).
*
* @note if failure, data to be inserted would need to be reinserted by the caller.
*
* @param[in] data data to be inserted, as byteArray
* @param[in] count number of bytes to be inserted in the the Buffer
* @param[in] targetProc messaging target for the data, decides which buffer to append into.
* @param[in] thread_id id of thread performing the append.
* @return std::pair containing the status of the append (boolean success/fail), and the id of a full buffer if there is one.
*/
template <typename T>
std::pair<bool, BufferType*> append(const T* data, const uint32_t el_count, T* &data_remain, uint32_t &count_remain, const int targetProc, int thread_id = -1) {
//== if data being set is null, throw error
if (data == nullptr || el_count <= 0) {
throw (std::invalid_argument("ERROR: calling MessageBuffer append with nullptr"));
}
//== if targetProc is outside the valid range, throw an error
if (targetProc < 0 || targetProc > nDests) {
throw (std::invalid_argument("ERROR: messageBuffer append with invalid targetProc"));
}
int tid = (thread_id < 0 ? omp_get_thread_num() : thread_id);
// NOTE: BufferPool is unlimited in size, so don't need to check for nullptr, can just append directly.
// since there is 1 buffer per threadid-processid pair, there is no data race. swap, if any, when append,
// is then sequential.
// in contrast, multithreaded version would require careful orchestration during buffer swap.
unsigned int appendResult = 0x0;
BufferType* ptr = this->at(targetProc, tid);
if (ptr != nullptr) {
appendResult = ptr->append(data, el_count, data_remain, count_remain);
}
else {
ERRORF("ERROR: Append: threadlocal Buffer ptr is null and no way to swap in a different one.");
throw std::logic_error("ERROR: Append: threadlocal Buffer ptr is null and no way to swap in a different one.");
}
if (appendResult != 0x1) {
DEBUGF("T %d destRank %d APPEND RESULT is %u, buffer ptr %p, in vec %p, buffer ptr size %lu, is read only %s", tid, targetProc, appendResult, ptr, this->at(targetProc, tid), ptr->getSize(), (ptr->is_read_only() ? "y" : "n") );
}
// now if appendResult is false, then we return false, but also swap in a new buffer.
// conditions are either full buffer, or blocked buffer.
// this call will mark the fullBuffer as blocked to prevent multiple write attempts while flushing the buffer
// ideally, we want it to be a reference that gets updated for all threads.
if ((appendResult & 0x2) > 0) { // only 1 thread gets 0x2 result for a buffer. all other threads either writes successfully or fails.
DEBUGF("Swap Start");
BufferType* oldptr = swapInEmptyBuffer(targetProc, tid);
DEBUGF("Swap End");
DEBUGF("T %d destRank %d FULL and swap. appendResult is %u, oldptr is %p, newptr %p", tid, targetProc, appendResult, oldptr, this->at(targetProc, tid));
return std::make_pair((appendResult & 0x1) > 0, oldptr );
} else {
return std::make_pair((appendResult & 0x1) > 0, nullptr);
}
}
/**
* @brief flushes the buffer at rank targetProc. all buffers for that rank will be sent.
*
* @note only 1 thread should call this per proc.
* multiple calls to this may be needed to get all data that are written to the new empty buffer.
*
* @param targetProc
* @return
*/
std::vector<BufferType*> flushBufferForRank(const int targetProc) {
DEBUGF("Flush Start");
//== if targetProc is outside the valid range, throw an error
if (targetProc < 0 || targetProc >= nDests) {
throw (std::invalid_argument("ERROR: messageBuffer append with invalid targetProc"));
}
BufferType* old;
std::vector<BufferType*> result;
int nthreads = buffers.at(targetProc).size();
for (int t = 0; t < nthreads; ++t) {
old = swapInEmptyBuffer(targetProc, t);
if (old) result.push_back(old); // && !(old->isEmpty())
}
DEBUGF("Flush End");
return result;
}
protected:
/**
* @brief Swap in an empty Buffer from BufferPool at the dest location in MessageBuffers. The old buffer is returned.
* @details The new buffer may be nullptr (invalid buffer, when there is no available Buffer from pool)
*
* @param dest position in bufferIdForProcId array to swap out
* @return the BufferId that was swapped out.
*/
BufferType* swapInEmptyBuffer(const int dest, int thread_id = -1) {
int tid = thread_id < 0 ? omp_get_thread_num() : thread_id;
BufferType* oldbuf = VAR(buffers.at(dest).at(tid));
if (oldbuf) oldbuf->block_and_flush();
BufferType* ptr = this->pool.tryAcquireObject();
int i = 1;
while (!ptr) {
_mm_pause();
ptr = this->pool.tryAcquireObject();
++i;
}
if (i > 200) WARNINGF("NOTICE: non-Concurrent Pool threadlocal Buffer ptr took %d iterations to acquire, %d threads.", i, omp_get_num_threads());
if (ptr) {
ptr->clear_and_unblock_writes();
}
VAR(buffers.at(dest).at(tid)) = ptr; // one thread accessing at a time.
if (oldbuf) {
if (oldbuf->isEmpty()) {
releaseBuffer(oldbuf);
oldbuf = nullptr;
DEBUGF("MessageBuffers Thread Id = %d, target %d, ptr = empty -> %p", tid, dest, ptr);
} else {
DEBUGF("MessageBuffers Thread Id = %d, target %d, ptr = %p -> %p", tid, dest, oldbuf, ptr);
}
} else {
DEBUGF("MessageBuffers Thread Id = %d, target %d, ptr = nullptr -> %p", tid, dest, ptr);
}
return oldbuf;
}
};
} /* namespace io */
} /* namespace bliss */
#endif /* MESSAGEBUFFERS_HPP_ */
| 46.571429 | 239 | 0.586268 | [
"object",
"vector",
"model"
] |
7749fff442a080b768a98c4eb430bd7229982376 | 3,792 | cpp | C++ | code/source/utils.cpp | vastopol/FP_Interpreter | 768e668f4112086f9d69d6df34a795625aae1ec3 | [
"MIT"
] | 4 | 2017-05-24T21:20:14.000Z | 2018-05-22T21:22:46.000Z | code/source/utils.cpp | vastopol/FP_Interpreter | 768e668f4112086f9d69d6df34a795625aae1ec3 | [
"MIT"
] | null | null | null | code/source/utils.cpp | vastopol/FP_Interpreter | 768e668f4112086f9d69d6df34a795625aae1ec3 | [
"MIT"
] | null | null | null | // utility functions used in different parts
#include "../header/func.h" // need the maps for the classifier
#include "../header/object.h" // need the maps for the classifier
#include "../header/memory.h" // need the maps for the classifier
#include <cstring> // strtok
#include <cstdlib> // atoi
//----------------------------------------------------------------------------------------------
std::string trimSpace(std::string s) // removes any (leading || trailing) whitespace characters
{
if(s.empty()){return s;}
while(s.at(0) == ' ' || s.at(0) == '\t') // remove any leading whitespace
{
if(s.size() == 1){return "";}
s = s.substr(1, (s.size()-1));
}
while(s.at(s.size()-1) == ' ' || s.at(s.size()-1) == '\t') // remove any trailing whitespace
{
if(s.size() == 1){return "";}
s = s.substr(0, (s.size()-1));
}
return s;
}
//----------------------------------------------------------------------------------------------
std::string trimSharp(std::string s) // remove comments
{
unsigned pos = s.find('#');
if( pos != std::string::npos && pos < s.size() )
{
s = s.substr(0, pos);
}
return s;
}
//----------------------------------------------------------------------------------------------
int func_classifier(std::string s) // what type of function
{
int ftype = -1;
if(U_E_R_E.find(s) != U_E_R_E.end()) // int -> int
ftype = 0;
if(U_E_R_S.find(s) != U_E_R_S.end()) // int -> list
ftype = 1;
if(U_S_R_E.find(s) != U_S_R_E.end()) // list -> int
ftype = 2;
if(U_S_R_S.find(s) != U_S_R_S.end()) // list -> list
ftype = 3;
return ftype;
}
//----------------------------------------------------------------------------------------------
Sequence* seq_par(std::string val, Memory* m) // based on interpreter code need to parse in concat operator in action
{
Sequence* ob = 0;
std::list<int> ilst;
// remove <>
val = val.substr(1, (val.size() - 1)); // gone <
val = val.substr(0, (val.size() - 1)); // gone >
val = trimSpace(val);
// add empty list HERE
if(val.empty())
{
ob = new Sequence(ilst);
return ob;
}
// remove bad junk before segfault
while( !isalnum(val.at(0)) && val.size() >= 1 )
{
if(val.size() == 1){val = ""; break;}
if(val.at(0) == '-') {break;} // a negative number
val = val.substr(1, (val.size() - 1));
}
// add empty list HERE
if(val.empty())
{
ob = new Sequence(ilst);
return ob;
}
// extract && store the elements of the sequence
char* copy = (char*)(val.c_str()); // copy to give strtok for parse
char* arr = strtok(copy, ","); // temp array
// get 1st element
Object* tmpobj = m->goGet(std::string(arr)); // have to see if list has vars: <1,2,x,3>
if(tmpobj != 0 && tmpobj->type() == "Element")
{
ilst.push_back( (static_cast<Element*>(tmpobj)->getElement() ) );
}
else
{
ilst.push_back( atoi( arr ) );
}
// get rest of the elements
for(unsigned i = 1; arr != 0; i++)
{
arr = strtok(NULL, ",");
if(arr)
{
tmpobj = m->goGet( std::string(arr) ); // have to see if list has vars: <1,2,x,3>
if(tmpobj != 0 && tmpobj->type() == "Element")
{
ilst.push_back( (static_cast<Element*>(tmpobj)->getElement() ) );
}
else
{
ilst.push_back( atoi( arr ) );
}
}
}
ob = new Sequence(ilst); // list with data HERE
return ob;
}
//----------------------------------------------------------------------------------------------
| 29.395349 | 117 | 0.448049 | [
"object"
] |
77509549822ef68ad9b0d4da4745c537297e468f | 1,036 | cpp | C++ | src/memory.cpp | ninjabear/dr-doom | 6e068981ed0eb4c2131b9b62940f519fc42869ae | [
"MIT"
] | 4 | 2017-02-16T22:12:00.000Z | 2018-01-12T20:10:48.000Z | src/memory.cpp | ninjabear/dr-doom | 6e068981ed0eb4c2131b9b62940f519fc42869ae | [
"MIT"
] | 1 | 2017-02-20T15:15:18.000Z | 2017-03-16T12:01:38.000Z | src/memory.cpp | ninjabear/dr-doom | 6e068981ed0eb4c2131b9b62940f519fc42869ae | [
"MIT"
] | null | null | null | #include "memory.h"
void mt_consume_memory() {
int max_cores = std::thread::hardware_concurrency();
std::thread threads[max_cores];
for (int i=0; i<max_cores; i++) {
threads[i] = std::thread(consume_memory);
}
for (int i=0; i<max_cores; i++) {
threads[i].join();
}
}
void consume_memory() {
std::thread::id thread_id = std::this_thread::get_id();
std::vector<void*> mem_ptrs;
for (;;) {
void* ptr = malloc(ALLOC_SIZE);
if (ptr == NULL) {
// reached peak?
break;
}
std::memset(ptr, 0, ALLOC_SIZE);
mem_ptrs.push_back(ptr);
}
std::cout << "thread(" << thread_id << "): allocated " << (((mem_ptrs.size() * ALLOC_SIZE) / 1024.0) / 1024.0) << " MiB total" << std::endl;
std::cout << "thread(" << thread_id << "): unwinding..." << std::endl;
for (auto & ptr : mem_ptrs) { // we'll probably never get here
free(ptr);
}
std::cout << "thread(" << thread_id << "): done." << std::endl;
} | 25.9 | 143 | 0.533784 | [
"vector"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.