2007-11-28 04:19:21 +01:00
|
|
|
/*
|
|
|
|
|
VISITOR.hpp - Acyclic Visitor library
|
|
|
|
|
|
2008-03-10 04:25:03 +01:00
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2008, Hermann Vosseler <Ichthyostega@web.de>
|
2007-11-28 04:19:21 +01:00
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program 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 General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2008-01-05 01:38:32 +01:00
|
|
|
/** @file visitorpolicies.hpp
|
|
|
|
|
** Policies usable for configuring the cinelerra::visitor::Tool for different kinds of error handling.
|
|
|
|
|
** @see buildertool.hpp for another flavor (calling and catch-all-function)
|
|
|
|
|
**
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2007-11-28 04:19:21 +01:00
|
|
|
|
|
|
|
|
#ifndef CINELERRA_VISITORPOLICIES_H
|
|
|
|
|
#define CINELERRA_VISITORPOLICIES_H
|
|
|
|
|
|
|
|
|
|
#include "common/error.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace cinelerra
|
|
|
|
|
{
|
|
|
|
|
namespace visitor
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Policy returning just the default return value in case
|
|
|
|
|
* of encountering an unknown Visitor (typically caused by
|
|
|
|
|
* adding a new class to the visitable hierarchy)
|
|
|
|
|
*/
|
2008-01-05 01:38:32 +01:00
|
|
|
template<class RET>
|
2007-11-28 04:19:21 +01:00
|
|
|
struct UseDefault
|
|
|
|
|
{
|
2008-01-04 15:10:18 +01:00
|
|
|
template<class TAR>
|
2008-01-05 01:38:32 +01:00
|
|
|
RET
|
|
|
|
|
onUnknown (TAR&)
|
2007-11-28 04:19:21 +01:00
|
|
|
{
|
2008-01-05 01:38:32 +01:00
|
|
|
return RET();
|
2007-11-28 04:19:21 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Policy to throw when encountering an unknown visiting tool
|
|
|
|
|
*/
|
2008-01-05 01:38:32 +01:00
|
|
|
template<class RET>
|
2007-11-28 04:19:21 +01:00
|
|
|
struct ThrowException
|
|
|
|
|
{
|
2008-01-04 15:10:18 +01:00
|
|
|
template<class TAR>
|
2008-01-05 01:38:32 +01:00
|
|
|
RET
|
|
|
|
|
onUnknown (TAR&)
|
2007-11-28 04:19:21 +01:00
|
|
|
{
|
|
|
|
|
throw cinelerra::error::Config("unable to decide what tool operation to call");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2008-01-05 01:38:32 +01:00
|
|
|
|
2007-11-28 04:19:21 +01:00
|
|
|
|
|
|
|
|
} // namespace visitor
|
|
|
|
|
|
|
|
|
|
} // namespace cinelerra
|
|
|
|
|
#endif
|