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
nasolution.cpp
Go to the documentation of this file.
1
/*
2
* nasolution.cpp - nodal analysis solution template class implementation
3
*
4
* Copyright (C) 2006 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: nasolution.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 <assert.h>
30
#include <stdio.h>
31
#include <stdlib.h>
32
#include <string.h>
33
34
#include "
nasolution.h
"
35
36
// Constructor creates an instance of the nasolution class.
37
template
<
class
nr_type_t>
38
nasolution<nr_type_t>::nasolution
() {
39
}
40
41
/* This copy constructor creates a instance of the nasolution class based
42
on the given nasolution. */
43
template
<
class
nr_type_t>
44
nasolution<nr_type_t>::nasolution
(
const
nasolution<nr_type_t>
& p) {
45
entries =
valuelist< naentry<nr_type_t>
> (p.entries);
46
}
47
48
// Destructor deletes a nasolution object.
49
template
<
class
nr_type_t>
50
nasolution<nr_type_t>::~nasolution
() {
51
clear ();
52
}
53
54
// Resets the nasolution object.
55
template
<
class
nr_type_t>
56
void
nasolution<nr_type_t>::clear
(
void
) {
57
entries.clear ();
58
}
59
60
// Adds a new solution entry into the nasolution list.
61
template
<
class
nr_type_t>
62
void
nasolution<nr_type_t>::add
(
char
*
n
, nr_type_t value,
int
current) {
63
naentry<nr_type_t>
* entry =
new
naentry<nr_type_t>
(
n
, value, current);
64
entries.add (n, entry);
65
}
66
67
// Finds the given nasolution entry in the list.
68
template
<
class
nr_type_t>
69
naentry<nr_type_t>
*
nasolution<nr_type_t>::find
(
char
*
n
,
int
current) {
70
for
(
valuelistiterator
<
naentry<nr_type_t>
> it (entries); *it; ++it) {
71
naentry<nr_type_t>
* na = it.currentVal ();
72
if
(na->
current
== current) {
73
if
(na->
n
&& n && !strcmp (na->
n
, n))
74
return
na;
75
}
76
}
77
return
NULL;
78
}
79
80
// Constructor creates an instance of the naentry class.
81
template
<
class
nr_type_t>
82
naentry<nr_type_t>::naentry
() {
83
value = 0;
84
n
= NULL;
85
current = -1;
86
}
87
88
// Constructor creates an instance of the naentry class.
89
template
<
class
nr_type_t>
90
naentry<nr_type_t>::naentry
(
char
* na, nr_type_t val,
int
cur) {
91
value = val;
92
n
= na ? strdup (na) : NULL;
93
current = cur;
94
}
95
96
/* This copy constructor creates a instance of the naentry class based
97
on the given naentry. */
98
template
<
class
nr_type_t>
99
naentry<nr_type_t>::naentry
(
const
naentry<nr_type_t>
& o) {
100
value = o.
value
;
101
n
= o.
n
? strdup (o.
n
) : NULL;
102
current = o.
current
;
103
}
104
105
// Destructor deletes a naentry object.
106
template
<
class
nr_type_t>
107
naentry<nr_type_t>::~naentry
() {
108
if
(
n
) free (
n
);
109
}
Generated on Tue Dec 25 2012 14:30:34 for My Project by
1.8.2