00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #define ACEDIA_REDUCED_ANNOUNCE
00031
00032 #include "any.hpp"
00033 #include "actorref.hpp"
00034
00035 #include <sstream>
00036
00037 namespace acedia {
00038
00039 Any::Any(details::AnyVal *m_value) : val(m_value) { }
00040
00041 Any::Any() : val(NULL) { }
00042
00043 Any::Any(bool m_value) : val(new details::AnyValImpl<bool>(m_value)) { }
00044
00045 Any::Any(boost::int8_t m_value) : val(new details::AnyValImpl<boost::int8_t>(m_value)) { }
00046
00047 Any::Any(boost::uint8_t m_value) : val(new details::AnyValImpl<boost::uint8_t>(m_value)) { }
00048
00049 Any::Any(boost::int16_t m_value) : val(new details::AnyValImpl<boost::int16_t>(m_value)) { }
00050
00051 Any::Any(boost::uint16_t m_value) : val(new details::AnyValImpl<boost::uint16_t>(m_value)) { }
00052
00053 Any::Any(boost::int32_t m_value) : val(new details::AnyValImpl<boost::int32_t>(m_value)) { }
00054
00055 Any::Any(boost::uint32_t m_value) : val(new details::AnyValImpl<boost::uint32_t>(m_value)) { }
00056
00057 Any::Any(boost::int64_t m_value) : val(new details::AnyValImpl<boost::int64_t>(m_value)) { }
00058
00059 Any::Any(boost::uint64_t m_value) : val(new details::AnyValImpl<boost::uint64_t>(m_value)) { }
00060
00061 Any::Any(double m_value) : val(new details::AnyValImpl<double>(m_value)) { }
00062
00063 Any::Any(float m_value) : val(new details::AnyValImpl<float>(m_value)) { }
00064
00065 Any::Any(const char *str) : val(new details::AnyValImpl<String>(str)) { }
00066
00067 Any::Any(const String &str) : val(new details::AnyValImpl<String>(str)) { }
00068
00069 Any::Any(const StringList &strList) : val(new details::AnyValImpl<StringList>(strList)) { }
00070
00071
00072
00073 Any::Any(const Any &other) : val(NULL)
00074 {
00075 if (other.val) val = other.val->copy();
00076 }
00077
00078 Any::~Any() { if (val) delete val; }
00079
00080 Any &Any::operator=(const Any &other)
00081 {
00082 if (val) delete val;
00083 if (other.val)
00084 {
00085 val = other.val->copy();
00086 }
00087 else
00088 {
00089 val = NULL;
00090 }
00091 return *this;
00092 }
00093
00094 MetaClass *Any::metaClass() const
00095 {
00096 if (val) return val->metaClass();
00097 return details::MetaClassImpl<void>::instance();
00098 }
00099
00100 void Any::serialize(boost::archive::text_oarchive &ar, const unsigned int)
00101 {
00102 if (val)
00103 {
00104 val->serialize(ar);
00105 }
00106 }
00107
00108 void Any::serialize(boost::archive::text_iarchive &ar, const unsigned int)
00109 {
00110 String mcname;
00111 ar >> mcname;
00112 MetaClass *mc = getMetaClass(mcname);
00113 if (mc)
00114 {
00115 details::AnyVal *v = mc->deserialize(ar);
00116 if (val) delete val;
00117 val = v;
00118 }
00119 }
00120
00121 String Any::toString(bool verbose) const
00122 {
00123 if (!val) return "NULL";
00124 else return val->toString(verbose);
00125 }
00126
00127 bool Any::operator==(const Any &other) const
00128 {
00129 return (val ? val->equals(other.val) : other.val == NULL);
00130 }
00131
00132 }