Commit 49f6314d authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

started function toolbox

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1667
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 281184f9
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: README.changelog,v 1.47 2004-02-10 15:27:39 tforb Exp $
* $Id: README.changelog,v 1.48 2005-03-21 09:35:32 tforb Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -21,11 +21,16 @@
/*! \page page_changelog ChangeLog (AFF)
$Id: README.changelog,v 1.47 2004-02-10 15:27:39 tforb Exp $
$Id: README.changelog,v 1.48 2005-03-21 09:35:32 tforb Exp $
\sa \ref page_project_status
Major changes in the interface of the library are marked by \b !!.
- \b 20/3/2005 (thof)
- Added function templates to scan and map values in containers.
They are collected in subdirectory functions and use collector.h and
mapper.h
- \b 10/02/2004 (thof)
- removed lib/iteratable.h
......@@ -206,7 +211,7 @@
/*! \page page_project_status Project status (AFF)
$Id: README.changelog,v 1.47 2004-02-10 15:27:39 tforb Exp $
$Id: README.changelog,v 1.48 2005-03-21 09:35:32 tforb Exp $
\sa \ref page_changelog
......@@ -352,6 +357,29 @@
<TR><TD>libaff/lib/dump_simplerigidarray.h</TD>
<TD>19/12/02</TD><TD> </TD><TD>19/12/02</TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/collector.h</TD>
<TD></TD><TD> </TD><TD></TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/mapper.h</TD>
<TD></TD><TD> </TD><TD></TD><TD> </TD>
</TR>
<TR><TD><BR><B>subdirectory "functions"</B></TD></TR>
<TR><TD>libaff/functions/max.h</TD>
<TD></TD><TD></TD><TD></TD><TD> </TD>
</TR>
<TR><TD>libaff/functions/min.h</TD>
<TD></TD><TD></TD><TD></TD><TD> </TD>
</TR>
<TR><TD>libaff/functions/avg.h</TD>
<TD></TD><TD></TD><TD></TD><TD> </TD>
</TR>
<TR><TD>libaff/functions/rms.h</TD>
<TD></TD><TD></TD><TD></TD><TD> </TD>
</TR>
<TR><TD>libaff/functions/valmap.h</TD>
<TD></TD><TD></TD><TD></TD><TD> </TD>
</TR>
<TR><TD><BR><B>tests and examples</B></TD></TR>
<TR><TD>libaff/tests/arraytest.cc</TD>
......
This is a legacy version of the repository. It may be incomplete as well as
inconsistent. See README.history for details. For the old stock of the
repository copyright and licence conditions apply as specified for versions
commited after 2015-03-01. Use recent versions as a base for new development.
The legacy version is only stored to keep a record of history.
/*! \file avg.h
* \brief return average of element values (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: avg.h,v 1.1 2005-03-21 09:35:33 tforb Exp $
* \author Thomas Forbriger
* \date 20/03/2005
*
* return average of element values (prototypes)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 20/03/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef AFF_AVG_H_VERSION
#define AFF_AVG_H_VERSION \
"AFF_AVG_H V1.0 "
#define AFF_AVG_H_CVSID \
"$Id: avg.h,v 1.1 2005-03-21 09:35:33 tforb Exp $"
namespace tf {
}
#endif // AFF_AVG_H_VERSION (includeguard)
/* ----- END OF avg.h ----- */
/*! \file max.h
* \brief return maximum element value (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: max.h,v 1.1 2005-03-21 09:35:33 tforb Exp $
* \author Thomas Forbriger
* \date 20/03/2005
*
* return maximum element value (prototypes)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 20/03/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef AFF_MAX_H_VERSION
#define AFF_MAX_H_VERSION \
"AFF_MAX_H V1.0 "
#define AFF_MAX_H_CVSID \
"$Id: max.h,v 1.1 2005-03-21 09:35:33 tforb Exp $"
#include<aff/lib/collector.h>
namespace aff {
namespace func {
namespace util {
template<class T>
class MaxCollector {
public:
typedef T Tvalue;
MaxCollector(): Mval(Tvalue()) { }
MaxCollector(const Tvalue& v): Mval(v) { }
MaxCollector operator() (cont Tvalue& v)
{
Mval
private:
T Mval;
}; // class MaxCollector
} // namespace util
template<class C, class T>
T max(const typename C<T>::Tcoc& c)
{
}
} // namespace func
} // namespace aff
#endif // AFF_MAX_H_VERSION (includeguard)
/* ----- END OF max.h ----- */
/*! \file min.h
* \brief return minimum element value (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: min.h,v 1.1 2005-03-21 09:35:33 tforb Exp $
* \author Thomas Forbriger
* \date 20/03/2005
*
* return minimum element value (prototypes)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 20/03/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef AFF_MIN_H_VERSION
#define AFF_MIN_H_VERSION \
"AFF_MIN_H V1.0 "
#define AFF_MIN_H_CVSID \
"$Id: min.h,v 1.1 2005-03-21 09:35:33 tforb Exp $"
namespace tf {
}
#endif // AFF_MIN_H_VERSION (includeguard)
/* ----- END OF min.h ----- */
/*! \file rms.h
* \brief return rms of element values (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: rms.h,v 1.1 2005-03-21 09:35:34 tforb Exp $
* \author Thomas Forbriger
* \date 20/03/2005
*
* return rms of element values (prototypes)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 20/03/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef AFF_RMS_H_VERSION
#define AFF_RMS_H_VERSION \
"AFF_RMS_H V1.0 "
#define AFF_RMS_H_CVSID \
"$Id: rms.h,v 1.1 2005-03-21 09:35:34 tforb Exp $"
namespace tf {
}
#endif // AFF_RMS_H_VERSION (includeguard)
/* ----- END OF rms.h ----- */
/*! \file valmap.h
* \brief map element values (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: valmap.h,v 1.1 2005-03-21 09:35:34 tforb Exp $
* \author Thomas Forbriger
* \date 20/03/2005
*
* map element values (prototypes)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 20/03/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef AFF_VALMAP_H_VERSION
#define AFF_VALMAP_H_VERSION \
"AFF_VALMAP_H V1.0 "
#define AFF_VALMAP_H_CVSID \
"$Id: valmap.h,v 1.1 2005-03-21 09:35:34 tforb Exp $"
namespace tf {
}
#endif // AFF_VALMAP_H_VERSION (includeguard)
/* ----- END OF valmap.h ----- */
/*! \file collector.h
* \brief collect values (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: collector.h,v 1.1 2005-03-21 09:35:34 tforb Exp $
* \author Thomas Forbriger
* \date 20/03/2005
*
* collect values (prototypes)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 20/03/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_COLLECTOR_H_VERSION
#define TF_COLLECTOR_H_VERSION \
"TF_COLLECTOR_H V1.0 "
#define TF_COLLECTOR_H_CVSID \
"$Id: collector.h,v 1.1 2005-03-21 09:35:34 tforb Exp $"
namespace aff {
namespace func {
namespace util {
template<class C, class T>
class Collector {
public:
typedef T Tvalue;
typedef C<T>::Tcontainer;
typedef Tvalue (*Tfunction) (const Tvalue&, const Tvalue&);
Collector(Tfunction, function, const Tvalue& v=Tvalue()):
Mfunction(function), Mvalue(v) { }
private:
Tfunction Mfunction;
Tvalue Mvalue;
}; // class Collector
} // namespace util
} // namespace func
} // namespace aff
#endif // TF_COLLECTOR_H_VERSION (includeguard)
/* ----- END OF collector.h ----- */
/*! \file mapper.h
* \brief map values (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: mapper.h,v 1.1 2005-03-21 09:35:34 tforb Exp $
* \author Thomas Forbriger
* \date 20/03/2005
*
* map values (prototypes)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 20/03/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_MAPPER_H_VERSION
#define TF_MAPPER_H_VERSION \
"TF_MAPPER_H V1.0 "
#define TF_MAPPER_H_CVSID \
"$Id: mapper.h,v 1.1 2005-03-21 09:35:34 tforb Exp $"
namespace tf {
}
#endif // TF_MAPPER_H_VERSION (includeguard)
/* ----- END OF mapper.h ----- */
/*! \file functionstest.cc
* \brief test function templates
*
* ----------------------------------------------------------------------------
*
* $Id: functionstest.cc,v 1.1 2005-03-21 09:35:35 tforb Exp $
* \author Thomas Forbriger
* \date 20/03/2005
*
* test function templates
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 20/03/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define FUNCTIONSTEST_VERSION \
"FUNCTIONSTEST V1.0 test function templates"
#define FUNCTIONSTEST_CVSID \
"$Id: functionstest.cc,v 1.1 2005-03-21 09:35:35 tforb Exp $"
#include <iostream>
#include <tfxx/commandline.h>
using std::cout;
using std::cerr;
using std::endl;
int main(int iargc, char* argv[])
{
// define usage information
char usage_text[]=
{
FUNCTIONSTEST_VERSION "\n"
"usage: functionstest" "\n"
" or: functionstest --help|-h" "\n"
};
// define full help text
char help_text[]=
{
FUNCTIONSTEST_CVSID
};
// define commandline options
using namespace tfxx::cmdline;
static Declare options[]=
{
// 0: print help
{"help",arg_no,"-"},
// 1: verbose mode
{"v",arg_no,"-"},
{NULL}
};
// no arguments? print usage...
if (iargc<2)
{
cerr << usage_text << endl;
exit(0);
}
// collect options from commandline
Commandline cmdline(iargc, argv, options);
// help requested? print full help text...
if (cmdline.optset(0))
{
cerr << usage_text << endl;
cerr << help_text << endl;
exit(0);
}
// dummy operation: print option settings
for (int iopt=0; iopt<2; iopt++)
{
cout << "option: '" << options[iopt].opt_string << "'" << endl;
if (cmdline.optset(iopt)) { cout << " option was set"; }
else { cout << "option was not set"; }
cout << endl;
cout << " argument (string): '" << cmdline.string_arg(iopt) << "'" << endl;
cout << " argument (int): '" << cmdline.int_arg(iopt) << "'" << endl;
cout << " argument (long): '" << cmdline.long_arg(iopt) << "'" << endl;
cout << " argument (float): '" << cmdline.float_arg(iopt) << "'" << endl;
cout << " argument (double): '" << cmdline.double_arg(iopt) << "'" << endl;
cout << " argument (bool): '";
if (cmdline.bool_arg(iopt))
{ cout << "true"; } else { cout << "false"; }
cout << "'" << endl;
}
while (cmdline.extra()) { cout << cmdline.next() << endl; }
// dummy operation: print rest of command line
while (cmdline.extra()) { cout << cmdline.next() << endl; }
}
/* ----- END OF functionstest.cc ----- */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment