File: stubServer.h

package info (click to toggle)
eris 1.3.13-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,916 kB
  • ctags: 1,679
  • sloc: cpp: 12,043; sh: 9,050; perl: 287; makefile: 197; ansic: 165
file content (84 lines) | stat: -rw-r--r-- 2,312 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef ERIS_STUB_SERVER_H
#define ERIS_STUB_SERVER_H

#include <map>
#include <vector>
#include <set>
#include <memory>

#include <skstream/skserver.h>
#include <skstream/skserver_unix.h>

#include <Atlas/Objects/ObjectsFwd.h>
#include <Atlas/Objects/RootEntity.h>
#include <Atlas/Objects/Entity.h>

class Commander;
class ClientConnection;
class Agent;

typedef std::set<std::string> StringSet;

typedef std::map<std::string, Atlas::Objects::Entity::Account> AccountMap;

class StubServer
{ 
public:
    StubServer(short port);
    ~StubServer();

    int run(pid_t childPid);	// run the server until the child exists, return a process result
  
    void setupTestAccounts();

    ClientConnection* getConnectionForAccount(const std::string& accId);
    
    AccountMap::const_iterator findAccountByUsername(const std::string &uname);
    
    Agent* findAgentForEntity(const std::string& eid);
    
    Atlas::Objects::Entity::RootEntity getEntity(const std::string& eid) const;
    
    void resetWorld();
    void addManyObjects(const std::string& );
private:
    void joinRoom(const std::string& acc, const std::string& room);
    void partRoom(const std::string& acc, const std::string& room);
    void talkInRoom(const Atlas::Objects::Operation::Talk& tk, const std::string& room);
    
    StringSet peopleInRoom(const std::string& room);
    
    void subclassType(const std::string& base, const std::string& derivedName);
    
    void defineEntity(const std::string& id, 
        const std::string& type,
        const std::string& loc,
        const std::string& nm);
    
    void initCalendarOn(Atlas::Objects::Entity::RootEntity& ent);
    
    tcp_socket_server m_serverSocket;
    
    friend class ClientConnection;
    friend class Agent;
    friend class Commander;
    
    typedef std::vector<ClientConnection*> ConArray;
    ConArray m_clients;
    
    AccountMap m_accounts;
    
    typedef std::map<std::string, Atlas::Objects::Entity::RootEntity> EntityMap;
    EntityMap m_world;
    
    typedef std::map<std::string, Atlas::Objects::Entity::RootEntity> RoomMap;
    RoomMap m_rooms;
    
    typedef std::map<std::string, Atlas::Objects::Root> AtlasTypeMap;
    AtlasTypeMap m_types;
    
    unix_socket_server m_commandSocket;
    std::auto_ptr<Commander> m_command;
};

#endif