KiCad PCB EDA Suite
Loading...
Searching...
No Matches
rule_editor_data_base.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef RULE_EDITOR_DATA_BASE_H_
21#define RULE_EDITOR_DATA_BASE_H_
22
23#include <lset.h>
24#include <lseq.h>
25
30{
31public:
32 virtual ~ICopyable() = default;
33
34 virtual void CopyFrom( const ICopyable& source ) = 0;
35};
36
41{
42public:
44
45 explicit RULE_EDITOR_DATA_BASE( int aId, wxString aRuleName ) :
46 m_id( aId ),
47 m_ruleName( aRuleName ),
48 m_isNew( false )
49 {
50 }
51
52 virtual ~RULE_EDITOR_DATA_BASE() = default;
53
59 int GetId() { return m_id; }
60
66 void SetId( int aId ) { m_id = aId; }
67
73 wxString GetRuleName() const { return m_ruleName; }
74
80 void SetRuleName( wxString aRuleName ) { m_ruleName = aRuleName; }
81
87 wxString GetComment() { return m_comment; }
88
94 void SetComment( wxString aComment ) { m_comment = aComment; }
95
101 bool IsNew() { return m_isNew; }
102
108 void SetIsNew( bool aIsNew ) { m_isNew = aIsNew; }
109
115 void CopyFrom( const ICopyable& aSource ) override
116 {
117 const auto& baseSource = dynamic_cast<const RULE_EDITOR_DATA_BASE&>( aSource );
118
119 m_comment = baseSource.m_comment;
120 }
121
122private:
123 int m_id = 0; // Unique ID of the rule.
124 wxString m_ruleName;
125 wxString m_comment;
126 bool m_isNew = false;
128};
129
130#endif // RULE_EDITOR_DATA_BASE_H_
Abstract interface class to enable polymorphic copying between objects.
virtual void CopyFrom(const ICopyable &source)=0
virtual ~ICopyable()=default
virtual ~RULE_EDITOR_DATA_BASE()=default
RULE_EDITOR_DATA_BASE()=default
bool m_isNew
Flag indicating if the user is creating a new rule (true) or editing an existing rule (false).
bool IsNew()
Check if the rule is marked as new.
int GetId()
Get the unique ID of the rule.
void SetIsNew(bool aIsNew)
Mark the rule as new or not.
RULE_EDITOR_DATA_BASE(int aId, wxString aRuleName)
void SetId(int aId)
Set the unique ID of the rule.
void CopyFrom(const ICopyable &aSource) override
Implementation of the polymorphic CopyFrom method.
wxString GetComment()
Get the comment associated with the rule.
void SetRuleName(wxString aRuleName)
Set the name of the rule.
void SetComment(wxString aComment)
Set the comment for the rule.
wxString GetRuleName() const
Get the name of the rule.
std::string source