15 #include "transaction_impl.h"
23 XNode::Payload::setUIEnabled(
bool var) {
24 if(isDisabled())
return;
25 m_flags = (m_flags & ~NODE_UI_ENABLED) | (var ? NODE_UI_ENABLED : 0);
29 XNode::Payload::disable() {
30 m_flags = (m_flags & ~(NODE_DISABLED | NODE_UI_ENABLED)) | NODE_DISABLED;
31 tr().mark(onUIFlagsChanged(), &node());
34 XNode::XNode(
const char *name,
bool runtime)
35 : Transactional::
Node<
XNode>(), m_name(name ? name :
"") {
37 XNode::stl_thisCreating->push_back(shared_ptr<XNode>(
this));
38 assert(shared_from_this());
40 trans( *this).setRuntime(runtime);
42 dbgPrint(QString(
"xnode %1 is created., addr=0x%2, size=0x%3")
44 .arg((uintptr_t)
this, 0, 16)
45 .arg((uintptr_t)
sizeof(
XNode), 0, 16));
48 dbgPrint(QString(
"xnode %1 is being deleted., addr=0x%2").arg(
getLabel()).arg((uintptr_t)
this, 0, 16));
55 XNode::getTypename()
const {
56 XString name =
typeid( *this).name();
57 int i = name.find(
'X');
58 assert(i != std::string::npos);
59 assert(i + 1 < name.length());
60 return name.substr(i + 1);
65 trans(*this).disable();
69 trans( *this).setUIEnabled(v);
73 XNode::getChild(
const XString &var)
const {
75 shared_ptr<XNode> node;
76 shared_ptr<const NodeList> list(shot.list());
78 for(
auto it = list->begin(); it != list->end(); it++) {
79 if(dynamic_pointer_cast<XNode>( *it)->getName() == var) {
80 node = dynamic_pointer_cast<
XNode>( *it);
89 XTouchableNode::Payload::touch() {
90 tr().mark(
onTouch(), static_cast<XTouchableNode *>(&
node()));
93 template <
typename T,
int base>
101 int var = QString(str).toInt(&ok, 10);
103 throw XKameError(i18n(
"Ill string conversion to integer."), __FILE__, __LINE__);
110 unsigned int var = QString(str).toUInt(&ok);
112 throw XKameError(i18n(
"Ill string conversion to unsigned integer."), __FILE__, __LINE__);
119 long var = QString(str).toLong(&ok, 10);
121 throw XKameError(i18n(
"Ill string conversion to integer."), __FILE__, __LINE__);
128 unsigned long var = QString(str).toULong(&ok);
130 throw XKameError(i18n(
"Ill string conversion to unsigned integer."), __FILE__, __LINE__);
137 unsigned int var = QString(str).toULong(&ok, 16);
139 throw XKameError(i18n(
"Ill string conversion to hex."), __FILE__, __LINE__);
146 bool x = QString(str).toInt(&ok);
148 *
this = x ?
true : false ;
151 if(QString(str).trimmed().toLower() ==
"true") {
152 *
this =
true;
return;
154 if(QString(str).trimmed().toLower() ==
"false") {
155 *
this =
false;
return;
157 throw XKameError(i18n(
"Ill string conversion to boolean."), __FILE__, __LINE__);
160 template <
typename T,
int base>
163 return QString::number(m_var, base);
168 return m_var ?
"true" :
"false";
178 XStringNode::XStringNode(
const char *name,
bool runtime)
181 XDoubleNode::XDoubleNode(
const char *name,
bool runtime,
const char *format)
189 static_cast<const XDoubleNode&>(node()).format(), m_var);
194 double var = QString(str).toDouble(&ok);
196 throw XKameError(i18n(
"Ill string conversion to double float."), __FILE__, __LINE__);
201 XDoubleNode::setFormat(
const char* format) {
206 formatDoubleValidator(fmt);
207 m_format.reset(
new XString(fmt));