strus  0.17
functionDescription.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Patrick P. Frey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
10 #ifndef _STRUS_FUNCTION_DESCRIPTION_HPP_INCLUDED
11 #define _STRUS_FUNCTION_DESCRIPTION_HPP_INCLUDED
12 #include "strus/numericVariant.hpp"
13 #include <string>
14 #include <vector>
15 
16 namespace strus
17 {
18 
21 {
22 public:
24  struct Parameter
25  {
26  enum Type
27  {
33  };
34  static const char* typeName( Type i)
35  {
36  static const char* ar[] = {"Feature","Attribute","Metadata","Numeric","String",0};
37  return ar[i];
38  }
39 
41  Parameter( const Type& type_, const std::string& name_, const std::string& text_, const std::string& domain_)
42  :m_type(type_),m_name(name_),m_text(text_),m_domain(domain_){}
44  Parameter( const Parameter& o)
45  :m_type(o.m_type),m_name(o.m_name),m_text(o.m_text),m_domain(o.m_domain){}
46 
48  Type type() const {return m_type;}
50  const char* typeName() const {return typeName(m_type);}
51 
53  const std::string& name() const {return m_name;}
54 
56  const std::string& text() const {return m_text;}
57 
70  const std::string& domain() const {return m_domain;}
71 
72  private:
73  Type m_type;
74  std::string m_name;
75  std::string m_text;
76  std::string m_domain;
77  };
78 
79 public:
81  FunctionDescription& operator()( Parameter::Type type_, const std::string& name_, const std::string& text_, const std::string& domain_=std::string())
82  {
83  m_param.push_back( Parameter( type_, name_, text_, domain_));
84  return *this;
85  }
86 
89 
91  explicit FunctionDescription( const std::string& text_)
92  :m_text(text_){}
93 
96  :m_text(o.m_text),m_param(o.m_param){}
97 
99  FunctionDescription( const FunctionDescription& o, const std::string& text_)
100  :m_text(text_ + ": " + o.m_text),m_param(o.m_param){}
101 
103  const std::string& text() const {return m_text;}
104 
106  const std::vector<Parameter>& parameter() const {return m_param;}
107 
108 private:
109  std::string m_text;
110  std::vector<Parameter> m_param;
111 };
112 
113 } //namespace
114 #endif
115 
116 
parameter specifies a document attribute identifier
Definition: functionDescription.hpp:29
Parameter(const Type &type_, const std::string &name_, const std::string &text_, const std::string &domain_)
Constructor.
Definition: functionDescription.hpp:41
parameter specifies a document metadata identifier
Definition: functionDescription.hpp:30
const std::vector< Parameter > & parameter() const
Get the description parameter list.
Definition: functionDescription.hpp:106
const std::string & text() const
Get the description text.
Definition: functionDescription.hpp:103
FunctionDescription(const std::string &text_)
Constructor.
Definition: functionDescription.hpp:91
FunctionDescription(const FunctionDescription &o)
Copy constructor.
Definition: functionDescription.hpp:95
const std::string & domain() const
Get the description of the parameter domain.
Definition: functionDescription.hpp:70
FunctionDescription()
Default constructor.
Definition: functionDescription.hpp:88
parameter specifies a string constant or enumeration item as string
Definition: functionDescription.hpp:32
const char * typeName() const
Get the type of the parameter as string.
Definition: functionDescription.hpp:50
const std::string & text() const
Get the description text of the parameter.
Definition: functionDescription.hpp:56
FunctionDescription & operator()(Parameter::Type type_, const std::string &name_, const std::string &text_, const std::string &domain_=std::string())
Add a parameter description.
Definition: functionDescription.hpp:81
parameter specifies a numeric constant (NumericVariant type)
Definition: functionDescription.hpp:31
Type
Definition: functionDescription.hpp:26
FunctionDescription(const FunctionDescription &o, const std::string &text_)
Derived constructor.
Definition: functionDescription.hpp:99
Parameter(const Parameter &o)
Copy constructor.
Definition: functionDescription.hpp:44
Structure that describes a parameter.
Definition: functionDescription.hpp:24
static const char * typeName(Type i)
Definition: functionDescription.hpp:34
const std::string & name() const
Get the name of the parameter.
Definition: functionDescription.hpp:53
Structure that describes a function (weighting or summarizer function) for introspection.
Definition: functionDescription.hpp:20
parameter specifies a feature value passed as posting iterator to the function context ...
Definition: functionDescription.hpp:28
Type type() const
Get the type of the parameter.
Definition: functionDescription.hpp:48