File indexing completed on 2024-05-12 05:39:29
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 "result.h" 0023 #include <QUuid> 0024 0025 Result::Result() 0026 : m_resultTypes(static_cast<int>(Dice::RESULT_TYPE::NONE)) 0027 , m_id(QString("\"%1\"").arg(QUuid::createUuid().toString())) 0028 , m_previous(nullptr) 0029 { 0030 } 0031 Result::~Result() {} 0032 0033 Result* Result::getPrevious() const 0034 { 0035 return m_previous; 0036 } 0037 0038 void Result::setPrevious(Result* p) 0039 { 0040 Q_ASSERT(p != this); 0041 m_previous= p; 0042 } 0043 0044 bool Result::isStringResult() const 0045 { 0046 return false; 0047 } 0048 void Result::clear() {} 0049 bool Result::hasResultOfType(Dice::RESULT_TYPE type) const 0050 { 0051 return (m_resultTypes & static_cast<int>(type)); 0052 } 0053 void Result::generateDotTree(QString& s) 0054 { 0055 auto str= toString(true); 0056 if(s.contains(str)) 0057 return; 0058 s.append(str); 0059 s.append(";\n"); 0060 0061 if(nullptr != m_previous) 0062 { 0063 s.append(toString(false)); 0064 s.append(" -> "); 0065 s.append(m_previous->toString(false)); 0066 s.append("[label=\"previousResult\"]\n"); 0067 m_previous->generateDotTree(s); 0068 } 0069 else 0070 { 0071 s.append(toString(false)); 0072 s.append(" -> "); 0073 s.append("nullptr"); 0074 s.append(" [label=\"previousResult\", shape=\"box\"];\n"); 0075 } 0076 } 0077 0078 QString Result::getId() const 0079 { 0080 return m_id; 0081 } 0082 0083 QString Result::getStringResult() const 0084 { 0085 return {}; 0086 }