Commit 2fd71c46 authored by vlad_burin's avatar vlad_burin
Browse files

Serializer little update to more proper work with containers. (still a lot of work)

Same with BasePropCreator.

--HG--
branch : MockCompsTest
parent 719402f255e3
......@@ -117,11 +117,17 @@ void UBasePropCreator::CreateProperty(RDK::USerStorageXML* serstorage, RDK::UMoc
}
// ( CreatePropertyByType) -
if(type == "std::vector" || type == "simplevector")
if(type == "std::vector")
{
CreatorProperty<PropType, TypeInt, std::vector<UnKnow> >::CreatePropertyByType(serstorage,mock_unet);
return;
}
// (bool, int, double)
if(type == "simplevector")
{
CreatorProperty<PropType, TypeInt, simpleVector >::CreatePropertyByType(serstorage,mock_unet);
return;
}
// list
if(type == "std::list")
......@@ -317,12 +323,22 @@ public:
static bool CreatePropertyByType(RDK::USerStorageXML* serstorage, UMockUNet* mock_unet)
{
std::string prop_name = serstorage->GetNodeName();
int size=serstorage->GetNumNodes();
if(!(serstorage->SelectNode("elem",size-1)))
return false;
// - elemType
//
std::string type;
if(size == 0)
{
type = serstorage->GetNodeAttribute("elemType");
}
else
{
serstorage->SelectNode("elem",size-1);
type = serstorage->GetNodeAttribute("elemType");
serstorage->SelectUp();
}
std::string type = serstorage->GetNodeAttribute("Type");
serstorage->SelectUp();
if(type == typeid(bool).name())
{
......@@ -421,12 +437,86 @@ public:
CreatorProperty<PropType, TypeInt, std::vector<std::pair<UnKnow,UnKnow> > >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
// MVector<double>
//
if(type == "simplevector")
{
CreatorProperty<PropType, TypeInt, std::vector<simpleVector> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
// MVector<T>
if(type.find("MVector",0) == 0)
{
CreatorProperty<PropType, TypeInt, std::vector<MVector<UnKnow, 0> > >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
// MDMatrix<T>
if(type.find("MDMatrix",0) == 0)
{
CreatorProperty<PropType, TypeInt, std::vector<MDMatrix<UnKnow> > >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
}
};
//
template <template<typename, typename, unsigned int> class PropType, unsigned int TypeInt>
class CreatorProperty<PropType, TypeInt, simpleVector >
{
public:
static bool CreatePropertyByType(RDK::USerStorageXML* serstorage, UMockUNet* mock_unet)
{
std::string prop_name = serstorage->GetNodeName();
std::string type = serstorage->GetNodeAttribute("elemType");
if(type == typeid(bool).name())
{
CreatorProperty<PropType, TypeInt, std::vector<char> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(int).name())
{
CreatorProperty<PropType, TypeInt, std::vector<int> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(double).name())
{
CreatorProperty<PropType, TypeInt, std::vector<double> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
}
};
//
template <template<typename, typename, unsigned int> class PropType, unsigned int TypeInt>
class CreatorProperty<PropType, TypeInt, std::vector<simpleVector> >
{
public:
static bool CreatePropertyByType(RDK::USerStorageXML* serstorage, UMockUNet* mock_unet)
{
std::string prop_name = serstorage->GetNodeName();
int size=serstorage->GetNumNodes();
if(!(serstorage->SelectNode("elem",size-1)))
return false;
std::string type = serstorage->GetNodeAttribute("elemType");
serstorage->SelectUp();
if(type == typeid(bool).name())
{
CreatorProperty<PropType, TypeInt, std::vector<std::vector<char> > >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(int).name())
{
CreatorProperty<PropType, TypeInt, std::vector<std::vector<int> > >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(double).name())
{
CreatorProperty<PropType, TypeInt, std::vector<std::vector<double> > >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
}
};
......@@ -469,7 +559,7 @@ public:
}
};
//
// MVector<T>
template <template<typename, typename, unsigned int> class PropType, unsigned int TypeInt>
class CreatorProperty<PropType, TypeInt, std::vector<MVector<UnKnow, 0> > >
{
......@@ -521,6 +611,114 @@ public:
}
};
// MDMatrix<T>
template <template<typename, typename, unsigned int> class PropType, unsigned int TypeInt>
class CreatorProperty<PropType, TypeInt, std::vector<MDMatrix<UnKnow> > >
{
public:
static bool CreatePropertyByType(RDK::USerStorageXML* serstorage, UMockUNet* mock_unet)
{
std::string prop_name = serstorage->GetNodeName();
int size=serstorage->GetNumNodes();
// - elemType
//
std::string type;
if(size == 0)
{
type = serstorage->GetNodeAttribute("elemType");
}
else
{
serstorage->SelectNode("elem",size-1);
type = serstorage->GetNodeAttribute("Type");
serstorage->SelectUp();
}
// MDMatrix
size_t pos = type.find("MDMatrix");
if (pos != std::string::npos)
{
type.erase(pos, std::string("MDMatrix").length());
}
// '<' '>'
type.erase(std::remove(type.begin(), type.end(), '>'), type.end());
type.erase(std::remove(type.begin(), type.end(), '<'), type.end());
if(type == typeid(bool).name())
{
CreatorProperty<PropType, TypeInt, MDVector<bool> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(char).name())
{
CreatorProperty<PropType, TypeInt, MDVector<char> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(unsigned char).name())
{
CreatorProperty<PropType, TypeInt, MDVector<unsigned char> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(short).name())
{
CreatorProperty<PropType, TypeInt, MDVector<short> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(unsigned short).name())
{
CreatorProperty<PropType, TypeInt, MDVector<unsigned short> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(int).name())
{
CreatorProperty<PropType, TypeInt, MDVector<int> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(unsigned int).name())
{
CreatorProperty<PropType, TypeInt, MDVector<unsigned int> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(long).name())
{
CreatorProperty<PropType, TypeInt, MDVector<long> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(unsigned long).name())
{
CreatorProperty<PropType, TypeInt, MDVector<unsigned long> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(long long).name())
{
CreatorProperty<PropType, TypeInt, MDVector<long long> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(unsigned long long).name())
{
CreatorProperty<PropType, TypeInt, MDVector<unsigned long long> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(float).name())
{
CreatorProperty<PropType, TypeInt, MDVector<float> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(double).name())
{
CreatorProperty<PropType, TypeInt, MDVector<double> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
if(type == typeid(long double).name())
{
CreatorProperty<PropType, TypeInt, MDVector<long double> >::CreatePropertyByType(serstorage, mock_unet);
return true;
}
}
};
// list
template <template<typename, typename, unsigned int> class PropType, unsigned int TypeInt>
class CreatorProperty<PropType, TypeInt, std::list<UnKnow> >
......@@ -530,11 +728,20 @@ public:
{
std::string prop_name = serstorage->GetNodeName();
int size=serstorage->GetNumNodes();
if(!(serstorage->SelectNode("elem",size-1)))
return false;
// - elemType
//
std::string type;
if(size == 0)
{
type = serstorage->GetNodeAttribute("elemType");
}
else
{
serstorage->SelectNode("elem",size-1);
type = serstorage->GetNodeAttribute("elemType");
serstorage->SelectUp();
}
std::string type = serstorage->GetNodeAttribute("Type");
serstorage->SelectUp();
if(type == typeid(bool).name())
{
......
......@@ -48,7 +48,14 @@ public:
class UnKnow
{
private:
UnKnow() {};
UnKnow() {}
};
// ""
class simpleVector
{
private:
simpleVector() {}
};
......
......@@ -5,7 +5,7 @@
#include "UStorage.h"
namespace RDK {
//TODO simplevector-a
/* *************************************************************************** */
// --------------------------
//
......@@ -31,42 +31,53 @@ UMockUNet::UMockUNet(RDK::USerStorageXML *serstorage, UStorage* storage)
(*f)(serstorage, this);
}
// TODO , -
// UploadClass
// UploadClass ( ?)
//
std::map<NameT,UVariable> propers = this->GetPropertiesList();
std::vector<std::string> PropsNames;
// xml-
std::vector<std::pair<std::string,std::string> > PropsNames;
// : Paramenters -> State -> Input -> Output
for(int i =0, params = serstorage->GetNumNodes(); i <params; i++)
{
serstorage->SelectNode(i);
std::string prop_type = serstorage->GetNodeName();
for(int j = 0, props = serstorage->GetNumNodes(); j < props; j++)
{
serstorage->SelectNode(j);
std::string prop_name = serstorage->GetNodeName();
std::string type = serstorage->GetNodeAttribute("Type");
PropsNames.push_back(make_pair(prop_name,type));
PropsNames.push_back(prop_name);
serstorage->SelectUp();
}
}
serstorage->SelectUp();
}
static std::vector<std::string> errors;
std::vector<std::string> errors;
errors.clear();
//
for(std::vector<std::string>::iterator p = PropsNames.begin(); p != PropsNames.end(); ++p)
for(std::vector<std::pair<std::string,std::string> >::iterator p = PropsNames.begin(); p != PropsNames.end(); ++p)
{
if(propers.find(*p) == propers.end())
if(propers.find((*p).first) == propers.end())
{
std::string temp;
temp = *p + "Wasn't created in " + class_name;
if(std::find(ForbiddenInputs.begin(),ForbiddenInputs.end(),(*p).first) != ForbiddenInputs.end())
continue;
if(std::find(ForbiddenOutputs.begin(),ForbiddenOutputs.end(),(*p).first) != ForbiddenOutputs.end())
continue;
temp = (*p).first + " in " + class_name +" Type: " + (*p).second;
errors.push_back(temp);
}
}
SetStorage(0);
ClassDesriptionXML.Destroy();
......
......@@ -3,6 +3,9 @@
#include "UNet.h"
extern std::vector<std::string> ForbiddenInputs;
extern std::vector<std::string> ForbiddenOutputs;
// RTV UBVSObject
//#include "../../../Libraries/Rtv-BasicLib/Core/RTVSupport.h"
......
......@@ -163,6 +163,7 @@ USerStorageXML& operator << (USerStorageXML& storage, const std::vector<bool> &d
storage.SetNodeAttribute("Type","simplevector");
size_t size=data.size();
storage.SetNodeAttribute("Size",sntoa(size));
storage.SetNodeAttribute("elemType",typeid(bool).name());
if(size <= 0)
return storage;
......@@ -232,6 +233,7 @@ USerStorageXML& operator << (USerStorageXML& storage, const std::vector<double>
storage.SetNodeAttribute("Type","simplevector");
size_t size=data.size();
storage.SetNodeAttribute("Size",sntoa(size));
storage.SetNodeAttribute("elemType",typeid(double).name());
if(size <= 0)
return storage;
......@@ -297,6 +299,7 @@ USerStorageXML& operator << (USerStorageXML& storage, const std::vector<int> &da
storage.SetNodeAttribute("Type","simplevector");
int size=int(data.size());
storage.SetNodeAttribute("Size",sntoa(size));
storage.SetNodeAttribute("elemType",typeid(int).name());
if(size <= 0)
return storage;
......
......@@ -209,6 +209,15 @@ USerStorageXML& operator << (USerStorageXML& storage, const std::map<T1,T2> &dat
storage.SetNodeAttribute("Type","std::map");
storage.SetNodeAttribute("Size",sntoa(data.size()));
/* // ( )
T temp;
USerStorageXML tempXML;
tempXML.Destroy();
tempXML.Create("temp");
tempXML << temp;
std::string type = tempXML.GetNodeAttribute("Type");
storage.SetNodeAttribute("elemType",type);
*/
if(data.empty())
return storage;
......@@ -267,6 +276,15 @@ USerStorageXML& operator << (USerStorageXML& storage, const std::list<T> &data)
size_t size=data.size();
storage.SetNodeAttribute("Size",sntoa(size));
// ( )
T temp;
USerStorageXML tempXML;
tempXML.Destroy();
tempXML.Create("temp");
tempXML << temp;
std::string type = tempXML.GetNodeAttribute("Type");
storage.SetNodeAttribute("elemType",type);
if(size == 0)
return storage;
......@@ -334,6 +352,27 @@ USerStorageXML& operator << (USerStorageXML& storage, const std::vector<T> &data
size_t size=data.size();
storage.SetNodeAttribute("Size",sntoa(size));
// ( )
T temp;
USerStorageXML tempXML;
tempXML.Destroy();
tempXML.Create("temp");
tempXML << temp;
std::string type = tempXML.GetNodeAttribute("Type");
if(type == "UBVSObject")
{
int k=0;
k++;
}
//
if(type.empty())
{
type = typeid(T).name();
}
storage.SetNodeAttribute("elemType",type);
if(size == 0)
return storage;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment