/** * Copyright - See the COPYRIGHT that is included with this distribution. * pvxs is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ #include #include #include #include #include #include #include namespace { using namespace pvxs::server; DEFINE_LOGGER(dummy,"dummyserv"); struct DummyHandler : public Handler { virtual ~DummyHandler() {} virtual void onIntrospect(std::unique_ptr &&op) override final { op->error("Got nothing"); } }; struct DummySource : public Source { std::set names; virtual ~DummySource() {} // Source interface public: virtual void onSearch(Search &op) override final { for(auto& name : op) { if(names.find(name.name())!=names.end()) { log_printf(dummy, PLVL_INFO, "Claiming '%s'\n", name.name()); name.claim(); } else { log_printf(dummy, PLVL_DEBUG, "Ignoring '%s'\n", name.name()); } } } virtual void onCreate(std::unique_ptr&& op) override final { log_printf(dummy, PLVL_INFO, "Create '%s'\n", op->name.c_str()); op->setHandler(std::unique_ptr{new DummyHandler}); } }; } // namespace int main(int argc, char *argv[]) { int ret = 0; try { pvxs::logger_level_set("dummy", PLVL_INFO); pvxs::logger_config_env(); std::shared_ptr src(new DummySource); src->names.emplace("blah"); auto serv = std::move(Server::Config::from_env() .build() .addSource("dummy", src)); auto& conf = serv.config(); std::cout<<"Serving from :\n"; for(auto& iface : conf.interfaces) { std::cout<<" "<