Skip to content

StoreUserDefinedProperties

cschaerfe edited this page Feb 20, 2015 · 7 revisions

How can properties be stored?

BALL offers a class NamedProperty for assigning properties to objects (atoms, bonds, ...)

The following types are supported and can be accessed with

Type access
BOOL getProperty(property_name).getBool()
INT getProperty(property_name).getInt()
UNSIGNED_INT getProperty(property_name).getUnsignedInt ()
FLOAT getProperty(property_name).getFloat()
DOUBLE getProperty(property_name).getDouble()
STRING getProperty(property_name).getString ()

CPP

 #include <BALL/CONCEPT/property.h>
 
 Atom* atom;
 float my_fancy_property = 4.2;

 // assign your property 
 atom-> setProperty("myProperty", my_fancy_property)

 // query your property
 if (atom->hasProperty("myProperty"))
 {
   cout << atom->getProperty("myProperty").getFloat()) << endl;
 }

Python

#!python

from BALL import *
a = Atom()

# assign your property 
a.setProperty("myProperty", 3.25)

# query your property
if (a.hasProperty("myProperty")):
  print a.getProperty("myProperty").getFloat()
Clone this wiki locally