Qucs-core  0.0.19
property.h
Go to the documentation of this file.
00001 /*
00002  * property.h - generic property class definitions
00003  *
00004  * Copyright (C) 2003, 2004, 2006, 2008 Stefan Jahn <stefan@lkcc.org>
00005  *
00006  * This is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2, or (at your option)
00009  * any later version.
00010  *
00011  * This software is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this package; see the file COPYING.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  * $Id$
00022  *
00023  */
00024 
00025 #ifndef __PROPERTY_H__
00026 #define __PROPERTY_H__
00027 
00028 #include <string>
00029 #include <unordered_map>
00030 #include <utility>
00031 
00032 namespace qucs {
00033 
00034 class variable;
00035 class vector;
00036 
00037 enum property_type {
00038   PROPERTY_UNKNOWN = -1,
00039   PROPERTY_INT,
00040   PROPERTY_DOUBLE,
00041   PROPERTY_STR,
00042   PROPERTY_VAR
00043 };
00044 
00045 class property
00046 {
00047  public:
00048   property ();
00049   virtual ~property ();
00050 
00051   qucs::vector * getVector (void) const;
00052   nr_double_t getDouble (void) const;
00053   int getInteger (void) const;
00054   const char * getString (void) const;
00055   const char * getReference (void) const;
00056   void set (const nr_double_t);
00057   void set (int);
00058   void set (const std::string &);
00059   void set (variable *);
00060   std::string toString (void) const;
00061   bool isDefault (void) const { return def; }
00062   void setDefault (bool d) { def = d; }
00063 
00064  private:
00065   bool def;
00066   int type;
00067   std::string str;
00068   nr_double_t value;
00069   variable * var;
00070 };
00071 
00072 typedef std::unordered_map<std::string, property> properties;
00073  
00074 } // namespace qucs
00075 
00076 #endif /* __PROPERTY_H__ */