Bcp  1.4.4
BCP_message_single.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_SINGLE_H
4 #define _BCP_MESSAGE_SINGLE_H
5 
6 #include <map>
7 
8 #include "BcpConfig.h"
9 
10 #include "BCP_message.hpp"
11 
12 class BCP_process;
13 
14 //#############################################################################
15 
17 private:
20 protected:
21  // The argument list of the started process
22  int _argnum;
23  char ** _arglist;
24 public:
25  void set_arguments(const int argnum, const char* const * args);
26 protected:
28  _argnum(0), _arglist(NULL), _my_id(my_id) {}
29 protected:
30  int _my_id;
31  static std::map<int, BCP_process*> processes;
32 public:
34  virtual ~BCP_single_environment();
35 
36  int register_process(USER_initialize* user_init);
37  int parent_process();
38 
39  bool alive(const int pid);
40  const int* alive(int num, const int* pids);
41 
42  void send(const int target, const BCP_message_tag tag);
43  void send(const int target,
44  const BCP_message_tag tag, const BCP_buffer& buf);
45 
46  void multicast(int num, const int* targets,
47  const BCP_message_tag tag);
48  void multicast(int num, const int* targets,
49  const BCP_message_tag tag, const BCP_buffer& buf);
50 
51  void receive(const int source,
52  const BCP_message_tag tag, BCP_buffer& buf,
53  const double timeout);
54  bool probe(const int source, const BCP_message_tag tag);
55 
56  int start_process(const BCP_string& exe,
57  const bool debug);
58  int start_process(const BCP_string& exe,
59  const BCP_string& machine,
60  const bool debug);
61  bool start_processes(const BCP_string& exe,
62  const int proc_num,
63  const bool debug,
64  int* ids);
65  bool start_processes(const BCP_string& exe,
66  const int proc_num,
67  const BCP_vec<BCP_string>& machines,
68  const bool debug,
69  int* ids);
70 
71 // void stop_process(const int process);
72 // void stop_processes(const BCP_proc_array* processes);
73 };
74 
75 #endif
BCP_single_environment::_arglist
char ** _arglist
Definition: BCP_message_single.hpp:23
BCP_single_environment::BCP_single_environment
BCP_single_environment(int my_id)
Definition: BCP_message_single.hpp:27
BCP_single_environment::multicast
void multicast(int num, const int *targets, const BCP_message_tag tag)
Send an empty message (message tag only) to all the processes in the process array.
BCP_single_environment::parent_process
int parent_process()
Return the process id of the parent process (the process that spawned the currnet process.
BCP_message_tag
BCP_message_tag
This enumerative constant describes the message tags different processes of BCP understand.
Definition: BCP_message_tag.hpp:11
BCP_single_environment::processes
static std::map< int, BCP_process * > processes
Definition: BCP_message_single.hpp:31
BCP_vec< BCP_string >
BCP_single_environment::start_process
int start_process(const BCP_string &exe, const bool debug)
Spawn a new process.
BCP_single_environment::receive
void receive(const int source, const BCP_message_tag tag, BCP_buffer &buf, const double timeout)
Blocking receive with timeout.
BCP_single_environment::BCP_single_environment
BCP_single_environment()
Definition: BCP_message_single.hpp:33
BCP_message.hpp
BcpConfig.h
BCP_string
This class is a very simple impelementation of a constant length string.
Definition: BCP_string.hpp:13
BCP_single_environment::send
void send(const int target, const BCP_message_tag tag)
Send an empty message (message tag only) to the process given by the frist argument.
USER_initialize
This class is an abstract base class for the initializer class the user has to provide.
Definition: BCP_USER.hpp:160
BCP_single_environment::probe
bool probe(const int source, const BCP_message_tag tag)
Probe if there are any messages from the given process with the given message tag.
BCP_single_environment
Definition: BCP_message_single.hpp:16
BCP_single_environment::~BCP_single_environment
virtual ~BCP_single_environment()
BCP_single_environment::start_processes
bool start_processes(const BCP_string &exe, const int proc_num, const bool debug, int *ids)
Spawn proc_num processes, all with the same executable.
BCP_single_environment::set_arguments
void set_arguments(const int argnum, const char *const *args)
BCP_message_environment
This is an abstract base class that describes the message passing environment.
Definition: BCP_message.hpp:30
BCP_single_environment::_my_id
int _my_id
Definition: BCP_message_single.hpp:30
BCP_process
Definition: BCP_process.hpp:16
BCP_buffer
This class describes the message buffer used for all processes of BCP.
Definition: BCP_buffer.hpp:39
BCP_single_environment::register_process
int register_process(USER_initialize *user_init)
A process can register (receive its process id) with the message passing environment.
BCP_single_environment::alive
bool alive(const int pid)
Test if the process given by the argument is alive or not.
BCP_single_environment::_argnum
int _argnum
Definition: BCP_message_single.hpp:22