11 #ifndef GI_GBP_SUBJECT_HPP
12 #define GI_GBP_SUBJECT_HPP
14 #include <boost/optional.hpp>
15 #include "opflex/modb/URIBuilder.h"
16 #include "opflex/modb/mo-internal/MO.h"
20 #include "modelgbp/gbp/Rule.hpp"
26 :
public opflex::modb::mointernal::MO
33 static const opflex::modb::class_id_t
CLASS_ID = 103;
41 return getObjectInstance().isSet(3375105ul, opflex::modb::PropertyInfo::STRING);
48 boost::optional<const std::string&>
getName()
51 return getObjectInstance().getString(3375105ul);
60 const std::string&
getName(
const std::string& defaultValue)
62 return getName().get_value_or(defaultValue);
75 getTLMutator().modify(getClassId(), getURI())->setString(3375105ul, newValue);
87 getTLMutator().modify(getClassId(), getURI())->unset(3375105ul, opflex::modb::PropertyInfo::STRING, opflex::modb::PropertyInfo::SCALAR);
102 static boost::optional<boost::shared_ptr<modelgbp::gbp::Subject> >
resolve(
103 opflex::ofcore::OFFramework& framework,
104 const opflex::modb::URI& uri)
106 return opflex::modb::mointernal::MO::resolve<modelgbp::gbp::Subject>(framework,
CLASS_ID, uri);
120 static boost::optional<boost::shared_ptr<modelgbp::gbp::Subject> >
resolve(
121 const opflex::modb::URI& uri)
123 return opflex::modb::mointernal::MO::resolve<modelgbp::gbp::Subject>(opflex::ofcore::OFFramework::defaultInstance(),
CLASS_ID, uri);
146 static boost::optional<boost::shared_ptr<modelgbp::gbp::Subject> >
resolve(
147 opflex::ofcore::OFFramework& framework,
148 const std::string& policySpaceName,
149 const std::string& gbpContractName,
150 const std::string& gbpSubjectName)
152 return resolve(framework,opflex::modb::URIBuilder().addElement(
"PolicyUniverse").addElement(
"PolicySpace").addElement(policySpaceName).addElement(
"GbpContract").addElement(gbpContractName).addElement(
"GbpSubject").addElement(gbpSubjectName).build());
174 static boost::optional<boost::shared_ptr<modelgbp::gbp::Subject> >
resolve(
175 const std::string& policySpaceName,
176 const std::string& gbpContractName,
177 const std::string& gbpSubjectName)
179 return resolve(opflex::ofcore::OFFramework::defaultInstance(),policySpaceName,gbpContractName,gbpSubjectName);
194 const std::string& gbpRuleName)
196 return modelgbp::gbp::Rule::resolve(getFramework(), opflex::modb::URIBuilder(getURI()).addElement(
"GbpRule").addElement(gbpRuleName).build());
212 const std::string& gbpRuleName)
214 boost::shared_ptr<modelgbp::gbp::Rule> result = addChild<modelgbp::gbp::Rule>(
215 CLASS_ID, getURI(), 2150858856ul, 104,
216 opflex::modb::URIBuilder(getURI()).addElement(
"GbpRule").addElement(gbpRuleName).build()
218 result->setName(gbpRuleName);
238 opflex::modb::mointernal::MO::resolveChildren<modelgbp::gbp::Rule>(
239 getFramework(),
CLASS_ID, getURI(), 2150858856ul, 104, out);
252 getTLMutator().remove(
CLASS_ID, getURI());
265 static void remove(opflex::ofcore::OFFramework& framework,
266 const opflex::modb::URI& uri)
268 MO::remove(framework,
CLASS_ID, uri);
281 static void remove(
const opflex::modb::URI& uri)
283 remove(opflex::ofcore::OFFramework::defaultInstance(), uri);
305 opflex::ofcore::OFFramework& framework,
306 const std::string& policySpaceName,
307 const std::string& gbpContractName,
308 const std::string& gbpSubjectName)
310 MO::remove(framework,
CLASS_ID, opflex::modb::URIBuilder().addElement(
"PolicyUniverse").addElement(
"PolicySpace").addElement(policySpaceName).addElement(
"GbpContract").addElement(gbpContractName).addElement(
"GbpSubject").addElement(gbpSubjectName).build());
332 const std::string& policySpaceName,
333 const std::string& gbpContractName,
334 const std::string& gbpSubjectName)
336 remove(opflex::ofcore::OFFramework::defaultInstance(),policySpaceName,gbpContractName,gbpSubjectName);
351 opflex::ofcore::OFFramework& framework,
352 opflex::modb::ObjectListener* listener)
354 opflex::modb::mointernal
355 ::MO::registerListener(framework, listener,
CLASS_ID);
370 opflex::modb::ObjectListener* listener)
382 opflex::ofcore::OFFramework& framework,
383 opflex::modb::ObjectListener* listener)
385 opflex::modb::mointernal
386 ::MO::unregisterListener(framework, listener,
CLASS_ID);
396 opflex::modb::ObjectListener* listener)
406 opflex::ofcore::OFFramework& framework,
407 const opflex::modb::URI& uri,
408 const boost::shared_ptr<const opflex::modb::mointernal::ObjectInstance>& oi)
409 : MO(framework,
CLASS_ID, uri, oi) { }
414 #endif // GI_GBP_SUBJECT_HPP
modelgbp::gbp::Subject & setName(const std::string &newValue)
Set name to the specified value in the currently-active mutator.
Definition: Subject.hpp:73
static boost::optional< boost::shared_ptr< modelgbp::gbp::Rule > > resolve(opflex::ofcore::OFFramework &framework, const opflex::modb::URI &uri)
Retrieve an instance of Rule from the managed object store.
Definition: Rule.hpp:218
boost::shared_ptr< modelgbp::gbp::Rule > addGbpRule(const std::string &gbpRuleName)
Create a new child object with the specified naming properties and make it a child of this object in ...
Definition: Subject.hpp:211
boost::optional< boost::shared_ptr< modelgbp::gbp::Rule > > resolveGbpRule(const std::string &gbpRuleName)
Retrieve the child object with the specified naming properties.
Definition: Subject.hpp:193
Definition: Subject.hpp:25
static const opflex::modb::class_id_t CLASS_ID
The unique class ID for Subject.
Definition: Subject.hpp:33
static boost::optional< boost::shared_ptr< modelgbp::gbp::Subject > > resolve(const std::string &policySpaceName, const std::string &gbpContractName, const std::string &gbpSubjectName)
Retrieve an instance of Subject from the default managed object store by constructing its URI from th...
Definition: Subject.hpp:174
boost::optional< const std::string & > getName()
Get the value of name if it has been set.
Definition: Subject.hpp:48
static void unregisterListener(opflex::ofcore::OFFramework &framework, opflex::modb::ObjectListener *listener)
Unregister a listener from updates to this class.
Definition: Subject.hpp:381
bool isNameSet()
Check whether name has been set.
Definition: Subject.hpp:39
static boost::optional< boost::shared_ptr< modelgbp::gbp::Subject > > resolve(opflex::ofcore::OFFramework &framework, const std::string &policySpaceName, const std::string &gbpContractName, const std::string &gbpSubjectName)
Retrieve an instance of Subject from the managed object store by constructing its URI from the path e...
Definition: Subject.hpp:146
static void unregisterListener(opflex::modb::ObjectListener *listener)
Unregister a listener from updates to this class from the default framework instance.
Definition: Subject.hpp:395
static void registerListener(opflex::modb::ObjectListener *listener)
Register a listener that will get called for changes related to this class with the default framework...
Definition: Subject.hpp:369
modelgbp::gbp::Subject & unsetName()
Unset name in the currently-active mutator.
Definition: Subject.hpp:85
static void registerListener(opflex::ofcore::OFFramework &framework, opflex::modb::ObjectListener *listener)
Register a listener that will get called for changes related to this class.
Definition: Subject.hpp:350
const std::string & getName(const std::string &defaultValue)
Get the value of name if set, otherwise the value of default passed in.
Definition: Subject.hpp:60
static boost::optional< boost::shared_ptr< modelgbp::gbp::Subject > > resolve(const opflex::modb::URI &uri)
Retrieve an instance of Subject from the managed object store using the default framework instance...
Definition: Subject.hpp:120
Subject(opflex::ofcore::OFFramework &framework, const opflex::modb::URI &uri, const boost::shared_ptr< const opflex::modb::mointernal::ObjectInstance > &oi)
Construct an instance of Subject.
Definition: Subject.hpp:405
static boost::optional< boost::shared_ptr< modelgbp::gbp::Subject > > resolve(opflex::ofcore::OFFramework &framework, const opflex::modb::URI &uri)
Retrieve an instance of Subject from the managed object store.
Definition: Subject.hpp:102
void resolveGbpRule(std::vector< boost::shared_ptr< modelgbp::gbp::Rule > > &out)
Resolve and retrieve all of the immediate children of type modelgbp::gbp::Rule.
Definition: Subject.hpp:236