3 using namespace YACS::ENGINE;
5 const char Data::UNRECOGNIZEDTYPENAME[]="Unrecognized type";
7 Data::Data(DynType typeOfContent):_edType(typeOfContent),_exContent(ContentOfDataFlow::neuter())
11 Data::Data(const std::string& content, DynType typeOfContent) throw(Exception):_edType(typeOfContent)
13 _exContent=ContentOfDataFlow::createNewContent(content,typeOfContent);
16 Data::Data(const Data& other):_edType(other._edType)
18 ContentOfDataFlow::duplicate(other._exContent);
19 _exContent=other._exContent;
24 ContentOfDataFlow::release(_exContent);
27 Data &Data::operator =(const Data& other) throw(ConversionException)
31 if(other._exContent==ContentOfDataFlow::neuter())
33 ContentOfDataFlow::release(_exContent);
34 _exContent=ContentOfDataFlow::neuter();
37 if(other._edType==_edType)
39 ContentOfDataFlow::duplicate(other._exContent);
40 ContentOfDataFlow::release(_exContent);
41 _exContent=other._exContent;
45 ContentOfDataFlow::release(_exContent);
46 _exContent=ContentOfDataFlow::convertContent(other._exContent,other._edType,_edType);
52 std::string Data::edGetRepresentation() const
54 std::ostringstream stream;
55 stream << _edType << "_" << ContentOfDataFlow::getRepresentation(_exContent);
59 void Data::edSetNewType(DynType newTypeOfContent) throw(ConversionException)
61 if(_edType==newTypeOfContent)
63 ContentOfDataFlow::Type newContent=ContentOfDataFlow::convertContent(_exContent,_edType,newTypeOfContent);
64 ContentOfDataFlow::release(_exContent);
65 _exContent=newContent;
66 _edType=newTypeOfContent;
69 void Data::exSetContent(const std::string& content) throw(ConversionException)
71 ContentOfDataFlow::release(_exContent);
72 _exContent=ContentOfDataFlow::createNewContent(content,_edType);
75 void Data::edInitToType(DynType typeOfContent)
77 ContentOfDataFlow::release(_exContent);
78 _exContent=ContentOfDataFlow::neuter();
79 _edType=typeOfContent;
84 ContentOfDataFlow::release(_exContent);
85 _exContent=ContentOfDataFlow::neuter();
88 // Part of Data::edGetType implementation
89 template< YACS::DynType type >
90 class TreatmentForNameOfType
93 static void perform(int input, std::string& ret)
95 ret=TypeDescriptorTraits<type>::_name;
99 std::string Data::edGetTypeInPrintableForm(DynType type)
105 DynToStaticTypeDispatcher1<TreatmentForNameOfType>::perform(type, fake1, ret);
110 return UNRECOGNIZEDTYPENAME;
114 bool Data::isStaticallyCompatibleWith(const Data& other) const throw(Exception)
116 return areStaticallyCompatible(_edType, other._edType);
119 bool Data::areStaticallyCompatible(DynType type1, DynType type2) throw(Exception)
121 return ContentOfDataFlow::isStaticallyCompatibleWith(type1, type2);
124 bool Data::empty() const
126 return _exContent==ContentOfDataFlow::neuter();