LCOV - code coverage report
Current view: top level - src - nasolution.cpp (source / functions) Hit Total Coverage
Test: qucs-core-0.0.19 Code Coverage Lines: 27 35 77.1 %
Date: 2015-01-05 16:01:02 Functions: 10 15 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 30 53.3 %

           Branch data     Line data    Source code
       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$
      22                 :            :  *
      23                 :            :  */
      24                 :            : 
      25                 :            : #include <assert.h>
      26                 :            : #include <stdio.h>
      27                 :            : #include <stdlib.h>
      28                 :            : #include <string.h>
      29                 :            : 
      30                 :            : #include "nasolution.h"
      31                 :            : 
      32                 :            : namespace qucs {
      33                 :            : 
      34                 :            : // Constructor creates an instance of the nasolution class.
      35                 :            : template <class nr_type_t>
      36                 :        103 : nasolution<nr_type_t>::nasolution () {
      37                 :        103 : }
      38                 :            : 
      39                 :            : /* This copy constructor creates a instance of the nasolution class based
      40                 :            :    on the given nasolution. */
      41                 :            : template <class nr_type_t>
      42                 :          0 : nasolution<nr_type_t>::nasolution (const nasolution<nr_type_t> & p) {
      43 [ #  # ][ #  # ]:          0 :   entries = valuelist< naentry<nr_type_t> > (p.entries);
      44                 :          0 : }
      45                 :            : 
      46                 :            : // Destructor deletes a nasolution object.
      47                 :            : template <class nr_type_t>
      48                 :        103 : nasolution<nr_type_t>::~nasolution () {
      49         [ +  - ]:        103 :   clear ();
      50                 :        103 : }
      51                 :            : 
      52                 :            : // Resets the nasolution object.
      53                 :            : template <class nr_type_t>
      54                 :        167 : void nasolution<nr_type_t>::clear (void) {
      55                 :        167 :   entries.clear ();
      56                 :        167 : }
      57                 :            : 
      58                 :            : // Adds a new solution entry into the nasolution list.
      59                 :            : template <class nr_type_t>
      60                 :        706 : void nasolution<nr_type_t>::add (char * n, nr_type_t value, int current) {
      61         [ +  - ]:        706 :   naentry<nr_type_t> * entry = new naentry<nr_type_t> (n, value, current);
      62                 :        706 :   entries.add (n, entry);
      63                 :        706 : }
      64                 :            : 
      65                 :            : // Finds the given nasolution entry in the list.
      66                 :            : template <class nr_type_t>
      67                 :        711 : naentry<nr_type_t> * nasolution<nr_type_t>::find (char * n, int current) {
      68 [ +  - ][ +  - ]:       7175 :   for (valuelistiterator< naentry<nr_type_t> > it (entries); *it; ++it) {
                 [ +  + ]
      69                 :       7161 :     naentry<nr_type_t> * na = it.currentVal ();
      70         [ +  + ]:       7161 :     if (na->current == current) {
      71 [ +  - ][ +  - ]:       3891 :       if (na->n && n && !strcmp (na->n, n))
                 [ +  + ]
      72         [ +  + ]:        711 :         return na;
      73                 :            :     }
      74                 :            :   }
      75                 :        711 :   return NULL;
      76                 :            : }
      77                 :            : 
      78                 :            : // Constructor creates an instance of the naentry class.
      79                 :            : template <class nr_type_t>
      80                 :            : naentry<nr_type_t>::naentry () {
      81                 :            :   value = 0;
      82                 :            :   n = NULL;
      83                 :            :   current = -1;
      84                 :            : }
      85                 :            : 
      86                 :            : // Constructor creates an instance of the naentry class.
      87                 :            : template <class nr_type_t>
      88                 :        706 : naentry<nr_type_t>::naentry (char * na, nr_type_t val, int cur) {
      89                 :        706 :   value = val;
      90         [ +  - ]:        706 :   n = na ? strdup (na) : NULL;
      91                 :        706 :   current = cur;
      92                 :        706 : }
      93                 :            : 
      94                 :            : /* This copy constructor creates a instance of the naentry class based
      95                 :            :    on the given naentry. */
      96                 :            : template <class nr_type_t>
      97                 :          0 : naentry<nr_type_t>::naentry (const naentry<nr_type_t> & o) {
      98                 :          0 :   value = o.value;
      99         [ #  # ]:          0 :   n = o.n ? strdup (o.n) : NULL;
     100                 :          0 :   current = o.current;
     101                 :          0 : }
     102                 :            : 
     103                 :            : // Destructor deletes a naentry object.
     104                 :            : template <class nr_type_t>
     105                 :        706 : naentry<nr_type_t>::~naentry () {
     106         [ +  - ]:        706 :   if (n) free (n);
     107                 :        706 : }
     108                 :            : 
     109                 :            : } // namespace qucs

Generated by: LCOV version 1.11