请恋爱

文章 评论 浏览 29

请恋爱 2025-02-20 19:12:21

连接到LDS的客户端与非分辨率UA服务器有什么区别?

除了意图之外,别无其他。连接到LDS时,您可能期望在调用 FindServers 时,可能会为其他非LDS服务器提供多个条目,但是在连接到非LDDS服务器时只有一个条目。

由于UA服务器需要在调用compisterserver()函数之前连接到LDS,是否必须给出ua服务器的LDS URL?如果是这样,您是否为UA服务器提供LDS的发现或LDS的端点?

是的,它必须使用LDS的URL配置以注册,尽管LDS的最初意图是它在LocalHost上运行,并且具有 opc.tcp.tcp:// localhost:4840/的规范地址uadiscovery 带有规范的端点URL opc.tcp:// localhost:4840/uadiscovery/registration 用于服务器将使用的端点。

我认为要做的正确的事情是为服务器提供注册地址,但实际上可能并不重要。

要使客户端发现所有本地UA服务器,是否必须首先给出LDS的发现,然后需要连接到LDS的端点,然后call findservers()?

是的。在许多情况下,发现URL和端点URL是相同的,但是如果您获得的发现URL不同,则应使用它。

所有非发现UA服务器还必须包含FindServers()和registerserver()函数调用?

FindServers 应实现, registerserver registerserver2 不需要,不需要。

我对如何用Eclipse Milo实施LDS感到困惑,因为文档的文档很少。我当时想首先创建虚拟/裸露的UA服务器,然后以某种方式添加发现服务,但我不确定如何做。你们有任何想法/建议吗?

实施LDS是一项非平凡的事业,由于规格中LDS的文献不足,因此更加困难,因为这是在现实世界中从未真正脱过来的东西。

除非您只是想了解这个OPC UA概念,否则我认为您可能会浪费时间。

What's the difference between a client connecting to a LDS and a non-discovery UA Server?

Nothing other than perhaps intention. Connecting to an LDS you might expect to get multiple entries for other non-LDS servers when you call FindServers, but only one when connecting to a non-LDS server.

Since the UA Servers needs to connect to the LDS before calling registerServer() function, does the UA Server have to be given the URL of the LDS? If so, do you provide the UA Servers the discoveryURL of the LDS or the endpointURL of the LDS?

Yes, it has to be configured with the URL of the LDS to register with, though the original intention for an LDS would be that it runs on localhost and has a canonical address of opc.tcp://localhost:4840/UADiscovery with a canonical endpoint URL of opc.tcp://localhost:4840/UADiscovery/registration for the endpoint that servers will use to register with.

I think the correct thing to do would be provide the server with the registration address, but it may not matter in practice.

For a client to discover all the local UA Servers, does it first have to be given the discoveryURl of the LDS, then it needs to connect to the endpointURL of the LDS, then call findServers()?

Yes. In many cases the discovery URL and endpoint URL are the same, but if you're given a discovery URL that is different then you should use it.

Do all non-discovery UA Servers also have to contain findServers() and registerServer() function calls?

FindServers should be implemented, RegisterServer and RegisterServer2 are not required and should not be.

I am kind of confused on how to implement a LDS with Eclipse Milo since there is minimal documentation. I was thinking of first creating a dummy/bare-bone UA Server and then somehow adding in the Discovery Services but I am unsure of how to do it. Do you guys have any ideas/suggestions?

Implementing an LDS is a non-trivial undertaking, made more difficult by the fact that LDS in general is under-documented in the spec because it's something that never really took off in the real world.

Unless you're just trying to learn about this OPC UA concept I think you may be wasting your time.

如何使用Eclipse Milo实施OPC UA LD?

请恋爱 2025-02-20 16:05:20

让我们使用伪代码推理:

>>> aa = [[1,2,3],
          [4,5,6]].T
>>> aa
[[1,4],
 [2,5],
 [3,6]]

>>> bb = [0,1,1].T
>>> b
[0,
 1,
 1]

>>> cc = zeros(2, 2)
>>> cc
[[0,0],
 [0,0]]

下一个指令是一个分配,该分配在第一个索引 cc 带有 bb 值。在这里,我们使用 bb 中的索引从 cc 选择整个行。由于 bb 中有三行,因此结果张量将由 cc [bb [0]] cc [bb [1]] 组成。 ,and cc [bb [2]] bb [1] and bb [2] 是相等的 cc [0] cc [1]

右侧操作数为 aa ,由三行组成: [1,4] [2,5] [3,6] 。这意味着执行的最终操作将等同于(行和行):

cc[0] += [1,4]
cc[1] += [3,6]

由于 cc 以零值初始化,我们可以总结到:

>>> cc[0] = [1,4]
>>> cc[1] = [3,6]

这意味着:

>>> cc
[[1,4],
 [3,6]]

Let us reason with pseudo code:

>>> aa = [[1,2,3],
          [4,5,6]].T
>>> aa
[[1,4],
 [2,5],
 [3,6]]

>>> bb = [0,1,1].T
>>> b
[0,
 1,
 1]

>>> cc = zeros(2, 2)
>>> cc
[[0,0],
 [0,0]]

The next instruction is an assignment which consists in first indexing cc with bb values. Here we are picking entire rows from cc using indices in bb. Since there are three rows in bb, the resulting tensor will consist of cc[bb[0]], cc[bb[1]], and cc[bb[2]] but bb[1] and bb[2] are equal which means it comes down to cc[0] and cc[1].

The right-hand side operand is aa and consists of three rows: [1,4], [2,5], and [3,6]. This means that the final operation performed will be equivalent to (row-wise):

cc[0] += [1,4]
cc[1] += [3,6]

Since cc is initialized with zero values, we can sum this up to:

>>> cc[0] = [1,4]
>>> cc[1] = [3,6]

This means that:

>>> cc
[[1,4],
 [3,6]]

如何理解代码“ cc [bb]+ = aa;在Pytorch?

请恋爱 2025-02-20 14:49:11

好的,我找到了解决方案。 express-fileupload 使用 busbboy 在引擎盖下。您可以传递Busboy选项,其中之一是 defparamcharset

“对于多部分表单,默认字符设置用于用于值的值
未扩展的部分标题参数(例如文件名)
参数(其中包含一个明确的字符集)。”

文档状态默认值:'latin1'。,但在我的情况下,它取决于运行的OS!

如果您初始化了中间件如以下内容,它应该正确地编码文件名:

app.use(fileUpload({
    defCharset: 'utf8',
    defParamCharset: 'utf8'
}));

Ok i found the solution. express-fileupload uses busboy under the hood. You can pass in busboy options and one of them is defParamCharset:

"For multipart forms, the default character set to use for values of
part header parameters (e.g. filename) that are not extended
parameters (that contain an explicit charset)."

The documentation states Default: 'latin1'. but in my case it was dependent on the running OS!

If you initialize the middleware as following it should properly UTF8 encode filenames:

app.use(fileUpload({
    defCharset: 'utf8',
    defParamCharset: 'utf8'
}));

nodejs express -fileupload-在docker环境中的文件名上编码错误

请恋爱 2025-02-20 10:05:49

共享指针是问题。 bind<> 模板参数不能是指针或参考类型

有一些有关为什么在 bind<> 中禁止指针的信息: https://github.com/boost-ext/di/issues/317

我想出了一种工作方式来绑定依赖性:

const auto injector =
    di::make_injector(di::bind<ioperation>().to(
        [=, &use_sum](const auto& injector) -> op_ptr
        {
            return use_sum
                ? sum_creator()
                : dot_product_creator(sum_creator());
        }) //
    );

请注意,只要存在注射器,通过值捕获工厂功能就可以保持DLL。这比参考捕获更安全。
通过参考突出显示喷油器是动态的,捕获 use_sum 。如果不需要,那么我将用:

替换整个喷油器

  const auto inector = di :: make_injector(di :: bind&lt; ioperation&gt;()。
    use_sum? sum_creator():dot_product_creator(sum_creator())//
);
 

完整演示

另请参见GitHub: https ://github.com/sehe/boost-plugins-prework

  • 文件 ioperation.hpp

      #pragma一次
     #include&lt; boost/shared_ptr.hpp&gt;
     #include&lt; string&gt;
    
     结构ioperation {
       虚拟std :: string name()const = 0;
       虚拟浮点计算(float x,float y)= 0;
    
       Virtual〜ioperation()=默认值;
     };
    
     使用op_ptr = boost :: shared_ptr&lt; ioperation&gt;;
     
  • 文件 sum.cpp

      #include&lt; boost/config.hpp&gt;
     #include&lt; boost/dll/alias.hpp&gt;
     #include&lt; boost/dll/import.hpp&gt;
     #include“ ioperation.hpp”
     #include&lt; iostream&gt;
    
     名称空间sum_namespace {
         班级总和:公共ioperation {
           民众:
             sum(){std :: cout&lt;&lt; “ [sum_constructor]”&lt;&lt; std :: endl; }
             std :: string name()const {返回“ sum”; }
             float计算(float x,float y){返回x + y; }
             〜sum(){std :: cout&lt;&lt; “ [〜sum_destructor]”&lt;&lt; std :: endl; }
    
             //工厂方法
             static op_ptr create_sum(){return op_ptr(new sum()); }
         };
     } //名称空间sum_namespace
    
     BOOST_DLL_ALIAS(
         sum_namespace :: sum :: create_sum,//&lt;  - 此函数由...导出...
         create_sum //&lt;  -  ...这个别名名称
     )
     
  • 文件 sum.hpp

      #pragma一次
     #include“ ioperation.hpp”
     #include“ ioperation.hpp”
    
     名称空间sum_namespace {
         结构总和:ioperation {
             和();
             〜sum()覆盖;
             std :: string name()const覆盖;
             浮点计算(浮动,浮点)覆盖;
    
             static op_ptr create_sum();
         };
     } //名称空间sum_namespace
     
  • 文件 dot_product.cpp

      #include“ dot_product.h”
     #include&lt; boost/config.hpp&gt;
     #include&lt; boost/dll/alias.hpp&gt;
     #include&lt; boost/dll/import.hpp&gt;
     #include&lt; iostream&gt;
    
     命名空间dot_product_namespace {
    
         dot_product :: dot_product(op_ptr&amp; arg){
             sum_ptr = arg;
             std :: cout&lt;&lt; “ [dot_product_constructor]”&lt;&lt; std :: endl;
         }
    
         std :: String dot_product :: name()const {返回“ dot_product”; }
    
         float dot_product ::计算(float a1,float a2){
             //与给定矢量的点产品
             //公式:AB = A1*B1 + A2*B2
             返回sum_ptr-&gt;计算(a1 * a1,a2 * a2);
         }
    
         //工厂方法
         /*static*/ op_ptr dot_product :: create_dot_product(op_ptr sum_ptr){
             return op_ptr(new Dot_product(sum_ptr));
         }
    
         dot_product :: 〜dot_product(){
             std :: cout&lt;&lt; “ [〜DOT_PRODUCT_DESTRUCTOR]”&lt;&lt; std :: endl;
         }
     }; //名称空间dot_product_namespace
    
     BOOST_DLL_ALIAS(dot_product_namespace :: dot_product ::
                         create_dot_product,//&lt;  - 此功能由...导出
                     create_dot_product //&lt;  -  ...此别名名称
     )
     
  • 文件 dot_product.h

      #pragma一次
     #include“ ioperation.hpp”
    
     命名空间dot_product_namespace {
    
         struct dot_product:ioperation {
             dot_product(op_ptr&amp;);
             〜dot_product()覆盖;
             std :: string name()const覆盖;
             浮点计算(浮动,浮点)覆盖;
    
             static op_ptr create_dot_product(op_ptr sum_ptr);
    
           私人的:
             op_ptr sum_ptr;
         };
     }; //名称空间dot_product_namespace
     
  • 文件 application_di.cpp

      #include“ boost/function.hpp”
     #include“ ioperation.hpp”
     #include&lt; boost/di.hpp&gt;
     #include&lt; boost/dll/import.hpp&gt;
     #include&lt; iostream&gt;
    
     命名空间di = boost :: di;
     命名空间dll = boost :: dll;
    
     类应用程序{
      私人的:
        op_ptr ptr_;
    
      民众:
          app(boost :: shared_ptr&lt; ioperation&gt; ptr)
              :ptr_(ptr)
          {
              std :: cout&lt;&lt; “名称:”&lt;&lt; ptr _--&gt; name()&lt;&lt;&lt; std :: endl;
          }
     };
    
     使用boost :: filesystem :: path;
    
     int main(int argc,char ** argv){
         //设置通往库(.so)文件的路径
         路径lib_path(argc&gt; 1?argv [1]:“。”),
             child_library_path = lib_path /“ dot_product”,
             parent_library_path = lib_path /“ sum”;
    
         //定义LIB构造函数的功能类型
         使用sum_create_t = op_ptr();
         使用dot_product_create_t = op_ptr(op_ptr);
    
         //进口总和工厂
         auto sum_creator = boost :: dll :: import_alias&lt; sum_create_t&gt;(
             parent_library_path,
             “ create_sum”,
             dll :: load_mode :: append_decorations);
    
         //导入dot_product lib工厂
         auto dot_product_creator =
             boost :: dll :: import_alias&lt; dot_product_create_t&gt;(
                 child_library_path,
                 “ create_dot_product”,
                 dll :: load_mode :: append_decorations);
    
         auto use_sum = true;
    
         const auto注射器=
             di :: make_injector(di :: bind&lt; ioperation&gt;()。
                 [=,&amp; use_sum](const auto&amp;喷油器) - &gt; OP_PTR
                 {
                     返回use_sum
                         ? sum_creator()
                         :dot_product_creator(sum_creator());
                 })//
             );
    
         use_sum = argc&gt; 2;
         注射器。
     }
     
  • 文件 application_main.cpp

      #include“ boost/shared_ptr.hpp”
     #include&lt; boost/dll/import.hpp&gt;
     #include“ boost/function.hpp”
     #include&lt; iostream&gt;
     #include“ ioperation.hpp”
    
     命名空间dll = boost :: dll;
     使用boost :: filesystem :: path;
    
     int main(int argc,char ** argv)
     {
         //设置通往库(.so)文件的路径
         路径lib_path(argc&gt; 1?argv [1]:“。”),
             child_library_path = lib_path /“ dot_product”,
             parent_library_path = lib_path /“ sum”;
    
         //定义LIB构造函数的功能类型
         使用sum_create_t = op_ptr();
         使用dot_product_create_t = op_ptr(op_ptr);
    
         //进口总和工厂
         auto sum_creator = dll :: import_alias&lt; sum_create_t&gt;(
             parent_library_path,
             “ create_sum”,
             dll :: load_mode :: append_decorations);
    
         //导入dot_product lib工厂
         auto dot_product_creator =
             dll :: import_alias&lt; dot_product_create_t&gt;(
                 child_library_path,
                 “ create_dot_product”,
                 dll :: load_mode :: append_decorations);
    
         auto sum_ptr = sum_creator();
         auto dot_product_ptr = dot_product_creator(sum_ptr);
    
         //执行计算对象PTR的方法
         for(op_ptr op:{sum_creator(),dot_product_creator(sum_creator())}){
             std :: cout&lt;&lt; “ \ nplugin名称:”&lt;&lt; op-&gt; name()&lt;&lt; “ \ n”;
             std :: cout&lt;&lt; “计算(1,2):”&lt;&lt; op-&gt;计算(1,2)&lt;&lt;&lt; “ \ n”;
         }
     }
     
  • 文件 compile_n_run.sh

     #!/bin/bash
    
     设置-e -x -u
     ./cleanup.sh
    
     echo“ =&gt;现在编译...”
     cppflags =“  -  std = c ++ 14 -fpic -i/home/sehe/sehe/custom/boost -di/include/include/”
     ldflags =“”
    
     #在Sehe的机器上编译所需:
     #cppflags =“ $ cppflags -i/home/sehe/sehe/custom/boost -di/include/include/'
     #cppflags =“ $ cppflags -isystem/home/sehe/sehe/custom/superboost/”;
     #ldflags =“ $ ldflags -l/home/sehe/sehe/custom/superboost/stage/lib”
    
     g ++ $ cppflags sum.cpp -shared -o libsum.so $ ldflags
     g ++ $ cppflags dot_product.cpp -shared -o libdot_product.so $ ldflags
    
     #添加应用程序库
     ldflags =“ $ ldflags -lboost_filesystem -lboost_system -ldl”
     g ++ $ cppflags application_main.cpp -o application_main $ ldflags
     g ++ $ cppflags application_di.cpp -o application_di $ ldflags
    
     ./application_main。
    
     ./application_di。 use_sum
     ./application_di。 #使用dot_product
     

使用

compile_n_run.sh

+ ./cleanup.sh
removed 'application_main'
removed 'libdot_product.so'
removed 'libsum.so'
=> cleaned up!
+ echo '=> Compiling now...'
=> Compiling now...
+ CPPFLAGS='-std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/'
+ LDFLAGS=
+ g++ -std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/ sum.cpp -shared -o libsum.so
+ g++ -std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/ dot_product.cpp -shared -o libdot_product.so
+ LDFLAGS=' -lboost_filesystem -lboost_system -ldl'
+ g++ -std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/ application_main.cpp -o application_main -lboost_filesystem -lboost_system -ldl
+ g++ -std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/ application_di.cpp -o application_di -lboost_filesystem -lboost_system -ldl
+ ./application_main .
[sum_constructor]
[dot_product_constructor]
[sum_constructor]
[sum_constructor]
[dot_product_constructor]

Plugin Name: sum
calculate(1, 2): 3

Plugin Name: dot_product
calculate(1, 2): 5
[~dot_product_destructor]
[~sum_destructor]
[~sum_destructor]
[~dot_product_destructor]
[~sum_destructor]
+ ./application_di . use_sum
[sum_constructor]
name: sum
[~sum_destructor]
+ ./application_di .
[sum_constructor]
[dot_product_constructor]
name: dot_product
[~dot_product_destructor]
[~sum_destructor]

或更多live: “在此处输入图像描述”

Shared pointer is the problem. The bind<> template argument cannot be a pointer or reference type

There's some information about why pointers are disallowed in bind<>: https://github.com/boost-ext/di/issues/317

I figured out a working way to bind the dependency:

const auto injector =
    di::make_injector(di::bind<ioperation>().to(
        [=, &use_sum](const auto& injector) -> op_ptr
        {
            return use_sum
                ? sum_creator()
                : dot_product_creator(sum_creator());
        }) //
    );

Note that capturing the factory functions by value keeps the DLL around as long as the injector exists. This is safer than capturing by reference.
Capturing the use_sum by reference highlights that the injector is dynamic. If that's not required, then I'd replace the whole injector with:

const auto injector = di::make_injector(di::bind<ioperation>().to(
    use_sum ? sum_creator() : dot_product_creator(sum_creator())) //
);

Full Demo

See also Github: https://github.com/sehe/boost-plugins-prework

  • File ioperation.hpp

     #pragma once
     #include <boost/shared_ptr.hpp>
     #include <string>
    
     struct ioperation {
       virtual std::string name() const                = 0;
       virtual float       calculate(float x, float y) = 0;
    
       virtual ~ioperation() = default;
     };
    
     using op_ptr = boost::shared_ptr<ioperation>;
    
  • File sum.cpp

     #include <boost/config.hpp>
     #include <boost/dll/alias.hpp>
     #include <boost/dll/import.hpp>
     #include "ioperation.hpp"
     #include <iostream>
    
     namespace sum_namespace {
         class sum : public ioperation {
           public:
             sum() { std::cout << "[sum_constructor]" << std::endl; }
             std::string name() const { return "sum"; }
             float calculate(float x, float y) { return x + y; }
             ~sum() { std::cout << "[~sum_destructor]" << std::endl; }
    
             // Factory method
             static op_ptr create_sum() { return op_ptr(new sum()); }
         };
     } // namespace sum_namespace
    
     BOOST_DLL_ALIAS(
         sum_namespace::sum::create_sum, // <-- this function is exported with...
         create_sum                      // <-- ...this alias name
     )
    
  • File sum.hpp

     #pragma once
     #include "ioperation.hpp"
     #include "ioperation.hpp"
    
     namespace sum_namespace {
         struct sum : ioperation {
             sum();
             ~sum() override;
             std::string name() const override;
             float       calculate(float, float) override;
    
             static op_ptr create_sum();
         };
     } // namespace sum_namespace
    
  • File dot_product.cpp

     #include "dot_product.h"
     #include <boost/config.hpp>
     #include <boost/dll/alias.hpp>
     #include <boost/dll/import.hpp>
     #include <iostream>
    
     namespace dot_product_namespace {
    
         dot_product::dot_product(op_ptr& arg) {
             sum_ptr = arg;
             std::cout << "[dot_product_constructor]" << std::endl;
         }
    
         std::string dot_product::name() const { return "dot_product"; }
    
         float dot_product::calculate(float a1, float a2) {
             // dot product given vector with itself
             // formula: a.b = a1*b1 + a2*b2
             return sum_ptr->calculate(a1 * a1, a2 * a2);
         }
    
         // Factory method
         /*static*/ op_ptr dot_product::create_dot_product(op_ptr sum_ptr) {
             return op_ptr(new dot_product(sum_ptr));
         }
    
         dot_product::~dot_product() {
             std::cout << "[~dot_product_destructor]" << std::endl;
         }
     }; // namespace dot_product_namespace
    
     BOOST_DLL_ALIAS(dot_product_namespace::dot_product::
                         create_dot_product, // <-- this function is exported with...
                     create_dot_product      // <-- ...this alias name
     )
    
  • File dot_product.h

     #pragma once
     #include "ioperation.hpp"
    
     namespace dot_product_namespace {
    
         struct dot_product : ioperation {
             dot_product(op_ptr&);
             ~dot_product() override;
             std::string name() const override;
             float       calculate(float, float) override;
    
             static op_ptr create_dot_product(op_ptr sum_ptr);
    
           private:
             op_ptr sum_ptr;
         };
     }; // namespace dot_product_namespace
    
  • File application_di.cpp

     #include "boost/function.hpp"
     #include "ioperation.hpp"
     #include <boost/di.hpp>
     #include <boost/dll/import.hpp>
     #include <iostream>
    
     namespace di = boost::di;
     namespace dll = boost::dll;
    
     class app {
      private:
        op_ptr ptr_;
    
      public:
          app(boost::shared_ptr<ioperation> ptr)
              : ptr_(ptr)
          {
              std::cout << "name: " << ptr_->name() << std::endl;
          }
     };
    
     using boost::filesystem::path;
    
     int main(int argc, char** argv) {
         // setting up paths to library(.so) files
         path lib_path(argc > 1 ? argv[1] : "."),
             child_library_path = lib_path / "dot_product",
             parent_library_path = lib_path / "sum";
    
         // defining function types for lib constructors
         using sum_create_t = op_ptr();
         using dot_product_create_t = op_ptr(op_ptr);
    
         // importing SUM lib factory
         auto sum_creator = boost::dll::import_alias<sum_create_t>(
             parent_library_path,
             "create_sum",
             dll::load_mode::append_decorations);
    
         // importing DOT_PRODUCT lib factory
         auto dot_product_creator =
             boost::dll::import_alias<dot_product_create_t>(
                 child_library_path,
                 "create_dot_product",
                 dll::load_mode::append_decorations);
    
         auto use_sum = true;
    
         const auto injector =
             di::make_injector(di::bind<ioperation>().to(
                 [=, &use_sum](const auto& injector) -> op_ptr
                 {
                     return use_sum
                         ? sum_creator()
                         : dot_product_creator(sum_creator());
                 }) //
             );
    
         use_sum = argc > 2;
         injector.create<app>();
     }
    
  • File application_main.cpp

     #include "boost/shared_ptr.hpp"
     #include <boost/dll/import.hpp>
     #include "boost/function.hpp"
     #include <iostream>
     #include "ioperation.hpp"
    
     namespace dll = boost::dll;
     using boost::filesystem::path;
    
     int main(int argc, char** argv)
     {
         // setting up paths to library(.so) files
         path lib_path(argc > 1 ? argv[1] : "."),
             child_library_path = lib_path / "dot_product",
             parent_library_path = lib_path / "sum";
    
         // defining function types for lib constructors
         using sum_create_t = op_ptr();
         using dot_product_create_t = op_ptr(op_ptr);
    
         // importing SUM lib factory
         auto sum_creator = dll::import_alias<sum_create_t>(
             parent_library_path,
             "create_sum",
             dll::load_mode::append_decorations);
    
         // importing DOT_PRODUCT lib factory
         auto dot_product_creator =
             dll::import_alias<dot_product_create_t>(
                 child_library_path,
                 "create_dot_product",
                 dll::load_mode::append_decorations);
    
         auto sum_ptr = sum_creator();
         auto dot_product_ptr = dot_product_creator(sum_ptr);
    
         //executing calculate methods for object ptrs
         for (op_ptr op : {sum_creator(), dot_product_creator(sum_creator()) }) {
             std::cout << "\nPlugin Name: " << op->name() << "\n";
             std::cout << "calculate(1, 2): " << op->calculate(1, 2) << "\n";
         }
     }
    
  • File compile_n_run.sh

     #!/bin/bash
    
     set -e -x -u
     ./cleanup.sh
    
     echo "=> Compiling now..."
     CPPFLAGS="-std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/"
     LDFLAGS=""
    
     # Required to compile on sehe's machine:
     #CPPFLAGS="$CPPFLAGS -I /home/sehe/custom/boost-di/include/"
     #CPPFLAGS="$CPPFLAGS -isystem /home/sehe/custom/superboost/ ";
     #LDFLAGS="$LDFLAGS -L /home/sehe/custom/superboost/stage/lib"
    
     g++ $CPPFLAGS sum.cpp -shared -o libsum.so $LDFLAGS
     g++ $CPPFLAGS dot_product.cpp -shared -o libdot_product.so $LDFLAGS
    
     # add application libraries
     LDFLAGS="$LDFLAGS -lboost_filesystem -lboost_system -ldl"
     g++ $CPPFLAGS application_main.cpp -o application_main $LDFLAGS
     g++ $CPPFLAGS application_di.cpp -o application_di $LDFLAGS
    
     ./application_main .
    
     ./application_di . use_sum
     ./application_di . # uses dot_product
    

Output

Using compile_n_run.sh:

+ ./cleanup.sh
removed 'application_main'
removed 'libdot_product.so'
removed 'libsum.so'
=> cleaned up!
+ echo '=> Compiling now...'
=> Compiling now...
+ CPPFLAGS='-std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/'
+ LDFLAGS=
+ g++ -std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/ sum.cpp -shared -o libsum.so
+ g++ -std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/ dot_product.cpp -shared -o libdot_product.so
+ LDFLAGS=' -lboost_filesystem -lboost_system -ldl'
+ g++ -std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/ application_main.cpp -o application_main -lboost_filesystem -lboost_system -ldl
+ g++ -std=c++14 -fPIC -I /home/sehe/custom/boost-di/include/ application_di.cpp -o application_di -lboost_filesystem -lboost_system -ldl
+ ./application_main .
[sum_constructor]
[dot_product_constructor]
[sum_constructor]
[sum_constructor]
[dot_product_constructor]

Plugin Name: sum
calculate(1, 2): 3

Plugin Name: dot_product
calculate(1, 2): 5
[~dot_product_destructor]
[~sum_destructor]
[~sum_destructor]
[~dot_product_destructor]
[~sum_destructor]
+ ./application_di . use_sum
[sum_constructor]
name: sum
[~sum_destructor]
+ ./application_di .
[sum_constructor]
[dot_product_constructor]
name: dot_product
[~dot_product_destructor]
[~sum_destructor]

Or more live:enter image description here

C&#x2B;&#x2B;动态库加载的依赖注入

请恋爱 2025-02-20 04:57:22

user.fromsnap 中的 snap 在其某些值上返回 null 。要解决此问题,您应该执行以下操作:

      static User fromSnap(DocumentSnapshot snap) {
        var snapshot = snap.data() as Map<String, dynamic>;
    
        return User(
          username: snapshot['username'] ?? 'Unknown',
          uid: snapshot['uid'] ?? '0000000000',
          email: snapshot['email'] ?? '',
          photoUrl: snapshot['photoUrl'] ?? '',
          bio: snapshot['bio'] ?? '',
          followers: snapshot['followers'] ?? [],
          following: snapshot['following'] ?? [],
        );
      }

Most probably the snap in User.fromSnap is returning null on some of its values. To solve this you should do the following:

  • First, you should make sure the values are not null from the API/DB/whatever the snapshot comes from;
  • For the null ones, default them to another value like below with the ?? operator in a conditional expression;
      static User fromSnap(DocumentSnapshot snap) {
        var snapshot = snap.data() as Map<String, dynamic>;
    
        return User(
          username: snapshot['username'] ?? 'Unknown',
          uid: snapshot['uid'] ?? '0000000000',
          email: snapshot['email'] ?? '',
          photoUrl: snapshot['photoUrl'] ?? '',
          bio: snapshot['bio'] ?? '',
          followers: snapshot['followers'] ?? [],
          following: snapshot['following'] ?? [],
        );
      }

由小部件库捕获的例外,null检查运算符在空值上使用

请恋爱 2025-02-19 18:25:41

当您在搜索中运行Profiler时,查询的总时间将比通常运行高得多,检查总时间的最佳方法是在没有profiler的情况下运行查询,并将时间与每个节点进行比较。

When you run profiler in the search the total time of your query would be much higher than usual run, best way to check the total time is to run the query without profiler and compare the time with each node.

为什么总查询时间比弹性搜索中的单分碎时间更长?

请恋爱 2025-02-19 04:36:45

当我从RESTTEMPLATE更改为httpurlconnection时,它的工作

Its working when i changed from Resttemplate to HttpURLConnection

从RESTTEMPLATE中获得401,但从Chrome获得响应

请恋爱 2025-02-18 23:43:04

NPM上的v.8.4.4有一个问题,

更改您的软件包。JSON并改用8.4.3!

将其固定在

  "resolutions": {
    "@types/eslint": "8.4.3"
  }

https://classic.yarnpkg.com/ 对于 npm

  "overrides": {
    "@types/eslint": "8.4.3"
  }

“ :
我如何覆盖NPM依赖的NPM依赖性版本?

有关问题的更多信息(在此处检查):

There is an issue with v.8.4.4 on the NPM

Change your package.json and use 8.4.3 instead!

Pin it in "resolutions" for yarn

  "resolutions": {
    "@types/eslint": "8.4.3"
  }

or "overrides" for npm

  "overrides": {
    "@types/eslint": "8.4.3"
  }

more info about overriding values in NPM:
How do I override nested NPM dependency versions?

more about issue (check it here):

something went wrong

404尝试使用Create-React-App安装ESLINT 8.4.4时找不到

请恋爱 2025-02-18 21:59:30

.container div 选择A div class container 。

它没有针对HTML中的任何元素,因为 condure> container 类中没有 div

也许您的意思是,

.Container P

.container div selects a div inside class container.

It is not targeting any element in your html as there is no div inside container class.

Perhaps you mean,

.container p

使用CSS 3在Firefox中向上滚动文本的问题3

请恋爱 2025-02-18 18:19:31

“我发现的主要麻烦是如何在两个不同时间之间标记时间,例如上午11点至5:59,而不是仅仅是晚上11点。”

添加一个列H2 = G2 + 1/24
然后,您的范围为0至7/24、7/24至19/24和19/24至24/24,因此您没有将时钟重置为零的间隔分开。

"The main trouble I'm finding there is how to label time between two different times such as between 11pm - 5:59am instead of just past 11pm."

Add a column H2 = G2 + 1/24
Then your ranges are 0 to 7/24, 7/24 to 19/24 and 19/24 to 24/24, so you don't have an interval split over a resetting of the clock to zero.

是否可以根据时间值来使用Excel函数来给出值?

请恋爱 2025-02-18 17:38:36

尝试增加请求的尺寸限制,
在您的项目中添加WebConfig并添加此代码

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <security>
      <requestFiltering>
        <!-- This will handle requests up to 50MB -->
        <requestLimits maxAllowedContentLength="52428800" />
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

try increasing size limit of your requests,
add a webconfig to your project and add this code

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <security>
      <requestFiltering>
        <!-- This will handle requests up to 50MB -->
        <requestLimits maxAllowedContentLength="52428800" />
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

AJAX POST ASP.NET CORE 3.1服务器端Problme

请恋爱 2025-02-18 16:56:22
select
    p1.item as item1,
    p2.item as item2,
    count(*) as occurrences
from
    purchases p1
    join
    purchases p2 on p2.customer_email = p1.customer_email and p2.item > p1.item
group by
    p1.item,
    p2.item
order by
    occurrences desc
select
    p1.item as item1,
    p2.item as item2,
    count(*) as occurrences
from
    purchases p1
    join
    purchases p2 on p2.customer_email = p1.customer_email and p2.item > p1.item
group by
    p1.item,
    p2.item
order by
    occurrences desc

从桌子上找到流行对

请恋爱 2025-02-18 09:48:52

您可以尝试使用视图的 contextualtitle 属性。根据发布时的文档,它应该满足您的需求:

用于扩展作者,贡献视​​图或查看容器

当围绕工作台周围移动视图时,如果它们不在默认位置,则有时需要以图标或额外的上下文来不同。当贡献观点时,作者现在可以提供图标属性和上下文属性。如果未提供,这些将默认为构造其贡献的视图容器的图标和标题。

从那时起,我不确定他们是否更新了API或更新了行为,但是,如果没有,您可能会在尝试使用它时遇到的相同问题。我什至为VS代码团队打开了问题( https://githbithub.com/microsoft/microsoft/vscscode /eskoes/102447 ),但他们将问题标记为设计,我放弃了使用它。

希望这会有所帮助

You may try to use the contextualTitle property of the view. Based on its documentation when launched, it should fit your needs:

https://code.visualstudio.com/updates/v1_46#_flexible-layout

For extension authors contributing views or view containers

When views are moved around the workbench, they sometimes need to be presented differently, either with an icon or extra context if they aren't in their default location. When contributing a view, authors may now provide an icon property and a contextualTitle. If not provided, these will default to the icon and title of the view container to which they are contributed.

I'm not sure they updated the API or updated the behavior since then but, if not, you will probably face the same issue I had while trying to use it. I even opened an issue to the VS Code team (https://github.com/microsoft/vscode/issues/102447), but they marked the issue as designed and I gave up on using it.

Hope this helps

查看带有单个标题的容器

请恋爱 2025-02-18 03:51:33

在coc-settings中。

{
    "prettier.singleQuote":true
}

In coc-settings.json you can set prettier with:

{
    "prettier.singleQuote":true
}

将Neovim的单Quotes COC-Prettier设置

请恋爱 2025-02-17 21:23:22

您可以使用“ 线性”,而不是“ radialgradient

更换梯度属性,在您的boxdecoration内部:

LinearGradient(
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
            colors: [
              Colors.white.withOpacity(0.0),
              const Color(0xFFFF7F37),
            ],           
          ),

You can use "LinearGradient" instead of "RadialGradient"

Replace your gradient property, inside your BoxDecoration for:

LinearGradient(
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
            colors: [
              Colors.white.withOpacity(0.0),
              const Color(0xFFFF7F37),
            ],           
          ),

Flutter-从无花果实现径向梯度按钮

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文