当前位置: 首页>>代码示例>>C++>>正文


C++ Serialiser类代码示例

本文整理汇总了C++中Serialiser的典型用法代码示例。如果您正苦于以下问题:C++ Serialiser类的具体用法?C++ Serialiser怎么用?C++ Serialiser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Serialiser类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void
CloudThermal::Save(Serialiser &s) const
{
  s.Write8(1);
  s.Write64(client_key);
  s << time;
  s.WriteT(Pack());
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:8,代码来源:Thermal.cpp

示例2:

void Scene3700::Viewer::synchronise(Serialiser &s) {
	SceneObject::synchronise(s);
	s.syncAsByte(_active);
	s.syncAsSint16LE(_countdownCtr);
	for (int idx = 0; idx < 4; ++idx) {
		s.syncAsSint16LE(_frameList[idx]);
		s.syncAsSint16LE(_percentList[idx]);
	}
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例3:

void
CloudData::Save(Serialiser &s) const
{
    s.Write32(CLOUD_MAGIC);
    s.Write32(CLOUD_VERSION);
    clients.Save(s);
    s.Write8(1);
    thermals.Save(s);
    s.Write8(0);
}
开发者ID:staylo,项目名称:XCSoar,代码行数:10,代码来源:Data.cpp

示例4: RemoteRenderer

		RemoteRenderer(Network::Socket *sock)
			: m_Socket(sock)
		{
			map<RDCDriver,wstring> m = RenderDoc::Inst().GetReplayDrivers();

			m_Proxies.reserve(m.size());
			for(auto it=m.begin(); it != m.end(); ++it) m_Proxies.push_back(*it);
			
			{
				PacketType type;
				Serialiser *ser = NULL;
				GetPacket(type, &ser);

				m.clear();

				if(ser)
				{
					uint32_t count = 0;
					ser->Serialise("", count);

					for(uint32_t i=0; i < count; i++)
					{
						RDCDriver driver = RDC_Unknown;
						wstring name = L"";
						ser->Serialise("", driver);
						ser->Serialise("", name);

						m[driver] = name;
					}

					delete ser;
				}
			}

			m_RemoteDrivers.reserve(m.size());
			for(auto it=m.begin(); it != m.end(); ++it) m_RemoteDrivers.push_back(*it);

			m_ProxyDriver = NULL;
			m_ProxySerialiser = NULL;
		}
开发者ID:FeuernD,项目名称:renderdoc,代码行数:40,代码来源:remote_replay.cpp

示例5: TargetControl

  TargetControl(Network::Socket *sock, string clientName, bool forceConnection, bool localhost)
      : m_Socket(sock), m_Local(localhost)
  {
    PacketType type;
    vector<byte> payload;

    m_PID = 0;

    {
      Serialiser ser("", Serialiser::WRITING, false);

      ser.SerialiseString("", clientName);
      ser.Serialise("", forceConnection);

      if(!SendPacket(m_Socket, ePacket_Handshake, ser))
      {
        SAFE_DELETE(m_Socket);
        return;
      }
    }

    Serialiser *ser = NULL;
    GetPacket(type, ser);

    // failed handshaking
    if(m_Socket == NULL || ser == NULL)
      return;

    RDCASSERT(type == ePacket_Handshake || type == ePacket_Busy);

    if(type == ePacket_Handshake)
    {
      ser->Serialise("", m_Target);
      ser->Serialise("", m_API);
      ser->Serialise("", m_PID);

      RDCLOG("Got remote handshake: %s (%s) [%u]", m_Target.c_str(), m_API.c_str(), m_PID);
    }
    else if(type == ePacket_Busy)
    {
      ser->Serialise("", m_Target);
      ser->Serialise("", m_API);
      ser->Serialise("", m_BusyClient);

      RDCLOG("Got remote busy signal: %s (%s) owned by %s", m_Target.c_str(), m_API.c_str(),
             m_BusyClient.c_str());
    }

    SAFE_DELETE(ser);
  }
开发者ID:Anteru,项目名称:renderdoc,代码行数:50,代码来源:target_control.cpp

示例6: CreateProxyRenderer

		ReplayCreateStatus CreateProxyRenderer(uint32_t proxyid, const char *logfile, float *progress, ReplayRenderer **rend)
		{
			if(rend == NULL) return eReplayCreate_InternalError;

			if(proxyid >= m_Proxies.size())
			{
				RDCERR("Invalid proxy driver id %d specified for remote renderer", proxyid);
				return eReplayCreate_InternalError;
			}
			
			float dummy = 0.0f;
			if(progress == NULL)
				progress = &dummy;

			RDCDriver proxydrivertype = m_Proxies[proxyid].first;

			Serialiser ser("", Serialiser::WRITING, false);
		
			if(!SendChunkedFile(m_Socket, ePacket_CopyCapture, logfile, ser, progress))
			{
				SAFE_DELETE(m_Socket);
				return eReplayCreate_NetworkIOFailed;
			}

			RDCLOG("Sent file to replay host. Loading...");
			
			PacketType type = ePacket_Noop;
			while(m_Socket)
			{
				Serialiser *progressSer;
				GetPacket(type, &progressSer);

				if(!m_Socket || type != ePacket_LogOpenProgress) break;

				progressSer->Serialise("", *progress);

				RDCLOG("% 3.0f%%...", (*progress)*100.0f);
			}

			if(!m_Socket || type != ePacket_LogReady)
				return eReplayCreate_NetworkIOFailed;

			*progress = 1.0f;

			RDCLOG("Log ready on replay host");

			IReplayDriver *proxyDriver = NULL;
			auto status = RenderDoc::Inst().CreateReplayDriver(proxydrivertype, NULL, &proxyDriver);

			if(status != eReplayCreate_Success || !proxyDriver)
			{
				if(proxyDriver) proxyDriver->Shutdown();
				return status;
			}

			ReplayRenderer *ret = new ReplayRenderer();

			ProxySerialiser *proxy = new ProxySerialiser(m_Socket, proxyDriver);
			status = ret->SetDevice(proxy);

			if(status != eReplayCreate_Success)
			{
				SAFE_DELETE(ret);
				return status;
			}
			
			// ReplayRenderer takes ownership of the ProxySerialiser (as IReplayDriver)
			// and it cleans itself up in Shutdown.

			*rend = ret;

			return eReplayCreate_Success;
		}
开发者ID:281627166,项目名称:renderdoc,代码行数:73,代码来源:remote_replay.cpp

示例7: ReceiveMessage

  void ReceiveMessage(RemoteMessage *msg)
  {
    if(m_Socket == NULL)
    {
      msg->Type = eRemoteMsg_Disconnected;
      return;
    }

    if(!m_Socket->IsRecvDataWaiting())
    {
      if(!m_Socket->Connected())
      {
        SAFE_DELETE(m_Socket);
        msg->Type = eRemoteMsg_Disconnected;
      }
      else
      {
        Threading::Sleep(2);
        msg->Type = eRemoteMsg_Noop;
      }

      return;
    }

    PacketType type;
    Serialiser *ser = NULL;

    GetPacket(type, ser);

    if(m_Socket == NULL)
    {
      SAFE_DELETE(ser);

      msg->Type = eRemoteMsg_Disconnected;
      return;
    }
    else
    {
      if(type == ePacket_Noop)
      {
        SAFE_DELETE(ser);

        msg->Type = eRemoteMsg_Noop;
        return;
      }
      else if(type == ePacket_Busy)
      {
        string existingClient;
        ser->Serialise("", existingClient);

        SAFE_DELETE(ser);

        SAFE_DELETE(m_Socket);

        RDCLOG("Got busy signal: '%s", existingClient.c_str());
        msg->Type = eRemoteMsg_Busy;
        msg->Busy.ClientName = existingClient;
        return;
      }
      else if(type == ePacket_CopyCapture)
      {
        msg->Type = eRemoteMsg_CaptureCopied;

        ser->Serialise("", msg->NewCapture.ID);

        SAFE_DELETE(ser);

        msg->NewCapture.localpath = m_CaptureCopies[msg->NewCapture.ID];

        if(!RecvChunkedFile(m_Socket, ePacket_CopyCapture, msg->NewCapture.localpath.elems, ser, NULL))
        {
          SAFE_DELETE(ser);
          SAFE_DELETE(m_Socket);

          msg->Type = eRemoteMsg_Disconnected;
          return;
        }

        m_CaptureCopies.erase(msg->NewCapture.ID);

        SAFE_DELETE(ser);

        return;
      }
      else if(type == ePacket_NewChild)
      {
        msg->Type = eRemoteMsg_NewChild;

        ser->Serialise("", msg->NewChild.PID);
        ser->Serialise("", msg->NewChild.ident);

        RDCLOG("Got a new child process: %u %u", msg->NewChild.PID, msg->NewChild.ident);

        SAFE_DELETE(ser);

        return;
      }
      else if(type == ePacket_NewCapture)
      {
        msg->Type = eRemoteMsg_NewCapture;
//.........这里部分代码省略.........
开发者ID:EecheE,项目名称:renderdoc,代码行数:101,代码来源:remote_access.cpp

示例8: ser

void RenderDoc::RemoteAccessClientThread(void *s)
{
  Threading::KeepModuleAlive();

  Network::Socket *client = (Network::Socket *)s;

  Serialiser ser("", Serialiser::WRITING, false);

  string api = "";
  RDCDriver driver;
  RenderDoc::Inst().GetCurrentDriver(driver, api);

  ser.Rewind();

  string target = RenderDoc::Inst().GetCurrentTarget();
  ser.Serialise("", target);
  ser.Serialise("", api);
  uint32_t mypid = Process::GetCurrentPID();
  ser.Serialise("", mypid);

  if(!SendPacket(client, ePacket_Handshake, ser))
  {
    SAFE_DELETE(client);

    {
      SCOPED_LOCK(RenderDoc::Inst().m_SingleClientLock);
      RenderDoc::Inst().m_SingleClientName = "";
    }

    Threading::ReleaseModuleExitThread();
    return;
  }

  const int pingtime = 1000;    // ping every 1000ms
  const int ticktime = 10;      // tick every 10ms
  int curtime = 0;

  vector<CaptureData> captures;
  vector<pair<uint32_t, uint32_t> > children;

  while(client)
  {
    if(RenderDoc::Inst().m_RemoteClientThreadShutdown || (client && !client->Connected()))
    {
      SAFE_DELETE(client);
      break;
    }

    ser.Rewind();

    Threading::Sleep(ticktime);
    curtime += ticktime;

    PacketType packetType = ePacket_Noop;

    string curapi;
    RenderDoc::Inst().GetCurrentDriver(driver, curapi);

    vector<CaptureData> caps = RenderDoc::Inst().GetCaptures();
    vector<pair<uint32_t, uint32_t> > childprocs = RenderDoc::Inst().GetChildProcesses();

    if(curapi != api)
    {
      api = curapi;

      ser.Serialise("", api);

      packetType = ePacket_RegisterAPI;
    }
    else if(caps.size() != captures.size())
    {
      uint32_t idx = (uint32_t)captures.size();

      captures.push_back(caps[idx]);

      packetType = ePacket_NewCapture;

      std::string path = FileIO::GetFullPathname(captures.back().path);

      ser.Serialise("", idx);
      ser.Serialise("", captures.back().timestamp);
      ser.Serialise("", path);

      uint32_t len = 0;
      RENDERDOC_GetThumbnail(captures.back().path.c_str(), NULL, len);
      byte *thumb = new byte[len];
      RENDERDOC_GetThumbnail(captures.back().path.c_str(), thumb, len);

      size_t l = len;
      ser.Serialise("", len);
      ser.SerialiseBuffer("", thumb, l);
      delete[] thumb;
    }
    else if(childprocs.size() != children.size())
    {
      uint32_t idx = (uint32_t)children.size();

      children.push_back(childprocs[idx]);

      packetType = ePacket_NewChild;
//.........这里部分代码省略.........
开发者ID:EecheE,项目名称:renderdoc,代码行数:101,代码来源:remote_access.cpp

示例9: while

void RenderDoc::RemoteAccessServerThread(void *s)
{
  Threading::KeepModuleAlive();

  Network::Socket *sock = (Network::Socket *)s;

  RenderDoc::Inst().m_SingleClientName = "";

  Threading::ThreadHandle clientThread = 0;

  RenderDoc::Inst().m_RemoteClientThreadShutdown = false;

  while(!RenderDoc::Inst().m_RemoteServerThreadShutdown)
  {
    Network::Socket *client = sock->AcceptClient(false);

    if(client == NULL)
    {
      if(!sock->Connected())
      {
        RDCERR("Error in accept - shutting down server");

        SAFE_DELETE(sock);
        Threading::ReleaseModuleExitThread();
        return;
      }

      Threading::Sleep(5);

      continue;
    }

    string existingClient;
    string newClient;
    bool kick = false;

    // receive handshake from client and get its name
    {
      PacketType type;
      Serialiser *ser = NULL;
      if(!RecvPacket(client, type, &ser))
      {
        SAFE_DELETE(ser);
        SAFE_DELETE(client);
        continue;
      }

      if(type != ePacket_Handshake)
      {
        SAFE_DELETE(ser);
        SAFE_DELETE(client);
        continue;
      }

      ser->SerialiseString("", newClient);
      ser->Serialise("", kick);

      SAFE_DELETE(ser);

      if(newClient.empty())
      {
        SAFE_DELETE(client);
        continue;
      }
    }

    // see if we have a client
    {
      SCOPED_LOCK(RenderDoc::Inst().m_SingleClientLock);
      existingClient = RenderDoc::Inst().m_SingleClientName;
    }

    if(!existingClient.empty() && kick)
    {
      // forcibly close communication thread which will kill the connection
      RenderDoc::Inst().m_RemoteClientThreadShutdown = true;
      Threading::JoinThread(clientThread);
      Threading::CloseThread(clientThread);
      clientThread = 0;
      RenderDoc::Inst().m_RemoteClientThreadShutdown = false;
      existingClient = "";
    }

    if(existingClient.empty())
    {
      SCOPED_LOCK(RenderDoc::Inst().m_SingleClientLock);
      RenderDoc::Inst().m_SingleClientName = newClient;
    }

    // if we've claimed client status, spawn a thread to communicate
    if(existingClient.empty() || kick)
    {
      clientThread = Threading::CreateThread(RemoteAccessClientThread, client);
      continue;
    }
    else
    {
      // if we've been asked to kick the existing connection off
      // reject this connection and tell them who is busy
      Serialiser ser("", Serialiser::WRITING, false);
//.........这里部分代码省略.........
开发者ID:EecheE,项目名称:renderdoc,代码行数:101,代码来源:remote_access.cpp

示例10: listenerSynchronise

void SoundManager::listenerSynchronise(Serialiser &s) {
	s.validate("SoundManager");
	warning("TODO: SoundManager listenerSynchronise");
}
开发者ID:,项目名称:,代码行数:4,代码来源:

示例11: ser

void RenderDoc::RemoteAccessClientThread(void *s)
{
	Network::Socket *client = (Network::Socket *)s;

	Serialiser ser(L"", Serialiser::WRITING, false);

	wstring api = L"";
	RDCDriver driver;
	RenderDoc::Inst().GetCurrentDriver(driver, api);

	ser.Rewind();

	wstring target = RenderDoc::Inst().GetCurrentTarget();
	ser.Serialise("", target);
	ser.Serialise("", api);

	if(!SendPacket(client, ePacket_Handshake, ser))
	{
		SAFE_DELETE(client);

		{
			SCOPED_LOCK(RenderDoc::Inst().m_SingleClientLock);
			RenderDoc::Inst().m_SingleClientName = L"";
		}

		return;
	}

	const int pingtime = 1000; // ping every 1000ms
	const int ticktime = 10; // tick every 10ms
	int curtime = 0;

	vector<wstring> captures;

	while(client)
	{
		if(RenderDoc::Inst().m_RemoteClientThreadShutdown || (client && !client->Connected()))
		{
			SAFE_DELETE(client);
			break;
		}

		ser.Rewind();

		Threading::Sleep(ticktime);
		curtime += ticktime;

		PacketType packetType = ePacket_Noop;

		wstring curapi;
		RenderDoc::Inst().GetCurrentDriver(driver, curapi);

		if(curapi != api)
		{
			api = curapi;

			ser.Serialise("", api);

			packetType = ePacket_RegisterAPI;
		}
		else
		{
			vector<wstring> caps = RenderDoc::Inst().GetCaptures();

			if(caps.size() != captures.size())
			{
				uint32_t idx = (uint32_t)captures.size();

				captures.push_back(caps[idx]);

				packetType = ePacket_NewCapture;

				uint64_t timestamp = FileIO::GetModifiedTimestamp(captures.back().c_str());
				ser.Serialise("", idx);
				ser.Serialise("", timestamp);

				ser.Serialise("", captures.back());

				uint32_t len = 128*1024;
				byte *thumb = new byte[len];
				RENDERDOC_GetThumbnail(captures.back().c_str(), thumb, len);

				size_t l = len;
				ser.Serialise("", len);
				ser.SerialiseBuffer("", thumb, l);
				delete[] thumb;
			}
		}

		if(curtime < pingtime && packetType == ePacket_Noop)
		{
			if(client->IsRecvDataWaiting())
			{
				PacketType type;
				Serialiser *recvser = NULL;

				if(!RecvPacket(client, type, &recvser))
					SAFE_DELETE(client);

				if(client == NULL)
//.........这里部分代码省略.........
开发者ID:CSRedRat,项目名称:renderdoc,代码行数:101,代码来源:remote_access.cpp

示例12: switch

void Compiler::scanStmt() {
    char buf[256]; // temporary buffer
    int t;
    
    switch(tok->getnext()){
    case T_IDENT: // it's an expression
    case T_INT:
    case T_FLOAT:
    case T_SUB:
    case T_BITNOT:
    case T_PLING:
    case T_STRING:
    case T_BACKTICK:
    case T_OPREN:
        // deal with debugging words!
        if(!strcmp(tok->getstring(),"dumplocs")){
            cg->emit(OP_SPECIAL,0);break;
        }
        if(!strcmp(tok->getstring(),"breakpoint")){
            cg->emit(OP_SPECIAL,1);break;
        }
        
        tok->rewind(); // put the token back
        // scan the expression, might be a label
        if(!scanExpr(true))
            // clear all statements if not a func or other oddity,
            // or just a dummy for recreation purposes if in immediate mode.
            cg->emit(cg->isCompiling()?OP_ENDESTMT:OP_ENDESTMT2);
        break;
    case T_LOAD:
        {
            if(cg->isCompiling())
                error("can only run 'load' in interactive mode");
            Session *s;
            if(tok->getnext()!=T_STRING)
                error("expected a string after 'load'");
            try {
                s = new Session(ses->api);
                s->feedFile(tok->getstring());
            } catch(Exception &e){
                delete s;
                throw e;
            }
            delete s;
        }
        break;
    case T_SAVE:
        {
            if(cg->isCompiling())
                error("can only run 'save' in interactive mode");
            if(tok->getnext()!=T_STRING)
                error("expected a string after 'save'");
            const char *fname = tok->getstring();
            
            FILE *a;
            if(!strlen(fname))
                a = stdout;
            else
                a = fopen(fname,"w");
            
            if(!a)
                error("cannot open file '%s'",fname);
            
            Serialiser *ser = new Serialiser(ses);
            ser->write(a);
            if(strlen(fname))
                fclose(a);
            delete ser;
        }
        break;
    case T_SAVEVAR:
        {
            if(cg->isCompiling())
                error("can only run 'savevar' in interactive mode");
            if(tok->getnext()!=T_IDENT)
                error("expected a variable name after 'savevar'");
            const char *vname = tok->getstring();
            int vdesc = lana->consts->findOrCreateString(vname);
            if(tok->getnext()!=T_STRING)
                error("expected a string after 'savevar'");
            const char *fname = tok->getstring();
            
            // try to get the value
            Value *v;
            int id;
            id = lana->globs->find(vdesc);
            if(id>=0) {
                v = lana->globs->get(id); // it's a global
            } else {
                id = ses->findSesVar(vdesc);
                if(id<0)
                    error("variable not found: %s",lana->consts->getStr(vdesc));
                v = ses->getSesVar(id);
            }
            
            FILE *a;
            if(!strlen(fname))
                a = stdout;
            else
                a = fopen(fname,"w");
//.........这里部分代码省略.........
开发者ID:jimfinnis,项目名称:lana-2,代码行数:101,代码来源:compiler.cpp


注:本文中的Serialiser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。