Browse Source

Started patterns

iam 1 year ago
parent
commit
1ff0984b84
8 changed files with 30 additions and 7 deletions
  1. BIN
      build/event.o
  2. BIN
      build/main.o
  3. BIN
      build/repeatTime.o
  4. 3 0
      includes/repeatTime.hxx
  5. 1 2
      includes/timeObject.hxx
  6. 1 0
      src/event.cpp
  7. 1 1
      src/main.cpp
  8. 24 4
      src/repeatTime.cpp

BIN
build/event.o


BIN
build/main.o


BIN
build/repeatTime.o


+ 3 - 0
includes/repeatTime.hxx

@@ -22,7 +22,10 @@ class propagateObjectRules
22 22
                     if(foundBeginning)
23 23
                         secondary.push_back(tempString);
24 24
                     else
25
+                    {
25 26
                         repeatType = tempString;
27
+                        foundBeginning = true;
28
+                    }
26 29
                     tempString = "";
27 30
                 }
28 31
                 else

+ 1 - 2
includes/timeObject.hxx

@@ -25,14 +25,13 @@ class timeObject {
25 25
         int minute;
26 26
         int hour;
27 27
         
28
-        timeObject(int toParse = 0);
28
+        timeObject(int toParse);
29 29
         bool setObject(timeObject *toCopy);
30 30
         int getUnixTimestamp();
31 31
         std::string getDate();
32 32
         
33 33
         void addMonth(int toAdd);
34 34
         void addDay(int toAdd);
35
-        
36 35
 };
37 36
 
38 37
 #endif

+ 1 - 0
src/event.cpp

@@ -16,6 +16,7 @@ Event::Event(std::string eventName, int _startTime, int _endTime, std::string ev
16 16
 bool Event::propagateEvent(int startTime, int endTime, std::string repeatRule)
17 17
 {
18 18
     propagateThis->addRule(startTime, endTime, repeatRule);
19
+    return true;
19 20
 }
20 21
 
21 22
 void Event::printEvents()

+ 1 - 1
src/main.cpp

@@ -6,7 +6,7 @@
6 6
 int main()
7 7
 {
8 8
     Event moo("Party", 1477717458, 1477789458,  "My birthday");
9
-    moo.propagateEvent(1475125457, 1479225600, "d");
9
+    moo.propagateEvent(1475125457, 1479225600, "m,d7,a1");
10 10
     moo.printEvents();
11 11
     
12 12
     return 0;

+ 24 - 4
src/repeatTime.cpp

@@ -11,8 +11,15 @@ propagateObject::propagateObject(timeObject *startTime, std::vector<timeObject*>
11 11
     //std::cout << "Object propagation complete\n";
12 12
 }
13 13
 
14
-void getTimeObject(timeObject &iterateTime, std::string repeatType, bool direction)
14
+void alignDay(timeObject &iterateTime, char alignTo)
15 15
 {
16
+    std::cout << alignTo << std::endl;
17
+}
18
+
19
+void getTimeObject(timeObject &iterateTime, propagateObjectRules &thisPropagateObject, bool direction)
20
+{
21
+    std::string repeatType = thisPropagateObject.repeatType;
22
+    
16 23
     if(repeatType == "y")
17 24
     {
18 25
         if(direction == 0)
@@ -34,6 +41,20 @@ void getTimeObject(timeObject &iterateTime, std::string repeatType, bool directi
34 41
         else
35 42
             iterateTime.addDay(-1);
36 43
     }
44
+    else if(repeatType == "p")
45
+    {
46
+        for(int i = 0; i < thisPropagateObject.secondary.size(); ++i)
47
+            if(thisPropagateObject.secondary.at(i) == "d7")
48
+                if(direction == 0)
49
+                    iterateTime.addDay(7);
50
+                else
51
+                    iterateTime.addDay(-7);
52
+    }
53
+    
54
+    for(int i = 0; i < thisPropagateObject.secondary.size(); ++i)
55
+        if(thisPropagateObject.secondary.at(i)[0] == 'a')
56
+            alignDay(iterateTime, thisPropagateObject.secondary.at(i)[0]);
57
+    
37 58
 }
38 59
 
39 60
 bool propagateObject::addRule(int startTime, int endTime, std::string propagateRule)
@@ -46,7 +67,6 @@ bool propagateObject::addRule(int startTime, int endTime, std::string propagateR
46 67
     eventVector->clear();
47 68
     
48 69
     timeObject iterateTime(eventStartTime->getUnixTimestamp());
49
-    
50 70
     myRules.push_back(new propagateObjectRules(propagateRule));
51 71
     
52 72
     int testingTime;
@@ -61,7 +81,7 @@ bool propagateObject::addRule(int startTime, int endTime, std::string propagateR
61 81
         {
62 82
             testingTime = iterateTime.getUnixTimestamp();
63 83
             eventVector->push_back(new timeObject(testingTime));
64
-            getTimeObject(iterateTime, myRules.at(i)->repeatType, 0);
84
+            getTimeObject(iterateTime, *myRules.at(i), 0);
65 85
         }
66 86
         
67 87
         //remove first date
@@ -86,7 +106,7 @@ bool propagateObject::addRule(int startTime, int endTime, std::string propagateR
86 106
         {
87 107
             testingTime = iterateTime.getUnixTimestamp();
88 108
             eventVector->push_back(new timeObject(testingTime));
89
-            getTimeObject(iterateTime, myRules.at(i)->repeatType, 1);
109
+            getTimeObject(iterateTime, *myRules.at(i), 1);
90 110
         }
91 111
         
92 112
         //remove extra date at beginning