Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /* mbed Microcontroller Library
sahilmgandhi 18:6a4db94011d3 2 * Copyright (c) 2006-2013 ARM Limited
sahilmgandhi 18:6a4db94011d3 3 *
sahilmgandhi 18:6a4db94011d3 4 * Licensed under the Apache License, Version 2.0 (the "License");
sahilmgandhi 18:6a4db94011d3 5 * you may not use this file except in compliance with the License.
sahilmgandhi 18:6a4db94011d3 6 * You may obtain a copy of the License at
sahilmgandhi 18:6a4db94011d3 7 *
sahilmgandhi 18:6a4db94011d3 8 * http://www.apache.org/licenses/LICENSE-2.0
sahilmgandhi 18:6a4db94011d3 9 *
sahilmgandhi 18:6a4db94011d3 10 * Unless required by applicable law or agreed to in writing, software
sahilmgandhi 18:6a4db94011d3 11 * distributed under the License is distributed on an "AS IS" BASIS,
sahilmgandhi 18:6a4db94011d3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sahilmgandhi 18:6a4db94011d3 13 * See the License for the specific language governing permissions and
sahilmgandhi 18:6a4db94011d3 14 * limitations under the License.
sahilmgandhi 18:6a4db94011d3 15 */
sahilmgandhi 18:6a4db94011d3 16 #ifndef MBED_DIRHANDLE_H
sahilmgandhi 18:6a4db94011d3 17 #define MBED_DIRHANDLE_H
sahilmgandhi 18:6a4db94011d3 18
sahilmgandhi 18:6a4db94011d3 19 #include <stdint.h>
sahilmgandhi 18:6a4db94011d3 20 #include "platform/platform.h"
sahilmgandhi 18:6a4db94011d3 21
sahilmgandhi 18:6a4db94011d3 22 #include "FileHandle.h"
sahilmgandhi 18:6a4db94011d3 23
sahilmgandhi 18:6a4db94011d3 24 namespace mbed {
sahilmgandhi 18:6a4db94011d3 25 /** \addtogroup drivers */
sahilmgandhi 18:6a4db94011d3 26 /** @{*/
sahilmgandhi 18:6a4db94011d3 27
sahilmgandhi 18:6a4db94011d3 28 /** Represents a directory stream. Objects of this type are returned
sahilmgandhi 18:6a4db94011d3 29 * by a FileSystemLike's opendir method. Implementations must define
sahilmgandhi 18:6a4db94011d3 30 * at least closedir, readdir and rewinddir.
sahilmgandhi 18:6a4db94011d3 31 *
sahilmgandhi 18:6a4db94011d3 32 * If a FileSystemLike class defines the opendir method, then the
sahilmgandhi 18:6a4db94011d3 33 * directories of an object of that type can be accessed by
sahilmgandhi 18:6a4db94011d3 34 * DIR *d = opendir("/example/directory") (or opendir("/example")
sahilmgandhi 18:6a4db94011d3 35 * to open the root of the filesystem), and then using readdir(d) etc.
sahilmgandhi 18:6a4db94011d3 36 *
sahilmgandhi 18:6a4db94011d3 37 * The root directory is considered to contain all FileLike and
sahilmgandhi 18:6a4db94011d3 38 * FileSystemLike objects, so the DIR* returned by opendir("/") will
sahilmgandhi 18:6a4db94011d3 39 * reflect this.
sahilmgandhi 18:6a4db94011d3 40 *
sahilmgandhi 18:6a4db94011d3 41 * @Note Synchronization level: Set by subclass
sahilmgandhi 18:6a4db94011d3 42 */
sahilmgandhi 18:6a4db94011d3 43 class DirHandle {
sahilmgandhi 18:6a4db94011d3 44 public:
sahilmgandhi 18:6a4db94011d3 45 MBED_DEPRECATED_SINCE("mbed-os-5.4",
sahilmgandhi 18:6a4db94011d3 46 "The mbed 2 filesystem classes have been superseeded by the FileSystem api, "
sahilmgandhi 18:6a4db94011d3 47 "Replaced by File")
sahilmgandhi 18:6a4db94011d3 48 DirHandle() {}
sahilmgandhi 18:6a4db94011d3 49
sahilmgandhi 18:6a4db94011d3 50 /** Closes the directory.
sahilmgandhi 18:6a4db94011d3 51 *
sahilmgandhi 18:6a4db94011d3 52 * @returns
sahilmgandhi 18:6a4db94011d3 53 * 0 on success,
sahilmgandhi 18:6a4db94011d3 54 * -1 on error.
sahilmgandhi 18:6a4db94011d3 55 */
sahilmgandhi 18:6a4db94011d3 56 virtual int closedir()=0;
sahilmgandhi 18:6a4db94011d3 57
sahilmgandhi 18:6a4db94011d3 58 /** Return the directory entry at the current position, and
sahilmgandhi 18:6a4db94011d3 59 * advances the position to the next entry.
sahilmgandhi 18:6a4db94011d3 60 *
sahilmgandhi 18:6a4db94011d3 61 * @returns
sahilmgandhi 18:6a4db94011d3 62 * A pointer to a dirent structure representing the
sahilmgandhi 18:6a4db94011d3 63 * directory entry at the current position, or NULL on reaching
sahilmgandhi 18:6a4db94011d3 64 * end of directory or error.
sahilmgandhi 18:6a4db94011d3 65 */
sahilmgandhi 18:6a4db94011d3 66 virtual struct dirent *readdir()=0;
sahilmgandhi 18:6a4db94011d3 67
sahilmgandhi 18:6a4db94011d3 68 /** Resets the position to the beginning of the directory.
sahilmgandhi 18:6a4db94011d3 69 */
sahilmgandhi 18:6a4db94011d3 70 virtual void rewinddir()=0;
sahilmgandhi 18:6a4db94011d3 71
sahilmgandhi 18:6a4db94011d3 72 /** Returns the current position of the DirHandle.
sahilmgandhi 18:6a4db94011d3 73 *
sahilmgandhi 18:6a4db94011d3 74 * @returns
sahilmgandhi 18:6a4db94011d3 75 * the current position,
sahilmgandhi 18:6a4db94011d3 76 * -1 on error.
sahilmgandhi 18:6a4db94011d3 77 */
sahilmgandhi 18:6a4db94011d3 78 virtual off_t telldir() { return -1; }
sahilmgandhi 18:6a4db94011d3 79
sahilmgandhi 18:6a4db94011d3 80 /** Sets the position of the DirHandle.
sahilmgandhi 18:6a4db94011d3 81 *
sahilmgandhi 18:6a4db94011d3 82 * @param location The location to seek to. Must be a value returned by telldir.
sahilmgandhi 18:6a4db94011d3 83 */
sahilmgandhi 18:6a4db94011d3 84 virtual void seekdir(off_t location) { (void)location;}
sahilmgandhi 18:6a4db94011d3 85
sahilmgandhi 18:6a4db94011d3 86 virtual ~DirHandle() {}
sahilmgandhi 18:6a4db94011d3 87
sahilmgandhi 18:6a4db94011d3 88 protected:
sahilmgandhi 18:6a4db94011d3 89
sahilmgandhi 18:6a4db94011d3 90 /** Acquire exclusive access to this object.
sahilmgandhi 18:6a4db94011d3 91 */
sahilmgandhi 18:6a4db94011d3 92 virtual void lock() {
sahilmgandhi 18:6a4db94011d3 93 // Stub
sahilmgandhi 18:6a4db94011d3 94 }
sahilmgandhi 18:6a4db94011d3 95
sahilmgandhi 18:6a4db94011d3 96 /** Release exclusive access to this object.
sahilmgandhi 18:6a4db94011d3 97 */
sahilmgandhi 18:6a4db94011d3 98 virtual void unlock() {
sahilmgandhi 18:6a4db94011d3 99 // Stub
sahilmgandhi 18:6a4db94011d3 100 }
sahilmgandhi 18:6a4db94011d3 101
sahilmgandhi 18:6a4db94011d3 102 protected:
sahilmgandhi 18:6a4db94011d3 103 /** Internal-only constructor to work around deprecated notices when not used
sahilmgandhi 18:6a4db94011d3 104 *. due to nested deprecations and difficulty of compilers finding their way around
sahilmgandhi 18:6a4db94011d3 105 * the class hierarchy
sahilmgandhi 18:6a4db94011d3 106 */
sahilmgandhi 18:6a4db94011d3 107 friend class FileSystemLike;
sahilmgandhi 18:6a4db94011d3 108 DirHandle(int) {}
sahilmgandhi 18:6a4db94011d3 109 };
sahilmgandhi 18:6a4db94011d3 110
sahilmgandhi 18:6a4db94011d3 111 } // namespace mbed
sahilmgandhi 18:6a4db94011d3 112
sahilmgandhi 18:6a4db94011d3 113 #endif /* MBED_DIRHANDLE_H */
sahilmgandhi 18:6a4db94011d3 114
sahilmgandhi 18:6a4db94011d3 115 /** @}*/