LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Design Pattern Selection - (Singleton obj contains by standard objs.)

Hi Experts!

 

I need your opinion about the following. I have a class(Data Storage) with many class attributes... (standard by value obj DP.). I wanna use this class in many places,  ie. parallel running vis where wiring is not possibe but i have to wire it somehow to keep the dataflow.

My first solution was the following: - Used Global Variable every time when I call any method on object. Get object from Global var. -> Call Method -> Set object to Global var. I knew this is not the best sloution what I could use, but two days ago I read an article about Global/Local vars. and the article said, every time when i use Global/Local Vars, the data is copied every time. ( the above mentioned class prupose is a general data storage). So I have started to look for any usable soution and found the following:

  1. Use Function Global - at the "Init" state i create the obj, and its curret state is hold by shift register. It is easy to implement it, but I 'm affaid I will have problems with race conditions.
  2. Singleton Design  Pattern: - Object attribute will be my Data Storage Class (using Goop3 - Singleton Desing Pattern). - I have never used this DP before with this complexity. ( by Ref Container class  and by value Attribute classes)

so I don't now how to go on! Could you help me to make a right decision or suggest me any solutions? Thank you very much

 

---
+++ In God we believe, in Trance we Trust +++
[Hungary]
0 Kudos
Message 1 of 3
(2,813 Views)

Hi Durnek,

 

Singleton design pattern can be easily implemented by using classes by reference.

I included example of using classes by reference and example of Singleton class.

 

Regards,

 

Jiri Keprt

NI EE Czech Republic

CLA, CTA

Download All
0 Kudos
Message 2 of 3
(2,783 Views)

Thank you again! 🙂

---
+++ In God we believe, in Trance we Trust +++
[Hungary]
0 Kudos
Message 3 of 3
(2,779 Views)