Bcp 1.4.4
Loading...
Searching...
No Matches
BCP_message.hpp
Go to the documentation of this file.
1// Copyright (C) 2000, International Business Machines
2// Corporation and others. All Rights Reserved.
3#ifndef _BCP_MESSAGE_H
4#define _BCP_MESSAGE_H
5
6// This file is fully docified.
7
8#include <utility>
9
10#include "BCP_string.hpp"
11#include "BCP_message_tag.hpp"
12#include "BCP_vector.hpp"
13
14//#############################################################################
15
16class BCP_buffer;
17class USER_initialize;
18
19//#############################################################################
20
21const int BCP_AnyProcess = -1;
22
31public:
43 virtual int register_process(USER_initialize* user_init) = 0;
50 virtual int parent_process() = 0;
57 virtual bool alive(const int pid) = 0;
61 virtual const int* alive(int num, const int* pids) = 0;
68 virtual void send(const int target, const BCP_message_tag tag) = 0;
71 virtual void send(const int target, const BCP_message_tag tag,
72 const BCP_buffer& buf) = 0;
79 virtual void multicast(int num, const int* targets,
80 const BCP_message_tag tag) = 0;
83 virtual void multicast(int num, const int* targets,
84 const BCP_message_tag tag,
85 const BCP_buffer& buf) = 0;
88 // blocking receive w/ timeout (ms??) from given source given msgtag (can
89 // give wildcard anymsg, anyproc)
90
103 virtual void receive(const int source,
104 const BCP_message_tag tag, BCP_buffer& buf,
105 const double timeout) = 0;
112 virtual bool probe(const int source, const BCP_message_tag tag) = 0;
120 virtual int start_process(const BCP_string& exe,
121 const bool debug) = 0;
123 virtual int start_process(const BCP_string& exe,
124 const BCP_string& machine,
125 const bool debug) = 0;
131 virtual bool start_processes(const BCP_string& exe,
132 const int proc_num,
133 const bool debug,
134 int* ids) = 0;
141 virtual bool start_processes(const BCP_string& exe,
142 const int proc_num,
143 const BCP_vec<BCP_string>& machines,
144 const bool debug,
145 int* ids) = 0;
151 virtual int num_procs() { return 0; }
154 // virtual void stop_process(int process) = 0;
155 // virtual void stop_processes(BCP_proc_array& processes) = 0;
156};
157
158#endif
const int BCP_AnyProcess
BCP_message_tag
This enumerative constant describes the message tags different processes of BCP understand.
This class describes the message buffer used for all processes of BCP.
This is an abstract base class that describes the message passing environment.
virtual bool start_processes(const BCP_string &exe, const int proc_num, const BCP_vec< BCP_string > &machines, const bool debug, int *ids)=0
Spawn proc_num processes on the machines given by the third argument, all with the same executable.
virtual int register_process(USER_initialize *user_init)=0
A process can register (receive its process id) with the message passing environment.
virtual bool start_processes(const BCP_string &exe, const int proc_num, const bool debug, int *ids)=0
Spawn proc_num processes, all with the same executable.
virtual int num_procs()
Return the number of processes.
virtual int parent_process()=0
Return the process id of the parent process (the process that spawned the currnet process.
virtual void multicast(int num, const int *targets, const BCP_message_tag tag, const BCP_buffer &buf)=0
Send the message in the buffer with the given message tag to all processes in the process array.
virtual bool alive(const int pid)=0
Test if the process given by the argument is alive or not.
virtual bool probe(const int source, const BCP_message_tag tag)=0
Probe if there are any messages from the given process with the given message tag.
virtual void receive(const int source, const BCP_message_tag tag, BCP_buffer &buf, const double timeout)=0
Blocking receive with timeout.
virtual void multicast(int num, const int *targets, const BCP_message_tag tag)=0
Send an empty message (message tag only) to all the processes in the process array.
virtual void send(const int target, const BCP_message_tag tag, const BCP_buffer &buf)=0
Send the message in the buffer with the given message tag to the process given by the first argument.
virtual int start_process(const BCP_string &exe, const BCP_string &machine, const bool debug)=0
Spawn a new process on the machine specified by the second argument.
virtual int start_process(const BCP_string &exe, const bool debug)=0
Spawn a new process.
virtual void send(const int target, const BCP_message_tag tag)=0
Send an empty message (message tag only) to the process given by the frist argument.
virtual const int * alive(int num, const int *pids)=0
Test if the processes given by the process array in the argument are alive or not.
virtual ~BCP_message_environment()
Being virtual, the destructor invokes the destructor for the real type of the object being deleted.
This class is a very simple impelementation of a constant length string.
The class BCP_vec serves the same purpose as the vector class in the standard template library.
This class is an abstract base class for the initializer class the user has to provide.
Definition BCP_USER.hpp:160