Skip to content

Applications/shapeworks/Command.h

Namespaces

Name
shapeworks
User usage reporting (telemetry)

Classes

Name
class shapeworks::Command
class shapeworks::ImageCommand
class shapeworks::MeshCommand
class shapeworks::OptimizeCommandGroup
class shapeworks::GroomCommandGroup
class shapeworks::AnalyzeCommandGroup
class shapeworks::ProjectCommandGroup
class shapeworks::ParticleSystemCommand
class shapeworks::ShapeworksCommand

Functions

Name
std::ostream & operator<<(std::ostream & os, const shapeworks::Command & cmd)

Defines

Name
COMMAND_DECLARE(CommandName, CommandType)

Functions Documentation

function operator<<

std::ostream & operator<<(
    std::ostream & os,
    const shapeworks::Command & cmd
)

Macros Documentation

define COMMAND_DECLARE

#define COMMAND_DECLARE(
    CommandName,
    CommandType
)
  class CommandName : public CommandType                                                   \
  {                                                                                        \
  public:                                                                                  \
    static CommandName &getCommand() { static CommandName instance; return instance; }     \
                                                                                           \
  private:                                                                                 \
    CommandName() { buildParser(); }                                                       \
    void buildParser() override;                                                           \
    bool execute(const optparse::Values &options, SharedCommandData &sharedData) override; \
  }

Source code

#pragma once

/*
 * Command provided by unified shapeworks executable.
 */

#include "OptionParser.h"
#include "SharedCommandData.h"

#include <iostream>
#include <stdexcept>

#define COMMAND_DECLARE(CommandName, CommandType)                                          \
  class CommandName : public CommandType                                                   \
  {                                                                                        \
  public:                                                                                  \
    static CommandName &getCommand() { static CommandName instance; return instance; }     \
                                                                                           \
  private:                                                                                 \
    CommandName() { buildParser(); }                                                       \
    void buildParser() override;                                                           \
    bool execute(const optparse::Values &options, SharedCommandData &sharedData) override; \
  }

namespace shapeworks {

class Command {
public:
  virtual const std::string type() { return "General"; }

  const std::string name() const { return parser.prog(); }
  const std::string usage() const { return parser.get_usage(); }
  const std::string desc() const { return parser.description(); }

  std::vector<std::string> parse_args(const std::vector<std::string> &arguments);

  int run(SharedCommandData &sharedData);

private:
  virtual bool execute(const optparse::Values &options, SharedCommandData &sharedData) = 0;

protected:
  virtual void buildParser(); // derived classes should specialize and call this as well

  optparse::OptionParser parser;
};

class ImageCommand : public Command
{
public:
  const std::string type() override { return "Image"; }

private:
};

class MeshCommand : public Command
{
public:
  const std::string type() override { return "Mesh"; }

private:
};

class OptimizeCommandGroup : public Command
{
public:
  const std::string type() override { return "Optimize"; }

private:
};

class GroomCommandGroup : public Command
{
public:
  const std::string type() override { return "Groom"; }

private:
};

class AnalyzeCommandGroup : public Command
{
public:
  const std::string type() override { return "Analyze"; }

private:
};

class ProjectCommandGroup : public Command
{
public:
  const std::string type() override { return "Project"; }

private:
};

class ParticleSystemCommand : public Command
{
public:
  const std::string type() override { return "ParticleSystem"; }

private:
};

class ShapeworksCommand : public Command
{
public:
  const std::string type() override { return "Shapeworks"; }

private:
};

}; // shapeworks

std::ostream& operator<<(std::ostream& os, const shapeworks::Command &cmd);

Updated on 2024-07-12 at 20:10:35 +0000