ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

取消
显示结果 
搜索替代 
您的意思是: 

Best way to access a class for read/write from multiple other classes?

已解决!
转到解答
I need runtime to be preserved on a class that gets read to and written to by other classes. They share no common ancestry. The read/writes will be synchronous so there's no race conditions to worry about. My idea is to just have the class be private data of all the classes that need to access it and do a "handoff" between classes, eg bundling and unbundling it into the classes that need it. This seems messy though. Any ideas?
0 项奖励
1 条消息(共 7 条)
4,070 次查看
One idea is to use a functional global, but I don't think Labview classes would like that.
0 项奖励
2 条消息(共 7 条)
4,067 次查看

AE's can work but can also put a restriction on how re-usable your code will be.

 

I think you are looking for a Singleton Design pattern.

 

Search this site, there used tobe links and examples.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 项奖励
3 条消息(共 7 条)
4,053 次查看
解答
已被主题作者 ijustlovemath 接受

I use a Data Value Reference in this situation.  You just make a DVR that contains your shared class and then pass that DVR into all of your other objects at their initialization.  Since everybody who needs to alter the data has a reference to the data, everybody can change it inside of their private methods via an In Place Element Structure.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
4 条消息(共 7 条)
4,028 次查看

You can install G# and use referrence based classes, which'd make it simple enough. 🙂

They basically work like Crossrulz suggest.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 项奖励
5 条消息(共 7 条)
4,014 次查看
Is G# supported in the runtime engine?
0 项奖励
6 条消息(共 7 条)
4,010 次查看

Yes.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 项奖励
7 条消息(共 7 条)
3,943 次查看