gloox  1.0.1
resource.h
1 /*
2  Copyright (c) 2004-2012 by Jakob Schroeter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef RESOURCE_H__
15 #define RESOURCE_H__
16 
17 #include "presence.h"
18 #include "util.h"
19 
20 #include <string>
21 
22 namespace gloox
23 {
24 
25  class Presence;
26 
35  class GLOOX_API Resource
36  {
37 
38  friend class RosterItem;
39 
40  public:
47  Resource( int priority, const std::string& msg, Presence::PresenceType presence )
48  : m_priority( priority ), m_message( msg ), m_presence( presence ) {}
49 
53  virtual ~Resource()
54  {
55  util::clearList( m_extensions );
56  }
57 
62  int priority() const { return m_priority; }
63 
68  const std::string& message() const { return m_message; }
69 
74  Presence::PresenceType presence() const { return m_presence; }
75 
81  const StanzaExtensionList& extensions() const { return m_extensions; }
82 
83  private:
84  void setPriority( int priority ) { m_priority = priority; }
85  void setMessage( std::string message ) { m_message = message; }
86  void setStatus( Presence::PresenceType presence ) { m_presence = presence; }
87  void setExtensions( const StanzaExtensionList& exts )
88  {
89  StanzaExtensionList::const_iterator it = exts.begin();
90  for( ; it != exts.end(); ++it )
91  {
92  m_extensions.push_back( (*it)->clone() );
93  }
94  }
95 
96  int m_priority;
97  std::string m_message;
98  std::string m_name;
99  Presence::PresenceType m_presence;
100  StanzaExtensionList m_extensions;
101 
102  };
103 
104 }
105 
106 #endif // RESOURCE_H__