FoodData& SingleFoodImpl::serialize(FoodData& fdata) const { *(fdata.add_singlefoods()) = serialize(); return fdata; }
// ----------------------------------------------------------------------------- bool DeviceManager::initialize() { GamepadConfig *gamepadConfig = NULL; GamePadDevice *gamepadDevice = NULL; m_map_fire_to_select = false; bool created = false; // Shutdown in case the device manager is being re-initialized shutdown(); if(UserConfigParams::logMisc()) { Log::info("Device manager","Initializing Device Manager"); Log::info("-","---------------------------"); } deserialize(); // Assign a configuration to the keyboard, or create one if we haven't yet if(UserConfigParams::logMisc()) Log::info("Device manager","Initializing keyboard support."); if (m_keyboard_configs.size() == 0) { if(UserConfigParams::logMisc()) Log::info("Device manager","No keyboard configuration exists, creating one."); m_keyboard_configs.push_back(new KeyboardConfig()); created = true; } const int keyboard_amount = m_keyboard_configs.size(); for (int n=0; n<keyboard_amount; n++) { m_keyboards.push_back(new KeyboardDevice(m_keyboard_configs.get(n))); } if(UserConfigParams::logMisc()) Log::info("Device manager","Initializing gamepad support."); irr_driver->getDevice()->activateJoysticks(m_irrlicht_gamepads); int num_gamepads = m_irrlicht_gamepads.size(); if(UserConfigParams::logMisc()) { Log::info("Device manager","Irrlicht reports %d gamepads are attached to the system.", num_gamepads); } // Create GamePadDevice for each physical gamepad and find a GamepadConfig to match for (int id = 0; id < num_gamepads; id++) { core::stringc name = m_irrlicht_gamepads[id].Name; // Some linux systems report a disk accelerometer as a gamepad, skip that if (name.find("LIS3LV02DL") != -1) continue; #ifdef WIN32 // On Windows, unless we use DirectInput, all gamepads are given the // same name ('microsoft pc-joystick driver'). This makes configuration // totally useless, so append an ID to the name. We can't test for the // name, since the name is even translated. name = name + " " + StringUtils::toString(id).c_str(); #endif if (UserConfigParams::logMisc()) { Log::info("Device manager","#%d: %s detected...", id, name.c_str()); } // Returns true if new configuration was created if (getConfigForGamepad(id, name, &gamepadConfig) == true) { if(UserConfigParams::logMisc()) Log::info("Device manager","creating new configuration."); created = true; } else { if(UserConfigParams::logMisc()) Log::info("Device manager","using existing configuration."); } gamepadConfig->setPlugged(); gamepadDevice = new GamePadDevice(id, name.c_str(), m_irrlicht_gamepads[id].Axes, m_irrlicht_gamepads[id].Buttons, gamepadConfig ); addGamepad(gamepadDevice); } // end for if (created) serialize(); return created; } // initialize
void serialize(const char *id, varchar<S> &x) { serialize(id, serializer::to_varchar_base(x)); }
void Property::serializeValue(XmlSerializer& s) { serializeValue_ = true; serialize(s); serializeValue_ = false; }
void org::mpisws::p2p::transport::simpleidentity::InetSocketAddressSerializer::serialize(::java::lang::Object* i, ::rice::p2p::commonapi::rawserialization::OutputBuffer* b) { serialize(dynamic_cast< ::java::net::InetSocketAddress* >(i), b); }
// shortcut long HashTableX::serialize ( SafeBuf *sb ) { long nb = serialize ( sb->getBuf() , sb->getAvail() ); // update sb sb->incrementLength ( nb ); return nb; }
void SystemComponent::sendRoutes(std::string const &routes) { Buffer<> buf; messages::RoutesFromServer::MessageSerialization msg(routes); serialize(buf, msg); m_getParent().packMessage(buf, routesOut.getMessageType()); }
int _tmain(int argc, _TCHAR* argv[]) { std::wcout << L"version : 2015.09.14" << std::endl; std::wcout << L"Usage : FbxExporter <path to fbx file> <outdir> [/fps:60|30|24] [/skipemptynodes] [/animstack:\"animstack name\"]" << std::endl; if (argc < 3) { std::wcerr << L"Invalid argument count" << std::endl; return -1; } std::wstring wInputPath(argv[1]); std::wstring wInputDir(argv[1]); std::wstring wInputFileName(argv[1]); auto lastDirSeparator = wInputDir.find_last_of(L'\\'); if (lastDirSeparator == wInputDir.npos) { wInputDir = L"."; } else { wInputDir.erase(lastDirSeparator); wInputFileName.erase(0, lastDirSeparator + 1); } std::wstring wOutputPath(argv[2]); CreateDirectory(wOutputPath.c_str(), nullptr); bool skipEmptyNodes = false; std::wstring animStackName; for (int i = 3; i < argc; ++i){ std::wstring warg = argv[i]; if (warg == L"/skipemptynodes") { skipEmptyNodes = true; } else if (warg.find(L"/fps:") == 0){ if (warg == L"/fps:60"){ GlobalSettings::Current().AnimationsTimeMode = FbxTime::EMode::eFrames60; } else if (warg == L"/fps:30"){ GlobalSettings::Current().AnimationsTimeMode = FbxTime::EMode::eFrames30; } else if (warg == L"/fps:24"){ GlobalSettings::Current().AnimationsTimeMode = FbxTime::EMode::eFrames24; } else{ std::wcerr << L"Unrecognized fps parameter" << std::endl; return -2; } } else if (warg.find(L"/animstack:") == 0) { animStackName = warg.substr(11); if (animStackName.size()>0 && animStackName[0] == L'\"') { animStackName.erase(0, 1); } if (animStackName.size() > 0 && animStackName[animStackName.size() - 1] == L'\"') { animStackName.erase(animStackName.size() - 1, 1); } } } FbxSceneLoader sceneLoader(wstringToUtf8(wInputPath)); auto animStackCount = sceneLoader.getScene()->GetSrcObjectCount<FbxAnimStack>(); if (animStackName.size() == 0) { GlobalSettings::Current().AnimStackIndex = 0; } else { for (auto ix = 0; ix < animStackCount; ++ix) { auto animStack = sceneLoader.getScene()->GetSrcObject<FbxAnimStack>(ix); if (utf8ToWstring(animStack->GetName()) == animStackName) { GlobalSettings::Current().AnimStackIndex = ix; } } } std::wcout << L"Animation stacks : " << std::endl; for (auto ix = 0; ix < animStackCount; ++ix) { auto animStack = sceneLoader.getScene()->GetSrcObject<FbxAnimStack>(ix); if (ix == GlobalSettings::Current().AnimStackIndex) { std::wcout << L"[X] "; sceneLoader.getScene()->SetCurrentAnimationStack(animStack); } else { std::wcout << L"[ ] "; } std::wcout << utf8ToWstring(animStack->GetName()); auto ts=animStack->GetLocalTimeSpan(); auto start = ts.GetStart(); auto stop = ts.GetStop(); std::wcout << L"(" << start.GetMilliSeconds() << L" - " << stop.GetMilliSeconds() << L")" << std::endl; } auto root = sceneLoader.rootNode(); BabylonScene babScene(*root, skipEmptyNodes); for (auto& mat : babScene.materials()){ exportTexture(mat.ambientTexture, wOutputPath); exportTexture(mat.diffuseTexture, wOutputPath); exportTexture(mat.specularTexture, wOutputPath); exportTexture(mat.emissiveTexture, wOutputPath); exportTexture(mat.reflectionTexture, wOutputPath); exportTexture(mat.bumpTexture, wOutputPath); } auto json = babScene.toJson(); if (L'\\' != *wOutputPath.crbegin()) { wOutputPath.append(L"\\"); } wOutputPath.append(wInputFileName); auto lastDot = wOutputPath.find_last_of(L'.'); wOutputPath.erase(lastDot); wOutputPath.append(L".babylon"); DeleteFile(wOutputPath.c_str()); std::ofstream stream(wOutputPath); json.serialize(stream); stream.flush(); return 0; }
std::string ConnectionDescription::toString() const { std::ostringstream description; serialize( description ); return description.str(); }
void QZebraScopeSerializer::serialize(const AdcBoardReport& data) { serialize(data.powerStatus); serialize(data.fdReport); serialize(data.tdReport); }
void btRigidBody::serializeSingleObject(class btSerializer* serializer) const { btChunk* chunk = serializer->allocate(calculateSerializeBufferSize(),1); const char* structType = serialize(chunk->m_oldPtr, serializer); serializer->finalizeChunk(chunk,structType,BT_RIGIDBODY_CODE,(void*)this); }
void ModelManager::serialize(const std::string& filename) { std::ofstream ofs(filename.c_str()); serialize::TextOutArchive textOutArchive(ofs); serialize(textOutArchive); }
ArchiveType & operator()(T && arg) { serialize(std::forward<T> (arg)); return *pointArchive; }
template<class X> void serialize(std::iostream &fs, serialization_context &context, X *&x) { fs << "pointer "; serialize(fs, context, *x); }
size_t CNetworkChat::Serialize(unsigned char *buf) const { unsigned char *p = buf; p += serialize(p, this->Text); return p - buf; }
static void do_mysql_comms(int to_server, int from_server) { struct sql_request req; static char *buffer = 0; static int buflen = 0; static char *serial; Timer_ID id; Var args; Var result; set_server_cmdline("(MOO mysql-client slave)"); my_handle = moomysql_open_connection(SQLHOST, SQLUSER, SQLPASS, SQLDB, SQLPORT, 0); for (;;) { oklog("MYSQL CHILD: ready to read!\n"); if (robust_read(from_server, &req, sizeof(req)) != sizeof(req)) end_sql(); oklog("MYSQL CHILD read!\n"); if (req.length) { ensure_buffer(&buffer, &buflen, req.length + 1); if (robust_read(from_server, buffer, req.length) != req.length) end_sql(); buffer[req.length] = '\0'; oklog("MYSQL CHILD got stuff!\n"); args = deserialize(buffer); } id = set_timer(req.timeout, timeout_proc, 0); if (req.kind == SQLREQ_DO_QUERY) { oklog("MYSQL CHILD: doing query '%s'\n", args.v.list[1].v.str); result = moomysql_send_query(my_handle, args.v.list[1].v.str); oklog("got result: %s\n", value2str(result)); serial = serialize(result); oklog("MYSQL CHILD: serialized!\n"); req.length = strlen(serial); oklog("MYSQL CHILD: strlenned!\n"); } else if (req.kind == SQLREQ_GET_ROW) { result = moomysql_next_row(my_handle); serial = serialize(result); req.length = strlen(serial); } else { req.kind = SQLREQ_ERROR; req.length = 0; } oklog("MYSQL CHILD: writing..\n"); write(to_server, &req, sizeof(req)); oklog("MYSQL CHILD: wrote req..\n"); if (req.length) { write(to_server, serial, req.length); oklog("MYSQL CHILD: wrote serial..\n"); free(serial); oklog("MYSQL CHILD: freed serial!\n"); } } }
size_t CNetworkChat::Size() const { size_t size = 0; size += serialize(NULL, this->Text); return size; }
string Server::createResponse(Status status, string description){ Response response(status, description); cout<<"Response: "<<response.toString()<<endl; return serialize(response); }
void org::mpisws::p2p::testing::transportlayer::peerreview::MyInetSocketAddress_1::serialize(::java::lang::Object* i, ::rice::p2p::commonapi::rawserialization::OutputBuffer* buf) { serialize(dynamic_cast< MyInetSocketAddress* >(i), buf); }
string Server::createResponse(Status status, vector<string>& parameters){ Response response(status, "", parameters); cout<<"Response: "<<response.toString()<<endl; return serialize(response); }
void SystemComponent::sendClientRouteUpdate(std::string const &route) { Buffer<> buf; messages::ClientRouteToServer::MessageSerialization msg(route); serialize(buf, msg); m_getParent().packMessage(buf, routeIn.getMessageType()); }
void PostscriptIO::write (const std::string& fname) { // We may need to gather a ParallelMesh to output it, making that // const qualifier in our constructor a dirty lie MeshSerializer serialize(const_cast<MeshBase&>(this->mesh()), !_is_parallel_format); if (libMesh::processor_id() == 0) { // Get a constant reference to the mesh. const MeshBase& mesh = MeshOutput<MeshBase>::mesh(); // Only works in 2D libmesh_assert_equal_to (mesh.mesh_dimension(), 2); // Create output file stream. // _out is now a private member of the class. _out.open(fname.c_str()); // Make sure it opened correctly if (!_out.good()) libmesh_file_error(fname.c_str()); // The mesh bounding box gives us info about what the // Postscript bounding box should be. MeshTools::BoundingBox bbox = MeshTools::bounding_box(mesh); // Add a little extra padding to the "true" bounding box so // that we can still see the boundary const Real percent_padding = 0.01; const Real dx=bbox.second(0)-bbox.first(0); libmesh_assert_greater (dx, 0.0); const Real dy=bbox.second(1)-bbox.first(1); libmesh_assert_greater (dy, 0.0); const Real x_min = bbox.first(0) - percent_padding*dx; const Real y_min = bbox.first(1) - percent_padding*dy; const Real x_max = bbox.second(0) + percent_padding*dx; const Real y_max = bbox.second(1) + percent_padding*dy; // Width of the output as given in postscript units. // This usually is given by the strange unit 1/72 inch. // A width of 300 represents a size of roughly 10 cm. const Real width = 300; _scale = width / (x_max-x_min); _offset(0) = x_min; _offset(1) = y_min; // Header writing stuff stolen from Deal.II std::time_t time1= std::time (0); std::tm *time = std::localtime(&time1); _out << "%!PS-Adobe-2.0 EPSF-1.2" << '\n' //<< "%!PS-Adobe-1.0" << '\n' // Lars' PS version << "%%Filename: " << fname << '\n' << "%%Title: LibMesh Output" << '\n' << "%%Creator: LibMesh: A C++ finite element library" << '\n' << "%%Creation Date: " << time->tm_year+1900 << "/" << time->tm_mon+1 << "/" << time->tm_mday << " - " << time->tm_hour << ":" << std::setw(2) << time->tm_min << ":" << std::setw(2) << time->tm_sec << '\n' << "%%BoundingBox: " // lower left corner << "0 0 " // upper right corner << static_cast<unsigned int>( rint((x_max-x_min) * _scale )) << ' ' << static_cast<unsigned int>( rint((y_max-y_min) * _scale )) << '\n'; // define some abbreviations to keep // the output small: // m=move turtle to // l=define a line // s=set rgb color // sg=set gray value // lx=close the line and plot the line // lf=close the line and fill the interior _out << "/m {moveto} bind def" << '\n' << "/l {lineto} bind def" << '\n' << "/s {setrgbcolor} bind def" << '\n' << "/sg {setgray} bind def" << '\n' << "/cs {curveto stroke} bind def" << '\n' << "/lx {lineto closepath stroke} bind def" << '\n' << "/lf {lineto closepath fill} bind def" << '\n'; _out << "%%EndProlog" << '\n'; // << '\n'; // Set line width in the postscript file. _out << line_width << " setlinewidth" << '\n'; // Set line cap and join options _out << "1 setlinecap" << '\n'; _out << "1 setlinejoin" << '\n'; // allow only five digits for output (instead of the default // six); this should suffice even for fine grids, but reduces // the file size significantly _out << std::setprecision (5); // Loop over the active elements, draw lines for the edges. We // draw even quadratic elements with straight sides, i.e. a straight // line sits between each pair of vertices. Also we draw every edge // for an element regardless of the fact that it may overlap with // another. This would probably be a useful optimization... MeshBase::const_element_iterator el = mesh.active_elements_begin(); const MeshBase::const_element_iterator end_el = mesh.active_elements_end(); for ( ; el != end_el; ++el) { //const Elem* elem = *el; this->plot_linear_elem(*el); //this->plot_quadratic_elem(*el); // Experimental } // Issue the showpage command, and we're done. _out << "showpage" << std::endl; } // end if (libMesh::processor_id() == 0) }
// Public functions Variant WidgetSaver::serialize(WidgetVirtual* w, std::map<std::string, WidgetVirtual*>& association, int& unknownIndex) { Variant rootVariant; rootVariant.createMap(); // write type switch (w->type) { case WidgetVirtual::VIRTUAL: rootVariant.insert("type", Variant("VIRTUAL")); break; case WidgetVirtual::BOARD: rootVariant.insert("type", Variant("BOARD")); break; case WidgetVirtual::IMAGE: rootVariant.insert("type", Variant("IMAGE")); break; case WidgetVirtual::LABEL: rootVariant.insert("type", Variant("LABEL")); break; case WidgetVirtual::CONSOLE: rootVariant.insert("type", Variant("CONSOLE")); break; case WidgetVirtual::RADIO_BUTTON: rootVariant.insert("type", Variant("RADIO_BUTTON"));break; default: rootVariant.insert("type", Variant("UNKNOWN")); break; } // write configuration rootVariant.insert("config", Variant((int)w->configuration)); // write sizes if (w->sizes[WidgetVirtual::DEFAULT] == w->sizes[WidgetVirtual::HOVER] && w->sizes[WidgetVirtual::DEFAULT] == w->sizes[WidgetVirtual::ACTIVE] && w->sizes[WidgetVirtual::DEFAULT] == w->sizes[WidgetVirtual::CURRENT]) rootVariant.insert("sizeAll", ToolBox::getFromVec2(w->sizes[WidgetVirtual::DEFAULT])); else { rootVariant.insert("sizeDefault", ToolBox::getFromVec2(w->sizes[WidgetVirtual::DEFAULT])); rootVariant.insert("sizeHover", ToolBox::getFromVec2(w->sizes[WidgetVirtual::HOVER])); rootVariant.insert("sizeActive", ToolBox::getFromVec2(w->sizes[WidgetVirtual::ACTIVE])); rootVariant.insert("sizeCurrent", ToolBox::getFromVec2(w->sizes[WidgetVirtual::CURRENT])); } // write positions if (w->positions[WidgetVirtual::DEFAULT] == w->positions[WidgetVirtual::HOVER] && w->positions[WidgetVirtual::DEFAULT] == w->positions[WidgetVirtual::ACTIVE] && w->positions[WidgetVirtual::DEFAULT] == w->positions[WidgetVirtual::CURRENT]) rootVariant.insert("positionAll", ToolBox::getFromVec3(w->positions[WidgetVirtual::DEFAULT])); else { rootVariant.insert("positionDefault", ToolBox::getFromVec3(w->positions[WidgetVirtual::DEFAULT])); rootVariant.insert("positionHover", ToolBox::getFromVec3(w->positions[WidgetVirtual::HOVER])); rootVariant.insert("positionActive", ToolBox::getFromVec3(w->positions[WidgetVirtual::ACTIVE])); rootVariant.insert("positionCurrent", ToolBox::getFromVec3(w->positions[WidgetVirtual::CURRENT])); } // write colors if (w->colors[WidgetVirtual::DEFAULT] == w->colors[WidgetVirtual::HOVER] && w->colors[WidgetVirtual::DEFAULT] == w->colors[WidgetVirtual::ACTIVE] && w->colors[WidgetVirtual::DEFAULT] == w->colors[WidgetVirtual::CURRENT]) rootVariant.insert("colorAll", ToolBox::getFromVec4(w->colors[WidgetVirtual::DEFAULT])); else { rootVariant.insert("colorDefault", ToolBox::getFromVec4(w->colors[WidgetVirtual::DEFAULT])); rootVariant.insert("colorHover", ToolBox::getFromVec4(w->colors[WidgetVirtual::HOVER])); rootVariant.insert("colorActive", ToolBox::getFromVec4(w->colors[WidgetVirtual::ACTIVE])); rootVariant.insert("colorCurrent", ToolBox::getFromVec4(w->colors[WidgetVirtual::CURRENT])); } // write shader and texture name if (w->shader && w->shader->name != "defaultWidget") rootVariant.insert("shader", Variant(w->shader->name)); if (w->texture) rootVariant.insert("texture", Variant(w->texture->name)); // derivate type switch (w->type) { case WidgetVirtual::BOARD: serializeBoard(static_cast<WidgetBoard*>(w), rootVariant); break; case WidgetVirtual::IMAGE: serializeImage(static_cast<WidgetImage*>(w), rootVariant); break; case WidgetVirtual::LABEL: serializeLabel(static_cast<WidgetLabel*>(w), rootVariant); break; case WidgetVirtual::CONSOLE: serializeConsole(static_cast<WidgetConsole*>(w), rootVariant); break; case WidgetVirtual::RADIO_BUTTON: serializeRadioButton(static_cast<WidgetRadioButton*>(w), rootVariant); break; default: break; } // children if (!w->children.empty()) { rootVariant.insert("children", Variant::MapType()); for (unsigned int i = 0; i < w->children.size(); ++i) { std::string name = "unknown_" + std::to_string(++unknownIndex); for (std::map<std::string, WidgetVirtual*>::iterator it = association.begin(); it != association.end(); ++it) { if (w->children[i] == it->second) { name = it->first; break; } } Variant child = serialize(w->children[i], association, unknownIndex); rootVariant.getMap()["children"].insert(name, child); } } // end return rootVariant; }
/* ** Serialize std::string */ inline void serialize(std::ofstream &file, std::string const & a) { serialize(file, (int)(a.size())); file.write(a.c_str(), a.size()); }
typename std::enable_if<std::is_enum<T>::value>::type serialize(OutputArchive& ar, const T& t) { serialize(ar, host_cast(static_cast<typename std::underlying_type<T>::type const>(t))); }
int UDPNetwork::SendTo(IPaddress address, PacketBase *packet) { serialize(packet); m_packet->address = address; return send(-1); }
/** * Test creating a JSON null value. */ bool example_6(Zorba* aZorba) { Item lNull = aZorba->getItemFactory()->createJSONNull(); return serialize(aZorba, lNull, "null"); }
int UDPNetwork::SendTo(int channel, PacketBase *packet) { serialize(packet); return send(channel); }
void serialize(const char *id, T &x) { serialize(id, serializer::to_basic_identifier(x)); }
void save(graphlab::oarchive &oarc) const { serialize(oarc, this, sizeof(sync_params)); }