Commit 56222bd4 authored by vlad_burin's avatar vlad_burin
Browse files

First working version of Mock Unets.

Libraries, Storage, Engine updated.
Array of functions for creating properties for MockUNet from XML information
added to Storage.
These functions can be added to Storage's array outside of RDK.
More properties types have to be added, and code refactor needed

--HG--
branch : MockCompsTest
parent d954cc60e923
This diff is collapsed.
This diff is collapsed.
#ifndef UBASEPROPCREATOR_H
#define UBASEPROPCREATOR_H
#include "UStorage.h"
#include "UMockUNet.h"
#include "../../Deploy/Include/rdk.h"
extern std::vector<std::string> ForbiddenInputs;
extern std::vector<std::string> ForbiddenOutputs;
//
class UBasePropCreator
{
public:
UBasePropCreator();
static bool AddFuncCrPropFunc(RDK::UStorage * storage);
static bool BaseCrPropMock(RDK::USerStorageXML* serstorage, RDK::UMockUNet* mock_unet);
// ()
template <template<typename, typename, unsigned int> class PropType, unsigned int TypeInt>
static void CreateProperty(RDK::USerStorageXML* serstorage, RDK::UMockUNet* mock_unet);
// ,
template <template<typename, typename, unsigned int> class PropType, unsigned int TypeInt>
static bool CreateSimpleTypeProperty(RDK::USerStorageXML* serstorage, RDK::UMockUNet* mock_unet);
//
//
template <template<typename, typename, unsigned int> class PropType, unsigned int TypeInt>
static bool CreatePropertyByType(RDK::USerStorageXML* serstorage, RDK::UMockUNet* mock_unet);
};
// CreatePropertyByType. CreateProperty
//
// (std::vector<typename>), UnKnow -
template <template<typename, typename, unsigned int> class PropType, unsigned int TypeInt, typename T>
class CreatorProperty
{
public:
static bool CreatePropertyByType(RDK::USerStorageXML* serstorage, RDK::UMockUNet* mock_unet);
};
// ,
class UnKnow
{
private:
UnKnow() {};
};
#endif // UBASEPROPCREATOR_H
......@@ -7357,7 +7357,12 @@ void UEngine::CreateEnvironment(bool isinit, list<UContainer*>* external_classes
Logger->LogMessage(RDK_EX_DEBUG, "Build storage has been started...");
Storage->InitRTlibs();
Storage->BuildStorage();
//Storage->CreateMockLibs();
//Storage->SaveMockLibs();
Logger->LogMessage(RDK_EX_DEBUG, "Build storage has been finished");
}
catch (RDK::UException &exception)
......
......@@ -652,9 +652,10 @@ bool UMockLibrary::SaveLibraryToFile()
CurrentComponentStruct.Create("MockLib");
CurrentComponentStruct.SelectRoot();
CurrentComponentStruct.SetNodeAttribute("name", Name);
CurrentComponentStruct.SetNodeAttribute("version", Version);
CurrentComponentStruct.SetNodeAttribute("revision", std::to_string(Revision));
CurrentComponentStruct.SetNodeAttribute("Name", Name);
CurrentComponentStruct.SetNodeAttribute("Version", Version);
CurrentComponentStruct.SetNodeAttribute("Revision", std::to_string(Revision));
CurrentComponentStruct.SetNodeAttribute("CoreVersion",GetGlobalVersion().ToStringFull());
// XML
USerStorageXML CompStruct;
......@@ -673,7 +674,7 @@ bool UMockLibrary::LoadFromXML(USerStorageXML& xml)
{
xml.SelectRoot();
//
//
for(int i = 0, size = xml.GetNumNodes() ; i < size; i++)
{
xml.SelectNode(i);
......@@ -688,13 +689,66 @@ bool UMockLibrary::LoadFromXML(USerStorageXML& xml)
/// xml
UEPtr<UContainer> UMockLibrary::CreateClassSample(UStorage *storage, USerStorageXML &xml)
{}
UEPtr<UContainer> UMockLibrary::CreateClassSample(USerStorageXML &xml, UStorage *storage)
{
std::string class_name=xml.GetNodeAttribute("Class");
UEPtr<UMockUNet> mock = new UMockUNet(&xml,storage);
UEPtr<UNet> cont =dynamic_pointer_cast<UNet>(mock);
if(!cont)
{
delete mock;
return 0;
}
/*
if(!cont->LoadComponent(&xml,true))
{
if(Storage->GetLogger())
Storage->GetLogger()->LogMessage(RDK_EX_DEBUG, __FUNCTION__, "Error while LoadComponent() from XML file for class \"" +class_name +"\"");
delete mock;
return 0;
}
*/
return cont;
}
// ClassSamples .
// .
void UMockLibrary::CreateClassSamples(UStorage *storage)
{}
{
int num_classes = ClassesStructures.size();
for(int i=0;i<num_classes;i++)
{
try
{
CurrentComponentStruct.Load(ClassesStructures[i],"");
UEPtr<UContainer> cont=CreateClassSample(CurrentComponentStruct,Storage);
if(!cont)
return;
CurrentComponentStruct.Load(ClassesStructures[i],"");
std::string class_name=CurrentComponentStruct.GetNodeAttribute("Class");
if(class_name == "UOpenCvDetector")
{
int g= 9;
g++;
}
UploadClass(class_name,cont);
}
catch(UException &ex)
{
if(Storage->GetLogger())
Storage->GetLogger()->LogMessage(RDK_EX_DEBUG, __FUNCTION__, ex.what());
}
}
}
}
......
......@@ -285,7 +285,7 @@ bool SaveLibraryToFile();
bool LoadFromXML(USerStorageXML& xml);
// --------------------------
/// xml
UEPtr<UContainer> CreateClassSample(UStorage *storage, USerStorageXML &xml);
UEPtr<UContainer> CreateClassSample(USerStorageXML &xml, UStorage *storage);
// ClassSamples .
// .
......
This diff is collapsed.
......@@ -3,6 +3,15 @@
#include "UNet.h"
// RTV UBVSObject
//#include "../../../Libraries/Rtv-BasicLib/Core/RTVSupport.h"
// RDK include
//#include "../../../Libraries/Rdk-PtzCameraControlLib/Core/UBPtzCameraControlPelco.h"
// UBVSObject
//#include "../../../Libraries/Rtv-BasicLib/Core/RTVXMLSerialize.h"
namespace RDK {
class RDK_LIB_TYPE UMockUNet: public UNet
......@@ -14,48 +23,16 @@ public: //
//
// --------------------------
UMockUNet(RDK::USerStorageXML *serstorage=0);
UMockUNet(RDK::USerStorageXML *serstorage=0, UStorage* storage = 0);
virtual ~UMockUNet(void);
//
virtual UMockUNet* New(void);
private:
static std::string ForbiddenInputs;
static std::string ForbiddenOutputs;
USerStorageXML ClassDesriptionXML;
// ()
template <template<typename, typename, unsigned int> class PropType, unsigned int TypeInt>
void CreateProperty(RDK::USerStorageXML* serstorage);
// ,
template <template<typename, typename, unsigned int> class PropType, unsigned int TypeInt>
bool CreateSimpleTypeProperty(RDK::USerStorageXML* serstorage, UMockUNet* mock_unet);
//
//
template <template<typename, typename, unsigned int> class PropType, unsigned int TypeInt>
bool CreatePropertyByType(RDK::USerStorageXML* serstorage, UMockUNet* mock_unet);
};
// CreatePropertyByType. CreateProperty
//
// (std::vector<typename>), UnKnow -
template <template<typename, typename, unsigned int> class PropType, unsigned int TypeInt, typename T>
class CreatorProperty
{
public:
static bool CreatePropertyByType(RDK::USerStorageXML* serstorage, UMockUNet* mock_unet);
};
// ,
class UnKnow
{
private:
UnKnow() {};
};
}
......
......@@ -19,7 +19,7 @@ See file license.txt for more information
#include "ULibrary.h"
#include "../../Deploy/Include/rdk_exceptions.h"
#include "UEnvException.h"
#include "UBasePropCreator.h"
namespace RDK {
/* *********************************************************************** */
......@@ -107,7 +107,7 @@ bool UInstancesStorageElement::operator != (const UInstancesStorageElement &valu
//
// --------------------------
UStorage::UStorage(void):
BuildMode(1)
BuildMode(3)
{
LastClassId=0;
}
......@@ -1320,6 +1320,8 @@ bool UStorage::DelCollection(int index)
bool UStorage::InitMockLibs(void)
{
UBasePropCreator::AddFuncCrPropFunc(this);
// -
std::string lib_path = "../../../MockLibs/";
std::string lib_list_file = "../../../MockLibs/0_LibList.xml";
......@@ -1418,8 +1420,10 @@ bool UStorage::SaveMockLibs(void)
library->SaveLibraryToFile();
LibList.AddNode("library");
LibList.SetNodeAttribute("Version",lib->GetVersion());
LibList.SetNodeAttribute("Revision",std::to_string(lib->GetRevision()));
LibList.SetNodeAttribute("CoreVersion",GetGlobalVersion().ToStringFull());
LibList.SetNodeText(lib->GetName());
LibList.SelectUp();
}
......@@ -1467,6 +1471,8 @@ bool UStorage::BuildStorage(void)
case 2:
{
// -
InitMockLibs();
BuildStorage(0);
BuildStorage(3);
BuildStorage(2);
......@@ -1475,6 +1481,8 @@ bool UStorage::BuildStorage(void)
case 3:
{
// -
InitMockLibs();
BuildStorage(3);
BuildStorage(2);
break;
......@@ -1701,6 +1709,27 @@ void UStorage::DelLookupClass(const NameT &name)
ClassesLookupTable.erase(I);
}
// --------------------------
// - UMockUnet-
bool UStorage::AddFuncCrPropMock(funcCrPropMock func_ptr)
{
//
if(func_ptr == 0)
return false;
//
if ( std::find(FunctionsCrPropMock.begin(), FunctionsCrPropMock.end(), func_ptr) != FunctionsCrPropMock.end() )
return false;
FunctionsCrPropMock.push_back(func_ptr);
return true;
}
const std::vector<funcCrPropMock>& UStorage::GetFunctionsCrPropMock() const
{
return FunctionsCrPropMock;
}
/* *************************************************************************** */
/*
// --------------------------
......
......@@ -84,8 +84,15 @@ typedef pair<UId,UInstancesStorage> UObjectStorageElement;
typedef map<UId, UInstancesStorage> UObjectsStorage;
typedef map<UId, UInstancesStorage>::iterator UObjectsStorageIterator;
typedef map<UId, UInstancesStorage>::const_iterator UObjectsStorageCIterator;
class UMockUNet;
// ,
// USerStorageXML UMockUNet
typedef bool (*funcCrPropMock)(USerStorageXML*, UMockUNet*);
/* *********************************************************************** */
class RDK_LIB_TYPE UStorage
{
//friend class UContainer;
......@@ -136,10 +143,16 @@ UId LastClassId;
// 3 - . -, . ( )
int BuildMode;
// - Property MockUNet
std::vector<funcCrPropMock> FunctionsCrPropMock;
protected: //
public: //
bool AddFuncCrPropMock(funcCrPropMock func_ptr);
const std::vector<funcCrPropMock> &GetFunctionsCrPropMock() const;
// --------------------------
//
// --------------------------
......
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