File: ArClientData.h

package info (click to toggle)
libaria 2.8.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,628 kB
  • ctags: 16,574
  • sloc: cpp: 135,490; makefile: 925; python: 597; java: 570; ansic: 182
file content (86 lines) | stat: -rw-r--r-- 3,446 bytes parent folder | download | duplicates (2)
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
85
86
#ifndef ARCLIENTDATA_H
#define ARCLIENTDATA_H

#include "Aria.h"
class ArNetPacket;

/// class to hold information about the different data the client has
/**
   This class is mostly just for holding all the information about one
   of the client data entires in one convenient spot

   Information about the data flags held here... The recognized ones
   right now are just for return values so some forwarding can be done
   intelligently, you should only have one return value, they are:
   RETURN_NONE (There are no return packets), RETURN_SINGLE (There is
   exactly one return packet), RETURN_UNTIL_EMPTY (There return goes
   until an empty packet), RETURN_VIDEO (this is the special case for
   video where basically its something thats always requested at an
   interval and everyone'll want it after we've transfered it),
   RETURN_COMPLEX (The return is more complex (so you'll need a helper
   class))
**/

class ArClientData
{
public:
  /// Constructor
  AREXPORT ArClientData(const char *name, const char *description, 
			unsigned int command, 
			ArFunctor1<ArNetPacket *> *functor);
  /// Destructor
  AREXPORT virtual ~ArClientData();
  /// Gets the name
  const char *getName(void) { return myName.c_str(); }
  /// Gets the description
  const char *getDescription(void) { return myDescription.c_str(); }
  unsigned int getCommand(void) { return myCommand; }
  /// Gets the argument description
  const char *getArgumentDescription(void) 
    { return myArgumentDescription.c_str(); }
  /// Gets the return description
  const char *getReturnDescription(void) 
    { return myReturnDescription.c_str(); }
  /// Gets the command group
  const char *getCommandGroup(void) { return myCommandGroup.c_str(); }
  AREXPORT bool hasDataFlag(const char *dataFlag);
  const char *getDataFlagsString(void) 
    { return myDataFlagsBuilder.getFullString(); }
  /// Gets the list of functors
  const std::list<ArFunctor1<ArNetPacket *> *> *getFunctorList(void) const
    { return &myFunctorList; };
  /// Locks the functor list so we can walk it without it changing
  AREXPORT int lockFunctorList(void) { return myMutex.lock(); }
  /// Tries to lock the functor list so we can walk it without it changing
  AREXPORT int tryLockFunctorList(void) { return myMutex.tryLock(); }
  /// Unlocks the functor list so we can walk it without it changing
  AREXPORT int unlockFunctorList(void) { return myMutex.unlock(); }
  
  /// Adds a new functor the end of the list
  void addFunctor(ArFunctor1<ArNetPacket *> *functor) 
    { myFunctorList.push_back(functor); }
  /// Removes a functor from the list all together
  void remFunctor(ArFunctor1<ArNetPacket *> *functor) 
    { myFunctorList.remove(functor); }
  /// Sets the argument and return descriptions
  void setArgRetDescs(const char *argDesc, const char *retDesc)
    { myArgumentDescription = argDesc; myReturnDescription = retDesc; }
  /// Sets the command group
  void setCommandGroup(const char *commandGroup) 
    { myCommandGroup = commandGroup; }
  /// Sets the data flags
  AREXPORT void addDataFlags(const char *dataFlags);
protected:
  std::string myName;
  std::string myDescription;
  unsigned int myCommand;
  std::string myArgumentDescription;
  std::string myReturnDescription;
  std::string myCommandGroup;
  ArMutex myDataMutex;
  ArArgumentBuilder myDataFlagsBuilder;
  ArMutex myMutex;
  std::list<ArFunctor1<ArNetPacket *> *> myFunctorList;
};

#endif // ARCLIENTDATA_H