9 SP::CORE_ClassFactory factory=getFactory();
12 if (factory.get()==
null)
throw CORE_Exception(
"UI",
"UI_Class::saveAssociation",
"factory not set");
28 for (
int i=0;i<n;i++) {
30 if (
object==
null)
continue;
31 uiObject=
dynamic_cast<const UI_Object *
>(object);
40 fi->setFactory(factory);
64 SP::CORE_ClassFactory factory=getFactory();
66 if (factory.get()==
null)
throw CORE_Exception(
"UI",
"UI_Class::loadAssociation",
"factory not set");
72 boost::shared_ptr<T> obj;
80 fi->setFactory(factory);
95 for (
int i=0;i<n;i++) {
100 obj=dynamic_sp_cast<T>(factory->getClass(fi->getClassName()));
101 if (obj.get()==
null) {
104 obj=dynamic_sp_cast<T>(factory->NewInstance(fi->getClassName()));
106 if (obj.get()!=
null) factory->addClass(fi->getClassName(),obj);
109 if (uiObject!=
null) {
123 if (obj.get()!=
null) objects.
add(obj);
133 SP::CORE_ClassFactory factory=getFactory();
136 if (factory.get()==
null)
throw CORE_Exception(
"UI",
"UI_Class::saveAssociation",
"factory not set");
152 for (
int i=0;i<n;i++) {
154 uiObject=
dynamic_cast<const UI_Object *
>(object);
159 if (fi.get()==
null) {
163 fi->setFactory(factory);
189 SP::CORE_ClassFactory factory=getFactory();
191 if (factory.get()==
null)
throw CORE_Exception(
"UI",
"UI_Class::loadAssociation",
"factory not set");
197 boost::shared_ptr<T> obj;
211 fi->setFactory(factory);
219 for (
int i=0;i<n;i++) {
224 obj=dynamic_sp_cast<T>(factory->getClass(fi->getClassName()));
225 if (obj.get()==
null) {
227 obj=dynamic_sp_cast<T>(factory->NewInstance(fi->getClassName()));
229 factory->addClass(fi->getClassName(),obj);
232 if (uiObject!=
null) {
249 template<
class T,
class V>
251 SP::CORE_ClassFactory factory=getFactory();
254 if (factory.get()==
null)
throw CORE_Exception(
"UI",
"UI_Class::saveAssociation",
"factory not set");
277 l->saveField(
"keys",keys);
281 l->createClassesList(
"values",isComposite,n);
290 for (
int i=0;i<n;i++) {
291 object=objs.
get(keys[i]);
292 uiObject=
dynamic_cast<const UI_Object *
>(object);
296 if (fi.get()==
null) {
300 fi->setFactory(factory);
313 l->setClassIntoList(
"values",i,*fi.get());
328 template<
class T,
class V>
330 SP::CORE_ClassFactory factory=getFactory();
332 if (factory.get()==
null)
throw CORE_Exception(
"UI",
"UI_Class::loadAssociation",
"factory not set");
338 boost::shared_ptr<V> obj;
352 int n=l->getClassesListSize(
"values");
367 fk->setFactory(factory);
379 fi->setFactory(factory);
383 l->loadField(
"keys",keys);
386 for (
int i=0;i<n;i++) {
389 l->getClassFromList(
"values",i,*fi.get());
392 obj=dynamic_sp_cast<V>(factory->getClass(fi->getClassName()));
393 if (obj.get()==
null) {
395 obj=dynamic_sp_cast<V>(factory->NewInstance(fi->getClassName()));
397 factory->addClass(fi->getClassName(),obj);
400 if (uiObject!=
null) {
415 objects.
put(keys[i],obj);
virtual tBoolean setClassIntoList(const tString &fieldName, const int &index, UI_Class &fieldValue)=0
set the index-th element of the classes list supposed to be composite or not depending on isComposite...
int getSize() const
return the size of the array
Definition: CORE_WeakPointersList.h:215
int getSize() const
return the size of the array
Definition: CORE_SharedPointersVMap.h:94
int getInterfaceType() const
set the interface type
Definition: UI_Class.h:116
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
void clear()
clear the array
Definition: CORE_SharedPointersList.h:206
This class is the base class of User Interface package.
Definition: UI_Object.h:23
This class describes the main interface class for a soft user interface (R,matlab,python etc...) class.
Definition: UI_Class.h:38
void add(boost::shared_ptr< T > obj)
add an element at the end
Definition: CORE_SharedPointersList.h:134
void setHasBeenLoaded(const tBoolean &v)
set the if the object has completely been loaded
Definition: UI_Object.h:55
virtual tBoolean hasField(const tString &field) const =0
verify if the data of the class is a struct with fields names
virtual void loadFromUIClass(const UI_Class &mclass)
how to load the object from a Meta Model class
Definition: UI_Object.cpp:15
#define tBoolean
Definition: types.h:48
void getKeys(vector< Key > &ks) const
return a vector of keys
Definition: CORE_SharedPointersVMap.hpp:129
void saveAssociation(const tString &name, const tBoolean &isComposite, const CORE_Object *obj)
save the association with single cardinality
Definition: UI_Class.cpp:40
#define null
Definition: types.h:13
tBoolean isArrayCopied() const
return true if the array must be copied
Definition: UI_Class.h:127
void add(const boost::shared_ptr< T > &obj)
add an element at the end
Definition: CORE_WeakPointersList.h:107
tBoolean hasBeenLoaded() const
return true if the object has completely been loaded
Definition: UI_Object.h:60
tString getIdentityString() const
return the identity string of the object of the form className_at_address
Definition: CORE_Object.h:136
This class describes a map: primitive type of Key -> shared pointer of Value.
Definition: CORE_SharedPointersVMap.h:15
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:15
virtual tBoolean getField(const tString &field, UI_Class &uiClass) const =0
get the field name of the class
SP::CORE_Object loadAssociation(const tString &name, const tBoolean &isComposite) const
load the association Note that the factory class must be set to create the class If nit the return ob...
Definition: UI_Class.cpp:86
virtual SP::UI_Class NewInstance() const =0
create a new instance of class
virtual int getClassesListSize(const tString &fieldName) const =0
get the number of classes of the list
const Value * get(const Key &k) const
get the value at key k
Definition: CORE_SharedPointersVMap.hpp:59
void clear()
clear the map
Definition: CORE_SharedPointersVMap.h:253
class CORE_WeakPointersList is a list of weak shared pointers
Definition: CORE_WeakPointersList.h:11
abstract base class for most classes.
Definition: CORE_Object.h:30
#define tString
Definition: types.h:49
virtual tBoolean setField(const tString &fieldName, const tBoolean &isComposite, UI_Class &fieldValue)=0
set the field fieldName of the class
const T * get(int i) const
get the pointer at index i ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_WeakPointersList.h:187
void clear()
clear the array
Definition: CORE_WeakPointersList.h:164
virtual void saveToUIClass(UI_Class &mclass) const
how to save the object from a mate model class
Definition: UI_Object.cpp:18
tBoolean put(const Key &k, const boost::shared_ptr< Value > &v)
set the value at the index k
Definition: CORE_SharedPointersVMap.h:192
virtual tBoolean getClassFromList(const tString &fieldName, const int &index, UI_Class &uiClass) const =0
get the field of the index-th class in the list
const T * get(const tVectorIndex &i) const
get the pointer at index i
Definition: CORE_SharedPointersList.h:227
virtual void createClassesList(const tString &fieldName, const tBoolean &isComposite, const int &n)=0
create a multiple association of size n with name fieldname of type isComoposite
tVectorIndex getSize() const
return the size of the array
Definition: CORE_SharedPointersList.h:245