+
+void SALOME_LogManager::accept(SALOME_VisitorContainerLog &visitor)
+{
+ visitor.enterLogManager( *this );
+ for(auto container : _containers)
+ {
+ PortableServer::ServantBase *serv = getPOA()->reference_to_servant( container );
+ serv->_remove_ref();
+ SALOME_ContainerPerfLog *servC = dynamic_cast<SALOME_ContainerPerfLog *>(serv);
+ servC->accept(visitor);
+ }
+ visitor.leaveLogManager( *this );
+}
+
+SALOME::vectorOfByte *SALOME_LogManager::getAllStruct()
+{
+ std::vector<char> data = this->dumpCppInternalFrmt();
+ return FromVectCharToCorba(data);
+}
+
+///////////////////////
+
+ #include <cstdint>
+
+static void PushIntInVC(std::uint32_t val, std::vector<char>& data)
+{
+ char *valPtr = reinterpret_cast<char *>(&val);
+ data.insert(data.end(),valPtr,valPtr+sizeof(std::uint32_t));
+}
+
+template<class T>
+static void PushStringInVC(const T& str, std::vector<char>& data)
+{
+ std::uint32_t sz = static_cast<std::uint32_t>( str.size() );
+ PushIntInVC(sz,data);
+ data.insert(data.end(),str.data(),str.data()+sz);
+}
+
+class InternalFormatVisitorDump : public SALOME_VisitorContainerLog
+{
+public:
+ InternalFormatVisitorDump(std::vector<char> *data):_data(data) { }
+ void enterLogManager(SALOME_LogManager& inst) override;
+ void leaveLogManager(SALOME_LogManager& inst) override { }
+ void enterContainerPerfLog(SALOME_ContainerPerfLog& inst) override;
+ void leaveContainerPerfLog(SALOME_ContainerPerfLog& inst) override { }
+ void enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) override;
+ void leaveContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) override { }
+ void visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst) override;
+private:
+ std::vector<char> *_data = nullptr;
+};
+
+void InternalFormatVisitorDump::visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst)
+{
+ PushStringInVC<std::vector<char>>(inst.data(),*_data);
+}
+
+void InternalFormatVisitorDump::enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst)
+{
+ PushStringInVC<std::string>(inst.name(),*_data);
+ PushStringInVC<std::string>(inst.code(),*_data);
+ PushIntInVC((std::uint32_t)inst.getNumberOfSessions(),*_data);
+}
+
+void InternalFormatVisitorDump::enterContainerPerfLog(SALOME_ContainerPerfLog& inst)
+{
+ PushStringInVC<std::string>(inst.nameInNS(),*_data);
+ PushStringInVC<std::string>(inst.logFile(),*_data);
+ PushIntInVC((std::uint32_t)inst.getNumberOfScripts(),*_data);
+}
+
+void InternalFormatVisitorDump::enterLogManager(SALOME_LogManager& inst)
+{
+ PushIntInVC((std::uint32_t)inst.getNumberOfContainers(),*_data);
+}
+
+///////////////////////
+
+std::vector<char> FetchVCFromVC(std::vector<char>& data, std::size_t& offset)
+{
+ std::uint32_t *sz = reinterpret_cast<std::uint32_t *>( data.data()+offset);
+ std::vector<char> ret(data.data()+offset+sizeof(std::uint32_t),data.data()+offset+sizeof(std::uint32_t)+*sz);
+ offset += sizeof(std::uint32_t)+*sz;
+ return ret;
+}
+
+std::string FetchStringFromVC(std::vector<char>& data, std::size_t& offset)
+{
+ std::uint32_t *sz = reinterpret_cast<std::uint32_t *>( data.data() );
+ std::string ret(data.data()+sizeof(std::uint32_t),*sz);
+ offset += sizeof(std::uint32_t)+*sz;
+ return ret;
+}
+
+class InternalFormatVisitorLoad : public SALOME_VisitorContainerLog
+{
+public:
+ InternalFormatVisitorLoad(std::vector<char> *data):_data(data) { }
+ void enterContainerPerfLog(SALOME_ContainerPerfLog& inst) override;
+ void leaveContainerPerfLog(SALOME_ContainerPerfLog& inst) override { }
+ void enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) override;
+ void leaveContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) override { }
+ void visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst) override;
+private:
+ std::vector<char> *_data = nullptr;
+ std::size_t _offset = 0;
+};
+
+void InternalFormatVisitorLoad::visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst)
+{
+ inst.setData( FetchVCFromVC( *_data, _offset ) );
+}
+
+void InternalFormatVisitorLoad::enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst)
+{
+ inst.setName( FetchStringFromVC(*_data, _offset) );
+ inst.setCode( FetchStringFromVC(*_data, _offset) );
+}
+
+void InternalFormatVisitorLoad::enterContainerPerfLog(SALOME_ContainerPerfLog& inst)
+{
+ inst.setNameInNS( FetchStringFromVC(*_data, _offset) );
+ inst.setLogFile( FetchStringFromVC(*_data, _offset) );
+}
+
+///////////////////////
+
+std::vector<char> SALOME_LogManager::dumpCppInternalFrmt()
+{
+ std::vector<char> ret;
+ InternalFormatVisitorDump visitor(&ret);
+ this->accept( visitor );
+ return ret;
+}