<commit_before>//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

// MOOSE includes
#include "ConsoleUtils.h"

#include "AuxiliarySystem.h"
#include "Conversion.h"
#include "Executioner.h"
#include "MoosePreconditioner.h"
#include "FEProblem.h"
#include "MooseApp.h"
#include "MooseMesh.h"
#include "NonlinearSystem.h"
#include "OutputWarehouse.h"
#include "SystemInfo.h"

#include "libmesh/string_to_enum.h"

namespace ConsoleUtils
{

std::string
indent(unsigned int spaces)
{
  return std::string(spaces, ' ');
}

std::string
outputFrameworkInformation(const MooseApp & app)
{
  std::stringstream oss;
  oss << std::left;

  if (app.getSystemInfo() != NULL)
    oss << app.getSystemInfo()->getInfo();

  oss << std::left << "Parallelism:\n"
      << std::setw(console_field_width)
      << "  Num Processors: " << static_cast<std::size_t>(app.n_processors()) << '\n'
      << std::setw(console_field_width)
      << "  Num Threads: " << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
      << '\n';

  return oss.str();
}

std::string
outputMeshInformation(FEProblemBase & problem, bool verbose)
{
  std::stringstream oss;
  oss << std::left;

  MooseMesh & moose_mesh = problem.mesh();
  MeshBase & mesh = moose_mesh.getMesh();

  if (verbose)
  {
    bool forced = moose_mesh.isParallelTypeForced();
    bool pre_split = problem.getMooseApp().isUseSplit();

    // clang-format off
    oss << "Mesh: " << '\n'
        << std::setw(console_field_width)
        << "  Parallel Type: " << (moose_mesh.isDistributedMesh() ? "distributed" : "replicated")
        << (forced || pre_split ? " (" : "")
        << (forced ? "forced" : "")
        << (forced && pre_split ? ", " : "")
        << (pre_split ? "pre-split" : "")
        << (forced || pre_split ? ")" : "")
        << '\n'
        << std::setw(console_field_width) << "  Mesh Dimension: " << mesh.mesh_dimension() << '\n'
        << std::setw(console_field_width) << "  Spatial Dimension: " << mesh.spatial_dimension()
        << '\n';
    // clang-format on
  }

  oss << std::setw(console_field_width) << "  Nodes:" << '\n'
      << std::setw(console_field_width) << "    Total:" << mesh.n_nodes() << '\n'
      << std::setw(console_field_width) << "    Local:" << mesh.n_local_nodes() << '\n'
      << std::setw(console_field_width) << "  Elems:" << '\n'
      << std::setw(console_field_width) << "    Total:" << mesh.n_active_elem() << '\n'
      << std::setw(console_field_width) << "    Local:" << mesh.n_active_local_elem() << '\n';

  if (verbose)
  {

    oss << std::setw(console_field_width)
        << "  Num Subdomains: " << static_cast<std::size_t>(mesh.n_subdomains()) << '\n'
        << std::setw(console_field_width)
        << "  Num Partitions: " << static_cast<std::size_t>(mesh.n_partitions()) << '\n';
    if (problem.n_processors() > 1)
      oss << std::setw(console_field_width) << "  Partitioner: " << moose_mesh.partitionerName()
          << (moose_mesh.isPartitionerForced() ? " (forced) " : "") << '\n';
  }

  oss << '\n';

  return oss.str();
}

std::string
outputAuxiliarySystemInformation(FEProblemBase & problem)
{
  return outputSystemInformationHelper(problem.getAuxiliarySystem().system());
}

std::string
outputSystemInformationHelper(std::stringstream & oss, System & system)
{
  oss << std::left;

  if (system.n_dofs())
  {
    oss << std::setw(console_field_width) << "  Num DOFs: " << system.n_dofs() << '\n'
        << std::setw(console_field_width) << "  Num Local DOFs: " << system.n_local_dofs() << '\n';

    std::streampos begin_string_pos = oss.tellp();
    std::streampos curr_string_pos = begin_string_pos;
    oss << std::setw(console_field_width) << "  Variables: ";
    for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
    {
      const VariableGroup & vg_description(system.variable_group(vg));

      if (vg_description.n_variables() > 1)
        oss << "{ ";
      if (vg_description.n_variables() > 10)
      {
        // when the number of variables in this group is larger than 10, we only output the first
        // and the last 5 variable names
        for (unsigned int vn = 0; vn < 5; vn++)
        {
          oss << "\"" << vg_description.name(vn) << "\" ";
          curr_string_pos = oss.tellp();
          insertNewline(oss, begin_string_pos, curr_string_pos);
        }
        oss << "... ";
        curr_string_pos = oss.tellp();
        insertNewline(oss, begin_string_pos, curr_string_pos);
        for (unsigned int vn = vg_description.n_variables() - 5; vn < vg_description.n_variables();
             vn++)
        {
          oss << "\"" << vg_description.name(vn) << "\" ";
          curr_string_pos = oss.tellp();
          insertNewline(oss, begin_string_pos, curr_string_pos);
        }
      }
      else
        for (unsigned int vn = 0; vn < vg_description.n_variables(); vn++)
        {
          oss << "\"" << vg_description.name(vn) << "\" ";
          curr_string_pos = oss.tellp();
          insertNewline(oss, begin_string_pos, curr_string_pos);
        }

      if (vg_description.n_variables() > 1)
        oss << "} ";
    }
    oss << '\n';

    begin_string_pos = oss.tellp();
    curr_string_pos = begin_string_pos;
    oss << std::setw(console_field_width) << "  Finite Element Types: ";
#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
    for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
    {
      oss << "\""
          << libMesh::Utility::enum_to_string<FEFamily>(
                 system.get_dof_map().variable_group(vg).type().family)
          << "\" ";
      curr_string_pos = oss.tellp();
      insertNewline(oss, begin_string_pos, curr_string_pos);
    }
    oss << '\n';
#else
    for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
    {
      oss << "\""
          << libMesh::Utility::enum_to_string<FEFamily>(
                 system.get_dof_map().variable_group(vg).type().family)
          << "\", \""
          << libMesh::Utility::enum_to_string<FEFamily>(
                 system.get_dof_map().variable_group(vg).type().radial_family)
          << "\" ";
      curr_string_pos = oss.tellp();
      insertNewline(oss, begin_string_pos, curr_string_pos);
    }
    oss << '\n';

    begin_string_pos = oss.tellp();
    curr_string_pos = begin_string_pos;
    oss << std::setw(console_field_width) << "  Infinite Element Mapping: ";
    for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
    {
      oss << "\""
          << libMesh::Utility::enum_to_string<InfMapType>(
                 system.get_dof_map().variable_group(vg).type().inf_map)
          << "\" ";
      curr_string_pos = oss.tellp();
      insertNewline(oss, begin_string_pos, curr_string_pos);
    }
    oss << '\n';
#endif

    begin_string_pos = oss.tellp();
    curr_string_pos = begin_string_pos;
    oss << std::setw(console_field_width) << "  Approximation Orders: ";
    for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
    {
#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
      oss << "\""
          << Utility::enum_to_string<Order>(system.get_dof_map().variable_group(vg).type().order)
          << "\" ";
#else
      oss << "\""
          << Utility::enum_to_string<Order>(system.get_dof_map().variable_group(vg).type().order)
          << "\", \""
          << Utility::enum_to_string<Order>(
                 system.get_dof_map().variable_group(vg).type().radial_order)
          << "\" ";
#endif
      curr_string_pos = oss.tellp();
      insertNewline(oss, begin_string_pos, curr_string_pos);
    }
    oss << "\n\n";
  }

  return oss.str();
}

std::string
outputNonlinearSystemInformation(FEProblemBase & problem)
{
  std::stringstream oss;
  oss << std::left;

#ifndef MOOSE_SPARSE_AD
  if (problem.haveADObjects())
  {
    oss << std::setw(console_field_width)
        << "  AD size required: " << problem.getNonlinearSystemBase().requiredDerivativeSize()
        << "\n";
  }
#endif
  return outputSystemInformationHelper(oss, problem.getNonlinearSystemBase().system());
}

std::string
outputSystemInformationHelper(System & system)
{
  std::stringstream oss;

  return outputSystemInformationHelper(oss, system);
}

std::string
outputRelationshipManagerInformation(const MooseApp & app)
{
  std::stringstream oss;
  oss << std::left;

  auto info_strings = app.getRelationshipManagerInfo();
  if (info_strings.size())
  {
    for (const auto & info_pair : info_strings)
      oss << std::setw(console_field_width)
          << "  " + MooseUtils::underscoreToCamelCase(MooseUtils::toLower(info_pair.first), true) +
                 ":"
          << info_pair.second << '\n';
    oss << '\n';
  }

  return oss.str();
}

std::string
outputExecutionInformation(const MooseApp & app, FEProblemBase & problem)
{

  std::stringstream oss;
  oss << std::left;

  Executioner * exec = app.getExecutioner();

  oss << "Execution Information:\n"
      << std::setw(console_field_width) << "  Executioner: " << demangle(typeid(*exec).name())
      << '\n';

  std::string time_stepper = exec->getTimeStepperName();
  if (time_stepper != "")
    oss << std::setw(console_field_width) << "  TimeStepper: " << time_stepper << '\n';

  oss << std::setw(console_field_width)
      << "  Solver Mode: " << Moose::stringify(problem.solverParams()._type) << '\n';

  const std::string & pc_desc = problem.getPetscOptions().pc_description;
  if (!pc_desc.empty())
    oss << std::setw(console_field_width) << "  PETSc Preconditioner: " << pc_desc << '\n';

  MoosePreconditioner const * mpc = problem.getNonlinearSystemBase().getPreconditioner();
  if (mpc)
  {
    oss << std::setw(console_field_width)
        << "  MOOSE Preconditioner: " << mpc->getParam<std::string>("_type");
    if (mpc->name() == "_moose_auto")
      oss << " (auto)";
    oss << '\n';
  }
  oss << '\n';

  return oss.str();
}

std::string
outputOutputInformation(MooseApp & app)
{
  std::stringstream oss;
  oss << std::left;

  const std::vector<Output *> outputs = app.getOutputWarehouse().getOutputs<Output>();
  oss << "Outputs:\n";
  for (const auto & out : outputs)
  {
    // Display the "execute_on" settings
    const MultiMooseEnum & execute_on = out->executeOn();
    oss << "  " << std::setw(console_field_width - 2) << out->name() << "\"" << execute_on
        << "\"\n";

    // Display the advanced "execute_on" settings, only if they are different from "execute_on"
    if (out->isAdvanced())
    {
      const OutputOnWarehouse & adv_on = out->advancedExecuteOn();
      for (const auto & adv_it : adv_on)
        if (execute_on != adv_it.second)
          oss << "    " << std::setw(console_field_width - 4) << adv_it.first + ":"
              << "\"" << adv_it.second << "\"\n";
    }
  }

  return oss.str();
}

std::string
outputLegacyInformation(MooseApp & app)
{
  std::stringstream oss;
  oss << std::left;

  if (app.parameters().get<bool>("use_legacy_material_output"))
  {
    oss << COLOR_RED << "LEGACY MODES ENABLED:" << COLOR_DEFAULT << '\n';
    oss << " This application uses the legacy material output option: material properties are "
           "output only on TIMESTEP_END, not INITIAL. To remove this message, set "
           "'use_legacy_material_output' to false in this application. If there are gold output "
           "files that contain material property output for which output occurs on INITIAL, then "
           "these will generate diffs due to zero values being stored, and these tests should be "
           "re-golded.\n"
        << COLOR_DEFAULT << '\n';
  }

  return oss.str();
}

void
insertNewline(std::stringstream & oss, std::streampos & begin, std::streampos & curr)
{
  if (curr - begin > console_line_length)
  {
    oss << "\n";
    begin = oss.tellp();
    oss << std::setw(console_field_width + 2) << ""; // "{ "
  }
}

} // ConsoleUtils namespace
<commit_msg>make console output of local numbers of elements/nodes more informative #18492<commit_after>//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

// MOOSE includes
#include "ConsoleUtils.h"

#include "AuxiliarySystem.h"
#include "Conversion.h"
#include "Executioner.h"
#include "MoosePreconditioner.h"
#include "FEProblem.h"
#include "MooseApp.h"
#include "MooseMesh.h"
#include "NonlinearSystem.h"
#include "OutputWarehouse.h"
#include "SystemInfo.h"

#include "libmesh/string_to_enum.h"

namespace ConsoleUtils
{

std::string
indent(unsigned int spaces)
{
  return std::string(spaces, ' ');
}

std::string
outputFrameworkInformation(const MooseApp & app)
{
  std::stringstream oss;
  oss << std::left;

  if (app.getSystemInfo() != NULL)
    oss << app.getSystemInfo()->getInfo();

  oss << std::left << "Parallelism:\n"
      << std::setw(console_field_width)
      << "  Num Processors: " << static_cast<std::size_t>(app.n_processors()) << '\n'
      << std::setw(console_field_width)
      << "  Num Threads: " << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
      << '\n';

  return oss.str();
}

std::string
outputMeshInformation(FEProblemBase & problem, bool verbose)
{
  std::stringstream oss;
  oss << std::left;

  MooseMesh & moose_mesh = problem.mesh();
  MeshBase & mesh = moose_mesh.getMesh();

  if (verbose)
  {
    bool forced = moose_mesh.isParallelTypeForced();
    bool pre_split = problem.getMooseApp().isUseSplit();

    // clang-format off
    oss << "Mesh: " << '\n'
        << std::setw(console_field_width)
        << "  Parallel Type: " << (moose_mesh.isDistributedMesh() ? "distributed" : "replicated")
        << (forced || pre_split ? " (" : "")
        << (forced ? "forced" : "")
        << (forced && pre_split ? ", " : "")
        << (pre_split ? "pre-split" : "")
        << (forced || pre_split ? ")" : "")
        << '\n'
        << std::setw(console_field_width) << "  Mesh Dimension: " << mesh.mesh_dimension() << '\n'
        << std::setw(console_field_width) << "  Spatial Dimension: " << mesh.spatial_dimension()
        << '\n';
    // clang-format on
  }

  if (mesh.n_processors() > 1)
  {
    dof_id_type nnodes = mesh.n_nodes();
    dof_id_type nnodes_local = mesh.n_local_nodes();
    oss << std::setw(console_field_width) << "  Nodes:" << '\n'
        << std::setw(console_field_width) << "    Total:" << nnodes << '\n';
    oss << std::setw(console_field_width) << "    Local:" << nnodes_local << '\n';
    dof_id_type min_nnodes = nnodes_local, max_nnodes = nnodes_local;
    mesh.comm().min(min_nnodes);
    mesh.comm().max(max_nnodes);
    if (mesh.processor_id() == 0)
      oss << std::setw(console_field_width) << "    Min/Max/Avg:" << min_nnodes << '/' << max_nnodes
          << '/' << nnodes / mesh.n_processors() << '\n';
  }
  else
    oss << std::setw(console_field_width) << "  Nodes:" << mesh.n_nodes() << '\n';

  if (mesh.n_processors() > 1)
  {
    dof_id_type nelems = mesh.n_active_elem();
    dof_id_type nelems_local = mesh.n_active_local_elem();
    oss << std::setw(console_field_width) << "  Elems:" << '\n'
        << std::setw(console_field_width) << "    Total:" << nelems << '\n';
    oss << std::setw(console_field_width) << "    Local:" << nelems_local << '\n';
    dof_id_type min_nelems = nelems_local, max_nelems = nelems_local;
    mesh.comm().min(min_nelems);
    mesh.comm().max(max_nelems);
    if (mesh.processor_id() == 0)
      oss << std::setw(console_field_width) << "    Min/Max/Avg:" << min_nelems << '/' << max_nelems
          << '/' << nelems / mesh.n_processors() << '\n';
  }
  else
    oss << std::setw(console_field_width) << "  Elems:" << mesh.n_active_elem() << '\n';

  if (verbose)
  {

    oss << std::setw(console_field_width)
        << "  Num Subdomains: " << static_cast<std::size_t>(mesh.n_subdomains()) << '\n';
    if (mesh.n_processors() > 1)
      oss << std::setw(console_field_width)
          << "  Num Partitions: " << static_cast<std::size_t>(mesh.n_partitions()) << '\n'
          << std::setw(console_field_width) << "  Partitioner: " << moose_mesh.partitionerName()
          << (moose_mesh.isPartitionerForced() ? " (forced) " : "") << '\n';
  }

  oss << '\n';

  return oss.str();
}

std::string
outputAuxiliarySystemInformation(FEProblemBase & problem)
{
  return outputSystemInformationHelper(problem.getAuxiliarySystem().system());
}

std::string
outputSystemInformationHelper(std::stringstream & oss, System & system)
{
  oss << std::left;

  if (system.n_dofs())
  {
    oss << std::setw(console_field_width) << "  Num DOFs: " << system.n_dofs() << '\n'
        << std::setw(console_field_width) << "  Num Local DOFs: " << system.n_local_dofs() << '\n';

    std::streampos begin_string_pos = oss.tellp();
    std::streampos curr_string_pos = begin_string_pos;
    oss << std::setw(console_field_width) << "  Variables: ";
    for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
    {
      const VariableGroup & vg_description(system.variable_group(vg));

      if (vg_description.n_variables() > 1)
        oss << "{ ";
      if (vg_description.n_variables() > 10)
      {
        // when the number of variables in this group is larger than 10, we only output the first
        // and the last 5 variable names
        for (unsigned int vn = 0; vn < 5; vn++)
        {
          oss << "\"" << vg_description.name(vn) << "\" ";
          curr_string_pos = oss.tellp();
          insertNewline(oss, begin_string_pos, curr_string_pos);
        }
        oss << "... ";
        curr_string_pos = oss.tellp();
        insertNewline(oss, begin_string_pos, curr_string_pos);
        for (unsigned int vn = vg_description.n_variables() - 5; vn < vg_description.n_variables();
             vn++)
        {
          oss << "\"" << vg_description.name(vn) << "\" ";
          curr_string_pos = oss.tellp();
          insertNewline(oss, begin_string_pos, curr_string_pos);
        }
      }
      else
        for (unsigned int vn = 0; vn < vg_description.n_variables(); vn++)
        {
          oss << "\"" << vg_description.name(vn) << "\" ";
          curr_string_pos = oss.tellp();
          insertNewline(oss, begin_string_pos, curr_string_pos);
        }

      if (vg_description.n_variables() > 1)
        oss << "} ";
    }
    oss << '\n';

    begin_string_pos = oss.tellp();
    curr_string_pos = begin_string_pos;
    oss << std::setw(console_field_width) << "  Finite Element Types: ";
#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
    for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
    {
      oss << "\""
          << libMesh::Utility::enum_to_string<FEFamily>(
                 system.get_dof_map().variable_group(vg).type().family)
          << "\" ";
      curr_string_pos = oss.tellp();
      insertNewline(oss, begin_string_pos, curr_string_pos);
    }
    oss << '\n';
#else
    for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
    {
      oss << "\""
          << libMesh::Utility::enum_to_string<FEFamily>(
                 system.get_dof_map().variable_group(vg).type().family)
          << "\", \""
          << libMesh::Utility::enum_to_string<FEFamily>(
                 system.get_dof_map().variable_group(vg).type().radial_family)
          << "\" ";
      curr_string_pos = oss.tellp();
      insertNewline(oss, begin_string_pos, curr_string_pos);
    }
    oss << '\n';

    begin_string_pos = oss.tellp();
    curr_string_pos = begin_string_pos;
    oss << std::setw(console_field_width) << "  Infinite Element Mapping: ";
    for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
    {
      oss << "\""
          << libMesh::Utility::enum_to_string<InfMapType>(
                 system.get_dof_map().variable_group(vg).type().inf_map)
          << "\" ";
      curr_string_pos = oss.tellp();
      insertNewline(oss, begin_string_pos, curr_string_pos);
    }
    oss << '\n';
#endif

    begin_string_pos = oss.tellp();
    curr_string_pos = begin_string_pos;
    oss << std::setw(console_field_width) << "  Approximation Orders: ";
    for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
    {
#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
      oss << "\""
          << Utility::enum_to_string<Order>(system.get_dof_map().variable_group(vg).type().order)
          << "\" ";
#else
      oss << "\""
          << Utility::enum_to_string<Order>(system.get_dof_map().variable_group(vg).type().order)
          << "\", \""
          << Utility::enum_to_string<Order>(
                 system.get_dof_map().variable_group(vg).type().radial_order)
          << "\" ";
#endif
      curr_string_pos = oss.tellp();
      insertNewline(oss, begin_string_pos, curr_string_pos);
    }
    oss << "\n\n";
  }

  return oss.str();
}

std::string
outputNonlinearSystemInformation(FEProblemBase & problem)
{
  std::stringstream oss;
  oss << std::left;

#ifndef MOOSE_SPARSE_AD
  if (problem.haveADObjects())
  {
    oss << std::setw(console_field_width)
        << "  AD size required: " << problem.getNonlinearSystemBase().requiredDerivativeSize()
        << "\n";
  }
#endif
  return outputSystemInformationHelper(oss, problem.getNonlinearSystemBase().system());
}

std::string
outputSystemInformationHelper(System & system)
{
  std::stringstream oss;

  return outputSystemInformationHelper(oss, system);
}

std::string
outputRelationshipManagerInformation(const MooseApp & app)
{
  std::stringstream oss;
  oss << std::left;

  auto info_strings = app.getRelationshipManagerInfo();
  if (info_strings.size())
  {
    for (const auto & info_pair : info_strings)
      oss << std::setw(console_field_width)
          << "  " + MooseUtils::underscoreToCamelCase(MooseUtils::toLower(info_pair.first), true) +
                 ":"
          << info_pair.second << '\n';
    oss << '\n';
  }

  return oss.str();
}

std::string
outputExecutionInformation(const MooseApp & app, FEProblemBase & problem)
{

  std::stringstream oss;
  oss << std::left;

  Executioner * exec = app.getExecutioner();

  oss << "Execution Information:\n"
      << std::setw(console_field_width) << "  Executioner: " << demangle(typeid(*exec).name())
      << '\n';

  std::string time_stepper = exec->getTimeStepperName();
  if (time_stepper != "")
    oss << std::setw(console_field_width) << "  TimeStepper: " << time_stepper << '\n';

  oss << std::setw(console_field_width)
      << "  Solver Mode: " << Moose::stringify(problem.solverParams()._type) << '\n';

  const std::string & pc_desc = problem.getPetscOptions().pc_description;
  if (!pc_desc.empty())
    oss << std::setw(console_field_width) << "  PETSc Preconditioner: " << pc_desc << '\n';

  MoosePreconditioner const * mpc = problem.getNonlinearSystemBase().getPreconditioner();
  if (mpc)
  {
    oss << std::setw(console_field_width)
        << "  MOOSE Preconditioner: " << mpc->getParam<std::string>("_type");
    if (mpc->name() == "_moose_auto")
      oss << " (auto)";
    oss << '\n';
  }
  oss << '\n';

  return oss.str();
}

std::string
outputOutputInformation(MooseApp & app)
{
  std::stringstream oss;
  oss << std::left;

  const std::vector<Output *> outputs = app.getOutputWarehouse().getOutputs<Output>();
  oss << "Outputs:\n";
  for (const auto & out : outputs)
  {
    // Display the "execute_on" settings
    const MultiMooseEnum & execute_on = out->executeOn();
    oss << "  " << std::setw(console_field_width - 2) << out->name() << "\"" << execute_on
        << "\"\n";

    // Display the advanced "execute_on" settings, only if they are different from "execute_on"
    if (out->isAdvanced())
    {
      const OutputOnWarehouse & adv_on = out->advancedExecuteOn();
      for (const auto & adv_it : adv_on)
        if (execute_on != adv_it.second)
          oss << "    " << std::setw(console_field_width - 4) << adv_it.first + ":"
              << "\"" << adv_it.second << "\"\n";
    }
  }

  return oss.str();
}

std::string
outputLegacyInformation(MooseApp & app)
{
  std::stringstream oss;
  oss << std::left;

  if (app.parameters().get<bool>("use_legacy_material_output"))
  {
    oss << COLOR_RED << "LEGACY MODES ENABLED:" << COLOR_DEFAULT << '\n';
    oss << " This application uses the legacy material output option: material properties are "
           "output only on TIMESTEP_END, not INITIAL. To remove this message, set "
           "'use_legacy_material_output' to false in this application. If there are gold output "
           "files that contain material property output for which output occurs on INITIAL, then "
           "these will generate diffs due to zero values being stored, and these tests should be "
           "re-golded.\n"
        << COLOR_DEFAULT << '\n';
  }

  return oss.str();
}

void
insertNewline(std::stringstream & oss, std::streampos & begin, std::streampos & curr)
{
  if (curr - begin > console_line_length)
  {
    oss << "\n";
    begin = oss.tellp();
    oss << std::setw(console_field_width + 2) << ""; // "{ "
  }
}

} // ConsoleUtils namespace
<|endoftext|>


<commit_before>#include "BindIndexInfo.h"
#include "Voxelization.h"
#include "Object.h"
#include "ResourceManager.h"
#include "EngineShaderFactory.hpp"

#include "MeshCamera.h"

using namespace Resource;
using namespace Core;
using namespace Math;
using namespace Rendering::Buffer;
using namespace Rendering::GI;
using namespace Rendering::Texture;
using namespace Rendering::Camera;
using namespace Rendering::Shader;
using namespace Rendering::Manager;
using namespace Rendering::View;
using namespace GPGPU::DirectCompute;

Voxelization::Voxelization()
:	_clearVoxelMapCS(nullptr),
	_voxelAlbedoMapAtlas(nullptr), _voxelNormalMapAtlas(nullptr), _voxelEmissionMapAtlas(nullptr)
{
}

Voxelization::~Voxelization()
{
	Destroy();

	SAFE_DELETE(_voxelAlbedoMapAtlas);
	SAFE_DELETE(_voxelNormalMapAtlas);
	SAFE_DELETE(_voxelEmissionMapAtlas);

	for(auto iter = _constBuffers.begin(); iter != _constBuffers.end(); ++iter)
		SAFE_DELETE(*iter);
	_constBuffers.clear();

	SAFE_DELETE(_clearVoxelMapCS);
}

void Voxelization::Initialize(const GlobalInfo& globalInfo)
{
	uint maxNumOfCascade = globalInfo.maxNumOfCascade;
	ASSERT_COND_MSG(maxNumOfCascade != 0, "Error, voxelization cascade num is zero.");

	auto Log2 = [](float v) -> float
	{
		return log(v) / log(2.0f);
	};

#if defined(USE_ANISOTROPIC_VOXELIZATION)
	bool isAnisotropic = true;
#else
	bool isAnisotropic = false;
#endif

	uint dimension = 1 << globalInfo.voxelDimensionPow2;

	_voxelAlbedoMapAtlas = new AnisotropicVoxelMapAtlas;
	_voxelAlbedoMapAtlas->Initialize(dimension, maxNumOfCascade, DXGI_FORMAT_R8G8B8A8_TYPELESS, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R32_UINT, 1, isAnisotropic);

	_voxelNormalMapAtlas = new AnisotropicVoxelMapAtlas;
	_voxelNormalMapAtlas->Initialize(dimension, maxNumOfCascade, DXGI_FORMAT_R32_TYPELESS, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_UINT, 1, isAnisotropic);

	_voxelEmissionMapAtlas = new AnisotropicVoxelMapAtlas;
	_voxelEmissionMapAtlas->Initialize(dimension, maxNumOfCascade, DXGI_FORMAT_R8G8B8A8_TYPELESS, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R32_UINT, 1, isAnisotropic);

	// Setting Const Buffers
	{
		for(uint i=0; i<maxNumOfCascade; ++i)
		{
			ConstBuffer* infoConstBuffer = new ConstBuffer;
			infoConstBuffer->Initialize(sizeof(InfoCBData));

			_constBuffers.push_back(infoConstBuffer);
		}

//		_renderInputCBContainer.push_back( ShaderForm::InputConstBuffer(uint(ConstBufferBindIndex::Voxelization_InfoCB), nullptr, false, true, false, true) );
	}

	InitializeClearVoxelMap(dimension, maxNumOfCascade);
}

void Voxelization::InitializeClearVoxelMap(uint dimension, uint maxNumOfCascade)
{
	std::string filePath = "";
	{
		Factory::EngineFactory pathFind(nullptr);
		pathFind.FetchShaderFullPath(filePath, "ClearVoxelMaps");

		ASSERT_COND_MSG(filePath.empty() == false, "Error, File path is empty");
	}

	ShaderManager* shaderMgr = ResourceManager::SharedInstance()->GetShaderManager();
	ID3DBlob* blob = shaderMgr->CreateBlob(filePath, "cs", "ClearVoxelMapCS", false, nullptr);

	ComputeShader::ThreadGroup threadGroup;
	{
		auto ComputeThreadGroupSideLength = [](uint sideLength)
		{
			return (uint)((float)(sideLength + 8 - 1) / 8.0f);
		};
#if defined(USE_ANISOTROPIC_VOXELIZATION)
		threadGroup.x = ComputeThreadGroupSideLength(dimension) * (uint)AnisotropicVoxelMapAtlas::Direction::Num;
#else
		threadGroup.x = ComputeThreadGroupSideLength(dimension);
#endif
		threadGroup.y = ComputeThreadGroupSideLength(dimension * maxNumOfCascade);
		threadGroup.z = ComputeThreadGroupSideLength(dimension);
	}

	_clearVoxelMapCS = new ComputeShader(threadGroup, blob);
	ASSERT_COND_MSG(_clearVoxelMapCS->Initialize(), "Error, Can't Init ClearVoxelMapCS");

	std::vector<ShaderForm::InputUnorderedAccessView> uavs;
	{
		ShaderForm::InputUnorderedAccessView uav;
		uav.bindIndex	= (uint)UAVBindIndex::VoxelMap_Albedo;
		uav.uav			= _voxelAlbedoMapAtlas->GetSourceMapUAV();
		uavs.push_back(uav);

		uav.bindIndex	= (uint)UAVBindIndex::VoxelMap_Normal;
		uav.uav			= _voxelNormalMapAtlas->GetSourceMapUAV();
		uavs.push_back(uav);

		uav.bindIndex	= (uint)UAVBindIndex::VoxelMap_Emission;
		uav.uav			= _voxelEmissionMapAtlas->GetSourceMapUAV();
		uavs.push_back(uav);
	}

	_clearVoxelMapCS->SetUAVs(uavs);
}

void Voxelization::Destroy()
{
	_voxelAlbedoMapAtlas->Destory();
	_voxelNormalMapAtlas->Destory();
	_voxelEmissionMapAtlas->Destory();

	for(auto iter = _constBuffers.begin(); iter != _constBuffers.end(); ++iter)
		(*iter)->Destory();

	_constBuffers.clear();
}

void Voxelization::ClearZeroVoxelMap(const Device::DirectX*& dx)
{
	_clearVoxelMapCS->Dispatch(dx->GetContext());
}

void Voxelization::Voxelize(const Device::DirectX*& dx,
							const MeshCamera*& camera, const RenderManager*& renderManager,
							const GlobalInfo& globalInfo,
							bool onlyStaticMesh)
{
	Math::Matrix camWorldMat;
	{
		const Transform* camTf = camera->GetOwner()->GetTransform();
		camTf->FetchWorldMatrix(camWorldMat);
	}

	if(onlyStaticMesh)
	{
		Matrix viewMat;
		CameraForm::GetViewMatrix(viewMat, camWorldMat);

		bool isDifferentViewMat = memcmp(&_prevStaticMeshVoxelizeViewMat, &viewMat, sizeof(Matrix)) != 0;
		if(isDifferentViewMat == false)
			return;

		_prevStaticMeshVoxelizeViewMat = viewMat;
	}

	ClearZeroVoxelMap(dx);
	Vector3 camWorldPos(camWorldMat._41, camWorldMat._42, camWorldMat._43);

	ID3D11DeviceContext* context = dx->GetContext();

	context->RSSetState(dx->GetRasterizerStateCWDisableCullingWithClip());
	context->OMSetDepthStencilState(dx->GetDepthStateLessEqual(), 0x00);

	float blendFactor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
	context->OMSetBlendState(dx->GetBlendStateOpaque(), blendFactor, 0xffffffff);

	float dimension = float(1 << globalInfo.voxelDimensionPow2);

	D3D11_VIEWPORT viewport;
	{
		viewport.TopLeftX	= 0.0f;
		viewport.TopLeftY	= 0.0f;
		viewport.MinDepth	= 0.0f;
		viewport.MaxDepth	= 1.0f;
		viewport.Width		= dimension;
		viewport.Height		= dimension;
	}
	context->RSSetViewports(1, &viewport);

	ID3D11SamplerState* samplerState = dx->GetSamplerStateAnisotropic();
	context->PSSetSamplers((uint)SamplerStateBindIndex::DefaultSamplerState, 1, &samplerState);

	ID3D11UnorderedAccessView* uavs [] =
	{
		_voxelAlbedoMapAtlas->GetSourceMapUAV()->GetView(),
		_voxelNormalMapAtlas->GetSourceMapUAV()->GetView(),
		_voxelEmissionMapAtlas->GetSourceMapUAV()->GetView()
	};

	float clearColor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
	context->ClearRenderTargetView(_voxelAlbedoMapAtlas->GetRenderTargetView(), clearColor);
	context->ClearRenderTargetView(_voxelNormalMapAtlas->GetRenderTargetView(), clearColor);
	context->ClearRenderTargetView(_voxelEmissionMapAtlas->GetRenderTargetView(), clearColor);

	context->OMSetRenderTargetsAndUnorderedAccessViews(0, nullptr, nullptr, 0, ARRAYSIZE(uavs), uavs, nullptr);

	uint maxCascade = globalInfo.maxNumOfCascade;
	for(uint currentCascade=0; currentCascade<maxCascade; ++currentCascade)
	{
		UpdateConstBuffer(dx, currentCascade, camWorldPos, globalInfo, dimension);

		// Render Voxel
		{
			ID3D11Buffer* buf = _constBuffers[currentCascade]->GetBuffer();
			context->GSSetConstantBuffers(uint(ConstBufferBindIndex::Voxelization_InfoCB), 1, &buf);
			context->PSSetConstantBuffers(uint(ConstBufferBindIndex::Voxelization_InfoCB), 1, &buf);

			const auto& opaqueMeshes = renderManager->GetOpaqueMeshes();
			MeshCamera::RenderMeshesUsingSortedMeshVectorByVB(dx, renderManager, opaqueMeshes, RenderType::Voxelization, nullptr);

			const auto& alphaTestMeshes = renderManager->GetAlphaTestMeshes();
			MeshCamera::RenderMeshesUsingSortedMeshVectorByVB(dx, renderManager, alphaTestMeshes, RenderType::Voxelization, nullptr);
		}
	}

	ID3D11Buffer* nullBuff = nullptr;
	context->GSSetConstantBuffers(uint(ConstBufferBindIndex::Voxelization_InfoCB), 1, &nullBuff);
	context->PSSetConstantBuffers(uint(ConstBufferBindIndex::Voxelization_InfoCB), 1, &nullBuff);

	ID3D11UnorderedAccessView* nullUAVs[] = {nullptr, nullptr, nullptr};
	context->OMSetRenderTargetsAndUnorderedAccessViews(0, nullptr, nullptr, 0, ARRAYSIZE(nullUAVs), nullUAVs, nullptr);

	ID3D11SamplerState* nullSampler = nullptr;
	context->PSSetSamplers((uint)SamplerStateBindIndex::DefaultSamplerState, 1, &nullSampler);

	context->RSSetState(nullptr);
}

void Voxelization::UpdateConstBuffer(const Device::DirectX*& dx, uint currentCascade,
									 const Vector3& camWorldPos, const GlobalInfo& globalInfo, float dimension)
{
	// Compute Voxelize Bound
	float worldSize;
	Vector3 bbMin, bbMax, bbMid;
	ComputeBound(&bbMin, &bbMid, &bbMax, &worldSize, currentCascade, camWorldPos, globalInfo.initWorldSize);

	InfoCBData currentVoxelizeInfo;
	currentVoxelizeInfo.currentCascade	= currentCascade;
	currentVoxelizeInfo.voxelizeMinPos	= bbMin;

	// Update View Proj ConstBuffer
	{
		Matrix voxelView;
		ComputeVoxelViewMatrix(voxelView, currentCascade, camWorldPos, globalInfo.initWorldSize);

		Matrix projMat;
		Matrix::OrthoLH(projMat, 2.0f, 2.0f, 1.0f, -1.0f);

		currentVoxelizeInfo.voxelView		= voxelView;
		currentVoxelizeInfo.voxelViewProj	= voxelView * projMat;
	}

	_constBuffers[currentCascade]->UpdateSubResource(dx->GetContext(), &currentVoxelizeInfo);
}

void Voxelization::ComputeVoxelViewMatrix(	Math::Matrix& outMat, uint currentCascade,
											const Math::Vector3& camWorldPos, float initVoxelizeSize)
{
	memset(&outMat, 0, sizeof(Math::Matrix));

	float worldSize = 0.0f;
	Vector3 centerPos;
	ComputeBound(nullptr, &centerPos, nullptr, &worldSize, currentCascade, camWorldPos, initVoxelizeSize);

	ASSERT_COND_MSG(worldSize != 0.0f, "Error, Voxelize Size is zero");

	outMat._11 = 2.0f / worldSize;
	outMat._22 = 2.0f / worldSize;
	outMat._33 = 2.0f / worldSize;

	outMat._41 = camWorldPos.x;
	outMat._42 = camWorldPos.y;
	outMat._43 = camWorldPos.z;
	outMat._44 = 1.0f;
}

void Voxelization::ComputeBound(
	Vector3* outMin, Vector3* outMid, Vector3* outMax, float* outWorldSize,
	uint currentCascade, const Vector3& camWorldPos, float initVoxelizeSize)
{
	float worldSize		= initVoxelizeSize * ( (float)( (currentCascade + 1) * (currentCascade + 1) ) );
	float halfWorldSize	= worldSize / 2.0f;

	Vector3 bbMin = camWorldPos - Vector3(halfWorldSize, halfWorldSize, halfWorldSize);
	Vector3 bbMax = bbMin + Vector3(worldSize, worldSize, worldSize);
	Vector3 bbMid = (bbMin + bbMax) / 2.0f;

	if(outMin)			(*outMin) = bbMin;
	if(outMid)			(*outMid) = bbMid;
	if(outMax)			(*outMax) = bbMax;
	if(outWorldSize)	(*outWorldSize) = worldSize;
}<commit_msg>Voxelization - USE_ANISOTROPIC_VOXELIZATION 사용이라면 voxelNormalMapAtlas 의 포맷을 r32가 아닌 r8g8b8a8을 사용<commit_after>#include "BindIndexInfo.h"
#include "Voxelization.h"
#include "Object.h"
#include "ResourceManager.h"
#include "EngineShaderFactory.hpp"

#include "MeshCamera.h"

using namespace Resource;
using namespace Core;
using namespace Math;
using namespace Rendering::Buffer;
using namespace Rendering::GI;
using namespace Rendering::Texture;
using namespace Rendering::Camera;
using namespace Rendering::Shader;
using namespace Rendering::Manager;
using namespace Rendering::View;
using namespace GPGPU::DirectCompute;

Voxelization::Voxelization()
:	_clearVoxelMapCS(nullptr),
	_voxelAlbedoMapAtlas(nullptr), _voxelNormalMapAtlas(nullptr), _voxelEmissionMapAtlas(nullptr)
{
}

Voxelization::~Voxelization()
{
	Destroy();

	SAFE_DELETE(_voxelAlbedoMapAtlas);
	SAFE_DELETE(_voxelNormalMapAtlas);
	SAFE_DELETE(_voxelEmissionMapAtlas);

	for(auto iter = _constBuffers.begin(); iter != _constBuffers.end(); ++iter)
		SAFE_DELETE(*iter);
	_constBuffers.clear();

	SAFE_DELETE(_clearVoxelMapCS);
}

void Voxelization::Initialize(const GlobalInfo& globalInfo)
{
	uint maxNumOfCascade = globalInfo.maxNumOfCascade;
	ASSERT_COND_MSG(maxNumOfCascade != 0, "Error, voxelization cascade num is zero.");

	auto Log2 = [](float v) -> float
	{
		return log(v) / log(2.0f);
	};

#if defined(USE_ANISOTROPIC_VOXELIZATION)
	bool isAnisotropic = true;
#else
	bool isAnisotropic = false;
#endif

	uint dimension = 1 << globalInfo.voxelDimensionPow2;

	_voxelAlbedoMapAtlas = new AnisotropicVoxelMapAtlas;
	_voxelAlbedoMapAtlas->Initialize(dimension, maxNumOfCascade, DXGI_FORMAT_R8G8B8A8_TYPELESS, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R32_UINT, 1, isAnisotropic);

	_voxelNormalMapAtlas = new AnisotropicVoxelMapAtlas;
#if defined(USE_ANISOTROPIC_VOXELIZATION)
	_voxelNormalMapAtlas->Initialize(dimension, maxNumOfCascade, DXGI_FORMAT_R32_TYPELESS, DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32_UINT, 1, isAnisotropic);
#else
	_voxelNormalMapAtlas->Initialize(dimension, maxNumOfCascade, DXGI_FORMAT_R8G8B8A8_TYPELESS, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R32_UINT, 1, isAnisotropic);
#endif
	_voxelEmissionMapAtlas = new AnisotropicVoxelMapAtlas;
	_voxelEmissionMapAtlas->Initialize(dimension, maxNumOfCascade, DXGI_FORMAT_R8G8B8A8_TYPELESS, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R32_UINT, 1, isAnisotropic);

	// Setting Const Buffers
	{
		for(uint i=0; i<maxNumOfCascade; ++i)
		{
			ConstBuffer* infoConstBuffer = new ConstBuffer;
			infoConstBuffer->Initialize(sizeof(InfoCBData));

			_constBuffers.push_back(infoConstBuffer);
		}

//		_renderInputCBContainer.push_back( ShaderForm::InputConstBuffer(uint(ConstBufferBindIndex::Voxelization_InfoCB), nullptr, false, true, false, true) );
	}

	InitializeClearVoxelMap(dimension, maxNumOfCascade);
}

void Voxelization::InitializeClearVoxelMap(uint dimension, uint maxNumOfCascade)
{
	std::string filePath = "";
	{
		Factory::EngineFactory pathFind(nullptr);
		pathFind.FetchShaderFullPath(filePath, "ClearVoxelMaps");

		ASSERT_COND_MSG(filePath.empty() == false, "Error, File path is empty");
	}

	ShaderManager* shaderMgr = ResourceManager::SharedInstance()->GetShaderManager();
	ID3DBlob* blob = shaderMgr->CreateBlob(filePath, "cs", "ClearVoxelMapCS", false, nullptr);

	ComputeShader::ThreadGroup threadGroup;
	{
		auto ComputeThreadGroupSideLength = [](uint sideLength)
		{
			return (uint)((float)(sideLength + 8 - 1) / 8.0f);
		};
#if defined(USE_ANISOTROPIC_VOXELIZATION)
		threadGroup.x = ComputeThreadGroupSideLength(dimension) * (uint)AnisotropicVoxelMapAtlas::Direction::Num;
#else
		threadGroup.x = ComputeThreadGroupSideLength(dimension);
#endif
		threadGroup.y = ComputeThreadGroupSideLength(dimension * maxNumOfCascade);
		threadGroup.z = ComputeThreadGroupSideLength(dimension);
	}

	_clearVoxelMapCS = new ComputeShader(threadGroup, blob);
	ASSERT_COND_MSG(_clearVoxelMapCS->Initialize(), "Error, Can't Init ClearVoxelMapCS");

	std::vector<ShaderForm::InputUnorderedAccessView> uavs;
	{
		ShaderForm::InputUnorderedAccessView uav;
		uav.bindIndex	= (uint)UAVBindIndex::VoxelMap_Albedo;
		uav.uav			= _voxelAlbedoMapAtlas->GetSourceMapUAV();
		uavs.push_back(uav);

		uav.bindIndex	= (uint)UAVBindIndex::VoxelMap_Normal;
		uav.uav			= _voxelNormalMapAtlas->GetSourceMapUAV();
		uavs.push_back(uav);

		uav.bindIndex	= (uint)UAVBindIndex::VoxelMap_Emission;
		uav.uav			= _voxelEmissionMapAtlas->GetSourceMapUAV();
		uavs.push_back(uav);
	}

	_clearVoxelMapCS->SetUAVs(uavs);
}

void Voxelization::Destroy()
{
	_voxelAlbedoMapAtlas->Destory();
	_voxelNormalMapAtlas->Destory();
	_voxelEmissionMapAtlas->Destory();

	for(auto iter = _constBuffers.begin(); iter != _constBuffers.end(); ++iter)
		(*iter)->Destory();

	_constBuffers.clear();
}

void Voxelization::ClearZeroVoxelMap(const Device::DirectX*& dx)
{
	_clearVoxelMapCS->Dispatch(dx->GetContext());
}

void Voxelization::Voxelize(const Device::DirectX*& dx,
							const MeshCamera*& camera, const RenderManager*& renderManager,
							const GlobalInfo& globalInfo,
							bool onlyStaticMesh)
{
	Math::Matrix camWorldMat;
	{
		const Transform* camTf = camera->GetOwner()->GetTransform();
		camTf->FetchWorldMatrix(camWorldMat);
	}

	if(onlyStaticMesh)
	{
		Matrix viewMat;
		CameraForm::GetViewMatrix(viewMat, camWorldMat);

		bool isDifferentViewMat = memcmp(&_prevStaticMeshVoxelizeViewMat, &viewMat, sizeof(Matrix)) != 0;
		if(isDifferentViewMat == false)
			return;

		_prevStaticMeshVoxelizeViewMat = viewMat;
	}

	ClearZeroVoxelMap(dx);
	Vector3 camWorldPos(camWorldMat._41, camWorldMat._42, camWorldMat._43);

	ID3D11DeviceContext* context = dx->GetContext();

	context->RSSetState(dx->GetRasterizerStateCWDisableCullingWithClip());
	context->OMSetDepthStencilState(dx->GetDepthStateLessEqual(), 0x00);

	float blendFactor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
	context->OMSetBlendState(dx->GetBlendStateOpaque(), blendFactor, 0xffffffff);

	float dimension = float(1 << globalInfo.voxelDimensionPow2);

	D3D11_VIEWPORT viewport;
	{
		viewport.TopLeftX	= 0.0f;
		viewport.TopLeftY	= 0.0f;
		viewport.MinDepth	= 0.0f;
		viewport.MaxDepth	= 1.0f;
		viewport.Width		= dimension;
		viewport.Height		= dimension;
	}
	context->RSSetViewports(1, &viewport);

	ID3D11SamplerState* samplerState = dx->GetSamplerStateAnisotropic();
	context->PSSetSamplers((uint)SamplerStateBindIndex::DefaultSamplerState, 1, &samplerState);

	ID3D11UnorderedAccessView* uavs [] =
	{
		_voxelAlbedoMapAtlas->GetSourceMapUAV()->GetView(),
		_voxelNormalMapAtlas->GetSourceMapUAV()->GetView(),
		_voxelEmissionMapAtlas->GetSourceMapUAV()->GetView()
	};

	float clearColor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
	context->ClearRenderTargetView(_voxelAlbedoMapAtlas->GetRenderTargetView(), clearColor);
	context->ClearRenderTargetView(_voxelNormalMapAtlas->GetRenderTargetView(), clearColor);
	context->ClearRenderTargetView(_voxelEmissionMapAtlas->GetRenderTargetView(), clearColor);

	context->OMSetRenderTargetsAndUnorderedAccessViews(0, nullptr, nullptr, 0, ARRAYSIZE(uavs), uavs, nullptr);

	uint maxCascade = globalInfo.maxNumOfCascade;
	for(uint currentCascade=0; currentCascade<maxCascade; ++currentCascade)
	{
		UpdateConstBuffer(dx, currentCascade, camWorldPos, globalInfo, dimension);

		// Render Voxel
		{
			ID3D11Buffer* buf = _constBuffers[currentCascade]->GetBuffer();
			context->GSSetConstantBuffers(uint(ConstBufferBindIndex::Voxelization_InfoCB), 1, &buf);
			context->PSSetConstantBuffers(uint(ConstBufferBindIndex::Voxelization_InfoCB), 1, &buf);

			const auto& opaqueMeshes = renderManager->GetOpaqueMeshes();
			MeshCamera::RenderMeshesUsingSortedMeshVectorByVB(dx, renderManager, opaqueMeshes, RenderType::Voxelization, nullptr);

			const auto& alphaTestMeshes = renderManager->GetAlphaTestMeshes();
			MeshCamera::RenderMeshesUsingSortedMeshVectorByVB(dx, renderManager, alphaTestMeshes, RenderType::Voxelization, nullptr);
		}
	}

	ID3D11Buffer* nullBuff = nullptr;
	context->GSSetConstantBuffers(uint(ConstBufferBindIndex::Voxelization_InfoCB), 1, &nullBuff);
	context->PSSetConstantBuffers(uint(ConstBufferBindIndex::Voxelization_InfoCB), 1, &nullBuff);

	ID3D11UnorderedAccessView* nullUAVs[] = {nullptr, nullptr, nullptr};
	context->OMSetRenderTargetsAndUnorderedAccessViews(0, nullptr, nullptr, 0, ARRAYSIZE(nullUAVs), nullUAVs, nullptr);

	ID3D11SamplerState* nullSampler = nullptr;
	context->PSSetSamplers((uint)SamplerStateBindIndex::DefaultSamplerState, 1, &nullSampler);

	context->RSSetState(nullptr);
}

void Voxelization::UpdateConstBuffer(const Device::DirectX*& dx, uint currentCascade,
									 const Vector3& camWorldPos, const GlobalInfo& globalInfo, float dimension)
{
	// Compute Voxelize Bound
	float worldSize;
	Vector3 bbMin, bbMax, bbMid;
	ComputeBound(&bbMin, &bbMid, &bbMax, &worldSize, currentCascade, camWorldPos, globalInfo.initWorldSize);

	InfoCBData currentVoxelizeInfo;
	currentVoxelizeInfo.currentCascade	= currentCascade;
	currentVoxelizeInfo.voxelizeMinPos	= bbMin;

	// Update View Proj ConstBuffer
	{
		Matrix voxelView;
		ComputeVoxelViewMatrix(voxelView, currentCascade, camWorldPos, globalInfo.initWorldSize);

		Matrix projMat;
		Matrix::OrthoLH(projMat, 2.0f, 2.0f, 1.0f, -1.0f);

		currentVoxelizeInfo.voxelView		= voxelView;
		currentVoxelizeInfo.voxelViewProj	= voxelView * projMat;
	}

	_constBuffers[currentCascade]->UpdateSubResource(dx->GetContext(), &currentVoxelizeInfo);
}

void Voxelization::ComputeVoxelViewMatrix(	Math::Matrix& outMat, uint currentCascade,
											const Math::Vector3& camWorldPos, float initVoxelizeSize)
{
	memset(&outMat, 0, sizeof(Math::Matrix));

	float worldSize = 0.0f;
	Vector3 centerPos;
	ComputeBound(nullptr, &centerPos, nullptr, &worldSize, currentCascade, camWorldPos, initVoxelizeSize);

	ASSERT_COND_MSG(worldSize != 0.0f, "Error, Voxelize Size is zero");

	outMat._11 = 2.0f / worldSize;
	outMat._22 = 2.0f / worldSize;
	outMat._33 = 2.0f / worldSize;

	outMat._41 = camWorldPos.x;
	outMat._42 = camWorldPos.y;
	outMat._43 = camWorldPos.z;
	outMat._44 = 1.0f;
}

void Voxelization::ComputeBound(
	Vector3* outMin, Vector3* outMid, Vector3* outMax, float* outWorldSize,
	uint currentCascade, const Vector3& camWorldPos, float initVoxelizeSize)
{
	float worldSize		= initVoxelizeSize * ( (float)( (currentCascade + 1) * (currentCascade + 1) ) );
	float halfWorldSize	= worldSize / 2.0f;

	Vector3 bbMin = camWorldPos - Vector3(halfWorldSize, halfWorldSize, halfWorldSize);
	Vector3 bbMax = bbMin + Vector3(worldSize, worldSize, worldSize);
	Vector3 bbMid = (bbMin + bbMax) / 2.0f;

	if(outMin)			(*outMin) = bbMin;
	if(outMid)			(*outMid) = bbMid;
	if(outMax)			(*outMax) = bbMax;
	if(outWorldSize)	(*outWorldSize) = worldSize;
}<|endoftext|>


<commit_before>#include "redisclient.h"
#include "redisreader.h"
#include "redismodule.h"

FxRedisClient::FxRedisClient()
{
    __Reset();
	sprintf(m_szLogPath, "./%s_%p_log.txt", GetExeName(), this);
}

FxRedisClient::~FxRedisClient()
{
	if(m_poMySqlConn != NULL)
    {
		delete m_poMySqlConn;
        m_poMySqlConn = NULL;
    }
}

void FxRedisClient::__Reset()
{
    m_bTerminate		= false;
    m_poMySqlConn		= NULL;
    m_nLastReconnectTime= 0;
    m_bDbOK				= false;
    m_poThrdHandler		= NULL;
}

bool FxRedisClient::Start()
{
	FxCreateThreadHandler(this, true, m_poThrdHandler);
	if(NULL == m_poThrdHandler)
	{
		ThreadLog(LogLv_Error, m_pFile, m_szLogPath, "%s", "FxCreateThreadHandler failed");
        return false;
	}

	return true;
}

void FxRedisClient::Stop()
{
    m_bTerminate = true;
//     m_poThrdHandler->Stop();
	if(m_poThrdHandler != NULL)
	{
		m_poThrdHandler->WaitFor(FX_INFINITE);
		m_poThrdHandler->Release();
		m_poThrdHandler = NULL;
	}
}

bool FxRedisClient::ConnectRedis(const std::string& szHost, unsigned int dwPort)
{
	m_poMySqlConn = new FxRedisConnection;
	if(NULL == m_poMySqlConn)
	{
		LogExe(LogLv_Error, "%s", "new FxRedisConnection failed");
		return false;
	}

	if(!m_poMySqlConn->Connect(szHost, dwPort))
	{
		LogExe(LogLv_Error, "Connect to redis %s:%d error", szHost.c_str(), dwPort);
		return false;
	}

	m_bDbOK = true;

	return true;
}

bool FxRedisClient::AddQuery(IRedisQuery *poDBCommand)
{
	m_oLock.Lock();
	m_oQuerys.push_back(poDBCommand);
	m_oLock.UnLock();

	return true;
}

INT32 FxRedisClient::Query(const char* pszSQL)
{
	if (false == m_bDbOK)
	{
		return -1;
	}

	return m_poMySqlConn->Query(pszSQL);
}

INT32 FxRedisClient::Query(const char* pszSQL, IRedisDataReader **ppReader)
{
    if (NULL != *ppReader)
    {
        return -1;
    }

    if (false == m_bDbOK)
    {
        *ppReader = NULL;
        return -1;
    }

    FxRedisReader* poReader = FxRedisModule::Instance()->FetchReader();
    if (NULL == poReader)
    {
        return -1;
    }
    *ppReader = poReader;

	INT32 nRetCode = m_poMySqlConn->Query( pszSQL, *poReader);

	if(-1 == nRetCode)
	{
		m_bDbOK = false;
	}

	return nRetCode;
}

void FxRedisClient::ThrdFunc()
{
	while(!m_bTerminate)
	{
		if(m_bDbOK)
		{
            if (!__DoQuery())
            {
                FxSleep(1);
            }
		}
		else
		{
			//每30秒重联一次
			time_t nNow = GetTimeHandler()->GetSecond();
			if(nNow - m_nLastReconnectTime > 10)
			{
				if(m_poMySqlConn->ReConnect())
				{
					m_bDbOK = true;
				}

				m_nLastReconnectTime = nNow;
			}
			else
			{
				__ClearQuery();
				FxSleep(1);
			}
		}
	}

	//退出前确保所有的请求都已执行完
	__ClearQuery();

	m_poMySqlConn->Close();
	m_bDbOK = false;
}

void FxRedisClient::__ClearQuery()
{
    while(__DoQuery()) {}
}

bool FxRedisClient::__DoQuery( void )
{
	IRedisQuery *poQuery = NULL;
    m_oLock.Lock();
    if(m_oQuerys.empty())
    {
        m_oLock.UnLock();
        return false;
    }

    poQuery = m_oQuerys.front();
    m_oQuerys.pop_front();

    m_oLock.UnLock();

    if(poQuery == NULL)
        return false;

    poQuery->OnQuery(this);
    FxRedisModule::Instance()->AddResult(poQuery);
    return true;
}

<commit_msg>参数名<commit_after>#include "redisclient.h"
#include "redisreader.h"
#include "redismodule.h"

FxRedisClient::FxRedisClient()
{
    __Reset();
	sprintf(m_szLogPath, "./%s_%p_log.txt", GetExeName(), this);
}

FxRedisClient::~FxRedisClient()
{
	if(m_poMySqlConn != NULL)
    {
		delete m_poMySqlConn;
        m_poMySqlConn = NULL;
    }
}

void FxRedisClient::__Reset()
{
    m_bTerminate		= false;
    m_poMySqlConn		= NULL;
    m_nLastReconnectTime= 0;
    m_bDbOK				= false;
    m_poThrdHandler		= NULL;
}

bool FxRedisClient::Start()
{
	FxCreateThreadHandler(this, true, m_poThrdHandler);
	if(NULL == m_poThrdHandler)
	{
		ThreadLog(LogLv_Error, m_pFile, m_szLogPath, "%s", "FxCreateThreadHandler failed");
        return false;
	}

	return true;
}

void FxRedisClient::Stop()
{
    m_bTerminate = true;
//     m_poThrdHandler->Stop();
	if(m_poThrdHandler != NULL)
	{
		m_poThrdHandler->WaitFor(FX_INFINITE);
		m_poThrdHandler->Release();
		m_poThrdHandler = NULL;
	}
}

bool FxRedisClient::ConnectRedis(const std::string& szHost, unsigned int dwPort)
{
	m_poMySqlConn = new FxRedisConnection;
	if(NULL == m_poMySqlConn)
	{
		LogExe(LogLv_Error, "%s", "new FxRedisConnection failed");
		return false;
	}

	if(!m_poMySqlConn->Connect(szHost, dwPort))
	{
		LogExe(LogLv_Error, "Connect to redis %s:%d error", szHost.c_str(), dwPort);
		return false;
	}

	m_bDbOK = true;

	return true;
}

bool FxRedisClient::AddQuery(IRedisQuery *poDBCommand)
{
	m_oLock.Lock();
	m_oQuerys.push_back(poDBCommand);
	m_oLock.UnLock();

	return true;
}

INT32 FxRedisClient::Query(const char* pszCMD)
{
	if (false == m_bDbOK)
	{
		return -1;
	}

	return m_poMySqlConn->Query(pszCMD);
}

INT32 FxRedisClient::Query(const char* pszCMD, IRedisDataReader **ppReader)
{
    if (NULL != *ppReader)
    {
        return -1;
    }

    if (false == m_bDbOK)
    {
        *ppReader = NULL;
        return -1;
    }

    FxRedisReader* poReader = FxRedisModule::Instance()->FetchReader();
    if (NULL == poReader)
    {
        return -1;
    }
    *ppReader = poReader;

	INT32 nRetCode = m_poMySqlConn->Query( pszCMD, *poReader);

	if(-1 == nRetCode)
	{
		m_bDbOK = false;
	}

	return nRetCode;
}

void FxRedisClient::ThrdFunc()
{
	while(!m_bTerminate)
	{
		if(m_bDbOK)
		{
            if (!__DoQuery())
            {
                FxSleep(1);
            }
		}
		else
		{
			//每30秒重联一次
			time_t nNow = GetTimeHandler()->GetSecond();
			if(nNow - m_nLastReconnectTime > 10)
			{
				if(m_poMySqlConn->ReConnect())
				{
					m_bDbOK = true;
				}

				m_nLastReconnectTime = nNow;
			}
			else
			{
				__ClearQuery();
				FxSleep(1);
			}
		}
	}

	//退出前确保所有的请求都已执行完
	__ClearQuery();

	m_poMySqlConn->Close();
	m_bDbOK = false;
}

void FxRedisClient::__ClearQuery()
{
    while(__DoQuery()) {}
}

bool FxRedisClient::__DoQuery( void )
{
	IRedisQuery *poQuery = NULL;
    m_oLock.Lock();
    if(m_oQuerys.empty())
    {
        m_oLock.UnLock();
        return false;
    }

    poQuery = m_oQuerys.front();
    m_oQuerys.pop_front();

    m_oLock.UnLock();

    if(poQuery == NULL)
        return false;

    poQuery->OnQuery(this);
    FxRedisModule::Instance()->AddResult(poQuery);
    return true;
}

<|endoftext|>


<commit_before>#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TChain.h>
#include <TSystem.h>
#include "AliAnalysisManager.h"
#include "AliESDInputHandler.h"
#include "AliAODHandler.h"
#include "AliAnalysisTaskESDfilter.h"
#include "AliAnalysisDataContainer.h"
#endif

void CreateAODfromESD(const char *inFileName = "AliESDs.root",
		      const char *outFileName = "AliAOD.root",
		      Bool_t bKineFilter = kTRUE)
{

    gSystem->Load("libTree");
    gSystem->Load("libGeom");
    gSystem->Load("libPhysics");
    gSystem->Load("libVMC");
    gSystem->Load("libSTEERBase");
    gSystem->Load("libESD");
    gSystem->Load("libAOD");

    gSystem->Load("libANALYSIS");
    gSystem->Load("libANALYSISalice");
    gSystem->Load("libCORRFW");
    gSystem->Load("libPWGHFbase");
    gSystem->Load("libPWGmuon");

    TChain *chain = new TChain("esdTree");
    // Steering input chain
    chain->Add(inFileName);
    AliAnalysisManager *mgr  = new AliAnalysisManager("ESD to AOD", "Analysis Manager");

    // Input
    AliESDInputHandler* inpHandler = new AliESDInputHandler();
    inpHandler->SetReadFriends(kFALSE);
    inpHandler->SetReadTags();
    mgr->SetInputEventHandler  (inpHandler);
    // Output
    AliAODHandler* aodHandler   = new AliAODHandler();
    aodHandler->SetOutputFileName(outFileName);
    mgr->SetOutputEventHandler(aodHandler);

    // MC Truth
    if(bKineFilter){
	AliMCEventHandler* mcHandler = new AliMCEventHandler();
	mgr->SetMCtruthEventHandler(mcHandler);
    }

    // Tasks
    // Filtering of MC particles (decays conversions etc)
    // this task is also needed to set the MCEventHandler
    // to the AODHandler, this will not be needed when
    // AODHandler goes to ANALYSISalice
    AliAnalysisTaskMCParticleFilter *kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Filter");
    if (bKineFilter) mgr->AddTask(kinefilter);

    // Barrel Tracks
    AliAnalysisTaskESDfilter *filter = new AliAnalysisTaskESDfilter("Filter");
    mgr->AddTask(filter);
    // Muons
    AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
    mgr->AddTask(esdmuonfilter);

    // Cuts on primary tracks
    AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Standard");
    esdTrackCutsL->SetMinNClustersTPC(50);
    esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
    esdTrackCutsL->SetMaxCovDiagonalElements(2, 2, 0.5, 0.5, 2);
    esdTrackCutsL->SetRequireTPCRefit(kTRUE);
    esdTrackCutsL->SetMaxDCAToVertexXY(3.0);
    esdTrackCutsL->SetMaxDCAToVertexZ(3.0);
    esdTrackCutsL->SetDCAToVertex2D(kTRUE);
    esdTrackCutsL->SetRequireSigmaToVertex(kFALSE);
    esdTrackCutsL->SetAcceptKinkDaughters(kFALSE);
    // ITS stand-alone tracks
    AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("AliESDtrackCuts", "ITS stand-alone");
    esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);

    AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
    trackFilter->AddCuts(esdTrackCutsL);
    trackFilter->AddCuts(esdTrackCutsITSsa);

    // Cuts on V0s
    AliESDv0Cuts*   esdV0Cuts = new AliESDv0Cuts("AliESDv0Cuts", "Standard pp");
    esdV0Cuts->SetMinRadius(0.2);
    esdV0Cuts->SetMaxRadius(200);
    esdV0Cuts->SetMinDcaPosToVertex(0.05);
    esdV0Cuts->SetMinDcaNegToVertex(0.05);
    esdV0Cuts->SetMaxDcaV0Daughters(1.0);
    esdV0Cuts->SetMinCosinePointingAngle(0.99);
    AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
    v0Filter->AddCuts(esdV0Cuts);

//
    filter->SetTrackFilter(trackFilter);
    filter->SetV0Filter(v0Filter);

//  Create AOD Tags
    AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator");
    mgr->AddTask(tagTask);

    // Pipelining
    AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();
    AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer();

    AliAnalysisDataContainer *coutputT
	= mgr->CreateContainer("cTag",  TTree::Class(), AliAnalysisManager::kOutputContainer, "AOD.tag.root");

    coutput1->SetSpecialOutput();
    coutputT->SetSpecialOutput();

    if(bKineFilter) {
	mgr->ConnectInput  (kinefilter,     0, cinput1  );
	mgr->ConnectOutput (kinefilter,     0, coutput1 );
    }

    mgr->ConnectInput (filter, 0, cinput1 );
    mgr->ConnectOutput(filter, 0, coutput1);

    mgr->ConnectInput (esdmuonfilter, 0, cinput1 );
//    mgr->ConnectOutput(esdmuonfilter, 0, coutput1);

    mgr->ConnectInput (tagTask, 0, cinput1);
    mgr->ConnectOutput(tagTask, 1, coutputT);

    //
    // Run the analysis
    //
    mgr->InitAnalysis();
    mgr->PrintStatus();
    mgr->StartAnalysis("local", chain);
}

<commit_msg>bug #98456: error in STEER/CreateAODfromESD.C  	Francesco Noferini <fnoferin><commit_after>#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TChain.h>
#include <TSystem.h>
#include "AliAnalysisManager.h"
#include "AliESDInputHandler.h"
#include "AliAODHandler.h"
#include "AliAnalysisTaskESDfilter.h"
#include "AliAnalysisDataContainer.h"
#endif

void CreateAODfromESD(const char *inFileName = "AliESDs.root",
		      const char *outFileName = "AliAOD.root",
		      Bool_t bKineFilter = kTRUE)
{

    gSystem->Load("libTree");
    gSystem->Load("libGeom");
    gSystem->Load("libPhysics");
    gSystem->Load("libVMC");
    gSystem->Load("libSTEERBase");
    gSystem->Load("libESD");
    gSystem->Load("libAOD");

    gSystem->Load("libANALYSIS");
    gSystem->Load("libANALYSISalice");
    gSystem->Load("libCORRFW");
    gSystem->Load("libPWGHFbase");
    gSystem->Load("libPWGmuon");

    TChain *chain = new TChain("esdTree");
    // Steering input chain
    chain->Add(inFileName);
    AliAnalysisManager *mgr  = new AliAnalysisManager("ESD to AOD", "Analysis Manager");

    // Input
    AliESDInputHandler* inpHandler = new AliESDInputHandler();
    inpHandler->SetReadFriends(kFALSE);
    inpHandler->SetReadTags();
    mgr->SetInputEventHandler  (inpHandler);
    // Output
    AliAODHandler* aodHandler   = new AliAODHandler();
    aodHandler->SetOutputFileName(outFileName);
    mgr->SetOutputEventHandler(aodHandler);

    // MC Truth
    if(bKineFilter){
	AliMCEventHandler* mcHandler = new AliMCEventHandler();
	mgr->SetMCtruthEventHandler(mcHandler);
    }

    // Tasks
    // Filtering of MC particles (decays conversions etc)
    // this task is also needed to set the MCEventHandler
    // to the AODHandler, this will not be needed when
    // AODHandler goes to ANALYSISalice

    // Barrel Tracks
    AliAnalysisTaskESDfilter *filter = new AliAnalysisTaskESDfilter("Filter");
    mgr->AddTask(filter);
    AliAnalysisTaskMCParticleFilter *kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Filter");
    if (bKineFilter) mgr->AddTask(kinefilter);
    // Muons
    AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
    mgr->AddTask(esdmuonfilter);

    // Cuts on primary tracks
    AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Standard");
    esdTrackCutsL->SetMinNClustersTPC(50);
    esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
    esdTrackCutsL->SetMaxCovDiagonalElements(2, 2, 0.5, 0.5, 2);
    esdTrackCutsL->SetRequireTPCRefit(kTRUE);
    esdTrackCutsL->SetMaxDCAToVertexXY(3.0);
    esdTrackCutsL->SetMaxDCAToVertexZ(3.0);
    esdTrackCutsL->SetDCAToVertex2D(kTRUE);
    esdTrackCutsL->SetRequireSigmaToVertex(kFALSE);
    esdTrackCutsL->SetAcceptKinkDaughters(kFALSE);
    // ITS stand-alone tracks
    AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("AliESDtrackCuts", "ITS stand-alone");
    esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);

    AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
    trackFilter->AddCuts(esdTrackCutsL);
    trackFilter->AddCuts(esdTrackCutsITSsa);

    // Cuts on V0s
    AliESDv0Cuts*   esdV0Cuts = new AliESDv0Cuts("AliESDv0Cuts", "Standard pp");
    esdV0Cuts->SetMinRadius(0.2);
    esdV0Cuts->SetMaxRadius(200);
    esdV0Cuts->SetMinDcaPosToVertex(0.05);
    esdV0Cuts->SetMinDcaNegToVertex(0.05);
    esdV0Cuts->SetMaxDcaV0Daughters(1.0);
    esdV0Cuts->SetMinCosinePointingAngle(0.99);
    AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
    v0Filter->AddCuts(esdV0Cuts);

//
    filter->SetTrackFilter(trackFilter);
    filter->SetV0Filter(v0Filter);

//  Create AOD Tags
    AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator");
    mgr->AddTask(tagTask);

    // Pipelining
    AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();
    AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer();

    AliAnalysisDataContainer *coutputT
	= mgr->CreateContainer("cTag",  TTree::Class(), AliAnalysisManager::kOutputContainer, "AOD.tag.root");

    coutput1->SetSpecialOutput();
    coutputT->SetSpecialOutput();

    if(bKineFilter) {
	mgr->ConnectInput  (kinefilter,     0, cinput1  );
	mgr->ConnectOutput (kinefilter,     0, coutput1 );
    }

    mgr->ConnectInput (filter, 0, cinput1 );
    mgr->ConnectOutput(filter, 0, coutput1);

    mgr->ConnectInput (esdmuonfilter, 0, cinput1 );
//    mgr->ConnectOutput(esdmuonfilter, 0, coutput1);

    mgr->ConnectInput (tagTask, 0, cinput1);
    mgr->ConnectOutput(tagTask, 1, coutputT);

    //
    // Run the analysis
    //
    mgr->InitAnalysis();
    mgr->PrintStatus();
    mgr->StartAnalysis("local", chain);
}

<|endoftext|>


<commit_before>// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/geolocation/wifi_data_provider_win.h"

#include <vector>

#include "base/scoped_ptr.h"
#include "base/string_util.h"
#include "chrome/browser/geolocation/wifi_data_provider_common.h"
#include "chrome/test/ui_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {
class MockWlanApi : public Win32WifiDataProvider::WlanApiInterface {
 public:
  MockWlanApi() : calls_(0), bool_return_(true) {
  }
  virtual bool GetAccessPointData(WifiData::AccessPointDataSet* data) {
    ++calls_;
    *data = data_out_;
    return bool_return_;
  }
  int calls_;
  bool bool_return_;
  WifiData::AccessPointDataSet data_out_;
};

class MockPollingPolicy : public PollingPolicyInterface {
 public:
  virtual void UpdatePollingInterval(bool scan_results_differ) {
    results_differed_.push_back(scan_results_differ);
  }
  virtual int PollingInterval() { return 1; }
  std::vector<bool> results_differed_;
};

// Stops the specified (nested) message loop when the listener is called back.
class MessageLoopQuitListener
    : public Win32WifiDataProvider::ListenerInterface {
 public:
  explicit MessageLoopQuitListener(MessageLoop* message_loop)
      : message_loop_to_quit_(message_loop) {
    assert(message_loop_to_quit_ != NULL);
  }
  // ListenerInterface
  virtual void DeviceDataUpdateAvailable(
      DeviceDataProvider<WifiData>* provider) {
    // We expect the callback to come from the provider's internal worker
    // thread. This is not a strict requirement, just a lot of the complexity
    // here is predicated on the need to cope with this scenario!
    EXPECT_NE(MessageLoop::current(), message_loop_to_quit_);
    provider_ = provider;
    // Can't call Quit() directly on another thread's message loop.
    message_loop_to_quit_->PostTask(FROM_HERE, new MessageLoop::QuitTask);
  }
  MessageLoop* message_loop_to_quit_;
  DeviceDataProvider<WifiData>* provider_;
};

// Main test fixture
class Win32WifiDataProviderTest : public testing::Test {
 public:
  static Win32WifiDataProvider* CreateWin32WifiDataProvider(
      MockWlanApi** wlan_api_out) {
    Win32WifiDataProvider* provider = new Win32WifiDataProvider;
    *wlan_api_out = new MockWlanApi;
    provider->inject_mock_wlan_api(*wlan_api_out);  // Takes ownership.
    provider->inject_mock_polling_policy(new MockPollingPolicy);  // ditto
    return provider;
  }
  virtual void SetUp() {
    provider_.reset(CreateWin32WifiDataProvider(&wlan_api_));
  }
  virtual void TearDown() {
    provider_.reset(NULL);
  }

 protected:
  MessageLoop main_message_loop_;
  scoped_ptr<Win32WifiDataProvider> provider_;
  MockWlanApi* wlan_api_;
};

WifiDataProviderImplBase* CreateWin32WifiDataProviderStatic() {
  MockWlanApi* wlan_api;
  return Win32WifiDataProviderTest::CreateWin32WifiDataProvider(&wlan_api);
}
}  // namespace

TEST_F(Win32WifiDataProviderTest, CreateDestroy) {
  // Test fixture members were SetUp correctly.
  EXPECT_EQ(&main_message_loop_, MessageLoop::current());
  EXPECT_TRUE(NULL != provider_.get());
  EXPECT_TRUE(NULL != wlan_api_);
}

TEST_F(Win32WifiDataProviderTest, StartThread) {
  EXPECT_TRUE(provider_->StartDataProvider());
  provider_.reset(NULL);  // Stop()s the thread.
  SUCCEED();
}

TEST_F(Win32WifiDataProviderTest, DoAnEmptyScan) {
  MessageLoopQuitListener quit_listener(&main_message_loop_);
  provider_->AddListener(&quit_listener);
  EXPECT_TRUE(provider_->StartDataProvider());
  main_message_loop_.Run();
  EXPECT_EQ(1, wlan_api_->calls_);
  WifiData data;
  EXPECT_TRUE(provider_->GetData(&data));
  EXPECT_EQ(0, data.access_point_data.size());
}

TEST_F(Win32WifiDataProviderTest, DoScanWithResults) {
  MessageLoopQuitListener quit_listener(&main_message_loop_);
  provider_->AddListener(&quit_listener);
  AccessPointData single_access_point;
  single_access_point.age = 1;
  single_access_point.channel = 2;
  single_access_point.mac_address = 3;
  single_access_point.radio_signal_strength = 4;
  single_access_point.signal_to_noise = 5;
  single_access_point.ssid = L"foossid";
  wlan_api_->data_out_.insert(single_access_point);

  EXPECT_TRUE(provider_->StartDataProvider());
  main_message_loop_.Run();
  EXPECT_EQ(1, wlan_api_->calls_);
  WifiData data;
  EXPECT_TRUE(provider_->GetData(&data));
  EXPECT_EQ(1, data.access_point_data.size());
  EXPECT_EQ(single_access_point.age, data.access_point_data.begin()->age);
  EXPECT_EQ(single_access_point.ssid, data.access_point_data.begin()->ssid);
}

TEST_F(Win32WifiDataProviderTest, StartThreadViaDeviceDataProvider) {
  MessageLoopQuitListener quit_listener(&main_message_loop_);
  DeviceDataProvider<WifiData>::SetFactory(CreateWin32WifiDataProviderStatic);
  DeviceDataProvider<WifiData>::Register(&quit_listener);
  main_message_loop_.Run();
  DeviceDataProvider<WifiData>::Unregister(&quit_listener);
  DeviceDataProvider<WifiData>::ResetFactory();
}
<commit_msg>Fix flaky test causing tree to go red<commit_after>// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/geolocation/wifi_data_provider_win.h"

#include <vector>

#include "base/scoped_ptr.h"
#include "base/string_util.h"
#include "chrome/browser/geolocation/wifi_data_provider_common.h"
#include "chrome/test/ui_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {
class MockWlanApi : public Win32WifiDataProvider::WlanApiInterface {
 public:
  MockWlanApi() : calls_(0), bool_return_(true) {
  }
  virtual bool GetAccessPointData(WifiData::AccessPointDataSet* data) {
    ++calls_;
    *data = data_out_;
    return bool_return_;
  }
  int calls_;
  bool bool_return_;
  WifiData::AccessPointDataSet data_out_;
};

class MockPollingPolicy : public PollingPolicyInterface {
 public:
  virtual void UpdatePollingInterval(bool scan_results_differ) {
    results_differed_.push_back(scan_results_differ);
  }
  virtual int PollingInterval() { return 1; }
  std::vector<bool> results_differed_;
};

// Stops the specified (nested) message loop when the listener is called back.
class MessageLoopQuitListener
    : public Win32WifiDataProvider::ListenerInterface {
 public:
  explicit MessageLoopQuitListener(MessageLoop* message_loop)
      : message_loop_to_quit_(message_loop) {
    assert(message_loop_to_quit_ != NULL);
  }
  // ListenerInterface
  virtual void DeviceDataUpdateAvailable(
      DeviceDataProvider<WifiData>* provider) {
    // We expect the callback to come from the provider's internal worker
    // thread. This is not a strict requirement, just a lot of the complexity
    // here is predicated on the need to cope with this scenario!
    EXPECT_NE(MessageLoop::current(), message_loop_to_quit_);
    provider_ = provider;
    // Can't call Quit() directly on another thread's message loop.
    message_loop_to_quit_->PostTask(FROM_HERE, new MessageLoop::QuitTask);
  }
  MessageLoop* message_loop_to_quit_;
  DeviceDataProvider<WifiData>* provider_;
};

// Main test fixture
class Win32WifiDataProviderTest : public testing::Test {
 public:
  static Win32WifiDataProvider* CreateWin32WifiDataProvider(
      MockWlanApi** wlan_api_out) {
    Win32WifiDataProvider* provider = new Win32WifiDataProvider;
    *wlan_api_out = new MockWlanApi;
    provider->inject_mock_wlan_api(*wlan_api_out);  // Takes ownership.
    provider->inject_mock_polling_policy(new MockPollingPolicy);  // ditto
    return provider;
  }
  virtual void SetUp() {
    provider_.reset(CreateWin32WifiDataProvider(&wlan_api_));
  }
  virtual void TearDown() {
    provider_.reset(NULL);
  }

 protected:
  MessageLoop main_message_loop_;
  scoped_ptr<Win32WifiDataProvider> provider_;
  MockWlanApi* wlan_api_;
};

WifiDataProviderImplBase* CreateWin32WifiDataProviderStatic() {
  MockWlanApi* wlan_api;
  return Win32WifiDataProviderTest::CreateWin32WifiDataProvider(&wlan_api);
}
}  // namespace

TEST_F(Win32WifiDataProviderTest, CreateDestroy) {
  // Test fixture members were SetUp correctly.
  EXPECT_EQ(&main_message_loop_, MessageLoop::current());
  EXPECT_TRUE(NULL != provider_.get());
  EXPECT_TRUE(NULL != wlan_api_);
}

TEST_F(Win32WifiDataProviderTest, StartThread) {
  EXPECT_TRUE(provider_->StartDataProvider());
  provider_.reset(NULL);  // Stop()s the thread.
  SUCCEED();
}

TEST_F(Win32WifiDataProviderTest, DoAnEmptyScan) {
  MessageLoopQuitListener quit_listener(&main_message_loop_);
  provider_->AddListener(&quit_listener);
  EXPECT_TRUE(provider_->StartDataProvider());
  main_message_loop_.Run();
  // Check we had at least one call. The worker thread may have raced ahead
  // and made multiple calls.
  EXPECT_GT(wlan_api_->calls_, 0);
  WifiData data;
  EXPECT_TRUE(provider_->GetData(&data));
  EXPECT_EQ(0, data.access_point_data.size());
  provider_->RemoveListener(&quit_listener);
}

TEST_F(Win32WifiDataProviderTest, DoScanWithResults) {
  MessageLoopQuitListener quit_listener(&main_message_loop_);
  provider_->AddListener(&quit_listener);
  AccessPointData single_access_point;
  single_access_point.age = 1;
  single_access_point.channel = 2;
  single_access_point.mac_address = 3;
  single_access_point.radio_signal_strength = 4;
  single_access_point.signal_to_noise = 5;
  single_access_point.ssid = L"foossid";
  wlan_api_->data_out_.insert(single_access_point);

  EXPECT_TRUE(provider_->StartDataProvider());
  main_message_loop_.Run();
  EXPECT_GT(wlan_api_->calls_, 0);
  WifiData data;
  EXPECT_TRUE(provider_->GetData(&data));
  EXPECT_EQ(1, data.access_point_data.size());
  EXPECT_EQ(single_access_point.age, data.access_point_data.begin()->age);
  EXPECT_EQ(single_access_point.ssid, data.access_point_data.begin()->ssid);
  provider_->RemoveListener(&quit_listener);
}

TEST_F(Win32WifiDataProviderTest, StartThreadViaDeviceDataProvider) {
  MessageLoopQuitListener quit_listener(&main_message_loop_);
  DeviceDataProvider<WifiData>::SetFactory(CreateWin32WifiDataProviderStatic);
  DeviceDataProvider<WifiData>::Register(&quit_listener);
  main_message_loop_.Run();
  DeviceDataProvider<WifiData>::Unregister(&quit_listener);
  DeviceDataProvider<WifiData>::ResetFactory();
}
<|endoftext|>


<commit_before>#include "myspectrumhandler.h"
<commit_msg>unused file<commit_after><|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: ddedummy.cxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-08 16:59:12 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _SVDDE_HXX
#include <svdde.hxx>
#endif
#ifndef INCLUDED_RTL_INSTANCE_HXX
#include <rtl/instance.hxx>
#endif

DdeData::DdeData()
{
}

DdeData::DdeData( const String& )
{
}

DdeData::DdeData( const DdeData& )
{
}

DdeData::DdeData( const void*, long, ULONG)
{
}

DdeData::~DdeData( void )
{
}

void DdeData::SetFormat( ULONG )
{
}

ULONG DdeData::GetFormat() const
{
  return 0L;
}

DdeData& DdeData::operator = ( const DdeData& rDdeData )
{
  return *this;
}

DdeData::operator long() const
{
  return 0L;
}

DdeData::operator const void*() const
{
  return NULL;
}

long DdeConnection::GetError()
{
  return 0L;
}

DdeConnection::DdeConnection( const String&, const String& )
{
}

DdeConnection::~DdeConnection( void )
{
}

const String& DdeConnection::GetServiceName()
{
  return String::EmptyString();
}

const String& DdeConnection::GetTopicName()
{
  return String::EmptyString();
}

DdeTransaction::DdeTransaction( DdeConnection& rConnection, const String&, long ) :
     rDde( rConnection )
{
}

DdeTransaction::DdeTransaction( const DdeTransaction& rTransaction ) :
     rDde( rTransaction.rDde )
{
}

void DdeTransaction::Execute(void)
{
}

void DdeTransaction::Done( BOOL bDataValid )
{
}

void DdeTransaction::Data( const DdeData* )
{
}

DdeTransaction::~DdeTransaction(void)
{
}

DdeRequest::DdeRequest(DdeConnection& rConnection, const String& rString, long lLong ) :
     DdeTransaction( rConnection, rString, lLong )
{
}

DdeExecute::DdeExecute( DdeConnection& rConnection, const String& rString, long lLong ) :
     DdeTransaction( rConnection, rString, lLong )
{
}

DdePoke::DdePoke( DdeConnection& rConnection, const String& rString, const DdeData&, long lLong ) :
     DdeTransaction( rConnection, rString, lLong )
{
}

DdeTopic::DdeTopic( const String& )
{
}

DdeTopic::~DdeTopic()
{
}

void DdeTopic::Connect (long )
{
}

void DdeTopic::Disconnect( long )
{
}

void DdeTopic::InsertItem( DdeItem* )
{
}

DdeItem* DdeTopic::AddItem( const DdeItem& rDdeItem )
{
  return (DdeItem*) &rDdeItem;
}

void DdeTopic::RemoveItem( const DdeItem& )
{
}

DdeData* DdeTopic::Get( ULONG )
{
  return NULL;
}

BOOL DdeTopic::MakeItem( const String& )
{
  return FALSE;
}

BOOL DdeTopic::StartAdviseLoop()
{
  return FALSE;
}

BOOL DdeTopic::StopAdviseLoop()
{
  return FALSE;
}

BOOL DdeTopic::Execute( const String* )
{
  return FALSE;
}

BOOL DdeTopic::Put( const DdeData* )
{
  return FALSE;
}

const String& DdeTopic::GetName() const
{
  return String::EmptyString();
}

DdeService::DdeService( const String& )
{
  nStatus = 0;
}

String DdeService::Topics() {
    return String();
}

String DdeService::Formats() {
    return String();
}

String DdeService::SysItems() {
    return String();
}

String DdeService::Status() {
    return String();
}

String DdeService::SysTopicGet(const String& rString) {
    return rString;
}

BOOL DdeService::SysTopicExecute(const String*) {
    return FALSE;
}

DdeService::~DdeService()
{
}

BOOL DdeService::IsBusy()
{
  return FALSE;
}

String DdeService::GetHelp()
{
  return String::EmptyString();
}

void DdeService::AddFormat( ULONG )
{
}

void DdeService::AddTopic( const DdeTopic& )
{
}

void DdeService::RemoveTopic( const DdeTopic& )
{
}

BOOL DdeService::MakeTopic( const String& )
{
  return FALSE;
}

const String& DdeService::GetName() const
{
  return String::EmptyString();
}

namespace
{
    struct theDdeServices
        : public rtl::Static< DdeServices, theDdeServices > {};
}

DdeServices& DdeService::GetServices()
{
  return theDdeServices::get();
}

DdeItem::DdeItem( const String& )
{
}

DdeItem::DdeItem( const DdeItem& )
{
}

DdeItem::~DdeItem()
{
}

void DdeItem::NotifyClient()
{
}

DdeGetPutItem::DdeGetPutItem( const String& rStr ) :
DdeItem( rStr )
{
}

DdeGetPutItem::DdeGetPutItem( const DdeItem& rItem ) :
DdeItem( rItem )
{
}

DdeData* DdeGetPutItem::Get( ULONG )
{
  return NULL;
}

BOOL DdeGetPutItem::Put( const DdeData* )
{
  return FALSE;
}

void DdeGetPutItem::AdviseLoop( BOOL )
{
}

DdeLink::DdeLink( DdeConnection& rConnection, const String& rString, long l ) :
DdeTransaction( rConnection, rString, l )
{
}

DdeLink::~DdeLink()
{
}

void DdeLink::Notify()
{
}

DdeHotLink::DdeHotLink( DdeConnection& rConnection, const String& rString, long l ) :
DdeLink( rConnection, rString, l )
{
}
<commit_msg>INTEGRATION: CWS warnings01 (1.3.62); FILE MERGED 2005/11/15 19:56:07 pl 1.3.62.1: #i55991# removed warnings<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: ddedummy.cxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: hr $ $Date: 2006-06-19 21:29:39 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _SVDDE_HXX
#include <svdde.hxx>
#endif
#ifndef INCLUDED_RTL_INSTANCE_HXX
#include <rtl/instance.hxx>
#endif

DdeData::DdeData()
{
}

DdeData::DdeData( const String& )
{
}

DdeData::DdeData( const DdeData& )
{
}

DdeData::DdeData( const void*, long, ULONG)
{
}

DdeData::~DdeData( void )
{
}

void DdeData::SetFormat( ULONG )
{
}

ULONG DdeData::GetFormat() const
{
  return 0L;
}

DdeData& DdeData::operator = ( const DdeData& )
{
  return *this;
}

DdeData::operator long() const
{
  return 0L;
}

DdeData::operator const void*() const
{
  return NULL;
}

long DdeConnection::GetError()
{
  return 0L;
}

DdeConnection::DdeConnection( const String&, const String& )
{
}

DdeConnection::~DdeConnection( void )
{
}

const String& DdeConnection::GetServiceName()
{
  return String::EmptyString();
}

const String& DdeConnection::GetTopicName()
{
  return String::EmptyString();
}

DdeTransaction::DdeTransaction( DdeConnection& rConnection, const String&, long ) :
     rDde( rConnection )
{
}

DdeTransaction::DdeTransaction( const DdeTransaction& rTransaction ) :
     rDde( rTransaction.rDde )
{
}

void DdeTransaction::Execute(void)
{
}

void DdeTransaction::Done( BOOL )
{
}

void DdeTransaction::Data( const DdeData* )
{
}

DdeTransaction::~DdeTransaction(void)
{
}

DdeRequest::DdeRequest(DdeConnection& rConnection, const String& rString, long lLong ) :
     DdeTransaction( rConnection, rString, lLong )
{
}

DdeExecute::DdeExecute( DdeConnection& rConnection, const String& rString, long lLong ) :
     DdeTransaction( rConnection, rString, lLong )
{
}

DdePoke::DdePoke( DdeConnection& rConnection, const String& rString, const DdeData&, long lLong ) :
     DdeTransaction( rConnection, rString, lLong )
{
}

DdeTopic::DdeTopic( const String& )
{
}

DdeTopic::~DdeTopic()
{
}

void DdeTopic::Connect (long )
{
}

void DdeTopic::Disconnect( long )
{
}

void DdeTopic::InsertItem( DdeItem* )
{
}

DdeItem* DdeTopic::AddItem( const DdeItem& rDdeItem )
{
  return (DdeItem*) &rDdeItem;
}

void DdeTopic::RemoveItem( const DdeItem& )
{
}

DdeData* DdeTopic::Get( ULONG )
{
  return NULL;
}

BOOL DdeTopic::MakeItem( const String& )
{
  return FALSE;
}

BOOL DdeTopic::StartAdviseLoop()
{
  return FALSE;
}

BOOL DdeTopic::StopAdviseLoop()
{
  return FALSE;
}

BOOL DdeTopic::Execute( const String* )
{
  return FALSE;
}

BOOL DdeTopic::Put( const DdeData* )
{
  return FALSE;
}

const String& DdeTopic::GetName() const
{
  return String::EmptyString();
}

DdeService::DdeService( const String& )
{
  nStatus = 0;
}

String DdeService::Topics() {
    return String();
}

String DdeService::Formats() {
    return String();
}

String DdeService::SysItems() {
    return String();
}

String DdeService::Status() {
    return String();
}

String DdeService::SysTopicGet(const String& rString) {
    return rString;
}

BOOL DdeService::SysTopicExecute(const String*) {
    return FALSE;
}

DdeService::~DdeService()
{
}

BOOL DdeService::IsBusy()
{
  return FALSE;
}

String DdeService::GetHelp()
{
  return String::EmptyString();
}

void DdeService::AddFormat( ULONG )
{
}

void DdeService::AddTopic( const DdeTopic& )
{
}

void DdeService::RemoveTopic( const DdeTopic& )
{
}

BOOL DdeService::MakeTopic( const String& )
{
  return FALSE;
}

const String& DdeService::GetName() const
{
  return String::EmptyString();
}

namespace
{
    struct theDdeServices
        : public rtl::Static< DdeServices, theDdeServices > {};
}

DdeServices& DdeService::GetServices()
{
  return theDdeServices::get();
}

DdeItem::DdeItem( const String& )
{
}

DdeItem::DdeItem( const DdeItem& )
{
}

DdeItem::~DdeItem()
{
}

void DdeItem::NotifyClient()
{
}

DdeGetPutItem::DdeGetPutItem( const String& rStr ) :
DdeItem( rStr )
{
}

DdeGetPutItem::DdeGetPutItem( const DdeItem& rItem ) :
DdeItem( rItem )
{
}

DdeData* DdeGetPutItem::Get( ULONG )
{
  return NULL;
}

BOOL DdeGetPutItem::Put( const DdeData* )
{
  return FALSE;
}

void DdeGetPutItem::AdviseLoop( BOOL )
{
}

DdeLink::DdeLink( DdeConnection& rConnection, const String& rString, long l ) :
DdeTransaction( rConnection, rString, l )
{
}

DdeLink::~DdeLink()
{
}

void DdeLink::Notify()
{
}

DdeHotLink::DdeHotLink( DdeConnection& rConnection, const String& rString, long l ) :
DdeLink( rConnection, rString, l )
{
}
<|endoftext|>