Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=b358e1585202e7ea877b8fdca50423e0e67dc1c6
commit b358e1585202e7ea877b8fdca50423e0e67dc1c6 Author: Michel Hermier <[email protected]> Date: Tue May 20 08:26:05 2014 +0200 libpacman: Move generic concepts from fsignal.h to falgorithms.h. diff --git a/lib/libpacman/CMakeLists.txt b/lib/libpacman/CMakeLists.txt index 25ca715..e8723ee 100644 --- a/lib/libpacman/CMakeLists.txt +++ b/lib/libpacman/CMakeLists.txt @@ -19,6 +19,7 @@ set(FLIB_SOURCES io/archive.c io/ffilelock.c io/ftp.c + util/falgorithms.h util/fcallback.h util/fdispatchlogger.c util/fdispatchlogger.h diff --git a/lib/libpacman/kernel/fsignal.h b/lib/libpacman/kernel/fsignal.h index 46e40eb..157fea1 100644 --- a/lib/libpacman/kernel/fsignal.h +++ b/lib/libpacman/kernel/fsignal.h @@ -21,6 +21,8 @@ #ifndef FSIGNAL_H #define FSIGNAL_H +#include "util/falgorithms.h" + #include <memory> // For std::unique_ptr #include <vector> // For std::vector @@ -29,48 +31,6 @@ namespace flib { -template <typename T> -T fdefault_constructor() -{ - return T(); -} - -template <typename T> -struct FAccumulator -{ - T value; - - FAccumulator() - : value(fdefault_constructor<T>()) - { } - - template <typename Any> - const T &operator += (const Any &any) - { - return value += any; - } -}; - -template <> -struct FAccumulator<void> -{ - template <typename Any> - void operator += (const Any &any) - { } -}; - -template <typename> -class FCallable; - -template <typename R, typename... Args> -struct FCallable<R(Args...)> -{ - virtual ~FCallable() - { } - - virtual R operator () (Args...) const = 0; -}; - namespace detail { diff --git a/lib/libpacman/util/falgorithms.h b/lib/libpacman/util/falgorithms.h new file mode 100644 index 0000000..b1a0a1e --- /dev/null +++ b/lib/libpacman/util/falgorithms.h @@ -0,0 +1,78 @@ +/* + * falgorithms.h + * + * Copyright (c) 2014 by Michel Hermier <[email protected]> + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ +#ifndef FALGORITHMS_H +#define FALGORITHMS_H + +#include <memory> // For std::unique_ptr +#include <vector> // For std::vector + +#include "util.h" // for ASSERT + +namespace flib +{ + +template <typename T> +T fdefault_constructor() +{ + return T(); +} + +template <typename T> +struct FAccumulator +{ + T value; + + FAccumulator() + : value(fdefault_constructor<T>()) + { } + + template <typename Any> + const T &operator += (const Any &any) + { + return value += any; + } +}; + +template <> +struct FAccumulator<void> +{ + template <typename Any> + void operator += (const Any &any) + { } +}; + +template <typename> +class FCallable; + +template <typename R, typename... Args> +struct FCallable<R(Args...)> +{ + virtual ~FCallable() + { } + + virtual R operator () (Args...) const = 0; +}; + +} + +#endif /* FALGORITHMS_H */ + +/* vim: set ts=2 sw=2 noet: */ _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
