VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Add Back-End Command Line Arguments via a Plug-in (addBackendCommandLine)

Table of Contents

This example shows how to add command-line arguments that can be used in a plug-in to the back-end list of command line arguments.

Adding New Command-Line Arguments

In order to add command-line arguments, you must implement the new plug-in entry point:

DT_VRF_DLL_PLUGIN void DtInitializeVrfSettings(DtApplicationSettings& settings)

You can add your command-line arguments to these settings:

  myBooleanFlag = new DtConfigVariable<bool>(settings, "exampleBoolean", false, "Example boolean flag.");
  myStringCommand = new DtConfigVariable<DtString>(settings, "exampleString", false, "Example string flag.");

These arguments will be available on the command line and, if specfied, will be set before DtInitializeVrfPlugin is called.

How to Run the Example

The Add Back-End Command Line demonstrates :

In the Launcher, click the Plug-ins button to bring up the Plug-ins Selection dialog. Enable the addBackendCommandLine plug-in for this example to work.

  1. Start VR-Forces GUI and SIM.
  2. In the vrfLauncher dialog - in the additional back-end command line arguments field - set the new arguments from this example.

      --exampleBoolean --exampleString teststr
    

    Keep in mind that the exampleBoolean should not be assigned a value. It gets set if present in the command line arguments.

  3. Continue with the VRF launch
  4. In the vrfSim console window - you should see message for the additional command line arguments being set or not.

      User DID set boolean flag on command line.     
      User DID set string flag to teststr
    

Command Line Plug-in Entry Point

To make use of the new functionality, you must implement the void DtInitializeVrfSettings(DtApplicationSettings& settings) function. The settings passed in can have arguments added to them that are of type DtConfigVariable.

Plug-in Entry Points

/*******************************************************************************
** Copyright (c) 2019 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/

#include "vrfcgf/vrfPluginExtension.h"
#include <mtl/applicationSettings.h>
#include "vrfcgf/cgf.h"

extern "C" {
   DtConfigVariable<bool>*       myBooleanFlag = 0;
   DtConfigVariable<DtString>*    myStringCommand = 0;

   DT_VRF_DLL_PLUGIN void DtPluginInformation(DtVrfPluginInformation& info)
   {
      info.pluginName = "Add Back-End Command Line";
      info.pluginVersion = "1.00";
      info.pluginDescription = "Adds a string and boolean command line argument to the back-end command line processor and then prints out the values when the plugin is initialized.";
      info.pluginCreator = "MAK Technologies";
      info.pluginCreatorEmail = "sales@mak.com";
      info.pluginContactWebPage = "www.mak.com";
      info.pluginContactMailingAddress = "10 Fawcett Street, Suite 204, Cambridge, MA 02138 USA";
      info.pluginContactPhone = "(617) 876 8085";
   }

   //! This function is implemented in order to add new command line arguments to the command line
   DT_VRF_DLL_PLUGIN void DtInitializeVrfSettings(DtApplicationSettings& settings)
   {
      myBooleanFlag = new DtConfigVariable<bool>(settings, "exampleBoolean", false, "Example boolean flag.");
      myStringCommand = new DtConfigVariable<DtString>(settings, "exampleString", false, "Example string flag.");
   }

   DT_VRF_DLL_PLUGIN bool DtInitializeVrfPlugin(DtCgf* cgf)
   {
      if (myBooleanFlag && myBooleanFlag->isSet())
      {
         DtWarn << "User DID set boolean flag on command line.\n";
      }
      else
      {
         DtWarn << "User DID NOT set boolean flag on command line.\n";
      }

      if (myStringCommand && myStringCommand->isSet())
      {
         DtWarn << "User DID set string flag to " << myStringCommand->value() << std::endl;
      }
      else
      {
         DtWarn << "User DID NOT set string flag on command line.\n";
      }

      return true;
   }
}


Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)