fbgsense 0.1
Generic FBG spectrum analysis tool
processor.h
1/*
2 * This file is a part of the project "fbgsense", which is released under MIT license.
3 * Copyright (c) 2022 Daniel Múčka, Masaryk University, Faculty of Informatics
4 * See file LICENSE or visit https://opensource.org/licenses/MIT for full license details.
5 */
6
7#pragma once
8
9#include <memory>
10
15template<typename T>
17{
18protected:
24 constexpr int get_hash(const char str[])
25 {
26 int h = 0;
27 size_t len = strlen(str);
28
29 for (int i = 0; i < len; ++i)
30 h = 31 * h + str[i];
31
32 return h;
33 }
34public:
39 constexpr virtual int get_type() = 0;
40
44 virtual std::unique_ptr<T> create() = 0;
45
46 virtual ~processor() = default;
47};
Provides support for custom computation implementations.
Definition: processor.h:17
virtual std::unique_ptr< T > create()=0
Factory for the current concrete subclass.
virtual constexpr int get_type()=0
Gets the unique identifier of the concrete subclass. Used for equal-type checking....
constexpr int get_hash(const char str[])
Java string hashing function. http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/cl...
Definition: processor.h:24