00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "any.h"
00023 #include "agent.h"
00024
00025 #include <cassert>
00026 #include <iostream>
00027
00028
00029
00030 Any::Any(int value)
00031 : m_type(ANY_INT), m_int_value(value)
00032 {}
00033
00034
00035
00036 Any::Any(unsigned int value)
00037 : m_type(ANY_UINT), m_uint_value(value)
00038 {}
00039
00040
00041
00042 Any::Any(double value)
00043 : m_type(ANY_DOUBLE), m_double_value(value)
00044 {}
00045
00046
00047
00048 Any::Any(const std::string& value):
00049 m_type(ANY_STRING),
00050 m_string_value(value)
00051 {}
00052
00053
00054
00055 Any_t
00056 Any::getType() const
00057 {
00058 return m_type;
00059 }
00060
00061
00062
00063 int
00064 Any::getInt() const {
00065 assert (m_type == ANY_INT);
00066 return m_int_value;
00067 }
00068
00069
00070
00071 unsigned int
00072 Any::getUInt() const {
00073 assert (m_type == ANY_UINT);
00074 return m_uint_value;
00075 }
00076
00077
00078
00079 double
00080 Any::getDouble() const
00081 {
00082 assert (m_type == ANY_DOUBLE);
00083 return m_double_value;
00084 }
00085
00086
00087
00088 const std::string&
00089 Any::getString() const
00090 {
00091 assert (m_type == ANY_STRING);
00092 return m_string_value;
00093 }
00094
00095
00096
00097 std::ostream&
00098 operator<< (std::ostream &os, const Any &any)
00099 {
00100 switch (any.getType())
00101 {
00102 case ANY_INT:
00103 MAS_DEBUG( "(int)" );
00104 os << any.getInt();
00105 break;
00106 case ANY_UINT:
00107 MAS_DEBUG( "(uint)" );
00108 os << any.getUInt();
00109 break;
00110 case ANY_DOUBLE:
00111 MAS_DEBUG( "(double)" );
00112 os << any.getDouble();
00113 break;
00114 case ANY_STRING:
00115 MAS_DEBUG( "(str)" );
00116 os << '"' << any.getString() << '"';
00117 break;
00118 }
00119 return os;
00120 }
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152