Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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$
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 namespace qucs {
38 
39 // Constructor creates an unnamed instance of the node set class.
41  name = NULL;
42  value = 0.0;
43  next = NULL;
44 }
45 
46 // Constructor creates a named instance of the node set class.
47 nodeset::nodeset (char * n) {
48  name = n ? strdup (n) : NULL;
49  value = 0.0;
50  next = NULL;
51 }
52 
53 /* This full qualified constructor creates an instance of the node set
54  class containing both the key and the value of the node set. */
55 nodeset::nodeset (char * n, nr_double_t val) {
56  name = n ? strdup (n) : NULL;
57  value = val;
58  next = NULL;
59 }
60 
61 /* The copy constructor creates a new instance of the node set class
62  based on the given node set object. */
64  name = NULL;
65  if (p.name) name = strdup (p.name);
66  value = p.value;
67  next = p.next;
68 }
69 
70 // Destructor deletes the node set object.
72  if (name) free (name);
73 }
74 
75 // Sets the name of the node set.
76 void nodeset::setName (char * n) {
77  if (name) free (name);
78  name = n ? strdup (n) : NULL;
79 }
80 
81 // Returns the name of the node set.
82 char * nodeset::getName (void) {
83  return name;
84 }
85 
86 /* Goes through the chained list of the node sets and looks for a node
87  set matching the given key and returns its value if possible. If
88  there is no such node set the function returns NULL. */
90  for (nodeset * p = this; p != NULL; p = p->getNext ()) {
91  if (!strcmp (p->getName (), n)) return p;
92  }
93  return NULL;
94 }
95 
96 // properties
97 PROP_REQ [] = {
98  { "U", PROP_REAL, { 0, PROP_NO_STR }, PROP_NO_RANGE }, PROP_NO_PROP };
99 PROP_OPT [] = {
100  PROP_NO_PROP };
101 struct define_t nodeset::miscdef =
103 
104 } // namespace qucs
nodeset * findNodeset(char *)
Definition: nodeset.cpp:89
void setName(char *)
Definition: nodeset.cpp:76
#define PROP_DEF
Definition: netdefs.h:189
PROP_OPT[]
Definition: acsolver.cpp:232
#define PROP_REAL
Definition: netdefs.h:174
char * name
Definition: nodeset.h:47
#define PROP_NO_PROP
Definition: netdefs.h:122
#define PROP_NO_RANGE
Definition: netdefs.h:126
#define PROP_NO_STR
Definition: netdefs.h:125
n
Definition: parse_citi.y:147
#define PROP_LINEAR
Definition: netdefs.h:120
char * getName(void)
Definition: nodeset.cpp:82
#define PROP_COMPONENT
Definition: netdefs.h:116
nodeset * next
Definition: nodeset.h:49
free($1)
nodeset * getNext(void)
Definition: nodeset.h:38
nr_double_t value
Definition: nodeset.h:48
nodeset(char *)
Definition: nodeset.cpp:47
virtual ~nodeset()
Definition: nodeset.cpp:71
PROP_REQ[]
Definition: acsolver.cpp:229