root/library/bdm/base/participants.h @ 819

Revision 819, 2.0 kB (checked in by smidl, 14 years ago)

agents for doprava

Line 
1/*!
2  \file
3  \brief Higher-level Objects - Participants
4  \author Vaclav Smidl.
5
6  -----------------------------------
7  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
8
9  Using IT++ for numerical operations
10  -----------------------------------
11*/
12
13#ifndef PARTICIPANTS_H
14#define PARTICIPANTS_H
15
16
17#include "bdmbase.h"
18#include "../base/user_info.h"
19
20namespace bdm {
21/*!
22* \brief Basic Participant
23
24This object is an active unit with name and capability to store results
25
26*/
27class Participant : public root {
28protected:
29        //! name - ID of the participant
30        string name;
31public:
32        //! Empty constructor
33        Participant(){}
34        //! set name
35        void set_name(const string &name0){name=name0;}
36        //! Process data
37        virtual void adapt(const vec &glob_dt){}
38        /*! create message -- use exclusively this function
39        Writes the following structure into \c msg:
40        \code
41        to = A1;                      // recepients
42        what = predictor;             // sort code
43        data = message_body;          // data itself
44        \endcode
45       
46        */
47        void create_message(Setting &msg,const string &to, const string &what, const root &data){
48                Setting &m_to=msg.add("to",Setting::TypeString);
49                m_to=to;
50                Setting &m_what=msg.add("what",Setting::TypeString);
51                m_what=what;
52                //Setting &m_data=msg.add("data",Setting::TypeGroup);
53                UI::save(&data, msg, "data");
54        }       
55        /*! Broadcast communication to the others. Add message(s) to the provided queue.
56        */
57        virtual void broadcast(Setting& queue){}
58        //! Receive one message from the queue
59        virtual void receive(const Setting& msg){}
60        //! Design control strategy
61        virtual void act(vec &glob_ut){}
62        //! Time step
63        virtual void step(){}
64        //! read only name
65        void from_setting(const Setting& set){
66                UI::get(name,set,"name",UI::compulsory);
67        }
68        void to_setting(Setting& set) const {
69                UI::save(name,set,"name");
70        }
71        //!access function
72        const string &_name() {return name;}
73        //! register data source where to get data
74        virtual void ds_register(const DS &ds){ }
75       
76};
77
78}; //namespace
79
80#endif // PARTICIPANTS_H
Note: See TracBrowser for help on using the browser.