strusModule  0.17
moduleEntryPoint.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_MODULE_HEADER_HPP_INCLUDED
11 #define _STRUS_MODULE_HEADER_HPP_INCLUDED
12 #include "strus/versionModule.hpp"
13 #include <cstring>
14 
16 namespace strus {
17 
20 {
22  enum Type
23  {
27  };
28  enum
29  {
38  };
39 
40  char signature[ 8];
42  unsigned short modversion_minor;
43  unsigned short compversion_major;
44  unsigned short compversion_minor;
45  unsigned int _reserved[6];
46  const char* version_3rdparty;
47  const char* license_3rdparty;
48 
50  explicit ModuleEntryPoint( Type type_, unsigned short version_major, unsigned short version_minor, const char* version_3rdparty_=0, const char* license_3rdparty_=0)
51  :type(type_),modversion_minor(STRUS_MODULE_VERSION_MINOR),version_3rdparty(version_3rdparty_),license_3rdparty(license_3rdparty_)
52  {
53  const char* declaration_signature = STRUS_MODULE_SIGNATURE;
54  //... signature contains major version number in it
55  std::memset( signature, 0, sizeof(signature));
56  std::memcpy( signature, declaration_signature, std::strlen( declaration_signature));
57  std::memset( _reserved, 0, sizeof(_reserved));
58  compversion_major = version_major;
59  compversion_minor = version_minor;
60  }
61 
62  struct Status
63  {
65  :errorcode(0)
66  {
67  errormsg[0] = '\0';
68  }
69 
70  bool ok() const {return errorcode==0;}
71 
72  int errorcode;
73  char errormsg[ 256];
74  };
75 
76  typedef void* Handle;
77  static void closeHandle( Handle& hnd);
78 
79 private:
80  ModuleEntryPoint( const ModuleEntryPoint&){} //< non copyable
81  ModuleEntryPoint(){} //< no implicit construction without data
82 };
83 
84 typedef bool (*MatchModuleVersionFunc)( const ModuleEntryPoint* entryPoint, int& errorcode);
86 
87 }//namespace
88 #endif
89 
char signature[8]
signature of the module (string + major version)
Definition: moduleEntryPoint.hpp:40
ModuleEntryPoint(Type type_, unsigned short version_major, unsigned short version_minor, const char *version_3rdparty_=0, const char *license_3rdparty_=0)
Constructor for derived classes.
Definition: moduleEntryPoint.hpp:50
the signature (composition of a string and the major module version number) does not match ...
Definition: moduleEntryPoint.hpp:32
unsigned int _reserved[6]
reserved for future use
Definition: moduleEntryPoint.hpp:45
Type type
type of the module
Definition: moduleEntryPoint.hpp:41
Entry point of a module with signature and version info to verify correctness of the dynamic linking...
Definition: moduleEntryPoint.hpp:19
module exporting objects for document and query analysis (moduleAnalyzer)
Definition: moduleEntryPoint.hpp:24
Definition: moduleEntryPoint.hpp:36
static void closeHandle(Handle &hnd)
Definition: moduleEntryPoint.hpp:37
void * Handle
Definition: moduleEntryPoint.hpp:76
the 'type' field has an unknown value
Definition: moduleEntryPoint.hpp:31
the components implemented in the module have a major version number than expected ...
Definition: moduleEntryPoint.hpp:34
bool(* MatchModuleVersionFunc)(const ModuleEntryPoint *entryPoint, int &errorcode)
Definition: moduleEntryPoint.hpp:84
the components minor version is smaller than required. The module may not implement the objects loade...
Definition: moduleEntryPoint.hpp:35
module exporting objects for storage and query evaluation (moduleStorage)
Definition: moduleEntryPoint.hpp:25
const char * version_3rdparty
3rd party version info
Definition: moduleEntryPoint.hpp:46
unsigned short compversion_minor
minor version of components in the module
Definition: moduleEntryPoint.hpp:44
Definition: moduleEntryPoint.hpp:62
char errormsg[256]
Definition: moduleEntryPoint.hpp:73
the loaded module minor version is higher than the one of the module loader. This means that the modu...
Definition: moduleEntryPoint.hpp:33
const ModuleEntryPoint * loadModuleEntryPoint(const char *modfilename, ModuleEntryPoint::Status &status, ModuleEntryPoint::Handle &hnd, MatchModuleVersionFunc)
const char * license_3rdparty
3rd party license text
Definition: moduleEntryPoint.hpp:47
int errorcode
Definition: moduleEntryPoint.hpp:72
module exporting objects for method call trace generation (moduleTrace)
Definition: moduleEntryPoint.hpp:26
bool ok() const
Definition: moduleEntryPoint.hpp:70
unsigned short modversion_minor
minor version of the module
Definition: moduleEntryPoint.hpp:42
Type
The module types supported.
Definition: moduleEntryPoint.hpp:22
Status()
Definition: moduleEntryPoint.hpp:64
unsigned short compversion_major
major version of components in the module
Definition: moduleEntryPoint.hpp:43
no error
Definition: moduleEntryPoint.hpp:30