Common.cpp

Go to the documentation of this file.
00001 /** @file Common.cpp
00002 * @author Gabor Madl
00003 * @date Created 08/2005
00004 * @brief Common declarations used in DREAM.
00005 *
00006 *
00007 * =================================================================
00008 * DREAM License v2.0
00009 * 
00010 * DREAM - Distributed Real-time Embedded Analysis Method
00011 * http://dre.sourceforge.net.
00012 * Copyright (c) 2005-2007 Gabor Madl, All Rights Reserved.
00013 * 
00014 * This file is part of DREAM.
00015 * 
00016 * DREAM is free software; you can redistribute it and/or modify it
00017 * under the terms of the GNU General Public License version 2 as
00018 * published by the Free Software Foundation. No future versions of
00019 * the GPL license may be automatically applied to DREAM. It is in
00020 * the sole discretion of the copyright holder to determine whether
00021 * DREAM may be released under a different license or terms. There
00022 * are no restrictions on the use of DREAM for any purpose.
00023 * 
00024 * DREAM is distributed in the hope that it will be useful,
00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00027 * GNU General Public License for more details.
00028 * 
00029 * You should have received a copy of the GNU General Public License
00030 * along with this program; if not, write to the Free Software
00031 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00032 * MA 02110-1301, USA.
00033 * 
00034 * By submitting comments, suggestions, code, code snippets,
00035 * techniques (including that of usage), and algorithms, submitters
00036 * acknowledge that they have the right to do so, that any such
00037 * submissions are given freely and unreservedly, and that they
00038 * waive any claims to copyright or ownership. In addition,
00039 * submitters acknowledge that any such submission might become
00040 * part of the copyright maintained on the overall body of code,
00041 * which comprises DREAM. By making a submission, submitter agrees
00042 * to these terms. Furthermore, submitters acknowledge that the
00043 * incorporation or modification of such submissions is entirely
00044 * at the discretion of the moderators of the DREAM project.
00045 * 
00046 * DREAM links to the Libxml2 third party library. Please see 
00047 * COPYING-libxml for the copyright information of Libxml2.
00048 * =================================================================
00049 */
00050 
00051 #include "Common.h"
00052 #include "Exception.h"
00053 
00054 DREAM::uint Option::number_of_repetitions_ = 0;
00055 DREAM::uint Option::optimization_space_ = 0;
00056 DREAM::uint Option::simulation_time_ = 0;
00057 bool Option::branching_ = true;
00058 bool Option::race_condition_ = true;
00059 bool Option::race_condition_combination_ = true;
00060 bool Option::race_condition_zero_ = false;
00061 bool Option::verbose1_ = false;
00062 #ifdef DREAM_VERBOSE2
00063 bool Option::verbose2_ = true;
00064 #endif
00065 bool Option::non_executing_tasks_ = false;
00066 
00067 namespace DREAM
00068 {
00069 
00070 double random (uint size)
00071 {
00072         if (size == 0)
00073                 return 0;
00074 
00075         double x = ((double)rand () / ((double) (RAND_MAX)+ (double) (1)));
00076         return (x * size);
00077 }
00078 
00079 std::string& operator<< (std::string& out, const std::string& parameter)
00080 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00081         throw (std::bad_exception)
00082 #endif
00083 {
00084         out += parameter;
00085         return out;
00086 }
00087 
00088 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00089 std::string& operator<< (std::string& out, const char* parameter)
00090         throw (std::bad_exception)
00091 #else
00092 std::string& operator<< (std::string& out, const char* parameter)
00093 #endif
00094 // link issue: inline std::string& operator<< (std::string& out, const char* parameter)
00095 {
00096         out += parameter;
00097         return out;
00098 }
00099 
00100 std::string& operator<< (std::string& out, uint parameter)
00101 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00102         throw (std::bad_exception)
00103 #endif
00104 {
00105         // Review size of char[]
00106         char number[char_size];
00107         snprintf (number, char_size, "%d", parameter);
00108         out += number;
00109         return out;
00110 }
00111 
00112 std::string& operator<< (std::string& out, double parameter)
00113 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00114         throw (std::bad_exception)
00115 #endif
00116 {
00117         // Review size of double[]
00118         char number[double_size];
00119         snprintf (number, double_size, "%.2f", parameter);
00120         out += number;
00121         return out;
00122 }
00123 
00124 };

Generated on Fri Jul 27 18:30:03 2007 for DREAM by  doxygen 1.5.1