Server: prefix special/automatic Sources with __

This commit is contained in:
Michael Davidsaver
2020-12-29 12:54:43 -08:00
parent 785e180f9b
commit 6aa1c76cb1
2 changed files with 15 additions and 7 deletions
+12 -4
View File
@@ -40,10 +40,13 @@ struct Config;
* In order to be useful, a Server will have one or more Source instances added
* to it with addSource().
*
* As a convenience, each Server instance automatically contains a "builtin" StaticSource
* As a convenience, each Server instance automatically contains a "__builtin" StaticSource
* to which SharedPV instances can be directly added.
* The "builtin" has priority zero, and can be accessed or even removed like any Source
* The "__builtin" has priority zero, and can be accessed or even removed like any Source
* explicitly added with addSource().
*
* There is also a "__server" source which provides the special "server" PV
* used by the pvlist CLI.
*/
class PVXS_API Server
{
@@ -80,16 +83,21 @@ public:
//! Suitable for use in self-contained unit-tests.
client::Config clientConfig() const;
//! Add a SharedPV to the "builtin" StaticSource
//! Add a SharedPV to the "__builtin" StaticSource
Server& addPV(const std::string& name, const SharedPV& pv);
//! Remove a SharedPV from the "builtin" StaticSource
//! Remove a SharedPV from the "__builtin" StaticSource
Server& removePV(const std::string& name);
//! Add a Source to this server with an arbitrary source name.
//!
//! Source names beginning with "__" are reserved for internal use.
//! eg. "__builtin" and "__server".
//!
//! @param name Source name
//! @param src The Source. A strong reference to this Source which will be released by removeSource() or ~Server()
//! @param order Determines the order in which this Source::onCreate() will be called. Lowest first.
//!
//! @throws std::runtime_error If this (name, order) has already been added.
Server& addSource(const std::string& name,
const std::shared_ptr<Source>& src,
int order =0);
+3 -3
View File
@@ -42,7 +42,7 @@ Server::Server(const Config& conf)
/* Here be dragons.
*
* We keep two different ref. counters.
* - "externel" counter which keeps a server running.
* - "external" counter which keeps a server running.
* - "internal" which only keeps server storage from being destroyed.
*
* External refs are held as Server::pvt. Internal refs are
@@ -405,8 +405,8 @@ Server::Pvt::Pvt(const Config &conf)
// Add magic "server" PV
{
auto L = sourcesLock.lockWriter();
sources[std::make_pair(-1, "server")] = std::make_shared<ServerSource>(this);
sources[std::make_pair(-1, "builtin")] = builtinsrc.source();
sources[std::make_pair(-1, "__server")] = std::make_shared<ServerSource>(this);
sources[std::make_pair(-1, "__builtin")] = builtinsrc.source();
}
}