File indexing completed on 2024-05-12 05:39:28
0001 /*************************************************************************** 0002 * Copyright (C) 2014 by Renaud Guezennec * 0003 * https://rolisteam.org/contact * 0004 * * 0005 * This file is part of DiceParser * 0006 * * 0007 * DiceParser is free software; you can redistribute it and/or modify * 0008 * it under the terms of the GNU General Public License as published by * 0009 * the Free Software Foundation; either version 2 of the License, or * 0010 * (at your option) any later version. * 0011 * * 0012 * This program is distributed in the hope that it will be useful, * 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0015 * GNU General Public License for more details. * 0016 * * 0017 * You should have received a copy of the GNU General Public License * 0018 * along with this program; if not, write to the * 0019 * Free Software Foundation, Inc., * 0020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0021 ***************************************************************************/ 0022 #include "numbernode.h" 0023 0024 NumberNode::NumberNode() : m_scalarResult(new ScalarResult()) 0025 { 0026 m_result= m_scalarResult; 0027 } 0028 NumberNode::~NumberNode() 0029 { 0030 /*if( nullptr != m_scalarResult) 0031 { 0032 delete m_scalarResult; 0033 m_scalarResult = nullptr; 0034 }*/ 0035 } 0036 0037 void NumberNode::run(ExecutionNode* previous) 0038 { 0039 m_previousNode= previous; 0040 if(nullptr != previous) 0041 { 0042 m_result->setPrevious(previous->getResult()); 0043 } 0044 if(nullptr != m_nextNode) 0045 { 0046 m_nextNode->run(this); 0047 } 0048 } 0049 0050 void NumberNode::setNumber(qint64 a) 0051 { 0052 m_scalarResult->setValue(a); 0053 m_number= a; 0054 } 0055 QString NumberNode::toString(bool withLabel) const 0056 { 0057 if(withLabel) 0058 { 0059 return QString("%1 [label=\"NumberNode %2\"]").arg(m_id).arg(m_number); 0060 } 0061 else 0062 { 0063 return m_id; 0064 } 0065 } 0066 qint64 NumberNode::getPriority() const 0067 { 0068 qint64 priority= 0; 0069 if(nullptr != m_nextNode) 0070 { 0071 priority= m_nextNode->getPriority(); 0072 } 0073 return priority; 0074 } 0075 ExecutionNode* NumberNode::getCopy() const 0076 { 0077 NumberNode* node= new NumberNode(); 0078 node->setNumber(m_number); 0079 if(nullptr != m_nextNode) 0080 { 0081 node->setNextNode(m_nextNode->getCopy()); 0082 } 0083 return node; 0084 }