ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
FAQ Downloads Calendar Search Mark Forums Read

Q&A Using Flexsim and building models

Reply
 
Thread Tools Display Modes
  #1  
Old 04-15-2010
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 678
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default Storing a C++ class pointer in a flexsim object

Would it be possible to store a pointer to a class in C++ into a Flexsim node? With other words make a link between a class object in a DLL and a Flexsim object?

Interested to hear your ideas.
Reply With Quote
  #2  
Old 04-15-2010
Anthony Johnson's Avatar
Anthony Johnson Anthony Johnson is offline
Manager of Product Development
 
Join Date: Jul 2007
Posts: 440
Downloads: 86
Uploads: 4
Thanks: 171
Thanked 899 Times in 288 Posts
Rep Power: 729
Anthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond repute
Default

You can always just give the node number data, and then set it to tonum(class pointer). The problem with that, though, is that you're explicitly breaking save state capability, so it's not "best practices." What I usually try to do is preserve the idea that all pointers need to be to nodes (not to custom c++ class instances), and then nodes can hold binary data such as custom classes that I define. With version 5 you have the added capability of using one-way coupling data that is properly saved, so this gives you more flexibility in using this method. Then I usually define structs, and store them in the nodes' data using the bb... commands: bbsetsize(), bbgetsize(), bbgetbuffer(). The main drawback here is that the definition of the struct needs to be completely serializable, meaning it has to be one contiguous block of bytes that contain all the class' information, or in other words, the struct/class can't contain pointers to other structs/classes. So it's not the most flexible method, but so far it's worked pretty well for me.
Reply With Quote
The Following 3 Users Say Thank You to Anthony Johnson For This Useful Post:
Carsten Seehafer (04-16-2010), Jason Lightfoot (04-15-2010), Phil BoBo (04-15-2010)
  #3  
Old 04-15-2010
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 678
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

Anthony,

I have to chew on your answer a bit, but thanks anyway. I think that breaking save state capability is not that big an issue because the DLL with it's class instances is also closed anyway and I don't think there is any use keeping links there between the DLL and Flexsim.
Reply With Quote
Reply

Tags
c++, class, pointer, store in node

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get object class juan alberto Q&A 1 09-24-2009 06:25 AM
COM Object for Controlling Flexsim Anthony Johnson User Development 6 02-25-2009 11:43 AM
I think an easy question... - how to pointer to objects david_white Q&A 21 08-18-2008 12:20 PM
How to select all objects of a class in your model Brenton King Tips and Tricks 3 04-03-2008 11:25 PM


All times are GMT -6. The time now is 06:10 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.