00001
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "tracking.h"
00036 #include "sensingS.h"
00037
00038 using namespace sensix;
00039
00040
00041 TaskImpl::TaskImpl(Functor *prev, Functor *f, Response *cb) : Task()
00042 {
00043 funct = f;
00044 parent = prev;
00045 passup = cb;
00046 num_peers = 0;
00047 cancel = false;
00048 }
00049
00050 TaskImpl::~TaskImpl()
00051 {
00052 }
00053
00054
00055 Functor *TaskImpl::f()
00056 {
00057 return funct;
00058 }
00059
00060 Functor *TaskImpl::superf()
00061 {
00062 return parent;
00063 }
00064
00065 Response *TaskImpl::callback()
00066 {
00067 return passup;
00068 }
00069
00070 ReqList *TaskImpl::subtasks()
00071 {
00072 return subs;
00073 }
00074
00075 void TaskImpl::addSubtask(Request *r, Functor *f)
00076 {
00077
00078 }
00079
00080 int TaskImpl::numPeers()
00081 {
00082 return num_peers;
00083 }
00084
00085 void TaskImpl::numPeers(int p)
00086 {
00087 num_peers = p;
00088 }
00089
00090 bool TaskImpl::cancelled()
00091 {
00092 return cancel;
00093 }
00094
00095 void TaskImpl::cancelled(bool c)
00096 {
00097 cancel = c;
00098 }
00099
00100
00101
00102 void CapabilityTracker::insertCapability(uint8_t cap, Capability *obj)
00103 {
00104 avl_insert((void*)obj, (unsigned long)cap, &tree);
00105 }
00106
00107
00108 Capability* CapabilityTracker::getCapability(uint8_t key)
00109 {
00110 return (Capability*)avl_find((unsigned long)key, &tree);
00111 }
00112
00113
00114
00115 void TaskTracking::addTask(sensix::TaskImpl *ti)
00116 {
00117 avl_insert((void*)ti, ti->f()->sequencer(), &tree);
00118 }
00119
00120
00121 TaskImpl* TaskTracking::getTask(sensix::Functor *f)
00122 {
00123 return (TaskImpl*)avl_find(f->sequencer(), &tree);
00124 }
00125
00126
00127 void TaskTracking::removeTask(sensix::Functor *f)
00128 {
00129 Functor *tmp = NULL;
00130 avl_delete(tmp, f->sequencer(), &tree);
00131 }
00132
00133
00134 int TaskTracking::numTaskPeers(sensix::Functor *f)
00135 {
00136 TaskImpl *ti = (TaskImpl*)avl_find(f->sequencer(), &tree);
00137 return ti->numPeers();
00138 }
00139
00140
00141 void TaskTracking::numTaskPeers(sensix::Functor *f, int p)
00142 {
00143 TaskImpl *ti = (TaskImpl*)avl_find(f->sequencer(), &tree);
00144 return ti->numPeers(p);
00145 }
00146
00147
00148 bool TaskTracking::cancelledTask(sensix::Functor *f)
00149 {
00150 TaskImpl *ti = (TaskImpl*)avl_find(f->sequencer(), &tree);
00151 return ti->cancelled();
00152 }
00153
00154
00155 void TaskTracking::cancelledTask(sensix::Functor *f, bool c)
00156 {
00157 TaskImpl *ti = (TaskImpl*)avl_find(f->sequencer(), &tree);
00158 return ti->cancelled(c);
00159 }