My Project
0.0.16
QUCS Mapping
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
DownLoad
QUCS-src
qucs-0.0.16
qucs-core
src
nodeset.cpp
Go to the documentation of this file.
1
/*
2
* nodeset.cpp - node set class implementation
3
*
4
* Copyright (C) 2004, 2008 Stefan Jahn <stefan@lkcc.org>
5
*
6
* This is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
9
* any later version.
10
*
11
* This software 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 package; see the file COPYING. If not, write to
18
* the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19
* Boston, MA 02110-1301, USA.
20
*
21
* $Id: nodeset.cpp 1825 2011-03-11 20:42:14Z ela $
22
*
23
*/
24
25
#if HAVE_CONFIG_H
26
# include <config.h>
27
#endif
28
29
#include <stdio.h>
30
#include <stdlib.h>
31
#include <string.h>
32
33
#include "
object.h
"
34
#include "
netdefs.h
"
35
#include "
nodeset.h
"
36
37
// Constructor creates an unnamed instance of the node set class.
38
nodeset::nodeset
() {
39
name
= NULL;
40
value = 0.0;
41
next
= NULL;
42
}
43
44
// Constructor creates a named instance of the node set class.
45
nodeset::nodeset
(
char
*
n
) {
46
name
= n ? strdup (n) : NULL;
47
value = 0.0;
48
next
= NULL;
49
}
50
51
/* This full qualified constructor creates an instance of the node set
52
class containing both the key and the value of the node set. */
53
nodeset::nodeset
(
char
*
n
, nr_double_t val) {
54
name
= n ? strdup (n) : NULL;
55
value = val;
56
next
= NULL;
57
}
58
59
/* The copy constructor creates a new instance of the node set class
60
based on the given node set object. */
61
nodeset::nodeset
(
const
nodeset
& p) {
62
name
= NULL;
63
if
(p.name)
name
= strdup (p.name);
64
value = p.value;
65
next
= p.next;
66
}
67
68
// Destructor deletes the node set object.
69
nodeset::~nodeset
() {
70
if
(
name
) free (
name
);
71
}
72
73
// Sets the name of the node set.
74
void
nodeset::setName
(
char
*
n
) {
75
if
(
name
) free (
name
);
76
name
= n ? strdup (n) : NULL;
77
}
78
79
// Returns the name of the node set.
80
char
*
nodeset::getName
(
void
) {
81
return
name
;
82
}
83
84
/* Goes through the chained list of the node sets and looks for a node
85
set matching the given key and returns its value if possible. If
86
there is no such node set the function returns NULL. */
87
nodeset
*
nodeset::findNodeset
(
char
*
n
) {
88
for
(
nodeset
* p =
this
; p != NULL; p = p->
getNext
()) {
89
if
(!strcmp (p->getName (),
n
))
return
p;
90
}
91
return
NULL;
92
}
93
94
// properties
95
PROP_REQ
[] = {
96
{
"U"
,
PROP_REAL
, { 0,
PROP_NO_STR
},
PROP_NO_RANGE
},
PROP_NO_PROP
};
97
PROP_OPT
[] = {
98
PROP_NO_PROP
};
99
struct
define_t
nodeset
::miscdef =
100
{
"NodeSet"
, 1,
PROP_COMPONENT
,
PROP_NO_SUBSTRATE
,
PROP_LINEAR
,
PROP_DEF
};
Generated on Tue Dec 25 2012 14:30:34 for My Project by
1.8.2