<commit_before>/**
 ** \file runner/interpreter.hh
 ** \brief Definition of runner::Interpreter.
 */

#ifndef RUNNER_INTERPRETER_HH
# define RUNNER_INTERPRETER_HH

# include <vector>

# include <boost/tuple/tuple.hpp>

# include <ast/default-visitor.hh>
# include <ast/fwd.hh>
# include <object/object.hh>
# include <scheduler/scheduler.hh>
# include <scheduler/job.hh>

# include <runner/runner.hh>
# include <runner/stacks.hh>

namespace runner
{

  /// Ast executor.
  class Interpreter : public ast::DefaultConstVisitor,
		      public runner::Runner
  {
  public:
    /// \name Useful shorthands.
    /// \{
    /// Super class type.
    typedef ast::DefaultConstVisitor super_type;
    typedef object::rObject rObject;
    typedef object::rrObject rrObject;
    typedef object::rCode rCode;
    typedef object::rLobby rLobby;
    /// \}

    /// \name Ctor & dtor.
    /// \{
    /// Construct a \c Interpreter in the \a lobby.  The runner needs
    /// to know its \a scheduler and will execute \a ast.  Memory
    /// ownership of \a ast is transferred to the Interpreter.  The
    /// new runner has no parent.
    Interpreter (rLobby lobby,
		 scheduler::Scheduler& scheduler,
		 ast::rConstAst ast,
		 const libport::Symbol& name = SYMBOL());

    Interpreter (const Interpreter&,
		 rObject code,
		 const libport::Symbol& name = SYMBOL());

    /// Create a copy of a runner starting with another ast.
    Interpreter (const Interpreter&,
		 ast::rConstAst ast,
		 const libport::Symbol& name = SYMBOL());

    /// Destroy a Interpreter.
    virtual ~Interpreter ();
    /// \}

    /// The entry point: visit \a e.
    virtual void operator() (ast::rConstAst e);

    /// \ name Accessors.
    /// \{
  public:
    /// \}

    /// Execute the code of function \a func with arguments \a args in
    /// the local runner.
    ///
    /// \param func  the "function" to call: Primitive, Delegate, Code
    ///              or even rObject, in which case it is returned.
    ///
    /// \param msg   the name of the called method, as it should be stored
    ///              in a call message in case further processing is
    ///              required.
    ///
    /// \param args  the arguments.  Used as given, they are not evaluated
    ///              here.
    ///
    /// \param call_message  the callMessage.  Valid only for \a func
    ///             being Code.
    ///
    /// One cannot have both a call message and args.
    virtual rObject apply (const rObject& func,
			   const libport::Symbol msg,
			   object::objects_type args,
			   rObject call_message = 0);

    /// Helpers to apply a function with the arguments as ast chunks
    rObject apply (rObject tgt, const libport::Symbol& msg,
                   const ast::exps_type* args);
    rObject apply (rObject tgt, rObject f, const libport::Symbol& msg,
                   const ast::exps_type* args);

    /// Evaluate an expression in the current scope and return its result.
    rObject eval (ast::rConstAst);

    /// Evaluate a tag and create it as well as the intermediate levels
    /// if needed.
    rObject eval_tag (ast::rConstExp);

    /// Make an urbi function from an ast chunk
    object::rCode make_code(ast::rConstCode f) const;

    /// Return the current scope_tag, after creating it if needed.
    scheduler::rTag scope_tag();

  protected:
    /// \name Evaluation.
    /// \{
    typedef std::pair<bool, const Interpreter::rObject> locate_type;

    /// Build an evaluated arguments list containing \a tgt and
    /// arguments coming from \a args evaluated in the current context.
    /// If check_void is true, raise an error if any argument is void.
    void push_evaluated_arguments (object::objects_type& args,
				   const ast::exps_type& ue_args,
				   bool check_void);

    /// Build a call message
    virtual rObject build_call_message
      (const rObject& tgt, const libport::Symbol& msg,
       const object::objects_type& args);

    /// Build a call message
    rObject build_call_message (const rObject& tgt, const libport::Symbol& msg,
				const ast::exps_type& args);

    /// Import from super.
    using super_type::visit;

    CONST_VISITOR_VISIT_NODES((And)
                              (Assignment)
                              (Call)
                              (CallMsg)
                              (Closure)
                              (Do)
                              (Declaration)
                              (Float)
                              (Foreach)
                              (Function)
                              (If)
                              (Lazy)
                              (List)
                              (Local)
                              (Message)
                              (Nary)
                              (Noop)
                              (Pipe)
                              (Scope)
                              (Stmt)
                              (String)
                              (Tag)
                              (TaggedStmt)
                              (This)
                              (Throw)
                              (While))

    /// Factor handling of Scope and Do
    void visit (ast::rConstAbstractScope e);
    /// Factor handling of Function and Closure
    void visit (ast::rConstCode e, bool closure);
    /// \}

    /// Do the actual work.  Implementation of \c Job::run.
    virtual void work ();

    virtual void show_backtrace(const std::string& chan);
    virtual backtrace_type backtrace_get() const;

  protected:
    void show_error_ (const object::UrbiException& ue);

  private:
    void init();
    void propagate_error_ (object::UrbiException& ue, const ast::loc& l);
    rObject apply_urbi (rCode func,
			const libport::Symbol& msg,
			const object::objects_type& args,
			rObject call_message);
    void cleanup_scope_tag();

  private:
    /// The root of the AST being executed.
    ast::rConstAst ast_;

    /// The urbi Code object to execute
    rObject code_;

    /// The current value during the evaluation of the AST.
    rObject current_;

    /// The scope tags stack.
    std::vector<scheduler::rTag> scope_tags_;

    /// The call stack.
    typedef object::UrbiException::call_stack_type call_stack_type;
    call_stack_type call_stack_;
    void show_backtrace(const call_stack_type& bt,
                        const std::string& chan);

    /// The local variable stacks
    Stacks stacks_;
  };

} // namespace runner

# include <runner/interpreter.hxx>

#endif // !RUNNER_INTERPRETER_HH
<commit_msg>Remove useless typedef.<commit_after>/**
 ** \file runner/interpreter.hh
 ** \brief Definition of runner::Interpreter.
 */

#ifndef RUNNER_INTERPRETER_HH
# define RUNNER_INTERPRETER_HH

# include <vector>

# include <boost/tuple/tuple.hpp>

# include <ast/default-visitor.hh>
# include <ast/fwd.hh>
# include <object/object.hh>
# include <scheduler/scheduler.hh>
# include <scheduler/job.hh>

# include <runner/runner.hh>
# include <runner/stacks.hh>

namespace runner
{

  /// Ast executor.
  class Interpreter : public ast::DefaultConstVisitor,
		      public runner::Runner
  {
  public:
    /// \name Useful shorthands.
    /// \{
    /// Super class type.
    typedef ast::DefaultConstVisitor super_type;
    typedef object::rObject rObject;
    typedef object::rrObject rrObject;
    typedef object::rCode rCode;
    typedef object::rLobby rLobby;
    /// \}

    /// \name Ctor & dtor.
    /// \{
    /// Construct a \c Interpreter in the \a lobby.  The runner needs
    /// to know its \a scheduler and will execute \a ast.  Memory
    /// ownership of \a ast is transferred to the Interpreter.  The
    /// new runner has no parent.
    Interpreter (rLobby lobby,
		 scheduler::Scheduler& scheduler,
		 ast::rConstAst ast,
		 const libport::Symbol& name = SYMBOL());

    Interpreter (const Interpreter&,
		 rObject code,
		 const libport::Symbol& name = SYMBOL());

    /// Create a copy of a runner starting with another ast.
    Interpreter (const Interpreter&,
		 ast::rConstAst ast,
		 const libport::Symbol& name = SYMBOL());

    /// Destroy a Interpreter.
    virtual ~Interpreter ();
    /// \}

    /// The entry point: visit \a e.
    virtual void operator() (ast::rConstAst e);

    /// \ name Accessors.
    /// \{
  public:
    /// \}

    /// Execute the code of function \a func with arguments \a args in
    /// the local runner.
    ///
    /// \param func  the "function" to call: Primitive, Delegate, Code
    ///              or even rObject, in which case it is returned.
    ///
    /// \param msg   the name of the called method, as it should be stored
    ///              in a call message in case further processing is
    ///              required.
    ///
    /// \param args  the arguments.  Used as given, they are not evaluated
    ///              here.
    ///
    /// \param call_message  the callMessage.  Valid only for \a func
    ///             being Code.
    ///
    /// One cannot have both a call message and args.
    virtual rObject apply (const rObject& func,
			   const libport::Symbol msg,
			   object::objects_type args,
			   rObject call_message = 0);

    /// Helpers to apply a function with the arguments as ast chunks
    rObject apply (rObject tgt, const libport::Symbol& msg,
                   const ast::exps_type* args);
    rObject apply (rObject tgt, rObject f, const libport::Symbol& msg,
                   const ast::exps_type* args);

    /// Evaluate an expression in the current scope and return its result.
    rObject eval (ast::rConstAst);

    /// Evaluate a tag and create it as well as the intermediate levels
    /// if needed.
    rObject eval_tag (ast::rConstExp);

    /// Make an urbi function from an ast chunk
    object::rCode make_code(ast::rConstCode f) const;

    /// Return the current scope_tag, after creating it if needed.
    scheduler::rTag scope_tag();

  protected:
    /// \name Evaluation.
    /// \{
    /// Build an evaluated arguments list containing \a tgt and
    /// arguments coming from \a args evaluated in the current context.
    /// If check_void is true, raise an error if any argument is void.
    void push_evaluated_arguments (object::objects_type& args,
				   const ast::exps_type& ue_args,
				   bool check_void);

    /// Build a call message
    virtual rObject
    build_call_message(const rObject& tgt, const libport::Symbol& msg,
                       const object::objects_type& args);

    /// Build a call message
    rObject build_call_message(const rObject& tgt, const libport::Symbol& msg,
                               const ast::exps_type& args);

    /// Import from super.
    using super_type::visit;

    CONST_VISITOR_VISIT_NODES((And)
                              (Assignment)
                              (Call)
                              (CallMsg)
                              (Closure)
                              (Do)
                              (Declaration)
                              (Float)
                              (Foreach)
                              (Function)
                              (If)
                              (Lazy)
                              (List)
                              (Local)
                              (Message)
                              (Nary)
                              (Noop)
                              (Pipe)
                              (Scope)
                              (Stmt)
                              (String)
                              (Tag)
                              (TaggedStmt)
                              (This)
                              (Throw)
                              (While))

    /// Factor handling of Scope and Do
    void visit (ast::rConstAbstractScope e);
    /// Factor handling of Function and Closure
    void visit (ast::rConstCode e, bool closure);
    /// \}

    /// Do the actual work.  Implementation of \c Job::run.
    virtual void work ();

    virtual void show_backtrace(const std::string& chan);
    virtual backtrace_type backtrace_get() const;

  protected:
    void show_error_ (const object::UrbiException& ue);

  private:
    void init();
    void propagate_error_ (object::UrbiException& ue, const ast::loc& l);
    rObject apply_urbi (rCode func,
			const libport::Symbol& msg,
			const object::objects_type& args,
			rObject call_message);
    void cleanup_scope_tag();

  private:
    /// The root of the AST being executed.
    ast::rConstAst ast_;

    /// The urbi Code object to execute
    rObject code_;

    /// The current value during the evaluation of the AST.
    rObject current_;

    /// The scope tags stack.
    std::vector<scheduler::rTag> scope_tags_;

    /// The call stack.
    typedef object::UrbiException::call_stack_type call_stack_type;
    call_stack_type call_stack_;
    void show_backtrace(const call_stack_type& bt,
                        const std::string& chan);

    /// The local variable stacks
    Stacks stacks_;
  };

} // namespace runner

# include <runner/interpreter.hxx>

#endif // !RUNNER_INTERPRETER_HH
<|endoftext|>


<commit_before>#include "functional.h"
#include "constants.h"
#include "tpssc_eps.h"

template<class num>
static num energy(const densvars<num> &d)
{
  num eps = tpssc_eps::tpssc_eps(d);
  return d.n*eps;
}

void setup_tpssc(functional &f)
{
  f.describe(XC_TPSSC, XC_MGGA,
	     "TPSS original correlation functional",
	     "TPSS original correlation functional.\n"
	     "J. Tao, J.P. Perdew, V. N. Staroverov, G. E. Scuseria,\n"
             "Climbing the Density Functional Ladder:\n"
	     "Nonempirical Meta-Generalized Gradient Approximation\n"
             "Designed for Molecules and Solids,\n"
	     "Phys. Rev. Lett. 91 (2003) 146401\n"
	     "Implemented by Andrea Debnarova\n");
  SET_MGGA_ENERGY_FUNCTION(f,energy);
  // Test case from ??
 // const double d[1] =
 //  {0};
 // const double ref[1] =
  //  {0};
 // f.add_test(XC_VARS_AB,2,d,ref,1e-11);
}

<commit_msg>Add test for tpssc<commit_after>#include "functional.h"
#include "constants.h"
#include "tpssc_eps.h"

template<class num>
static num energy(const densvars<num> &d)
{
  num eps = tpssc_eps::tpssc_eps(d);
  return d.n*eps;
}

void setup_tpssc(functional &f)
{
  f.describe(XC_TPSSC, XC_MGGA,
	     "TPSS original correlation functional",
	     "TPSS original correlation functional.\n"
	     "J. Tao, J.P. Perdew, V. N. Staroverov, G. E. Scuseria,\n"
             "Climbing the Density Functional Ladder:\n"
	     "Nonempirical Meta-Generalized Gradient Approximation\n"
             "Designed for Molecules and Solids,\n"
	     "Phys. Rev. Lett. 91 (2003) 146401\n"
	     "Implemented by Andrea Debnarova\n");
  SET_MGGA_ENERGY_FUNCTION(f,energy);
  // Test case from A**
  const double d[] = {0.153652558932587,
		      0.153652558932587,
		      8.390981882024583E-002,
		      8.390981882024583E-002,
		      8.390981882024583E-002,
		      6.826262722466284E-002,
		      6.826262722466284E-002};
  const double ref[] = {0,//Fill in energy
			   -7.299596527683171E-002,
		       -7.299596527683171E-002,
		       1.247652223035057E-002,
		       5.978495466748646E-002,
		       1.247652223035057E-002,
		       -4.068185412322921E-002,
		       -4.068185412322921E-002};
 // f.add_test(XC_VARS_AB,1,d,ref,1e-11);
}

<|endoftext|>


<commit_before>#include "stdafx.h"
#include "AnnLevelManager.hpp"
#include "AnnEngine.hpp"
#include "AnnLogger.hpp"
#include "AnnGetter.hpp"

using namespace Annwvyn;

AnnLevelManager::AnnLevelManager() : AnnSubSystem("LevelManager"),
current(nullptr),
jumpRequested(false),
jumpTo(0)
{
}

AnnLevelManager::~AnnLevelManager()
{
	AnnGetEngine()->log("Deleting the Level Manager. Destroying every level known by the Level Manager before.");
	//clear the levels
	levelList.clear();
}

void AnnLevelManager::jump(level_id levelId)
{
	AnnDebug() << "LevelManager jumping to levelId : " << levelId;

	if (!(levelId < levelList.size())) return;

	//Deferred level jump
	if (!jumpRequested)
	{
		jumpRequested = true;
		jumpTo = levelId;
		return;
	}

	jumpRequested = false;
	jumpTo = 0;
	if (current)
		current->unload();
	current = levelList[levelId];
	current->load();
}

void AnnLevelManager::jump(std::shared_ptr<AnnLevel> level)
{
	for (level_id i(0); i < levelList.size(); i++)
		if (levelList[i] == level)
		{
			jump(i);
			break;
		}
}

void AnnLevelManager::addLevel(std::shared_ptr<AnnLevel> level)
{
	AnnDebug() << "Adding level " << level << " to LevelManager";
	levelList.push_back(level);
}

void AnnLevelManager::jumpToFirstLevel()
{
	jump(level_id(0));
}

void AnnLevelManager::update()
{
	if (jumpRequested)
		return jump(jumpTo);
	if (current) current->runLogic();
}

void AnnLevelManager::unloadCurrentLevel()
{
	if (current) current->unload();
	current = nullptr;
}

std::shared_ptr<AnnLevel> AnnLevelManager::getLastLevelLoaded()
{
	return levelList.back();
}

std::shared_ptr<AnnLevel> AnnLevelManager::getFirstLevelLoaded()
{
	return levelList.front();
}

std::shared_ptr<AnnLevel> AnnLevelManager::getLevelByIndex(level_id id)
{
	if (id >= levelList.size()) return nullptr;
	return levelList[id];
}

void AnnLevelManager::addToCurrentLevel(std::shared_ptr<AnnGameObject> obj) const
{
	if (!current || !obj) return;
	current->levelContent.push_back(obj);
}

void AnnLevelManager::removeFromCurrentLevel(std::shared_ptr<AnnGameObject> obj) const
{
	if (!current || !obj) return;
	current->levelContent.remove(obj);
}

std::shared_ptr<AnnLevel> AnnLevelManager::getCurrentLevel() const
{
	return current;
}<commit_msg>Fix AnnLevelManager's destructor. Wasn't releasing current level<commit_after>#include "stdafx.h"
#include "AnnLevelManager.hpp"
#include "AnnEngine.hpp"
#include "AnnLogger.hpp"
#include "AnnGetter.hpp"

using namespace Annwvyn;

AnnLevelManager::AnnLevelManager() : AnnSubSystem("LevelManager"),
current(nullptr),
jumpRequested(false),
jumpTo(0)
{
}

AnnLevelManager::~AnnLevelManager()
{
	AnnDebug() << "Deleting the Level Manager. Unloading current level and releasing all level pointers";
	unloadCurrentLevel();
}

void AnnLevelManager::jump(level_id levelId)
{
	AnnDebug() << "LevelManager jumping to levelId : " << levelId;

	if (!(levelId < levelList.size())) return;

	//Deferred level jump
	if (!jumpRequested)
	{
		jumpRequested = true;
		jumpTo = levelId;
		return;
	}

	jumpRequested = false;
	jumpTo = 0;
	if (current)
		current->unload();
	current = levelList[levelId];
	current->load();
}

void AnnLevelManager::jump(std::shared_ptr<AnnLevel> level)
{
	for (level_id i(0); i < levelList.size(); i++)
		if (levelList[i] == level)
		{
			jump(i);
			break;
		}
}

void AnnLevelManager::addLevel(std::shared_ptr<AnnLevel> level)
{
	AnnDebug() << "Adding level " << level << " to LevelManager";
	levelList.push_back(level);
}

void AnnLevelManager::jumpToFirstLevel()
{
	jump(level_id(0));
}

void AnnLevelManager::update()
{
	if (jumpRequested)
		return jump(jumpTo);
	if (current) current->runLogic();
}

void AnnLevelManager::unloadCurrentLevel()
{
	if (current) current->unload();
	current = nullptr;
}

std::shared_ptr<AnnLevel> AnnLevelManager::getLastLevelLoaded()
{
	return levelList.back();
}

std::shared_ptr<AnnLevel> AnnLevelManager::getFirstLevelLoaded()
{
	return levelList.front();
}

std::shared_ptr<AnnLevel> AnnLevelManager::getLevelByIndex(level_id id)
{
	if (id >= levelList.size()) return nullptr;
	return levelList[id];
}

void AnnLevelManager::addToCurrentLevel(std::shared_ptr<AnnGameObject> obj) const
{
	if (!current || !obj) return;
	current->levelContent.push_back(obj);
}

void AnnLevelManager::removeFromCurrentLevel(std::shared_ptr<AnnGameObject> obj) const
{
	if (!current || !obj) return;
	current->levelContent.remove(obj);
}

std::shared_ptr<AnnLevel> AnnLevelManager::getCurrentLevel() const
{
	return current;
}<|endoftext|>


<commit_before>/*
 * C S O U N D
 *
 * L I C E N S E
 *
 * This software is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This software 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 software; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
#include "CppSound.hpp"

#if !defined(__BUILDING_LIBCSOUND)
#define __BUILDING_LIBCSOUND
#endif
#include <csoundCore.h>

#include <cstdio>
#include <cstring>
#include <ctime>

extern "C" int argdecode(CSOUND *csound, int argc, const char **argv_);

/*CppSound::CppSound() : Csound(),
                       go(false),
                       isCompiled(false),
                       isPerforming(false),
                       spoutSize(0)
{

  //SetHostData((CSOUND *)0);

}
*/
CppSound::~CppSound()
{
}

int CppSound::compile(int argc, const char **argv_)
{
  Message("BEGAN CppSound::compile(%d, %p)...\n", argc, argv_);
  int returnValue = 0;
  go = false;
  csound->orcname_mode = 1;
  // Changed to use only internally stored Csound orchestra and score.
  returnValue = csoundCompileOrc(csound, getOrchestra().c_str());
  returnValue = csoundReadScore(csound, getScore().c_str());
  for (int i = 0; (size_t) i < argv.size(); ++i) {
      Message("arg %3d: %s\n", i, argv[i]);
      csoundSetOption(csound, argv[i]);
  }
  returnValue = csoundStart(csound);
  spoutSize = GetKsmps() * GetNchnls() * sizeof(MYFLT);
  if(returnValue)
    {
      isCompiled = false;
    }
  else
    {
      const char *outfilename = GetOutputName();
      if (outfilename) {
        renderedSoundfile = outfilename;
      }
      isCompiled = true;
      go = true;
    }
  Message("ENDED CppSound::compile.\n");
  return returnValue;
}

int CppSound::compile()
{
  Message("BEGAN CppSound::compile()...\n");
  if(getCommand().length() <= 0)
    {
      Message("No Csound command.\n");
      return 0;
    }
  scatterArgs(getCommand(), const_cast< std::vector<std::string> & >(args), const_cast< std::vector<char *> &>(argv));
  int returnValue = compile(argv.size(), (const char **) &argv.front());
  Message("ENDED CppSound::compile.\n");
  return returnValue;
}

int CppSound::perform(int argc,  const char **argv_)
{
  double beganAt = double(std::clock()) / double(CLOCKS_PER_SEC);
  isCompiled = false;
  go = false;
  Message("BEGAN CppSound::perform(%d, %p)...\n", argc, argv_);
  if(argc <= 0)
    {
      Message("ENDED CppSound::perform without compiling or performing.\n");
      return 0;
    }
  int result = compile(argc, argv_);
  if(result == -1)
    {
      return result;
    }
  for(result = 0; (result == 0) && go; )
    {
      result = PerformKsmps();
    }
  cleanup();
  double endedAt = double(clock()) / double(CLOCKS_PER_SEC);
  double elapsed = endedAt - beganAt;
  Message("Elapsed time = %f seconds.\n", elapsed);
  Message("ENDED CppSound::perform.\n");
  isCompiled = false;
  isPerforming = false;
  return 1;
}

int CppSound::perform()
{
  int returnValue = 0;
  std::string command = getCommand();
  if(command.find("-") == 0)
    {
      const char *argv_[] = {"csound", getFilename().c_str(), 0};
      returnValue = perform(2, argv_);
    }
  else
    {
      scatterArgs(command, const_cast< std::vector<std::string> & >(args), const_cast< std::vector<char *> &>(argv));
      returnValue = perform(args.size(), (const char **)&argv.front());
    }
  return returnValue;
}

void CppSound::stop()
{
  isCompiled = false;
  isPerforming = false;
  go = false;
  Stop();
}

CSOUND *CppSound::getCsound()
{
  return csound;
}

int CppSound::performKsmps()
{
    return PerformKsmps();
}

void CppSound::cleanup()
{
  Cleanup();
  Reset();
}

size_t CppSound::getSpoutSize() const
{
  return spoutSize;
}

std::string CppSound::getOutputSoundfileName() const
{
  return renderedSoundfile;
}

void CppSound::inputMessage(const char *istatement)
{
  InputMessage(istatement);
}

void CppSound::write(const char *text)
{
  Message("%s", text);
}

intptr_t CppSound::getThis()
{
  return (intptr_t) this;
}

CsoundFile *CppSound::getCsoundFile()
{
  return dynamic_cast<CsoundFile *>(this);
}

bool CppSound::getIsCompiled() const
{
  return isCompiled;
}

void CppSound::setIsPerforming(bool isPerforming)
{
  this->isPerforming = isPerforming;
}

bool CppSound::getIsPerforming() const
{
  return isPerforming;
}

bool CppSound::getIsGo()
{
  if(csound) {
    if(GetSpin() && GetSpout()) {
      return go;
    }
  }
  return false;
}

<commit_msg>store temp to prevent dangling pointer [issue #1181]<commit_after>/*
 * C S O U N D
 *
 * L I C E N S E
 *
 * This software is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This software 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 software; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
#include "CppSound.hpp"

#if !defined(__BUILDING_LIBCSOUND)
#define __BUILDING_LIBCSOUND
#endif
#include <csoundCore.h>

#include <cstdio>
#include <cstring>
#include <ctime>

extern "C" int argdecode(CSOUND *csound, int argc, const char **argv_);

/*CppSound::CppSound() : Csound(),
                       go(false),
                       isCompiled(false),
                       isPerforming(false),
                       spoutSize(0)
{

  //SetHostData((CSOUND *)0);

}
*/
CppSound::~CppSound()
{
}

int CppSound::compile(int argc, const char **argv_)
{
  Message("BEGAN CppSound::compile(%d, %p)...\n", argc, argv_);
  int returnValue = 0;
  go = false;
  csound->orcname_mode = 1;
  // Changed to use only internally stored Csound orchestra and score.
  returnValue = csoundCompileOrc(csound, getOrchestra().c_str());
  returnValue = csoundReadScore(csound, getScore().c_str());
  for (int i = 0; (size_t) i < argv.size(); ++i) {
      Message("arg %3d: %s\n", i, argv[i]);
      csoundSetOption(csound, argv[i]);
  }
  returnValue = csoundStart(csound);
  spoutSize = GetKsmps() * GetNchnls() * sizeof(MYFLT);
  if(returnValue)
    {
      isCompiled = false;
    }
  else
    {
      const char *outfilename = GetOutputName();
      if (outfilename) {
        renderedSoundfile = outfilename;
      }
      isCompiled = true;
      go = true;
    }
  Message("ENDED CppSound::compile.\n");
  return returnValue;
}

int CppSound::compile()
{
  Message("BEGAN CppSound::compile()...\n");
  if(getCommand().length() <= 0)
    {
      Message("No Csound command.\n");
      return 0;
    }
  scatterArgs(getCommand(), const_cast< std::vector<std::string> & >(args), const_cast< std::vector<char *> &>(argv));
  int returnValue = compile(argv.size(), (const char **) &argv.front());
  Message("ENDED CppSound::compile.\n");
  return returnValue;
}

int CppSound::perform(int argc,  const char **argv_)
{
  double beganAt = double(std::clock()) / double(CLOCKS_PER_SEC);
  isCompiled = false;
  go = false;
  Message("BEGAN CppSound::perform(%d, %p)...\n", argc, argv_);
  if(argc <= 0)
    {
      Message("ENDED CppSound::perform without compiling or performing.\n");
      return 0;
    }
  int result = compile(argc, argv_);
  if(result == -1)
    {
      return result;
    }
  for(result = 0; (result == 0) && go; )
    {
      result = PerformKsmps();
    }
  cleanup();
  double endedAt = double(clock()) / double(CLOCKS_PER_SEC);
  double elapsed = endedAt - beganAt;
  Message("Elapsed time = %f seconds.\n", elapsed);
  Message("ENDED CppSound::perform.\n");
  isCompiled = false;
  isPerforming = false;
  return 1;
}

int CppSound::perform()
{
  int returnValue = 0;
  std::string command = getCommand();
  std::string filename = getFilename();
  if(command.find("-") == 0)
    {
      const char *argv_[] = {"csound", filename.c_str(), 0};
      returnValue = perform(2, argv_);
    }
  else
    {
      scatterArgs(command, const_cast< std::vector<std::string> & >(args), const_cast< std::vector<char *> &>(argv));
      returnValue = perform(args.size(), (const char **)&argv.front());
    }
  return returnValue;
}

void CppSound::stop()
{
  isCompiled = false;
  isPerforming = false;
  go = false;
  Stop();
}

CSOUND *CppSound::getCsound()
{
  return csound;
}

int CppSound::performKsmps()
{
    return PerformKsmps();
}

void CppSound::cleanup()
{
  Cleanup();
  Reset();
}

size_t CppSound::getSpoutSize() const
{
  return spoutSize;
}

std::string CppSound::getOutputSoundfileName() const
{
  return renderedSoundfile;
}

void CppSound::inputMessage(const char *istatement)
{
  InputMessage(istatement);
}

void CppSound::write(const char *text)
{
  Message("%s", text);
}

intptr_t CppSound::getThis()
{
  return (intptr_t) this;
}

CsoundFile *CppSound::getCsoundFile()
{
  return dynamic_cast<CsoundFile *>(this);
}

bool CppSound::getIsCompiled() const
{
  return isCompiled;
}

void CppSound::setIsPerforming(bool isPerforming)
{
  this->isPerforming = isPerforming;
}

bool CppSound::getIsPerforming() const
{
  return isPerforming;
}

bool CppSound::getIsGo()
{
  if(csound) {
    if(GetSpin() && GetSpout()) {
      return go;
    }
  }
  return false;
}

<|endoftext|>


<commit_before>/*
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Xerces" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache\@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation, and was
 * originally based on software copyright (c) 1999, International
 * Business Machines, Inc., http://www.ibm.com .  For more information
 * on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

/*
 * $Log$
 * Revision 1.8  2000/03/11 03:19:13  chchou
 * Fix bug # 19, add const keyword to API
 *
 * Revision 1.7  2000/02/24 20:11:28  abagchi
 * Swat for removing Log from API docs
 *
 * Revision 1.6  2000/02/17 17:47:25  andyh
 * Update Doc++ API comments
 * NameSpace update to track W3C
 * Changes were made by Chih Hsiang Chou
 *
 * Revision 1.5  2000/02/15 23:17:37  andyh
 * Update Doc++ API comments
 * NameSpace bugfix and update to track W3C
 * Chih Hsiang Chou
 *
 * Revision 1.4  2000/02/10 21:47:12  abagchi
 * Added API docs
 *
 * Revision 1.3  2000/02/06 07:47:30  rahulj
 * Year 2K copyright swat.
 *
 * Revision 1.2  2000/02/04 01:49:28  aruna1
 * TreeWalker and NodeIterator changes
 *
 * Revision 1.1.1.1  1999/11/09 01:09:00  twl
 * Initial checkin
 *
 * Revision 1.2  1999/11/08 20:44:19  rahul
 * Swat for adding in Product name and CVS comment log variable.
 *
 */

// DOM_NodeFilter.h: interface for the DOM_NodeFilter class.
//
//////////////////////////////////////////////////////////////////////

#ifndef DOM_NodeFilter_HEADER_GUARD_
#define DOM_NodeFilter_HEADER_GUARD_

#include "DOM_Node.hpp"

class NodeFilterImpl;

/**
 * Filters are objects that know how to "filter out" nodes. If a
 * DOM_NodeIterator or DOM_TreeWalker is given a
 * filter, it applies the filter before it returns the next node.
 *
 * If the filter says to accept the node, the iterator returns it; otherwise, the
 * iterator looks for the next node and pretends that the node that was rejected
 * was not there.
 *
 *  The DOM does not provide any filters. Filter is just an interface that users can
 *  implement to provide their own filters.
 *
 *  Filters do not need to know how to iterate, nor do they need to know anything
 *  about the data structure that is being iterated. This makes it very easy to write
 *  filters, since the only thing they have to know how to do is evaluate a single node.
 *  One filter may be used with a number of different kinds of iterators, encouraging
 *  code reuse.
 *
 *
"Experimental - subject to change"

 *
 */
class CDOM_EXPORT DOM_NodeFilter
{
    public:
	/** @name Enumerators for Node Filter */
        //@{
	/**
	  *

FILTER_ACCEPT
          *            Accept the node. Navigation methods defined for
          *                NodeIterator or TreeWalker will return this node.
	  *

	  *

          *               FILTER_REJECT
          *               Reject the node. Navigation methods defined for
          *               NodeIterator or TreeWalker will not return this
          *               node. For TreeWalker, the children of this node will
          *               also be rejected. Iterators treat this as a synonym
          *               for FILTER_SKIP.
	  *

	  *
FILTER_SKIP
          *              Reject the node. Navigation methods defined for
          *                  NodeIterator or TreeWalker will not return this
          *                  node. For both NodeIterator and Treewalker, the
          *                  children of this node will still be considered.
 	  *

	  *

          *
	  */
        enum FilterAction {FILTER_ACCEPT, FILTER_REJECT, FILTER_SKIP};
        enum ShowType {
            SHOW_ALL                       = 0x0000FFFF,
            SHOW_ELEMENT                   = 0x00000001,
            SHOW_ATTRIBUTE                 = 0x00000002,
            SHOW_TEXT                      = 0x00000004,
            SHOW_CDATA_SECTION             = 0x00000008,
            SHOW_ENTITY_REFERENCE          = 0x00000010,
            SHOW_ENTITY                    = 0x00000020,
            SHOW_PROCESSING_INSTRUCTION    = 0x00000040,
            SHOW_COMMENT                   = 0x00000080,
            SHOW_DOCUMENT                  = 0x00000100,
            SHOW_DOCUMENT_TYPE             = 0x00000200,
            SHOW_DOCUMENT_FRAGMENT         = 0x00000400,
            SHOW_NOTATION                  = 0x00000800
        };
	//@}

        /** @name Constructors */
        //@{
        /**
          * Default constructor for DOM_NodeFilter.
          */
        DOM_NodeFilter();
        //@}

        /** @name Destructor. */
        //@{
	/**
	  * Destructor for DOM_NodeFilter.
	  */
        virtual ~DOM_NodeFilter();
        //@}

        /** @name Test function. */
        //@{
	/**
	  * Test whether a specified node is visible in the logical view of a DOM_TreeWalker
	  * or DOM_NodeIterator. This function will be called by the implementation of
	  * DOM_TreeWalker and DOM_NodeIterator; it is not intended to be called directly from user
	  * code.
          *
          *
"Experimental - subject to change"

          *
          * @param node The node to check to see if it passes the filter or not.
          * @return A constant to determine whether the node is accepted, rejected, or skipped.
	  */
        virtual short acceptNode (const DOM_Node &node) const =0;
        //@}

    private:
        DOM_NodeFilter(const DOM_NodeFilter &other);
        DOM_NodeFilter & operator = (const DOM_NodeFilter &other);
        bool operator == (const DOM_NodeFilter &other) const;
        bool operator != (const DOM_NodeFilter &other) const;
};

#endif
<commit_msg>Removed tables. It was confusing doxygen<commit_after>/*
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Xerces" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache\@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation, and was
 * originally based on software copyright (c) 1999, International
 * Business Machines, Inc., http://www.ibm.com .  For more information
 * on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

/*
 * $Log$
 * Revision 1.9  2000/05/11 00:07:38  abagchi
 * Removed tables. It was confusing doxygen
 *
 * Revision 1.8  2000/03/11 03:19:13  chchou
 * Fix bug # 19, add const keyword to API
 *
 * Revision 1.7  2000/02/24 20:11:28  abagchi
 * Swat for removing Log from API docs
 *
 * Revision 1.6  2000/02/17 17:47:25  andyh
 * Update Doc++ API comments
 * NameSpace update to track W3C
 * Changes were made by Chih Hsiang Chou
 *
 * Revision 1.5  2000/02/15 23:17:37  andyh
 * Update Doc++ API comments
 * NameSpace bugfix and update to track W3C
 * Chih Hsiang Chou
 *
 * Revision 1.4  2000/02/10 21:47:12  abagchi
 * Added API docs
 *
 * Revision 1.3  2000/02/06 07:47:30  rahulj
 * Year 2K copyright swat.
 *
 * Revision 1.2  2000/02/04 01:49:28  aruna1
 * TreeWalker and NodeIterator changes
 *
 * Revision 1.1.1.1  1999/11/09 01:09:00  twl
 * Initial checkin
 *
 * Revision 1.2  1999/11/08 20:44:19  rahul
 * Swat for adding in Product name and CVS comment log variable.
 *
 */

// DOM_NodeFilter.h: interface for the DOM_NodeFilter class.
//
//////////////////////////////////////////////////////////////////////

#ifndef DOM_NodeFilter_HEADER_GUARD_
#define DOM_NodeFilter_HEADER_GUARD_

#include "DOM_Node.hpp"

class NodeFilterImpl;

/**
 * Filters are objects that know how to "filter out" nodes. If a
 * DOM_NodeIterator or DOM_TreeWalker is given a
 * filter, it applies the filter before it returns the next node.
 *
 * If the filter says to accept the node, the iterator returns it; otherwise, the
 * iterator looks for the next node and pretends that the node that was rejected
 * was not there.
 *
 *  The DOM does not provide any filters. Filter is just an interface that users can
 *  implement to provide their own filters.
 *
 *  Filters do not need to know how to iterate, nor do they need to know anything
 *  about the data structure that is being iterated. This makes it very easy to write
 *  filters, since the only thing they have to know how to do is evaluate a single node.
 *  One filter may be used with a number of different kinds of iterators, encouraging
 *  code reuse.
 *
 *
"Experimental - subject to change"

 *
 */
class CDOM_EXPORT DOM_NodeFilter
{
    public:
	/** @name Enumerators for Node Filter */
        //@{
	/*
	  *

FILTER_ACCEPT
      *            Accept the node. Navigation methods defined for
      *                NodeIterator or TreeWalker will return this node.
	  *

	  *

      *               FILTER_REJECT
      *               Reject the node. Navigation methods defined for
      *               NodeIterator or TreeWalker will not return this
      *               node. For TreeWalker, the children of this node will
      *               also be rejected. Iterators treat this as a synonym
      *               for FILTER_SKIP.
	  *

	  *
FILTER_SKIP
      *              Reject the node. Navigation methods defined for
      *                  NodeIterator or TreeWalker will not return this
      *                  node. For both NodeIterator and Treewalker, the
      *                  children of this node will still be considered.
 	  *

	  *

      *
	  */
        enum FilterAction {FILTER_ACCEPT, FILTER_REJECT, FILTER_SKIP};
        enum ShowType {
            SHOW_ALL                       = 0x0000FFFF,
            SHOW_ELEMENT                   = 0x00000001,
            SHOW_ATTRIBUTE                 = 0x00000002,
            SHOW_TEXT                      = 0x00000004,
            SHOW_CDATA_SECTION             = 0x00000008,
            SHOW_ENTITY_REFERENCE          = 0x00000010,
            SHOW_ENTITY                    = 0x00000020,
            SHOW_PROCESSING_INSTRUCTION    = 0x00000040,
            SHOW_COMMENT                   = 0x00000080,
            SHOW_DOCUMENT                  = 0x00000100,
            SHOW_DOCUMENT_TYPE             = 0x00000200,
            SHOW_DOCUMENT_FRAGMENT         = 0x00000400,
            SHOW_NOTATION                  = 0x00000800
        };
	//@}

        /** @name Constructors */
        //@{
        /**
          * Default constructor for DOM_NodeFilter.
          */
        DOM_NodeFilter();
        //@}

        /** @name Destructor. */
        //@{
	/**
	  * Destructor for DOM_NodeFilter.
	  */
        virtual ~DOM_NodeFilter();
        //@}

        /** @name Test function. */
        //@{
	/**
	  * Test whether a specified node is visible in the logical view of a DOM_TreeWalker
	  * or DOM_NodeIterator. This function will be called by the implementation of
	  * DOM_TreeWalker and DOM_NodeIterator; it is not intended to be called directly from user
	  * code.
          *
          *
"Experimental - subject to change"

          *
          * @param node The node to check to see if it passes the filter or not.
          * @return A constant to determine whether the node is accepted, rejected, or skipped.
	  */
        virtual short acceptNode (const DOM_Node &node) const =0;
        //@}

    private:
        DOM_NodeFilter(const DOM_NodeFilter &other);
        DOM_NodeFilter & operator = (const DOM_NodeFilter &other);
        bool operator == (const DOM_NodeFilter &other) const;
        bool operator != (const DOM_NodeFilter &other) const;
};

#endif
<|endoftext|>


<commit_before>/*
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Xerces" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache\@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation, and was
 * originally based on software copyright (c) 1999, International
 * Business Machines, Inc., http://www.ibm.com .  For more information
 * on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

/**
 * $Log$
 * Revision 1.3  2000/02/06 07:47:31  rahulj
 * Year 2K copyright swat.
 *
 * Revision 1.2  2000/02/04 01:49:27  aruna1
 * TreeWalker and NodeIterator changes
 *
 * Revision 1.1.1.1  1999/11/09 01:09:05  twl
 * Initial checkin
 *
 * Revision 1.3  1999/11/08 20:44:22  rahul
 * Swat for adding in Product name and CVS comment log variable.
 *
 */

#ifndef DOM_TreeWalker_HEADER_GUARD_
#define DOM_TreeWalker_HEADER_GUARD_

#include "DOM_Node.hpp"
#include "DOM_NodeFilter.hpp"

class TreeWalkerImpl;

class CDOM_EXPORT DOM_TreeWalker {

    public:

    DOM_TreeWalker ();
    DOM_TreeWalker (TreeWalkerImpl* impl);
    DOM_TreeWalker(const DOM_TreeWalker &other);
    DOM_TreeWalker & operator = (const DOM_TreeWalker &other);
    DOM_TreeWalker & operator = (const DOM_NullPtr *val);
    ~DOM_TreeWalker();
    bool operator == (const DOM_TreeWalker & other)const;
    bool operator == (const DOM_NullPtr *other) const;
    bool operator != (const DOM_TreeWalker & other) const;
    bool operator != (const DOM_NullPtr * other) const;

    unsigned long   				getWhatToShow();
    DOM_NodeFilter*					getFilter();
    DOM_Node						getCurrentNode();
    void							setCurrentNode(DOM_Node currentNode);
    DOM_Node						parentNode();
    DOM_Node						firstChild();
    DOM_Node						lastChild();
    DOM_Node						previousSibling();
    DOM_Node						nextSibling();
    DOM_Node						previousNode();
    DOM_Node						nextNode();

    void							detach();

    private:
      TreeWalkerImpl*                 fImpl;
};

#endif
<commit_msg>Added API docs<commit_after>/*
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Xerces" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache\@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation, and was
 * originally based on software copyright (c) 1999, International
 * Business Machines, Inc., http://www.ibm.com .  For more information
 * on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

/**
 * $Log$
 * Revision 1.4  2000/02/11 01:05:11  abagchi
 * Added API docs
 *
 * Revision 1.3  2000/02/06 07:47:31  rahulj
 * Year 2K copyright swat.
 *
 * Revision 1.2  2000/02/04 01:49:27  aruna1
 * TreeWalker and NodeIterator changes
 *
 * Revision 1.1.1.1  1999/11/09 01:09:05  twl
 * Initial checkin
 *
 * Revision 1.3  1999/11/08 20:44:22  rahul
 * Swat for adding in Product name and CVS comment log variable.
 *
 */

#ifndef DOM_TreeWalker_HEADER_GUARD_
#define DOM_TreeWalker_HEADER_GUARD_

#include "DOM_Node.hpp"
#include "DOM_NodeFilter.hpp"

class TreeWalkerImpl;

   /**
     * TreeWalker objects are used to navigate a document tree or subtree using the view of
     * the document defined by its whatToShow flags and any filters that are defined for the
     * TreeWalker. Any function which performs navigation using a TreeWalker will
     * automatically support any view defined by a TreeWalker.
     *
     * Omitting nodes from the logical view of a subtree can result in a structure that is
     * substantially different from the same subtree in the complete, unfiltered document. Nodes
     * that are siblings in the TreeWalker view may be children of different, widely separated
     * nodes in the original view. For instance, consider a Filter that skips all nodes except for
     * Text nodes and the root node of a document. In the logical view that results, all text
     * nodes will be siblings and appear as direct children of the root node, no matter how
     * deeply nested the structure of the original document.
     */

class CDOM_EXPORT DOM_TreeWalker {

    public:

        /** @name Constructors */
        //@{

        /**
          * Default constructor
          */
        DOM_TreeWalker ();

        /**
          * Copy constructor
          * @param other The object to be copied
          */
        DOM_TreeWalker(const DOM_TreeWalker &other);
        //@}

        /** @name Destructor */
        //@{
        /**
          * Destructor
          */
        ~DOM_TreeWalker();
        //@}

        /** @name Assignment operators */
        //@{
        /**
          * Assignment operator
          * @param other The object to be copied through assignment
          */
        DOM_TreeWalker & operator = (const DOM_TreeWalker &other);

        /**
          * Assignment operator
          *
          *   This overloaded variant is provided for
          *   the sole purpose of setting a DOM_Node reference variable to
          *   zero.  Nulling out a reference variable in this way will decrement
          *   the reference count on the underlying Node object that the variable
          *   formerly referenced.  This effect is normally obtained when reference
          *   variable goes out of scope, but zeroing them can be useful for
          *   global instances, or for local instances that will remain in scope
          *   for an extended time,  when the storage belonging to the underlying
          *   node needs to be reclaimed.
          * @param val Only a value of 0, or null, is allowed.
          */
        DOM_TreeWalker & operator = (const DOM_NullPtr *val);
        //@}

        /** @name Equality operators */
        //@{
        /**
         *  Test whether this TreeWalker reference refers to the same underlying
         *  tree walker as the other reference object.  This does not
         *  compare the contents of two different objects.
         *
         *  @param other The value to be compared
         *  @return Returns true if the underlying tree walker object is same
         */
        bool operator == (const DOM_TreeWalker & other)const;

        /**
         *  Use this comparison operator to test whether a tree walker reference
         *  is null.
         *
         *  @param other The value to be compared, which must be 0 or null.
         *  @return Returns true if the node iterator is null
         */
        bool operator == (const DOM_NullPtr *other) const;
        //@}

        /** @name Inequality operators */
        //@{

        /**
         *  Test whether this TreeWalker reference refers to the same underlying
         *  tree walker as the other reference object.  This does not
         *  compare the contents of two different objects.
         *
         *  @param other The value to be compared
         *  @return Returns true if the underlying tree walker is different
         */
        bool operator != (const DOM_TreeWalker & other) const;

        /**
         *  Use this comparison operator to test whether a tree walker reference
         *  is null.
         *
         *  @param other The value to be compared, which must be 0 or null.
         *  @return Returns true if the node iterator is NOT null
         */
        bool operator != (const DOM_NullPtr * other) const;
        //@}

        /** @name Get Functions */
        //@{
        /**
          *	 Returns the value of whatToShow
          *  This attribute determines which node types are presented via the
          *  TreeWalker. The available set of constants is defined in the Filters
          *  interface.
          */
        unsigned long   				getWhatToShow();
        /**
          *	Get the filter used to screen nodes.
          */
        DOM_NodeFilter*					getFilter();
        /**
          * Gets the node at which the tree walker is currently positioned.
          *
          * The value must not be null. Alterations to the DOM tree may cause the
          * current node to no longer be accepted by the TreeWalker's associated
          * filter. currentNode may also be explicitly set to any node, whether or not it
          * is within the subtree specified by the root node or would be accepted by
          * the filter and whatToShow flags. Further traversal occurs relative to
          * currentNode even if it is not part of the current view by applying the filters
          * in the requested direction (not changing currentNode where no traversal is
          * possible).
          */
        DOM_Node						getCurrentNode();
        //@}

        /** @name Set Functions */
        //@{
        /**
          *  Sets the current node of the DOM tree in tree walker
          *
          * To know more about the current node see getCurrentNode description.
          * @see #getCurrentNode
          */
        void							setCurrentNode(DOM_Node currentNode);
        //@}

        /** @name Iterator Methods */
        //@{

        /**
          * Moves to and returns the closest visible ancestor node of the current node.
          * If the search for parentNode attempts to step upward from the
          * TreeWalker's root node, or if it fails to find a visible ancestor node, this
          * method retains the current position and returns null.
          *
          * @return The new parent node, or null if the current node has no parent in
          *         the TreeWalker's logical view.
          */
        DOM_Node						parentNode();

        /**
          * Moves the TreeWalker to the first child of the current node, and returns the new node.
          * If the current node has no children, returns null, and retains
          * the current node
          * @return       The new node, or null if the current node has no children.
          */
        DOM_Node						firstChild();

        /**
          * Moves the TreeWalker to the last child of the current node, and returns the new node.
          * If the current node has no children, returns null, and retains
          * the current node.
          *
          * @return The new node, or null if the current node has no children.
          */
        DOM_Node						lastChild();

        /**
          * Moves the TreeWalker to the previous sibling of the current node, and returns the new node.
          * If the current node has no previous sibling, returns
          * null, and retains the current node.
          *
          * @return  The new node, or null if the current node has no previous sibling.
          */
        DOM_Node						previousSibling();

        /**
          * Moves the TreeWalker to the next sibling of the current node, and returns the new node.
          * If the current node has no next sibling, returns null, and
          * retains the current node.
          *
          * @return The new node, or null if the current node has no next sibling.
          */
        DOM_Node						nextSibling();

        /**
          * Moves the TreeWalker to the previous visible node in document order relative to the current node, and returns the new node.
          * If the current node
          * has no previous node, or if the search for previousNode attempts to step
          * upward from the TreeWalker's root node, returns null, and retains the
          * current node.
          *
          * @return  The new node, or null if the current node has no previous node.
          */
        DOM_Node						previousNode();

        /**
          * Moves the TreeWalker to the next visible node in document order relative to the current node, and returns the new node.
          * If the current node has no
          * next node, or if the search for nextNode attempts to step upward from the
          * TreeWalker's root node, returns null, and retains the current node.
          * @return The new node, or null if the current node has no next node.
          */
        DOM_Node						nextNode();

        /**
          *	 Detaches the iterator from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state.
          *  After detach has been invoked, calls to nextNode or previousNode
          *  will raise the exception INVALID_STATE_ERR.
          */
        void							detach();
        //@}

    private:
        TreeWalkerImpl*                 fImpl;

    protected:
        DOM_TreeWalker (TreeWalkerImpl* impl);
};

#endif
<|endoftext|>


<commit_before>/****************************************************************************
 *
 *   Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 3. Neither the name PX4 nor the names of its contributors may be
 *    used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 ****************************************************************************/

/**
 * @file sim.cpp
 *
 * Base class for simulated devices.
 *
 * @todo Bus frequency changes; currently we do nothing with the value
 *       that is supplied.  Should we just depend on the bus knowing?
 */

#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "sim.h"

namespace device
{

SIM::SIM(const char *name,
	 const char *devname,
	 int bus,
	 uint16_t address) :
	// base class
	Device(name),
	// public
	// protected
	// private
	_bus(bus),
	_address(address),
	_devname(devname)
{

	printf("SIM::SIM name = %s devname = %s\n", name, devname);
	// fill in _device_id fields for a SIM device
	_device_id.devid_s.bus_type = DeviceBusType_SIM;
	_device_id.devid_s.bus = bus;
	_device_id.devid_s.address = address;
	// devtype needs to be filled in by the driver
	_device_id.devid_s.devtype = 0;
}

SIM::~SIM()
{
}

int
SIM::init()
{
	int ret = PX4_OK;

	// Assume the driver set the desired bus frequency. There is no standard
	// way to set it from user space.

	// do base class init, which registers the virtual driver
	ret = Device::init();

	if (ret != PX4_OK) {
		debug("VDev::init failed");
		return ret;
	}

	return ret;
}

int
SIM::transfer(const uint8_t *send, unsigned send_len, uint8_t *recv, unsigned recv_len)
{
	if (send_len > 0) {
		printf("SIM: sending %d bytes\n", send_len);
	}

	if (recv_len > 0) {
		printf("SIM: receiving %d bytes\n", recv_len);

		// TODO - write data to recv;
	}

	printf("I2C SIM: transfer_4 on %s\n", _devname);

	return PX4_OK;
}

} // namespace device
<commit_msg>Used new debug macros for sim.cpp<commit_after>/****************************************************************************
 *
 *   Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 3. Neither the name PX4 nor the names of its contributors may be
 *    used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 ****************************************************************************/

/**
 * @file sim.cpp
 *
 * Base class for simulated devices.
 *
 * @todo Bus frequency changes; currently we do nothing with the value
 *       that is supplied.  Should we just depend on the bus knowing?
 */

#include <px4_debug.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "sim.h"

namespace device
{

SIM::SIM(const char *name,
	 const char *devname,
	 int bus,
	 uint16_t address) :
	// base class
	Device(name),
	// public
	// protected
	// private
	_bus(bus),
	_address(address),
	_devname(devname)
{

	PX4_DBG("SIM::SIM name = %s devname = %s", name, devname);
	// fill in _device_id fields for a SIM device
	_device_id.devid_s.bus_type = DeviceBusType_SIM;
	_device_id.devid_s.bus = bus;
	_device_id.devid_s.address = address;
	// devtype needs to be filled in by the driver
	_device_id.devid_s.devtype = 0;
}

SIM::~SIM()
{
}

int
SIM::init()
{
	int ret = PX4_OK;

	// Assume the driver set the desired bus frequency. There is no standard
	// way to set it from user space.

	// do base class init, which registers the virtual driver
	ret = Device::init();

	if (ret != PX4_OK) {
		PX4_ERR("VDev::init failed");
		return ret;
	}

	return ret;
}

int
SIM::transfer(const uint8_t *send, unsigned send_len, uint8_t *recv, unsigned recv_len)
{
	if (send_len > 0) {
		PX4_DBG("SIM: sending %d bytes", send_len);
	}

	if (recv_len > 0) {
		PX4_DBG("SIM: receiving %d bytes", recv_len);

		// TODO - write data to recv;
	}

	PX4_DBG("I2C SIM: transfer_4 on %s", _devname);

	return PX4_OK;
}

} // namespace device
<|endoftext|>


<commit_before>#include "scientistservice.h"
#include <algorithm>
#include <iostream>

using namespace std;

ScientistService::ScientistService()
{
}
//compares names of scientists in alphabetical order
struct ScientistComparisonNameForward
{
    bool operator() (Scientist i, Scientist j) {return (i.getName()<j.getName());}
};

//compares year of birth between scientists in ascending order
bool ScientistComparisonYearOfBirthForward (Scientist i, Scientist j)
{
    return (i.getYearOfBirth()<j.getYearOfBirth());
}
//compares year of death between scientists in ascending order
bool ScientistComparisonYearOfDeathForward (Scientist i, Scientist j)
{
    return (i.getYearOfDeath()<j.getYearOfDeath());
}
//compares age between scientists in ascending order
bool ScientistComparisonAgeForward (Scientist i, Scientist j)
{
    return (i.getAge()<j.getAge());
}

//NEED TO USE OR TERMINATE
/*
struct ScientistComparisonGenderForward
{
    bool operator() (Scientist i, Scientist j) {return (i.getGender()<j.getGender());}
};
*/
//sorts scientist by aplhabetical order, by year of birth, by year of death and by age
 vector<Scientist> ScientistService::sortScientists(vector<Scientist> _listOfScientists, string sort)
{
    if (sort == "name" || sort == "Name" || sort == "n")

    {
        ScientistComparisonNameForward cmp;
        std::sort(_scientists.begin(), _scientists.end(), cmp);
    }
    else if (sort == "birth" || sort == "Birth" || sort == "b")
    {
        std::sort(_scientists.begin(), _scientists.end(), ScientistComparisonYearOfBirthForward);
    }
    else if (sort == "death" || sort == "Death" || sort == "d")
    {
        std::sort(_scientists.begin(), _scientists.end(), ScientistComparisonYearOfDeathForward);
    }
    else if (sort == "age" || sort == "Age" || sort == "a")
    {
        std::sort(_scientists.begin(), _scientists.end(), ScientistComparisonAgeForward);
    }
    else
    {
        //default is to sort by name
        ScientistComparisonNameForward cmp;
        std::sort(_scientists.begin(), _scientists.end(), cmp);
    }
    return _listOfScientists;
}
//search for scientist by name
vector<int> ScientistService::searchScientists(string& searchData)
{
    vector<int> foundScientists;

    for(unsigned long i = 0; i < _scientists.size(); i++)
    {
        string name = _scientists[i].getName();
        if(name.substr(0,searchData.size()) == searchData)
        {
            //If we find the scientist then we...

            foundScientists.push_back(i);
        }
    }
    return foundScientists; //remeber to change
}
// adds an registered scientist to vector
void ScientistService::addScientist(Scientist scientist)
{
    bool isin = ifExist(scientist.getName());

    if (isin == false)
    {
         _scientists.push_back(scientist);
         _data.writeNewScientist(scientist);
    }
}
//get functions
Scientist ScientistService::getScientist(int index) const
{
    return _scientists[index];
}
//get vector size
int ScientistService::getSize() const
{
    return _scientists.size();
}
//validation - registering a scientist that is already registered is not allowed
bool ScientistService::ifExist(string name)
{
   for (size_t i = 0; i < _scientists.size(); i++)
   {
       if (_scientists[i].getName() == name)
       {
           return true;
       }
   }
   return false;
}
//get scientist vector
vector<Scientist> ScientistService::getScientistVector()
{
    return _scientists;
}
//loads from file to vector
bool ScientistService::load()
{
    _data.getData(_scientists);

    return DataAccessWorks();
}
//validates if DataAccess works
bool ScientistService::DataAccessWorks()
{
    if (_data.DataOk && _data.FileOpen)
    {
        return true;
    }

    return false;
}
//user can change characteristic of scientist
void ScientistService::editScientist(int index, string change, string input)
{
    if (change == "name")
    {
        _scientists[index].setName(input);
    }
    else if (change == "gender")
    {
        _scientists[index].setGender(input);
    }
    else if (change == "birth")
    {
        _scientists[index].setYearOfBirth(stoi(input, 0));
    }
    else if (change == "death")
    {
        _scientists[index].setYearOfDeath(stoi(input, 0));
    }
}
//user can delete scientist
void ScientistService::deleteScientist(int index)
{
    _scientists.erase(_scientists.begin()+index);
    _data.writeData(_scientists);
}

<commit_msg>Fixed disappearing code<commit_after>#include "scientistservice.h"
#include <algorithm>
#include <iostream>

using namespace std;

//operator instrument that compares names in alphabetical order
struct ScientistComparisonNameForward
{
    bool operator() (Scientist i, Scientist j) {return (i.getName()<j.getName());}
};

//operator instrument that compares year of birth in ascending order
bool ScientistComparisonYearOfBirthForward (Scientist i, Scientist j)
{
    return (i.getYearOfBirth()<j.getYearOfBirth());
}

bool ScientistComparisonYearOfDeathForward (Scientist i, Scientist j)
{
    return (i.getYearOfDeath()<j.getYearOfDeath());
}

bool ScientistComparisonAgeForward (Scientist i, Scientist j)
{
    return (i.getAge()<j.getAge());
}

struct ScientistComparisonGenderForward
{
    bool operator() (Scientist i, Scientist j) {return (i.getGender()<j.getGender());}
};

ScientistService::ScientistService()
{
}

 vector<Scientist> ScientistService::sortScientists(vector<Scientist> _listOfScientists, string sort)
{
    if (sort == "name" || sort == "Name" || sort == "n")

    {
        ScientistComparisonNameForward cmp;
        std::sort(_scientists.begin(), _scientists.end(), cmp);
    }
    else if (sort == "birth" || sort == "Birth" || sort == "b")
    {
        std::sort(_scientists.begin(), _scientists.end(), ScientistComparisonYearOfBirthForward);
    }
    else if (sort == "death" || sort == "Death" || sort == "d")
    {
        std::sort(_scientists.begin(), _scientists.end(), ScientistComparisonYearOfDeathForward);
    }
    else if (sort == "age" || sort == "Age" || sort == "a")
    {
        std::sort(_scientists.begin(), _scientists.end(), ScientistComparisonAgeForward);
    }
    else
    {
        //default is to sort by name
        ScientistComparisonNameForward cmp;
        std::sort(_scientists.begin(), _scientists.end(), cmp);
    }
    return _listOfScientists;
}

vector<int> ScientistService::searchScientists(string& searchData)
{
    vector<int> foundScientists;

    transform(searchData.begin(), searchData.end(), searchData.begin(), ::tolower);

    for(unsigned long i = 0; i < _scientists.size(); i++)
    {
        string name = _scientists[i].getName();
        transform(name.begin(), name.end(), name.begin(), ::tolower);
        if(name.substr(0,searchData.size()) == searchData)
        {
            //If we find the scientist then we...

            foundScientists.push_back(i);
        }
    }
    return foundScientists; //remeber to change
}

void ScientistService::addScientist(Scientist scientist)
{
    bool isin = ifExist(scientist.getName());

    if (isin == false)
    {
         _scientists.push_back(scientist);
         _data.writeNewScientist(scientist);
    }
}

Scientist ScientistService::getScientist(int index) const
{
    return _scientists[index];
}

int ScientistService::getSize() const
{
    return _scientists.size();
}

bool ScientistService::ifExist(string name)
{
   for (size_t i = 0; i < _scientists.size(); i++)
   {
       if (_scientists[i].getName() == name)
       {
           return true;
       }
   }
   return false;
}

vector<Scientist> ScientistService::getScientistVector()
{
    return _scientists;
}

bool ScientistService::load()
{
    _data.getData(_scientists);

    return DataAccessWorks();
}

bool ScientistService::DataAccessWorks()
{
    if (_data.DataOk && _data.FileOpen)
    {
        return true;
    }

    return false;
}

void ScientistService::editScientist(int index, string change, string input)
{
    if (change == "name")
    {
        _scientists[index].setName(input);
    }
    else if (change == "gender")
    {
        _scientists[index].setGender(input);
    }
    else if (change == "birth")
    {
        _scientists[index].setYearOfBirth(stoi(input, 0));
    }
    else if (change == "death")
    {
        _scientists[index].setYearOfDeath(stoi(input, 0));
    }
}

void ScientistService::deleteScientist(int index)
{
    _scientists.erase(_scientists.begin()+index);
    _data.writeData(_scientists);
}
<|endoftext|>


<commit_before>// $Id$

#include <iostream.h>

static Bool_t isGeant4 = false;
static Bool_t isSteer = false;
static Bool_t isDetector = false;

void g4libs()
{
  // g4libs_global();
  g4libs_granular();
}

void g4libs_global()
{
// Loads G4 global libraries,
// external packages: CLHEP, graphics drivers, .. used by G4
// and Alice G4 libraries: AliGeant4, TGeant4
// ---
  if (!isGeant4) {

    // CLHEP
    gSystem->Load("$(CLHEP_BASE_DIR)/lib/libCLHEP");

    // Geant4
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4global");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4graphics_reps");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4intercoms");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4materials");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4geometry");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4particles");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4track");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4processes");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4tracking");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4digits+hits");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4event");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4readout");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4run");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG3toG4");

    // Geant4 interfaces
    //gSystem->Load("/usr/X11R6/lib/libXt");
    //gSystem->Load("/usr/local/lib/libXm");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4UIcommon");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4UIbasic");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4UIGAG");

    // Geant4 visualization
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4vis_management");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4modeling");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4FR");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4OpenGL");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4VRML");

    // TGeant4, AliGeant4
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libTGeant4");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libAliGeant4");

    isGeant4 = true;
    cout << "Geant4 global libraries have been loaded." << endl;
  }
}

void g4libs_granular()
{
// Loads G4 granular libraries,
// external packages: CLHEP, graphics drivers, .. used by G4
// and Alice G4 libraries: AliGeant4, TGeant4
// ---
  if (!isGeant4) {

    // CLHEP
    gSystem->Load("$(CLHEP_BASE_DIR)/lib/libCLHEP");

    // G4 categories

    // global
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4globman");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hepnumerics");

    // graphics_reps
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4graphics_reps");

    // intercoms
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4intercoms");

    // materials
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4materials");

    // geometry
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4magneticfield");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4volumes");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4geometrymng");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4geomBoolean");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4csg");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4step");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4brep");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4specsolids");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4stepinterface");

    // particles
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4partman");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4bosons");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4baryons");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4ions");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4mesons");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4leptons");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4shortlived");

    // track
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4track");

    // processes
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4procman");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4parameterisation");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4decay");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4emutils");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4emstandard");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4emlowenergy");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4muons");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4xrays");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_xsect");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_mgt");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_proc");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_util");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_man_gen");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_util_gen");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_string_common");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_diffstring");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_stringfrag");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_HE_gen");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_kinetic");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_preequ");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_qgstring");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_HE");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_LE");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_deex");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_stop");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_neu");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_iso");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4optical");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4photolepton_hadron");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4transportation");

    // tracking
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4tracking");

    // digits+hits
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hits");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4digits");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4detector");

    // event
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4event");

    // readout
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4readout");

    // run
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4run");

    // g3tog4
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG3toG4");

    // interfaces
    //gSystem->Load("/usr/X11R6/lib/libXt");
    //gSystem->Load("/usr/local/lib/libXm");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4UIcommon");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4UIbasic");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4UIGAG");

    // visualisation
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4modeling");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4vis_management");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4FR");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4OpenGL");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4VRML");

    // TGeant4, AliGeant4
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libTGeant4");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libAliGeant4");

    isGeant4 = true;
    cout << "Geant4 granular libraries have been loaded." << endl;
  }
}

void steerlibs() {
// Loads AliRoot steer libraries
// ---
  if (!isSteer) {

    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libSTEER");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libdummypythia6");
    gSystem->Load("$(ROOTSYS)/lib/libEGPythia6");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libEVGEN");

    isSteer = true;
    cout << "AliRoot steer libraries have been loaded." << endl;
  }
}

void detlibs() {
// Load AliRoot modules libraries
// ---
  if (!isDetector) {

    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libminicern");
    // minicern required by MUON
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libSTRUCT");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libFMD");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libMUON");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libPHOS");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libPMD");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libRICH");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libTOF");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libTPC");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libTRD");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libZDC");
    #gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libITS");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libCASTOR");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libSTART");

    isDetector = true;
    cout << "AliRoot detectors libraries have been loaded." << endl;
  }
}
<commit_msg>loading granular libs updated to geant4 4.0 (I. Gonzalez)<commit_after>// $Id$

#include <iostream.h>

static Bool_t isGeant4 = false;
static Bool_t isSteer = false;
static Bool_t isDetector = false;

void g4libs()
{
  // g4libs_global();
  g4libs_granular();
}

void g4libs_global()
{
// Loads G4 global libraries,
// external packages: CLHEP, graphics drivers, .. used by G4
// and Alice G4 libraries: AliGeant4, TGeant4
// ---
  if (!isGeant4) {

    // CLHEP
    gSystem->Load("$(CLHEP_BASE_DIR)/lib/libCLHEP");

    // Geant4
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4global");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4graphics_reps");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4intercoms");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4materials");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4geometry");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4particles");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4track");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4processes");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4tracking");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4digits+hits");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4event");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4readout");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4run");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG3toG4");

    // Geant4 interfaces
    //gSystem->Load("/usr/X11R6/lib/libXt");
    //gSystem->Load("/usr/local/lib/libXm");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4UIcommon");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4UIbasic");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4UIGAG");

    // Geant4 visualization
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4vis_management");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4modeling");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4FR");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4OpenGL");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4VRML");

    // TGeant4, AliGeant4
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libTGeant4");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libAliGeant4");

    isGeant4 = true;
    cout << "Geant4 global libraries have been loaded." << endl;
  }
}

void g4libs_granular()
{
// Loads G4 granular libraries,
// external packages: CLHEP, graphics drivers, .. used by G4
// and Alice G4 libraries: AliGeant4, TGeant4
// ---
  if (!isGeant4) {

    // CLHEP
    gSystem->Load("$(CLHEP_BASE_DIR)/lib/libCLHEP");

    // G4 categories

    // global
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4globman");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hepnumerics");

    // graphics_reps
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4graphics_reps");

    // intercoms
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4intercoms");

    // materials
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4materials");

    // geometry
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4geomver");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4volumes");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4magneticfield");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4geometrymng");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4geomBoolean");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4csg");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4step");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4brep");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4specsolids");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4stepinterface");

    // particles
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4partman");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4bosons");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4baryons");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4ions");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4mesons");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4leptons");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4shortlived");

    // track
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4track");

    // processes
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4procman");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4parameterisation");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4decay");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4emutils");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4emstandard");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4emlowenergy");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4muons");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4xrays");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_xsect");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_mgt");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_proc");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_util");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_man_gen");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_util_gen");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_string_common");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_diffstring");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_stringfrag");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_HE_gen");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_kinetic");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_qgstring");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_HE");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_LE");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_deex");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_preequ");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_stop");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_neu");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hadronic_iso");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4optical");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4photolepton_hadron");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4transportation");

    // tracking
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4tracking");

    // digits+hits
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4hits");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4digits");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4detector");

    // event
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4event");

    // readout
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4readout");

    // run
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4run");

    // g3tog4
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG3toG4");

    // interfaces
    //gSystem->Load("/usr/X11R6/lib/libXt");
    //gSystem->Load("/usr/X11R6/lib/libXm");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4UIcommon");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4UIbasic");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4UIGAG");

    // visualisation
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4modeling");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4vis_management");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4FR");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4OpenGL");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4VRML");
    gSystem->Load("$(G4INSTALL)/lib/$(G4SYSTEM)/libG4RayTracer");

    // TGeant4, AliGeant4
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libTGeant4");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libAliGeant4");

    isGeant4 = true;
    cout << "Geant4 granular libraries have been loaded." << endl;
  }
}

void steerlibs() {
// Loads AliRoot steer libraries
// ---
  if (!isSteer) {

    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libSTEER");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libdummypythia6");
    gSystem->Load("$(ROOTSYS)/lib/libEGPythia6");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libEVGEN");

    isSteer = true;
    cout << "AliRoot steer libraries have been loaded." << endl;
  }
}

void detlibs() {
// Load AliRoot modules libraries
// ---
  if (!isDetector) {

    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libminicern");
    // minicern required by MUON
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libSTRUCT");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libFMD");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libMUON");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libPHOS");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libPMD");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libRICH");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libTOF");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libTPC");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libTRD");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libZDC");
    //gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libITS");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libCASTOR");
    gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libSTART");

    isDetector = true;
    cout << "AliRoot detectors libraries have been loaded." << endl;
  }
}
<|endoftext|>