/*! \brief Sets event type by name. \param[in] Name String containing name of event type. \param[in] context Pointer to runtime context. \return Returns dmz::True if the named event type was found. */ dmz::Boolean dmz::EventType::set_type (const String &Name, RuntimeContext *context) { Definitions defs (context); return defs.lookup_event_type (Name, *this); }
/*! \brief Sets the message type context to the type specified by the unique handle. \param[in] TypeHandle Unique handle of a message type context. \param[in] context Pointer to the runtime context. \return Returns dmz::True if the message type context is found. */ dmz::Boolean dmz::Message::set_type (const Handle TypeHandle, RuntimeContext *context) { Definitions defs (context); return defs.lookup_message_type (TypeHandle, *this); }
/*! \brief Sets the message type context to the named message type. \param[in] Name String containing name of desired message type context. \param[in] context Pointer to runtime context. \return Returns dmz::True if the named message type context is found. */ dmz::Boolean dmz::Message::set_type (const String &Name, RuntimeContext *context) { Definitions defs (context); return defs.lookup_message_type (Name, *this); }
static void printTimes (int total, const std::vector< std::pair< std::string, int > > ×, Definitions &defs) { if (!argTimes) { return; } // printf ("Times taken:\n"); int prev = 0; for (const std::pair< std::string, int > &stage : times) { int cur = stage.second - prev; prev = stage.second; printf (" %3ims %4.1f%% %s\n", cur, float (cur) / float (total) * 100.f, stage.first.c_str ()); } // printf (" %3ims 100%% total\n", total); // if (defs.timing ()) { printf ("Verbose parsing times: (Files #included multiple times are not shown)\n"); defs.timing ()->sort (); defs.timing ()->print (1); } }
void dmz::EntityPluginPortalFollow3D::_init (Config &local) { Definitions defs (get_plugin_runtime_context (), &_log); _defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName); _hilAttrHandle = activate_object_attribute ( ObjectAttributeHumanInTheLoopName, ObjectFlagMask); Boolean foundOffset (False); Config cameraParams; if (local.lookup_config ("offset", cameraParams)) { foundOffset = True; _offset = config_to_vector (cameraParams, _offset); } init_input_channels (local, InputEventChannelStateMask, &_log); _log.info << "Using " << (foundOffset ? "" : "default ") << "camera offset: " << _offset << endl; }
void dmz::NetExtPacketCodecObjectNative::_init (Config &local) { RuntimeContext *context (get_plugin_runtime_context ()); Definitions defs (context, &_log); _defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName); _lnvHandle = defs.create_named_handle (ObjectAttributeLastNetworkValueName); Config adapters; ObjectAttributeAdapter *current (0); if (local.lookup_all_config ("adapter", adapters)) { ConfigIterator it; Config data; while (adapters.get_next_config (it, data)) { ObjectAttributeAdapter *next (create_object_adapter (data, context, _log)); if (next) { if (current) { current->next = next; current = next; } else { _adapterList = current = next; } } } } }
void dmz::EntityPluginFreeFly::_init (Config &local) { Definitions defs (get_plugin_runtime_context (), &_log); _defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName); _hilHandle = activate_object_attribute ( ObjectAttributeHumanInTheLoopName, ObjectFlagMask); _move.moveSpeed = config_to_float64 ("movement.speed", local, _move.moveSpeed); _move.turnRate = config_to_float64 ("movement.turn-rate", local, _move.turnRate); init_input_channels ( local, InputEventButtonMask | InputEventAxisMask | InputEventChannelStateMask, &_log); _isectParameters.set_test_result_type (IsectClosestPoint); _isectParameters.set_calculate_normal (False); _isectParameters.set_calculate_object_handle (False); _isectParameters.set_calculate_distance (True); _isectParameters.set_calculate_cull_mode (False); }
void Compiler::parse( const QDomElement &element ) { NSManager namespaceManager; MessageHandler messageHandler; ParserContext context; context.setNamespaceManager( &namespaceManager ); context.setMessageHandler( &messageHandler ); context.setDocumentBaseUrl( Settings::self()->wsdlBaseUrl() ); Definitions definitions; definitions.setWantedService( Settings::self()->wantedService() ); if ( definitions.loadXML( &context, element, Settings::self()->ignoreSslErrors() ) ) { KODE::Code::setDefaultIndentation( 4 ); WSDL wsdl; wsdl.setDefinitions( definitions ); wsdl.setNamespaceManager( namespaceManager ); KWSDL::Converter converter; converter.setWSDL( wsdl ); if ( !converter.convert() ) { QCoreApplication::exit( 4 ); } else { KWSDL::Creator creator; creator.create( converter.classes() ); QCoreApplication::exit( 0 ); } } else { QCoreApplication::exit( 3 ); } }
void NBTrafficLightLogicCont::remapRemoved(NBEdge* removed, const EdgeVector& incoming, const EdgeVector& outgoing) { Definitions definitions = getDefinitions(); for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) { (*it)->remapRemoved(removed, incoming, outgoing); } }
void NBTrafficLightLogicCont::replaceRemoved(NBEdge* removed, int removedLane, NBEdge* by, int byLane) { Definitions definitions = getDefinitions(); for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) { (*it)->replaceRemoved(removed, removedLane, by, byLane); } }
void dmz::RenderModuleCoreOgreBasic::_init (Config &local, Config &global) { Definitions defs (get_plugin_runtime_context (), &_log); _defaultAttributeHandle = defs.create_named_handle (ObjectAttributeDefaultName); Config pluginList; if (local.lookup_all_config ("plugins.plugin", pluginList)) { RuntimeContext *context (get_plugin_runtime_context ()); dmz::load_plugins (context, pluginList, local, global, _extensions, &_log); } else { } Config ogreLocal; if (local.lookup_config ("ogre", ogreLocal)) { try { _init_root (ogreLocal); _init_resources (ogreLocal); _init_render_system (ogreLocal); _init_render_windows (); Ogre::ResourceGroupManager::getSingleton ().initialiseAllResourceGroups (); _init_scene_manager (ogreLocal); } catch (Ogre::Exception e) { if (_root) { if (_sceneManager) { _root->destroySceneManager (_sceneManager); _sceneManager = 0; } delete _root; _root = 0; } _log.error << e.getFullDescription ().c_str () << endl; } } else { } _extensions.discover_plugins (); }
void dmz::LuaExtObject::_init (Config &local) { _hilAttrHandle = activate_object_attribute ( ObjectAttributeHumanInTheLoopName, ObjectFlagMask); Definitions defs (get_plugin_runtime_context ()); _obj.defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName); }
NBTrafficLightLogicCont::Definitions NBTrafficLightLogicCont::getDefinitions() const { Definitions result; for (Id2Defs::const_iterator it_id = myDefinitions.begin(); it_id != myDefinitions.end(); it_id++) { const Program2Def& programs = it_id->second; for (Program2Def::const_iterator it_prog = programs.begin(); it_prog != programs.end(); it_prog++) { result.push_back(it_prog->second); } } return result; }
void dmz::EntityPluginRestoreHealth::_init (Config &local) { Definitions defs (get_plugin_runtime_context ()); defs.lookup_state (DefaultStateNameDead, _dead); _healthAttrHandle = defs.create_named_handle (EntityAttributeHealthName); _defaultAttrHandle = activate_default_object_attribute (ObjectStateMask); _health = config_to_float64 ("health.value", local, _health); }
int main (int argc, const char **argv) { std::vector< std::pair< std::string, int > > times; std::vector< std::string > arguments; FileMapper mapper; QTime timeTotal; timeTotal.start (); // Parse arguments const char *helpTitle = "Tria by the NuriaProject, built on " __DATE__ " " __TIME__; llvm::cl::ParseCommandLineOptions (argc, argv, helpTitle); initClangArguments (argv[0], arguments); std::string inputFile = addInputFiles (mapper); arguments.push_back (inputFile); // QVector< GenConf > generators = generatorsFromArguments (); mapper.mapRecursive (QDir (":/headers/"), QStringLiteral("/builtins/")); // Create tool instance Definitions definitions (sourceFileList ()); Compiler compiler (&definitions); if (!compiler.prepare (&mapper, arguments)) { return 1; } // Run it times.emplace_back ("init", timeTotal.elapsed ()); if (!compiler.run ()) { return 2; } // Generate code definitions.parsingComplete (); times.emplace_back ("parse", timeTotal.elapsed ()); // Run generators LuaGenerator luaGenerator (&definitions, &compiler); for (int i = 0; i < generators.length (); i++) { const GenConf &conf = generators.at (i); if (!luaGenerator.generate (conf)) { return 5; } times.emplace_back (conf.luaScript.toStdString (), timeTotal.elapsed ()); } // printTimes (timeTotal.elapsed (), times, definitions); return 0; }
void dmz::StarfighterPluginSpaceBoxOSG::_init (Config &local) { Definitions defs (get_plugin_runtime_context ()); _defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName); _imgRc = config_to_string ("image.resource", local, _imgRc); _offset = config_to_float64 ("box.offset", local, _offset); activate_object_attribute (ObjectAttributeHumanInTheLoopName, ObjectFlagMask); _create_box (); }
/*! \brief Converts Config to EventType. \details Defined in dmzRuntimeEventType.h. \code RuntimeContext *context (get_plugin_runtime_context ()); const dmz::String DefaultEventTypeName ("Some_Event"); dmz::EventType value = dmz::config_to_event_type ("dmz.event-type.name", local, DefaultEventTypeName, context); \endcode \param[in] Name String containing name of config context to convert. \param[in] Source Config containing config context to convert. \param[in] DefaultEventTypeName String containing default EventType name to use if the config context is not found. \param[in] context Pointer to the runtime context. \return Returns dmz::EventType containing value. */ dmz::EventType dmz::config_to_event_type ( const String &Name, const Config &Source, const String &DefaultEventTypeName, RuntimeContext *context) { EventType defaultEventType; Definitions defs (context); defs.lookup_event_type (DefaultEventTypeName, defaultEventType); return config_to_event_type (Name, Source, defaultEventType, context); }
~State () { levelTable.clear (); if (_handlePtr) { delete _handlePtr; _handlePtr = 0; } else { Definitions defs (context); defs.release_unique_name (Name); } if (context) { context->unref (); context = 0; } if (lib) { delete lib; lib = 0; } }
/*! \brief Converts Config to a Mask containing state values. \details Defined in dmzRuntimeConfigToState.h. \code RuntimeContext *context (get_plugin_runtime_context ()); const dmz::String DefaultStateName ("Some_State|Another_State"); dmz::Mask value = dmz::config_to_state ("dmz.state.value", local, DefaultStateName, context); \endcode \param[in] Name String containing name of config context to convert. \param[in] Source Config containing config context to convert. \param[in] DefaultStateName String containing default state name to use if the config context is not found. \param[in] context Pointer to the runtime context. \return Returns dmz::Mask containing the state values. */ dmz::Mask dmz::config_to_state ( const String &Name, const Config &Source, const String &DefaultStateName, RuntimeContext *context) { Mask defaultMask; Definitions defs (context); defs.lookup_state (DefaultStateName, defaultMask); return config_to_state (Name, Source, defaultMask, context); }
void dmz::RenderExtViewerOSG::discover_plugin ( const PluginDiscoverEnum Mode, const Plugin *PluginPtr) { if (Mode == PluginDiscoverAdd) { if (!_core) { _core = RenderModuleCoreOSG::cast (PluginPtr); if (_core) { osg::ref_ptr<osg::Group> scene = _core->get_scene (); if (scene.valid ()) { _viewer->setSceneData (scene.get ()); } _core->add_viewer (_viewerName, _viewer.get ()); } } if (!_channels) { _channels = InputModule::cast (PluginPtr); if (_channels) { Definitions defs (get_plugin_runtime_context (), &_log); const Handle SourceHandle = defs.create_named_handle (_viewerName); _eventHandler->set_input_module_channels (_channels, SourceHandle); } } } else if (Mode == PluginDiscoverRemove) { if (_core && (_core == RenderModuleCoreOSG::cast (PluginPtr))) { _core->remove_viewer (_viewerName); osg::ref_ptr<osg::Group> scene = new osg::Group; if (scene.valid ()) { _viewer->setSceneData (scene.get ()); } _core = 0; } if (_channels && (_channels == InputModule::cast (PluginPtr))) { _eventHandler->set_input_module_channels (0, 0); _channels = 0; } } }
void dmz::EntityPluginDeadTimer::_init (Config &local) { Definitions defs (get_plugin_runtime_context (), &_log); defs.lookup_state (DefaultStateNameDead, _deadState); _defaultHandle = activate_default_object_attribute (ObjectDestroyMask | ObjectStateMask); _hilHandle = activate_object_attribute ( ObjectAttributeHumanInTheLoopName, ObjectFlagMask); set_time_slice_interval ( config_to_float64 ("timer.value", local, get_time_slice_interval ())); }
void NBTrafficLightLogicCont::clear() { Definitions definitions = getDefinitions(); for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) { delete *it; } myDefinitions.clear(); Logics logics = getComputed(); for (Logics::iterator it = logics.begin(); it != logics.end(); it++) { delete *it; } myComputed.clear(); for (std::set<NBTrafficLightDefinition*>::iterator it = myExtracted.begin(); it != myExtracted.end(); it++) { delete *it; } myExtracted.clear(); }
void dmz::EntityPluginOverlayDead::_init (Config &local) { Definitions defs (get_plugin_runtime_context (), &_log); defs.lookup_state (DefaultStateNameDead, _deadState); activate_default_object_attribute (ObjectStateMask); _hilAttrHandle = activate_object_attribute ( ObjectAttributeHumanInTheLoopName, ObjectFlagMask); _overlaySwitchName = config_to_string ("overlay.switch.name", local, _overlaySwitchName); _overlayScaleName = config_to_string ("overlay.scale.name", local, _overlayScaleName); }
std::pair<unsigned int, unsigned int> NBTrafficLightLogicCont::computeLogics(OptionsCont& oc) { // clean previous logics Logics logics = getComputed(); for (Logics::iterator it = logics.begin(); it != logics.end(); it++) { delete *it; } myComputed.clear(); unsigned int numPrograms = 0; Definitions definitions = getDefinitions(); for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) { if (computeSingleLogic(oc, *it)) { numPrograms++; } } return std::pair<unsigned int, unsigned int>((unsigned int)myComputed.size(), numPrograms); }
/*! \brief Converts Data to Config. \details Defined in dmzRuntimeConfigWrite.h. \note Unlike the config_to_* functions, the \a Name parameter can not be scoped. The \a Name parameter should not contain "." characters. \param[in] Source Data object to convert. \param[in] context Pointer to the runtime context. \param[in] log Pointer to the Log to be used for log messages. \return Returns a Config object containing the converted Data object. \sa config_to_data(const String &Name, const Config &Source, RuntimeContext *context, Data &target, Log *log) */ dmz::Config dmz::data_to_config ( const String &Name, const Data &Source, RuntimeContext *context, Log *log) { Config result (Name); Definitions defs (context); RuntimeIterator it; Handle handle (Source.get_first_attribute (it)); while (handle) { Config attr ("attribute"); attr.store_attribute ("name", defs.lookup_named_handle_name (handle)); attr.store_attribute ( "type", base_type_enum_to_string (Source.lookup_attribute_base_type_enum (handle))); result.add_config (attr); const Int32 ElementCount (Source.lookup_attribute_element_count (handle)); for (Int32 ix = 0; ix < ElementCount; ix++) { Config element ("element"); String value; Source.lookup_string (handle, ix, value); element.store_attribute ("value", value); attr.add_config (element); } handle = Source.get_next_attribute (it); } return result; }
void dmz::EntityPluginDamage::_init (Config &local) { Definitions defs (get_plugin_runtime_context (), &_log); _targetHandle = defs.create_named_handle (EventAttributeTargetName); const String StateNames = config_to_string ("state.name", local, DefaultStateNameDead); defs.lookup_state (StateNames, _deadState); _defaultObjectHandle = activate_default_object_attribute (ObjectDestroyMask); _hilHandle = activate_object_attribute ( ObjectAttributeHumanInTheLoopName, ObjectFlagMask); _detonationType = activate_event_callback (EventDetonationName, EventCloseMask); }
/*! \brief Converts Config to name Handle. \details Defined in dmzRuntimeConfigToNamedHandle.h. This function converts the named attribute to a named Handle It is assumed that the last part of the \a Name variable specifies the attribute name. If the String "type.name" is passed in as \a Name, it will try to find a config context called "type" and the attribute "name" stored in the "type" config context. \code dmz::Handle handle = dmz::config_to_named_handle ("dmz.handle.name", global, get_plugin_runtime_context (), "DefaultHandleName"); \endcode \param[in] Name String containing name of the attribute in the config context to convert. \param[in] Source Config containing config context to convert. \param[in] DefaultValue String containing name of handle if not found in the Config. \param[in] context Pointer to the runtime context. \return Returns dmz::Handle containing the named Handle. Returns a zero handle if no name is given. */ dmz::Handle dmz::config_to_named_handle ( const String &Name, const Config &Source, const String &DefaultValue, RuntimeContext *context) { Handle result (0); const String HandleName (config_to_string (Name, Source, DefaultValue)); if (HandleName) { Definitions defs (context); result = defs.create_named_handle (HandleName); } return result; }
//! Write a Data object to the Stream. Stream & operator<< (Stream &stream, const Data &Value) { stream << "dmz::Data object" << endl; RuntimeContext *context (Value.get_runtime_context ()); Definitions defs (context); DataIterator it; String buffer; buffer.repeat (" ", 3); for ( Handle handle = Value.get_first_attribute (it); handle; handle = Value.get_next_attribute (it)) { if (context) { stream << buffer << defs.lookup_named_handle_name (handle) << "[" << handle << "]" << " ="; } else { stream << buffer << handle << " ="; } const Int32 Elements (Value.lookup_attribute_element_count (handle)); for (Int32 ix = 0; ix < Elements; ix++) { String value; if (Value.lookup_string (handle, ix, value)) { stream << " '" << value << "'"; } else { stream << " " << "<undefined element>"; } } stream << ";" << endl; } return stream; }
//! \cond dmz::NetModuleIdentityMapBasic::NetModuleIdentityMapBasic ( const PluginInfo &Info, Config &local) : Plugin (Info), NetModuleIdentityMap (Info), MessageObserver (Info), _log (Info), _site (0), _host (0), _netHandles (1001, 1, 0xFFFF), _handleConverter (Info.get_context ()) { _init (local); Definitions defs (Info, &_log); if (defs.create_message (ObjectDestroyMessageName, _removeObjMsg)) { subscribe_to_message (_removeObjMsg); } }
/*! \brief Converts Config to a Mask containing state values. \details Defined in dmzRuntimeConfigToState.h. \code RuntimeContext *context (get_plugin_runtime_context ()); const dmz::Mask DefaultState; dmz::Mask value = dmz::config_to_state ("dmz.state.value", local, DefaultState, context); \endcode \param[in] Name String containing name of config context to convert. \param[in] Source Config containing config context to convert. \param[in] DefaultState Mask containing default state to use if the config context is not found. \param[in] context Pointer to the runtime context. \return Returns dmz::Mask containing the state values. */ dmz::Mask dmz::config_to_state ( const String &Name, const Config &Source, const Mask &DefaultState, RuntimeContext *context) { Mask result; String stateName; if (local_config_to_string (Name, Source, stateName)) { Definitions defs (context); defs.lookup_state (stateName, result); } else { result = DefaultState; } return result; }