EIToolkit stub doc. main.cpp file int main(int argc, char* argv[]) { EIProperties::UseStandards(); // create the stub ExampleStub stub; stub.Start();

Slides:



Advertisements
Similar presentations
OpenGL Open a Win32 Console Application in Microsoft Visual C++.
Advertisements

1 Storage Duration and Scope –Local and global variables Storage classes –automatic, static, external, register Todays Material.
Welcome to VOIC USER TRAINING V8+ PowerPoint.
CPSC 441 TUTORIAL – JANUARY 16, 2012 TA: MARYAM ELAHI INTRODUCTION TO C.
Chapter 7 Process Environment Chien-Chung Shen CIS, UD
C Programming - Lecture 5
CIT 590 Intro to Programming Java lecture 3. Hashmaps The equivalent of python dictionaries. With both ArrayLists and Hashmaps, the syntax only allows.
Classes and Objects: Recap A typical Java program creates many objects which interact with one another by sending messages. Through the objects interactions,
Objects & Object-Oriented Programming (OOP) CSC 1401: Introduction to Programming with Java Week 15 – Lecture 1 Wanda M. Kunkle.
Client Server Model The client machine (or the client process) makes the request for some resource or service, and the server machine (the server process)
Classes and Objects  A typical Java program creates many objects which interact with one another by sending messages. Through the objects interactions,
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Advanced Programming in the UNIX Environment Hop Lee.
Overview scope - determines when an identifier can be referenced in a program storage class - determines the period of time during which that identifier.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Storage Classes.
Project 2 Data Communication Spring 2010, ICE Stephen Kim, Ph.D.
Beginning C++ Through Game Programming, Second Edition by Michael Dawson.
11 Chapter 5 METHODS CONT’D. 22 MORE ON PASSING ARGUMENTS TO A METHOD Passing an Object Reference as an Argument to a Method Objects are passed by reference.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
C# D1 CSC 298 Elements of C# code (part 2). C# D2 Writing a class (or a struct)  Similarly to Java or C++  Fields: to hold the class data  Methods:
Chapter 8 Scope of variables Name reuse. Scope The region of program code where it is legal to reference (use) a variable The scope of a variable depends.
User Defined Functions Chapter 7 2 Chapter Topics Void Functions Without Parameters Void Functions With Parameters Reference Parameters Value and Reference.
Lecture 3: Getting Started & Input / Output (I/O) “TRON” Copyright 1982 (Walt Disney Productions)
CPS4200 Unix Systems Programming Chapter 2. Programs, Processes and Threads A program is a prepared sequence of instructions to accomplish a defined task.
Java - Classes JPatterson. What is a class? public class _Alpha { public static void main(String [] args) { } You have been using classes all year – you.
C++ Programming Lecture 11 Functions – Part III By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
1 Command Processor II. 2 Command Processor Example Let's look at a simple example of a command processor using states and cities. Get initial information.
Server-Side Java Mapping Copyright © ZeroC, Inc. Ice Programming with Java 6. Server-Side Java Mapping.
Lin Chen 09/06/2011. Global variables const int maxCandidates = 10; // Names of the candidates participating in this state's primary string candidate[maxCandidates];
Server-Side C++ Mapping Copyright © ZeroC, Inc. Ice Programming with C++ 6. Server-Side C++ Mapping.
Static. 2 Objectives Introduce static keyword –examine syntax –describe common uses.
Java and C++ Transitioning. A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello.
An Introduction to MPI (message passing interface)
CIT 590 Intro to Programming Lecture 13. Some Eclipse shortcuts CTRL + SHIFT + F – format file (proper indentation etc). Please do this before you submit.
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
February 28, 2005 Introduction to Classes. Object Oriented Programming An object is a software bundle of related variables and methods. Software objects.
Classes in C++ And comparison to Java CS-1030 Dr. Mark L. Hornick.
Arrays-. An array is a way to hold more than one value at a time. It's like a list of items.
New Classes for Debug, Info and Error Messages Thomas Kuhr Offline Week 15/09/2004.
Department of Computer Science and Engineering, HKUST 1 HKUST Summer Programming Course 2008 Using Member Functions and Data Members.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
CHAPTER 8 Scope, Lifetime, and More on Functions.
1 Chapter 8 Scope, Lifetime, and More on Functions CS185/09 - Introduction to Programming Caldwell College.
“Success consists of going from failure to failure without loss of enthusiasm.” Winston Churchill.
Chapter 7 Process Environment Chien-Chung Shen CIS/UD
July FLTK The Fast Light Toolkit • A C++ graphical user interface toolkit • Can be used under X, Windows, MacOS • Supports OpenGL • Provides: – Interactive.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Functions Input and output Lecture 2. Constants #define – is a preprocessor directive Most common use.
Introduction to java (class and object). Programming languages: –Easier to understand than CPU instructions –Needs to be translated for the CPU to understand.
Lecture 3: Getting Started & Input / Output (I/O)
Test 2 Review Outline.
3 Introduction to Classes and Objects.
Friend Class Friend Class A friend class can access private and protected members of other class in which it is declared as friend. It is sometimes useful.
Some Eclipse shortcuts
UNIX PROCESSES.
Instructor: Ioannis A. Vetsikas
Lecturer: Mukhtar Mohamed Ali “Hakaale”
CSC 113 Tutorial QUIZ I.
User Defined Functions
Class Everything if Java is in a class. The class has a constructor that creates the object. public class ClassName private Field data (instance variables)
Simple Classes in Java CSCI 392 Classes – Part 1.
Constructors, GUI’s(Using Swing) and ActionListner
C++ Constructor Insanity CSE 333 Summer 2018
Fundamental OOP Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
In this class, we will cover:
Makefile Assignment Create a file called f1.cpp. It should contain the following function: int squareIt ( int x ) { //insert code to calc and return the.
C Programming Lecture-17 Storage Classes
Presentation transcript:

EIToolkit stub doc

main.cpp file int main(int argc, char* argv[]) { EIProperties::UseStandards(); // create the stub ExampleStub stub; stub.Start(); printf("Press ESC to quit.\n\n"); while (_getch() != 27); printf("Cleaning up...\n"); stub.Stop(); EIProperties::StopStandards(); return 0; } The main method should not contain much more than the example shows. A stub might be created from another application and then the main method will not be called. Put most initialisation code into the constructor of the stub or its Start() method. Wait for the user to press ESC. (In Java, this is not possible – need to wait for ENTER)

Main Compiler Options The following defines can be made globally in the Compiler options dialog in VStudio (or by using the /D compiler option) #define _NO_LISTENERS // if you don't need to listen to (UDP) packets #define _NO_SENDERS // if you don't need to send (UDP) packets #define _NO_PARTICLE_COMM // if you don't need particle communication In Java, use the following (static) boolean variables: – EIProperties.NO_SENDERS = …; – EIProperties.NO_LISTENERS = …;

ExampleStub::ExampleStub(void) : APPNAME("ExampleStub") { } ExampleStub::~ExampleStub(void) { ExampleStub::Stop(); } void ExampleStub::Start() { Stub::Start(); // register the stub to receive messages EIProperties::GetPacketReceiver()->AddPacketObserver(this); } void ExampleStub::Stop() { Stub::Stop(); } Code that is executed once. The APPNAME can be retrieved using GetName() Code that is executed right before the stub is closed. Code that is executed when the stub is activated (most probably only once when started...) If you want to receive toolkit messages, register yourself here. Code that is executed when the stub is deactivated (most probably only once when exited...) ExampleStub.cpp file In Java, these method calls look like this: EIProperties.getPacketReceiver().addPacketObserver(this); In Java, one instead overrides method getName(). If not, the classname is used as default. public String getName() { return "FacebookStub"; }

void ExampleStub::PacketReceived(PacketEvent &pktEvent) { Packet *pkt = pktEvent.GetPacket(); std::string msg; pkt->ToString(&msg); std::string *recvId = pkt->GetReceiverId(); // e.g.: only accept message if directed to all (GetWildcardAll()) or specifically to this stub (GetName()) if (*recvId == GetName() || *recvId == EIProperties::GetPacketFormatter()->GetWildcardAll()) { } // TODO react to packet or msg } // Example of how to send a message as UDP void ExampleStub::SendMessageToID(const char *msg, const char *id) { std::string message = GetName() + "::" + std::string(msg) + ":" + std::string(id); Packet packet(message); EIProperties::GetPacketSender()->SendPacket(&packet); } This method is automatically called whenever a toolkit message has arrived (if you have previously registered yourself) The GetWildcardAll() method gives the placeholder used to denote ‚everything‘ – currently the „*“ star To send a message, build a packet (sender, message type, message content, receiver) and use GetPacketSender()->SendPacket to send it (one could use the GetWildcardAll() placeholder for a placeholder meaning e.g. this packet is meant for ‚all‘)