Firewall-Masquerade avec interface http

crabs_firewall-3.0.1 ©2005-2011 - Christophe CAZAJUS (crabs-mettre_le_signe_at-crabs-world.com)

libgraph.a~~ / LIB / GRAPH / serie.cpp
Makefile graph.h serie.cpp timestamp.cpp graph.cpp graph_creer.cpp graph_util.cpp graph_titre_axe.cpp
    1 /*
    2 **=============================================================================
    3 ** crabs_firewall-3.0.1 : Firewall-Masquerade avec interface http
    4 ** Copyright (C) 2005-2011 : Christophe CAZAJUS (crabs-mettre_le_signe_at-crabs-world.com)
    5 **
    6 ** Ce source fait partie d'un projet logiciel libre. Vous pouvez le distribuer
    7 ** et/ou le modifier en respectant les termes de la GNU General Public License
    8 ** version 2 ou (suite a votre propre choix) une version ulterieure.
    9 **
   10 ** Ce programme est distribue dans l'espoir qu'il puisse etre utile, mais
   11 ** sans aucune garantie, meme si il est associe a un produit qui vous en
   12 ** propose une. Conformez-vous a la GNU General Public License pour avoir
   13 ** plus de precisions.
   14 **
   15 ** L'auteur ne peut etre tenu responsable de l'utilisation faite des
   16 ** composantes associees a ce projet (en partie ou dans leur totalite).
   17 **
   18 ** Une copie du fichier de la GNU GPL est fournie dans le repertoire DOC
   19 ** de ce projet sous le nom gnu_gpl.txt
   20 **
   21 **=============================================================================
   22 */
   23 #include "graph.h"
   24 #include <stdio.h>
   25 #include <string.h>
   26 
   27 CGserie::CGserie( int _nb )
   28     {
   29     nb = _nb ; v = 0 ; min_ = max_ = 0 ; no_value = 27e-27;
   30     no_v = true ; min_set = max_set = false ; strcpy( fmt, "%f" ) ; *nom=0 ;
   31     }
   32 CGserie::~CGserie() { if ( v ) delete v ; }
   33 
   34 void CGserie::textValeur( int ix, char* str, size_t sz )
   35     {
   36     if  ( ( !v ) || ( ix < 0 ) || ( ix >= nb ) )
   37         { snprintf( str, sz, "%s", "NaN" ) ; return ; }
   38     snprintf( str, sz, fmt, v[ix] ) ;
   39     }
   40 void CGserie::textValeur( double v_ , char* str, size_t sz )
   41     { snprintf( str, sz, fmt, v_ ) ; }
   42 void CGserie::setTextFormat( const char* _fmt ) { strcpy( fmt, _fmt ) ; }
   43 
   44 void CGserie::setMinMax( double _min, double _max )
   45     {
   46     min = _min; max = _max;
   47     min_set = max_set = true ;
   48     }
   49 void CGserie::setMin( double _min ) { min = _min; min_set = true; }
   50 void CGserie::setMax( double _max ) { max = _max; max_set = true; }
   51 void CGserie::unsetMinMax() { min_set = max_set = false ; }
   52 void CGserie::getMinMax( double& _min, double& _max )
   53     {
   54     _min=(min_set)?min:min_ ;
   55     _max=(max_set)?max:max_ ;
   56     }
   57 
   58 void CGserie::setMinMaxReel()
   59     {
   60     if ( min_set )
   61         {
   62         // recherche du nombre maximal inferieur à min
   63         double __max = min_ ; // on initialise avec le vrai min
   64         for( int ix=0; ix<nb; ix++ )
   65             if ( v[ix] < min ) if ( v[ix] > __max ) __max = v[ix] ;
   66         min = __max ;
   67         }
   68     if ( max_set )
   69         {
   70         // recherche du nombre minimal superieur a max
   71         double __min = max_ ; // on initialise avec le vrai max
   72         for( int ix=0; ix<nb; ix++ )
   73             if ( v[ix] > max ) if ( v[ix] < __min ) __min = v[ix] ;
   74         max = __min ;
   75         }
   76     }
   77 
   78 void CGserie::setValeur( int ix, double _v )
   79     {
   80     if ( ix < 0 ) return ; if ( ix >= nb ) return ;
   81     if ( no_v )
   82         {
   83         min_ = max_ = _v ; no_v = false ;
   84         if ( v ) delete v ; // Paranoiac !!!
   85         v = new double[nb] ;
   86         }
   87     if ( _v > max_ ) max_ = _v ;
   88     if ( _v < min_ ) min_ = _v ;
   89     v[ix] = _v ;
   90     }
   91 double CGserie::getValeur( int ix )
   92     {
   93     if ( !v ) return no_value ;
   94     if ( ix < 0 ) return no_value ; if ( ix >= nb ) return no_value ;
   95     return v[ix] ;
   96     }
   97 
   98 void CGserie::setNb( int _nb )
   99     {
  100     if ( v ) delete v ;
  101     nb = _nb ; v = 0 ; min_ = max_ = 0 ; no_v = true ;
  102     }
  103 int CGserie::getNb() { return nb ; }
  104 void CGserie::setNom(const char* _nom) { strcpy( nom, _nom ) ; }
  105 void CGserie::getNom(char* _nom) { strcpy( _nom, nom ) ; }
  106 void CGserie::setNaNValeur( double _v ) { no_value = _v ; }
  107 
  108 void CGserie::memeAxe( CGserie* premier, ... )
  109     {
  110     va_list     args    ;
  111     CGserie*    actual  ;
  112     double      min     ;
  113     double      max     ;
  114     double      min_a   ;
  115     double      max_a   ;
  116 
  117     premier->getMinMax( min, max ) ;
  118     va_start( args, premier ) ;
  119     while( actual = (CGserie*)va_arg( args, CGserie* ) )
  120         {
  121         actual->getMinMax( min_a, max_a ) ;
  122         if ( max_a > max ) max = max_a ;
  123         if ( min_a < min ) min = min_a ;
  124         }
  125     va_end( args ) ;
  126 
  127     premier->setMinMax( min, max ) ;
  128     va_start( args, premier ) ;
  129     while( actual = (CGserie*)va_arg( args, CGserie* ) )
  130         actual->setMinMax( min, max ) ;
  131     va_end( args ) ;
  132     }
  133 
  134 void CGserie::setMinMax( CGserie* plage )
  135     {
  136     double pmin, pmax ;  plage->getMinMax( pmin, pmax ) ;
  137     bool start=false ;
  138     for( int i=0; i<nb; i++ )
  139         {
  140         if ( plage->v[i] < pmin ) continue ;
  141         if ( plage->v[i] > pmax ) continue ;
  142         if ( !start )  { min=max=v[i] ; start=true; }
  143         if ( v[i] > max ) max = v[i] ;
  144         if ( v[i] < min ) min = v[i] ;
  145         }
  146     if (start) min_set=max_set=true ;
  147     }
  148 
Makefile graph.h serie.cpp timestamp.cpp graph.cpp graph_creer.cpp graph_util.cpp graph_titre_axe.cpp
libgraph.a~~ / LIB / GRAPH / serie.cpp

Haut de page

Contacter crabs

Date de génération : 22/09/2011 21:48