pev_priorities.cpp
Go to the documentation of this file.
1/** @file pev_priorities.cpp Classes AttributePriority, EventPriorities*/
2
3
4/* FAU Discrete Event Systems Library (libfaudes)
5
6 Copyright (C) 2025 Yiheng Tang, Thomas Moor
7 Exclusive copyright is granted to Klaus Schmidt
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23
24
25#include "pev_priorities.h"
26
27namespace faudes {
28
29
30/*
31********************************
32Autoregister
33********************************
34*/
35
38
39
40/*
41********************************
42implementation AttributePriority
43********************************
44*/
45
46// faudes type std
48
49
50// Assign my members
51void AttributePriority::DoAssign(const AttributePriority& rSrcAttr) {
52 // call base (incl. virtual clear)
54 // my additional members
55 mPriority = rSrcAttr.mPriority;
56}
57
58
59// Test equality
61 FD_DC("AttributePriority::DoEqual() A");
62 // call base
63 if(!AttributeCFlags::DoEqual(rOther)) return false;
64 // my additional members
65 FD_DC("AttributePriority::DoEqual() B " << mPriority << " vs " << rOther.mPriority);
66 return mPriority == rOther.mPriority;
67}
68
69// Write XML only
70void AttributePriority::DoXWrite(TokenWriter& rTw,const std::string& rLabel, const Type* pContext) const{
71 (void) pContext;
72 if(IsDefault()) return;
73 FD_DC("AttributeCFlags(" << this << ")::DoXWrite(tw)");
74 // let base calls do their job
75 AttributeCFlags::DoXWrite(rTw,rLabel,pContext);
76 // add mine
77 Token token;
78 if(mPriority!=0) {
79 token.SetEmpty("Priority");
80 token.InsAttributeInteger("value",mPriority);
81 rTw.Write(token);
82 }
83}
84
85// Write (XML only)
86void AttributePriority::DoWrite(TokenWriter& rTw,const std::string& rLabel, const Type* pContext) const {
87 DoXWrite(rTw,rLabel,pContext);
88}
89
90//DoRead(rTr)
91void AttributePriority::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
92 // let base do their job
93 AttributeCFlags::DoRead(rTr,rLabel,pContext);
94 // read my XML
95 Token token;
96 while(true) {
97 rTr.Peek(token);
98 // explicit integer
99 if(token.IsBegin("Priority")) {
100 rTr.ReadBegin("Priority",token);
101 mPriority=0;
102 if(token.ExistsAttributeInteger("value"))
103 mPriority=token.AttributeIntegerValue("value");
104 rTr.ReadEnd("Priority");
105 continue;
106 }
107 // stop at unknown tag
108 break;
109 }
110}
111
112
113
114
115
116}// namespace
117//
#define FD_DC(message)
#define FAUDES_TYPE_IMPLEMENTATION(ftype, ctype, cbase)
Definition cfl_types.h:958
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
bool DoEqual(const AttributeCFlags &rOther) const
void DoAssign(const AttributeCFlags &rSrcAttr)
virtual void DoXWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=nullptr)
virtual void DoXWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=nullptr) const
bool DoEqual(const AttributePriority &rOther) const
virtual bool IsDefault(void) const
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=nullptr) const
void ReadEnd(const std::string &rLabel)
void ReadBegin(const std::string &rLabel)
bool Peek(Token &token)
void Write(Token &rToken)
Int AttributeIntegerValue(const std::string &name)
bool IsBegin(void) const
void SetEmpty(const std::string &rName)
bool ExistsAttributeInteger(const std::string &name)
void InsAttributeInteger(const std::string &name, Int value)
AutoRegisterType< EventPriorities > gRtiEventPriorities("EventPriorities")
AutoRegisterType< FairnessConstraints > gRtiFairnessConstraints("FairnessConstraints")

libFAUDES 2.33k --- 2025.09.16 --- c++ api documentaion by doxygen