CProperty

Sample code

/**
 *  @file main.cpp
 *
 *  @author Manfred Morgner
 *  @date 10.02.2018
 */

#include <iostream>

#include "odb.h"
#include "thing.h"
#include "property.h"

/// @brief Demo main program for "property in thing"
int main()
   {
   auto oOdb = odb::COdb();
   auto thing = oOdb.MakeThing( "Tree" );
   auto property = oOdb.MakeProperty( "Acorn" );
   thing->Append(property);
   std::cout << "thing: " << *thing;
   std::cout << '\n';
   }

Output

thing: Tree
  Property: Acorn
class odb::CProperty

A Property for a CThing.

Inherits from Identifiable< CProperty >

Public Functions

CProperty()

deleted: default constructor

CProperty(CProperty const&)

There is no reason to copy a CProperty.

CProperty(CProperty&&)

There is no reason to moveconstruct a CProperty.

CProperty(std::string const &crsName)

Normal constructor, receiving the name of the property.

CProperty(size_t nId, std::string const &crsName)

Load constructor, receiving the id and the name of the property.

operator std::string const&()

Conversion operator will return the name of the instance.

void RelationAdd(PThing poThing)

Add the information about a link from a CThing.

void RelationSub(PThing poThing)

Removes a link to a CThing.

Parameters
  • poThing: The thing the link is pointing to

void print()

Prints an informational output to std::cout.

SThings const &Relations() const

Access function to call then container of PThings’s.

Public Static Attributes

constexpr auto s_csNameUnnamedProperty = {"unnamedProperty"}

The name of an unnamed property.

Protected Attributes

std::set<PThing> m_oRelations

A set containing backlinks from things.

Friends

std::ostream &operator<<(std::ostream &ros, CProperty const &croProperty)

Output operator to do an output of the instance.

bool operator==(PProperty const &croProperty, std::string const &crsInput)

Compares the name with an input string.