Skip to content

Conversation

@DerThorsten
Copy link
Member

@DerThorsten DerThorsten commented Jul 25, 2023

Todos:

  • add readme
  • add win to ci
  • create proper installer with cmake targets and stuff
  • add recommit hook to format
  • add wasm build and test to ci

Copy link
Member

@JohanMabille JohanMabille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice stuff, I really like the removal of the polymorphism for shared library implementations. Global remarks regarding the coding conventions:

  • opening curly braces should be on a new line
  • classes declarations should not contain any method implementation. I know it can be cumbersome to define the functions after, but it makes it easier to read the public API in the future.
  • public/protected/private accessors should be at the same indentation level as classes declarations.

We can setup a pre-commit hook and some clang configuration to automatically format the code (but obviously that won't move the definitions out of the classes).

We can handle the "pure C init plugin functions" in a dedicated PR (if we decide it is worth doing so).

* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#pragma once
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is non standard directive and should be avoided.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know any actually used compiler not supporting it? Fine with using include guards, but I think one can save assume that modern compilers support #pragma once

@@ -0,0 +1,100 @@
#pragma once
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark here, prefer include guards over non standard #pragma once

}
else
{
xunix_shared_library library(find_res->second);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xshared_library

class xplugin_registry{

public:
using create_plugin_factory_type = FACTORY * (*)();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be useful to create a type alias on FACTORY

* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#pragma once
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is non standard directive and should be avoided.

@DerThorsten DerThorsten marked this pull request as draft July 28, 2023 06:53
@DerThorsten DerThorsten marked this pull request as ready for review August 1, 2023 10:53
@DerThorsten DerThorsten changed the title draft implementation of minimal plugin system based on runtime polymorphism + factories implementation of minimal plugin system based on runtime polymorphism + factories Aug 1, 2023
@DerThorsten
Copy link
Member Author

whoever merges this, pls do "Squash and merge"

@SylvainCorlay
Copy link
Member

Bravo!

@SylvainCorlay SylvainCorlay dismissed JohanMabille’s stale review August 1, 2023 13:26

I think the outstanding pragma once can be removed later.

@SylvainCorlay SylvainCorlay merged commit cd5fc3b into QuantStack:master Aug 1, 2023
{
public:
using base_type = BASE_TYPE;
virtual ~xfactory_base()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= default;

using concrete_type = CONCRETE_TYPE;
using base_type = BASE_TYPE;
using factory_base_type = xfactory_base<BASE_TYPE, ARGS...>;
virtual ~xfactory()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= default;

namespace xp
{

template <class FACTORY_BASE>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting: everything in the namespace should be indented

template <class FACTORY_BASE>
class xplugin_registry
{
public:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting: indent should be 4 spaces

std::string name = entry.path().stem().string();

// remove prefix
if (name.substr(0, prefix.size()) == prefix)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep libraries without prefix in their path

Copy link
Member Author

@DerThorsten DerThorsten Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not for the path. this is for the name / key in the map.
For a lib at some/path/libfoobar.so we use foobar as name/key and some/path/libfoobar.so as value path/value.
We cannot keep the prefix in the name/ key, since this would give different name/keys on windows and UNIX.
Ie:

#if __unix__
auto foobar_factory = registry.create_factory("libfoobar")
#else // win
auto foobar_factory = registry.create_factory("foobar")
#endif 

while when we remove the prefix we can always use

auto foobar_factory = registry.create_factory("foobar")

@DerThorsten
Copy link
Member Author

@JohanMabille I addressed your comments in #2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants