/upo

Unidentified Programmed Object

Primary LanguageC++

upo

Unidentified Programmed Object

Dependancies

Examples

First, declare the relations of your new entity :

class ParentOf : public OneToMany<Person,Person> { };

class ChildOf : public ManyToOne<Person,Person>
{
  // LMANDATORY specifies that a Person has to be the child of someone
  static const Cardinality __cardinality__ = OneToMany<Person,Person>::__cardinality__ | LMANDATORY;
};

Next, declare the Person entity :

class Person : public Entity
{
public:
  StrAttribute name;
  ParentOf     parent_of;
  ChildOf      child_of;
};

And make some calls :

Person bob = Person(42); // Get the Person with id 42
Person kevin = Person(); // Create a new entity Person
kevin.name = "Kevin";
kevin.child_of = bob;
kevin.commit();
bob.parent_of += kevin;
bob.commit()